Skip to contentSkip to conversation

remoteproc: remoteproc_virtio: reset vdev before removing it

PATCH In review Tanmay Shah 4 participants 6 messages Sep 24 – Oct 2 Remote processor (remoteproc)

lore
Share & tools
lore
#0 lore raw

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.

Fixes 7a186941626d ("remoteproc: remove the single rpmsg vdev limitation")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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
#1 lore raw

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")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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
#2 lore raw
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")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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
maintainer
#3 lore raw
In reply to Francesco Valla
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() 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")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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
#4 lore raw
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() 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?

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")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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
maintainer
#5 lore raw
Quoted 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() 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.

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")
---
 drivers/remoteproc/remoteproc_virtio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/remoteproc_virtio.c +2 -0
index d5e9ff045a28..1cb0ee0ea656 100644
@@ -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