linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] virtio/vdpa: Clear the available index during probe
@ 2021-05-31 16:05 Eli Cohen
  2021-06-01  2:20 ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Cohen @ 2021-05-31 16:05 UTC (permalink / raw)
  To: mst, jasowang, virtualization, linux-kernel; +Cc: elic

Clear the available index as part of the initialization process to
clear and values that might be left from previous usage of the device.
For example, if the device was previously used by vhost_vdpa and now
probed by vhost_vdpa, you want to start with indices.

Fixes: c043b4a8cf3b ("virtio: introduce a vDPA based transport")
Signed-off-by: Eli Cohen <elic@nvidia.com>
---
 drivers/virtio/virtio_vdpa.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
index e28acf482e0c..32fb121a6ec4 100644
--- a/drivers/virtio/virtio_vdpa.c
+++ b/drivers/virtio/virtio_vdpa.c
@@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
 	struct vdpa_callback cb;
 	struct virtqueue *vq;
 	u64 desc_addr, driver_addr, device_addr;
+	struct vdpa_vq_state state = {0};
 	unsigned long flags;
 	u32 align, num;
 	int err;
@@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
 		goto err_vq;
 	}
 
+	/* reset available index */
+	err = ops->set_vq_state(vdpa, index, &state);
+	if (err)
+		goto err_vq;
+
 	ops->set_vq_ready(vdpa, index, 1);
 
 	vq->priv = info;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] virtio/vdpa: Clear the available index during probe
  2021-05-31 16:05 [PATCH 3/3] virtio/vdpa: Clear the available index during probe Eli Cohen
@ 2021-06-01  2:20 ` Jason Wang
  2021-06-01  5:40   ` Jason Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2021-06-01  2:20 UTC (permalink / raw)
  To: Eli Cohen, mst, virtualization, linux-kernel


在 2021/6/1 上午12:05, Eli Cohen 写道:
> Clear the available index as part of the initialization process to
> clear and values that might be left from previous usage of the device.
> For example, if the device was previously used by vhost_vdpa and now
> probed by vhost_vdpa, you want to start with indices.
>
> Fixes: c043b4a8cf3b ("virtio: introduce a vDPA based transport")
> Signed-off-by: Eli Cohen <elic@nvidia.com>
> ---


Acked-by: Jason Wang <jasowang@redhat.com>

Note that we probably need a follow-up fixes for vp_vdpa driver.

I will post it soon.

Thanks


>   drivers/virtio/virtio_vdpa.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
> index e28acf482e0c..32fb121a6ec4 100644
> --- a/drivers/virtio/virtio_vdpa.c
> +++ b/drivers/virtio/virtio_vdpa.c
> @@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
>   	struct vdpa_callback cb;
>   	struct virtqueue *vq;
>   	u64 desc_addr, driver_addr, device_addr;
> +	struct vdpa_vq_state state = {0};
>   	unsigned long flags;
>   	u32 align, num;
>   	int err;
> @@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
>   		goto err_vq;
>   	}
>   
> +	/* reset available index */
> +	err = ops->set_vq_state(vdpa, index, &state);
> +	if (err)
> +		goto err_vq;
> +
>   	ops->set_vq_ready(vdpa, index, 1);
>   
>   	vq->priv = info;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] virtio/vdpa: Clear the available index during probe
  2021-06-01  2:20 ` Jason Wang
@ 2021-06-01  5:40   ` Jason Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2021-06-01  5:40 UTC (permalink / raw)
  To: Eli Cohen, mst, virtualization, linux-kernel


在 2021/6/1 上午10:20, Jason Wang 写道:
>
> 在 2021/6/1 上午12:05, Eli Cohen 写道:
>> Clear the available index as part of the initialization process to
>> clear and values that might be left from previous usage of the device.
>> For example, if the device was previously used by vhost_vdpa and now
>> probed by vhost_vdpa, you want to start with indices.
>>
>> Fixes: c043b4a8cf3b ("virtio: introduce a vDPA based transport")
>> Signed-off-by: Eli Cohen <elic@nvidia.com>
>> ---
>
>
> Acked-by: Jason Wang <jasowang@redhat.com>
>
> Note that we probably need a follow-up fixes for vp_vdpa driver.
>
> I will post it soon.
>
> Thanks


Hi Eli:

Rethink about this, it only works for the case of split virtqueue.

I will post a series that makes it work for both packed and split 
virtqueue (with some tweak on this patch).

Does this work for you?

Thanks


>
>
>>   drivers/virtio/virtio_vdpa.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
>> index e28acf482e0c..32fb121a6ec4 100644
>> --- a/drivers/virtio/virtio_vdpa.c
>> +++ b/drivers/virtio/virtio_vdpa.c
>> @@ -142,6 +142,7 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, 
>> unsigned int index,
>>       struct vdpa_callback cb;
>>       struct virtqueue *vq;
>>       u64 desc_addr, driver_addr, device_addr;
>> +    struct vdpa_vq_state state = {0};
>>       unsigned long flags;
>>       u32 align, num;
>>       int err;
>> @@ -191,6 +192,11 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, 
>> unsigned int index,
>>           goto err_vq;
>>       }
>>   +    /* reset available index */
>> +    err = ops->set_vq_state(vdpa, index, &state);
>> +    if (err)
>> +        goto err_vq;
>> +
>>       ops->set_vq_ready(vdpa, index, 1);
>>         vq->priv = info;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-01  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31 16:05 [PATCH 3/3] virtio/vdpa: Clear the available index during probe Eli Cohen
2021-06-01  2:20 ` Jason Wang
2021-06-01  5:40   ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).