2021-10-22 02:47:32

by Wu Zongyong

[permalink] [raw]
Subject: [PATCH v6 5/8] vdpa: min vq num of vdpa device cannot be greater than max vq num

Just failed to probe the vdpa device if the min virtqueue num returned
by get_vq_num_min is greater than the max virtqueue num returned by
get_vq_num_max.

Signed-off-by: Wu Zongyong <[email protected]>
---
drivers/vdpa/vdpa.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 1dc121a07a93..fd014ecec711 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d)
{
struct vdpa_device *vdev = dev_to_vdpa(d);
struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
+ const struct vdpa_config_ops *ops = vdev->config;
+ u32 max_num, min_num = 0;
int ret = 0;

+ max_num = ops->get_vq_num_max(vdev);
+ if (ops->get_vq_num_min)
+ min_num = ops->get_vq_num_min(vdev);
+ if (max_num < min_num)
+ return -EINVAL;
+
if (drv && drv->probe)
ret = drv->probe(vdev);

--
2.31.1


2021-10-25 02:45:53

by Jason Wang

[permalink] [raw]
Subject: Re: [PATCH v6 5/8] vdpa: min vq num of vdpa device cannot be greater than max vq num

On Fri, Oct 22, 2021 at 10:44 AM Wu Zongyong
<[email protected]> wrote:
>
> Just failed to probe the vdpa device if the min virtqueue num returned
> by get_vq_num_min is greater than the max virtqueue num returned by
> get_vq_num_max.
>
> Signed-off-by: Wu Zongyong <[email protected]>

Acked-by: Jason Wang <[email protected]>

> ---
> drivers/vdpa/vdpa.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 1dc121a07a93..fd014ecec711 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -26,8 +26,16 @@ static int vdpa_dev_probe(struct device *d)
> {
> struct vdpa_device *vdev = dev_to_vdpa(d);
> struct vdpa_driver *drv = drv_to_vdpa(vdev->dev.driver);
> + const struct vdpa_config_ops *ops = vdev->config;
> + u32 max_num, min_num = 0;
> int ret = 0;
>
> + max_num = ops->get_vq_num_max(vdev);
> + if (ops->get_vq_num_min)
> + min_num = ops->get_vq_num_min(vdev);
> + if (max_num < min_num)
> + return -EINVAL;
> +
> if (drv && drv->probe)
> ret = drv->probe(vdev);
>
> --
> 2.31.1
>