remoteproc: remoteproc_virtio: reset vdev before removing it
PATCH 1/1 remoteproc: remoteproc_virtio: reset vdev before removing it
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }
base-commit: 5f639b3018c0026a5341949724b4b921cf3a3d5d
Signature · 1 line
2.43.0
Hi Tanmay,
Quoted 4 lines · Tanmay Shah
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
Shouldn't be the driver, and not the transport, the one that calls virtio_reset_device()?
Quoted 24 lines
Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/remoteproc_virtio.c +2
-0@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }base-commit:
5f639b3018c0026a5341949724b4b921cf3a3d5dSignature · 1 line
2.43.0
Quoted 11 lines · Francesco Valla
Hi Tanmay,
Quoted 4 lines · Tanmay Shah
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
Shouldn't be the driver, and not the transport, the one that calls
virtio_reset_device()?
Hello Francesco,
Thanks for your reviews. I will look into it.
Tanmay
Quoted 24 lines
Quoted 24 lines
Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/remoteproc_virtio.c +2
-0@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }base-commit:
5f639b3018c0026a5341949724b4b921cf3a3d5dSignature · 1 line
2.43.0
Mathieu Poirier
maintainerQuoted 10 lines · Francesco Valla
Hi Tanmay,
Quoted 4 lines · Tanmay Shah
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
Shouldn't be the driver, and not the transport, the one that calls
virtio_reset_device()?
Function rproc_remove_virtio_dev() calls unregister_virtio_device(), which calls device_unregister(), which should end up calling virtio_bus.remove(), in this case virtio_dev_remove(). virtio_dev_remove() calls drv->remove(). If we take the RPMSG driver, rpmsg_remove() calls virtio_reset_device(), so explicitly resetting devices as part of rproc_remove_virtio_dev() is not needed.
Tanmay, have you observed a scenario where the above isn't working?
Quoted 25 lines
Quoted 25 lines
Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/remoteproc_virtio.c +2
-0@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }base-commit:
5f639b3018c0026a5341949724b4b921cf3a3d5dSignature · 1 line
2.43.0
Quoted 12 lines · Mathieu Poirier
Quoted 10 lines · Francesco Valla
Hi Tanmay,
Quoted 4 lines · Tanmay Shah
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
Shouldn't be the driver, and not the transport, the one that calls
virtio_reset_device()?
Quoted 8 lines
Function
rproc_remove_virtio_dev()callsunregister_virtio_device(), which callsdevice_unregister(), which should end up callingvirtio_bus.remove(), in this casevirtio_dev_remove().virtio_dev_remove()callsdrv->remove(). If we take the RPMSG driver,rpmsg_remove()callsvirtio_reset_device(), so explicitly resetting devices as part ofrproc_remove_virtio_dev()is not needed.Tanmay, have you observed a scenario where the above isn't working?
Nope. I didn't send the patch based on any practical scenario. This is an old patch that I had used at the time to issue reset on shutdown. I missed that the driver is already doing it. Probably my assessment was incorrect at the time. I think we should remove this patch.
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/remoteproc_virtio.c +2
-0@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }base-commit:
5f639b3018c0026a5341949724b4b921cf3a3d5dSignature · 1 line
2.43.0
Mathieu Poirier
maintainerQuoted 22 lines · Tanmay
Quoted 18 lines · Mathieu Poirier
Quoted 10 lines · Francesco Valla
Hi Tanmay,
Quoted 4 lines · Tanmay Shah
The virtio device is removed when the remoteproc device is removed. The driver should issue reset on the virtio device so the remote can do corresponding cleanup.
Shouldn't be the driver, and not the transport, the one that calls
virtio_reset_device()?Function
rproc_remove_virtio_dev()callsunregister_virtio_device(), which callsdevice_unregister(), which should end up callingvirtio_bus.remove(), in this casevirtio_dev_remove().virtio_dev_remove()callsdrv->remove(). If we take the RPMSG driver,rpmsg_remove()callsvirtio_reset_device(), so explicitly resetting devices as part ofrproc_remove_virtio_dev()is not needed.
Quoted 8 lines
Quoted 2 lines
Tanmay, have you observed a scenario where the above isn't working?
Nope. I didn't send the patch based on any practical scenario. This is an old patch that I had used at the time to issue reset on shutdown. I missed that the driver is already doing it. Probably my assessment was incorrect at the time. I think we should remove this patch.
I backed it out.
Quoted 26 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")Signed-off-by Tanmay Shah <[email protected]>--- drivers/remoteproc/remoteproc_virtio.c | 2 ++ 1 file changed, 2 insertions(+)drivers/remoteproc/remoteproc_virtio.c +2
-0@@ -469,6 +469,8 @@ static int rproc_remove_virtio_dev(struct device *dev, void *data) {struct virtio_device *vdev =dev_to_virtio (dev); +virtio_reset_device (vdev); +unregister_virtio_device (vdev);return 0 ; }base-commit:
5f639b3018c0026a5341949724b4b921cf3a3d5d--
2.43.0