vsock/virtio: set vsock frontend ready in virtio_vsock_probe()
Subsystems (6)
PATCH v2 1/1 vsock/virtio: set vsock frontend ready in virtio_vsock_probe()
Add the missed virtio_device_ready() to set vsock frontend ready.
--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)
net/vmw_vsock/virtio_transport.c +2 -0
@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev); +return 0 ; out:
Signature · 1 line
2.17.1
Quoted 12 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian <[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)net/vmw_vsock/virtio_transport.c +0
-0
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 646
Quoted 8 lines
net/vmw_vsock/virtio_transport.c +2
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev); +return 0 ; out:
Just notice this:
commit 5b40a7daf51812b35cf05d1601a779a7043f8414
Author: Rusty Russell <[email protected]>
Date: Tue Feb 17 16:12:44 2015 +1030
virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice.
I noticed this with the console device. It's not *wrong*, just a bit weird.
drivers/virtio/virtio.c +0 -0
@@ -236,7 +236,10 @@ static int virtio_dev_probe(struct device *_d)
if (err)
goto err;
- add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
+ /* If probe didn't do it, mark device DRIVER_OK ourselves. */ + if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK)) + virtio_device_ready(dev);
+
if (drv->scan)
drv->scan(dev);
So I think we need to be consistent: switch to use virtio_device_ready() for all the drivers, and then we can remove this step and warn if (DRIVER_OK) is not set.
Thanks
thanks for the findings.
Let me make furture patches to make consistent.
Quoted 54 lines · Jason Wang
Quoted 17 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian <[email protected]>---
net/vmw_vsock/virtio_transport.c| 2 ++1 file changed, 2 insertions(+)net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev) mutex_unlock(&the_virtio_vsock_mutex); + virtio_device_ready(vdev); + return 0;Quoted 1 line
out:
Just notice this:
commit
5b40a7daf51812b35cf05d1601a779a7043f8414
Author: Rusty Russell <[email protected]>
Date: Tue Feb 17 16:12:44 2015 +1030virtio: don't set
VIRTIO_CONFIG_S_DRIVER_OKtwice.I noticed this with the console device. It's not *wrong*, just a bit weird.
Signed-off-by Rusty Russell <[email protected]>drivers/virtio/virtio.c +4
-1@@ -236,7 +236,10 @@ static int virtio_dev_probe(struct device *_d) if (err) goto err; - add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK); + /* If probe didn't do it, mark device DRIVER_OK ourselves. */ + if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK)) + virtio_device_ready(dev); + if (drv->scan) drv->scan(dev);So I think we need to be consistent: switch to use
virtio_device_ready()for all the drivers, and then we can remove this step and warn if (DRIVER_OK) is not set.Thanks
Stefan Hajnoczi
maintainerQuoted 6 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian <[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)
Please include a changelog when you send v2, v3, etc patches.
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 642
Quoted 10 lines
net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev);
Why is this patch necessary?
The core virtio_dev_probe() code already calls virtio_device_ready for us:
static int virtio_dev_probe(struct device *_d)
{
...
err = drv->probe(dev);
if (err)
goto err; /* If probe didn't do it, mark device DRIVER_OK ourselves. */
if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK))
virtio_device_ready(dev);OK,
thanks
Quoted 33 lines · Stefan Hajnoczi
Quoted 6 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian <[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)Please include a changelog when you send v2, v3, etc patches.
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 642
Quoted 9 lines
net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev);Why is this patch necessary?
The core
virtio_dev_probe()code already callsvirtio_device_readyfor us:static int virtio_dev_probe(struct device *_d) { ... err = drv->probe(dev); if (err) goto err;/* If probe didn't do it, mark device DRIVER_OK ourselves. */ if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK)) virtio_device_ready(dev);
Quoted 8 lines · Stefan Hajnoczi
Quoted 6 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian<[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)Please include a changelog when you send v2, v3, etc patches.
OK, thanks.
Quoted 10 lines
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 642
Quoted 9 lines
net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev);Why is this patch necessary?
Sorry, I didn't notice the check in virtio_dev_probe(),
As Jason comment, I alsoe think we need to be consistent: switch to use virtio_device_ready() for all the drivers. What's opinion about this?
Quoted 13 lines
The core
virtio_dev_probe()code already callsvirtio_device_readyfor us:static int virtio_dev_probe(struct device *_d) { ... err = drv->probe(dev); if (err) goto err;/* If probe didn't do it, mark device DRIVER_OK ourselves. */ if (!(dev->config->get_status(dev) & VIRTIO_CONFIG_S_DRIVER_OK)) virtio_device_ready(dev);
Stefan Hajnoczi
maintainerQuoted 20 lines · Xianting Tian
Quoted 8 lines · Stefan Hajnoczi
Quoted 6 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian<[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)Please include a changelog when you send v2, v3, etc patches.
OK, thanks.
Quoted 8 lines
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 640
Quoted 7 lines
net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev);Why is this patch necessary?
Quoted 4 lines
Sorry, I didn't notice the check in
virtio_dev_probe(),As Jason comment, I alsoe think we need to be consistent: switch to use
virtio_device_ready()for all the drivers. What's opinion about this?
According to the documentation the virtio_device_read() API is optional:
/**
* virtio_device_ready - enable vq use in probe function
* @vdev: the device
*
* Driver must call this to use vqs in the probe function.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*
* Note: vqs are enabled automatically after probe returns.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
Many drivers do not use vqs during the ->probe() function. They don't need to call virtio_device_ready(). That's why the virtio_vsock driver doesn't call it.
But if a ->probe() function needs to send virtqueue buffers, e.g. to query the device or activate some device feature, then the driver will need to call it explicitly.
The documentation is clear and this design is less error-prone than relying on all drivers to call it manually. I suggest leaving things unchanged.
Stefan
Got it.
thanks for the comments,
Quoted 49 lines · Stefan Hajnoczi
Quoted 18 lines · Xianting Tian
Quoted 8 lines · Stefan Hajnoczi
Quoted 6 lines · Xianting Tian
Add the missed
virtio_device_ready()to set vsock frontend ready.Signed-off-by Xianting Tian<[email protected]>--- net/vmw_vsock/virtio_transport.c | 2 ++ 1 file changed, 2 insertions(+)Please include a changelog when you send v2, v3, etc patches.
OK, thanks.
Quoted 8 lines
net/vmw_vsock/virtio_transport.c static int virtio_vsock_probe(struct virtio_device *vdev) · line 640
Quoted 7 lines
net/vmw_vsock/virtio_transport.c +1
-0@@ -639,6 +639,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)mutex_unlock (&the_virtio_vsock_mutex); +virtio_device_ready (vdev);Why is this patch necessary?
Quoted 4 lines
Sorry, I didn't notice the check in
virtio_dev_probe(),As Jason comment, I alsoe think we need to be consistent: switch to use
virtio_device_ready()for all the drivers. What's opinion about this?According to the documentation the
virtio_device_read()API is optional:/** * virtio_device_ready - enable vq use in probe function * @vdev: the device * * Driver must call this to use vqs in the probe function. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * * Note: vqs are enabled automatically after probe returns. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */Many drivers do not use vqs during the ->probe() function. They don't need to call
virtio_device_ready(). That's why thevirtio_vsockdriver doesn't call it.But if a ->probe() function needs to send virtqueue buffers, e.g. to query the device or activate some device feature, then the driver will need to call it explicitly.
The documentation is clear and this design is less error-prone than relying on all drivers to call it manually. I suggest leaving things unchanged.
Stefan