drm/virtio: implement virtio_gpu_shutdown
Subsystems (4)
Gerd Hoffmann
maintainerPATCH 1/1 drm/virtio: implement virtio_gpu_shutdown
Calling drm_dev_unplug() is the drm way to say the device is gone and can not be accessed any more.
--- drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.c +4 -4
@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/* -* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev); }static void virtio_gpu_config_changed (struct virtio_device *vdev)
Signature · 1 line
2.49.0
Maxime Ripard
maintainerHi,
Quoted 17 lines · Gerd Hoffmann
Calling
drm_dev_unplug()is the drm way to say the device is gone and can not be accessed any more.Cc Michael S. Tsirkin <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Eric Auger <[email protected]>Tested-by Eric Auger <[email protected]>--- drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/virtio/virtgpu_drv.c +0
-0@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
drivers/gpu/drm/virtio/virtgpu_drv.c static void virtio_gpu_remove(struct virtio_device *vdev) · line 136
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +4
-4static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/* -* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev);
I'm not necessarily opposed to using drm_dev_unplug() here, but it's still pretty surprising to me. It's typically used in remove, not shutdown. The typical helper to use at shutdown is drm_atomic_helper_shutdown.
So if the latter isn't enough or wrong, we should at least document why.
Maxime
Gerd Hoffmann
maintainerQuoted 22 lines
Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +0
-0@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)drivers/gpu/drm/virtio/virtgpu_drv.c static void virtio_gpu_remove(struct virtio_device *vdev) · line 136
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +4
-4static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/* -* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev);I'm not necessarily opposed to using
drm_dev_unplug()here, but it's still pretty surprising to me. It's typically used in remove, not shutdown. The typical helper to use at shutdown isdrm_atomic_helper_shutdown.
Quoted 1 line
So if the latter isn't enough or wrong, we should at least document why.
The intention of this is to make sure the driver stops talking to the device (as the comment already says).
There are checks in place in the virt queue functions which will make sure the driver will not try place new requests in the queues after drm_dev_unplug() has been called. Which why I decided to implement it that way.
drm_atomic_helper_shutdown() tears down all outputs according to the documentation. Which is something different. I don't think calling drm_atomic_helper_shutdown() will do what I need here. Calling it in addition to drm_dev_unplug() might make sense, not sure.
Suggestions are welcome.
take care,
Gerd
Michael S. Tsirkin
maintainerQuoted 37 lines · Gerd Hoffmann
Quoted 22 lines
Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +0
-0@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)drivers/gpu/drm/virtio/virtgpu_drv.c static void virtio_gpu_remove(struct virtio_device *vdev) · line 136
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +4
-4static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/* -* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev);I'm not necessarily opposed to using
drm_dev_unplug()here, but it's still pretty surprising to me. It's typically used in remove, not shutdown. The typical helper to use at shutdown isdrm_atomic_helper_shutdown.Quoted 1 line
So if the latter isn't enough or wrong, we should at least document why.
The intention of this is to make sure the driver stops talking to the device (as the comment already says).
There are checks in place in the virt queue functions which will make sure the driver will not try place new requests in the queues after
drm_dev_unplug()has been called. Which why I decided to implement it that way.
drm_atomic_helper_shutdown()tears down all outputs according to the documentation. Which is something different. I don't think callingdrm_atomic_helper_shutdown()will do what I need here. Calling it in addition todrm_dev_unplug()might make sense, not sure.
Quoted 4 lines
Suggestions are welcome.
take care,
Gerd
I suggest adding comments in code explaining why it's approriate here. Want to try?
Signature · 1 line
MST
Maxime Ripard
maintainerQuoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Gerd Hoffmann
Quoted 22 lines
Quoted 6 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +0
-0@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)drivers/gpu/drm/virtio/virtgpu_drv.c static void virtio_gpu_remove(struct virtio_device *vdev) · line 136
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +4
-4static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/* -* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev);I'm not necessarily opposed to using
drm_dev_unplug()here, but it's still pretty surprising to me. It's typically used in remove, not shutdown. The typical helper to use at shutdown isdrm_atomic_helper_shutdown.Quoted 1 line
So if the latter isn't enough or wrong, we should at least document why.
The intention of this is to make sure the driver stops talking to the device (as the comment already says).
There are checks in place in the virt queue functions which will make sure the driver will not try place new requests in the queues after
drm_dev_unplug()has been called. Which why I decided to implement it that way.
drm_atomic_helper_shutdown()tears down all outputs according to the documentation. Which is something different. I don't think callingdrm_atomic_helper_shutdown()will do what I need here. Calling it in addition todrm_dev_unplug()might make sense, not sure.
Quoted 8 lines
Quoted 4 lines
Suggestions are welcome.
take care,
GerdI suggest adding comments in code explaining why it's approriate here. Want to try?
Yes, that would be great
Maxime
Dmitry Osipenko
maintainerQuoted 20 lines · Gerd Hoffmann
Calling
drm_dev_unplug()is the drm way to say the device is gone and can not be accessed any more.Cc Michael S. Tsirkin <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>Reviewed-by Eric Auger <[email protected]>Tested-by Eric Auger <[email protected]>--- drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/virtio/virtgpu_drv.c +0
-1@@ -130,10 +130,10 @@ static void virtio_gpu_remove(struct virtio_device *vdev)static void virtio_gpu_shutdown (struct virtio_device *vdev) { -/*
drivers/gpu/drm/virtio/virtgpu_drv.c static void virtio_gpu_remove(struct virtio_device *vdev) · line 139
Quoted 10 lines
drivers/gpu/drm/virtio/virtgpu_drv.c +4
-3-* drm does its own synchronization on shutdown. -* Do nothing here, opt out of device reset. -*/ +struct drm_device *dev = vdev->priv; + +/* stop talking to the device */ +drm_dev_unplug (dev); }static void virtio_gpu_config_changed (struct virtio_device *vdev)
Could you please describe whether this patch is fixing a specific problem or it's a generic improvement for avoiding potential problems on shutdown.
Signature · 2 lines
Best regards, Dmitry