linux-stable/drivers/vdpa
Eli Cohen cc43c56d73 vdpa/mlx5: Use consistent RQT size
[ Upstream commit acde392949 ]

The current code evaluates RQT size based on the configured number of
virtqueues. This can raise an issue in the following scenario:

Assume MQ was negotiated.
1. mlx5_vdpa_set_map() gets called.
2. handle_ctrl_mq() is called setting cur_num_vqs to some value, lower
   than the configured max VQs.
3. A second set_map gets called, but now a smaller number of VQs is used
   to evaluate the size of the RQT.
4. handle_ctrl_mq() is called with a value larger than what the RQT can
   hold. This will emit errors and the driver state is compromised.

To fix this, we use a new field in struct mlx5_vdpa_net to hold the
required number of entries in the RQT. This value is evaluated in
mlx5_vdpa_set_driver_features() where we have the negotiated features
all set up.

In addition to that, we take into consideration the max capability of RQT
entries early when the device is added so we don't need to take consider
it when creating the RQT.

Last, we remove the use of mlx5_vdpa_max_qps() which just returns the
max_vas / 2 and make the code clearer.

Fixes: 52893733f2 ("vdpa/mlx5: Add multiqueue support")
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Eli Cohen <elic@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-25 09:59:11 +02:00
..
alibaba vdpa: Provide interface to read driver features 2022-01-14 18:50:53 -05:00
ifcvf vdpa: Provide interface to read driver features 2022-01-14 18:50:53 -05:00
mlx5 vdpa/mlx5: Use consistent RQT size 2022-05-25 09:59:11 +02:00
vdpa_sim vdpa/vdpa_sim_net: Report max device capabilities 2022-01-14 18:50:54 -05:00
vdpa_user vduse: Fix returning wrong type in vduse_domain_alloc_iova() 2022-03-04 11:56:34 -05:00
virtio_pci vdpa: fix use-after-free on vp_vdpa_remove 2022-03-06 06:06:50 -05:00
Kconfig eni_vdpa: add vDPA driver for Alibaba ENI 2021-11-01 05:23:41 -04:00
Makefile eni_vdpa: add vDPA driver for Alibaba ENI 2021-11-01 05:23:41 -04:00
vdpa.c vdpa: factor out vdpa_set_features_unlocked for vdpa internal use 2022-03-04 11:56:33 -05:00