* [PATCH] drm/virtio: implement virtio_gpu_shutdown
@ 2025-05-07 8:28 Gerd Hoffmann
2025-05-10 9:59 ` Maxime Ripard
2025-05-26 15:48 ` Dmitry Osipenko
0 siblings, 2 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2025-05-07 8:28 UTC (permalink / raw)
To: dri-devel
Cc: Gerd Hoffmann, Michael S. Tsirkin, Eric Auger, David Airlie,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, Simona Vetter, open list:VIRTIO GPU DRIVER,
open list
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 <mst@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index e32e680c7197..71c6ccad4b99 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -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)
--
2.49.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/virtio: implement virtio_gpu_shutdown
2025-05-07 8:28 [PATCH] drm/virtio: implement virtio_gpu_shutdown Gerd Hoffmann
@ 2025-05-10 9:59 ` Maxime Ripard
2025-05-13 10:18 ` Gerd Hoffmann
2025-05-26 15:48 ` Dmitry Osipenko
1 sibling, 1 reply; 6+ messages in thread
From: Maxime Ripard @ 2025-05-10 9:59 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: dri-devel, Michael S. Tsirkin, Eric Auger, David Airlie,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Thomas Zimmermann,
Simona Vetter, open list:VIRTIO GPU DRIVER, open list
[-- Attachment #1: Type: text/plain, Size: 1416 bytes --]
Hi,
On Wed, May 07, 2025 at 10:28:21AM +0200, Gerd Hoffmann wrote:
> 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 <mst@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> Tested-by: Eric Auger <eric.auger@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> index e32e680c7197..71c6ccad4b99 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -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);
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/virtio: implement virtio_gpu_shutdown
2025-05-10 9:59 ` Maxime Ripard
@ 2025-05-13 10:18 ` Gerd Hoffmann
2025-05-18 21:53 ` Michael S. Tsirkin
0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2025-05-13 10:18 UTC (permalink / raw)
To: Maxime Ripard
Cc: dri-devel, Michael S. Tsirkin, Eric Auger, David Airlie,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Thomas Zimmermann,
Simona Vetter, open list:VIRTIO GPU DRIVER, open list
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > index e32e680c7197..71c6ccad4b99 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > @@ -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);
>
> 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.
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/virtio: implement virtio_gpu_shutdown
2025-05-13 10:18 ` Gerd Hoffmann
@ 2025-05-18 21:53 ` Michael S. Tsirkin
2025-05-19 8:43 ` Maxime Ripard
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2025-05-18 21:53 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Maxime Ripard, dri-devel, Eric Auger, David Airlie,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Thomas Zimmermann,
Simona Vetter, open list:VIRTIO GPU DRIVER, open list
On Tue, May 13, 2025 at 12:18:44PM +0200, Gerd Hoffmann wrote:
> > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > index e32e680c7197..71c6ccad4b99 100644
> > > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > @@ -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);
> >
> > 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.
>
> 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
I suggest adding comments in code explaining why it's approriate here.
Want to try?
--
MST
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/virtio: implement virtio_gpu_shutdown
2025-05-18 21:53 ` Michael S. Tsirkin
@ 2025-05-19 8:43 ` Maxime Ripard
0 siblings, 0 replies; 6+ messages in thread
From: Maxime Ripard @ 2025-05-19 8:43 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Gerd Hoffmann, dri-devel, Eric Auger, David Airlie,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Thomas Zimmermann,
Simona Vetter, open list:VIRTIO GPU DRIVER, open list
[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]
On Sun, May 18, 2025 at 05:53:59PM -0400, Michael S. Tsirkin wrote:
> On Tue, May 13, 2025 at 12:18:44PM +0200, Gerd Hoffmann wrote:
> > > > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > > index e32e680c7197..71c6ccad4b99 100644
> > > > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > > > @@ -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);
> > >
> > > 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.
> >
> > 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
>
>
> I suggest adding comments in code explaining why it's approriate here.
> Want to try?
Yes, that would be great
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/virtio: implement virtio_gpu_shutdown
2025-05-07 8:28 [PATCH] drm/virtio: implement virtio_gpu_shutdown Gerd Hoffmann
2025-05-10 9:59 ` Maxime Ripard
@ 2025-05-26 15:48 ` Dmitry Osipenko
1 sibling, 0 replies; 6+ messages in thread
From: Dmitry Osipenko @ 2025-05-26 15:48 UTC (permalink / raw)
To: Gerd Hoffmann, dri-devel
Cc: Michael S. Tsirkin, Eric Auger, David Airlie, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Simona Vetter, open list:VIRTIO GPU DRIVER, open list
On 5/7/25 11:28, Gerd Hoffmann wrote:
> 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 <mst@redhat.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
> Tested-by: Eric Auger <eric.auger@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_drv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
> index e32e680c7197..71c6ccad4b99 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -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)
Could you please describe whether this patch is fixing a specific
problem or it's a generic improvement for avoiding potential problems on
shutdown.
--
Best regards,
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-05-26 15:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 8:28 [PATCH] drm/virtio: implement virtio_gpu_shutdown Gerd Hoffmann
2025-05-10 9:59 ` Maxime Ripard
2025-05-13 10:18 ` Gerd Hoffmann
2025-05-18 21:53 ` Michael S. Tsirkin
2025-05-19 8:43 ` Maxime Ripard
2025-05-26 15:48 ` Dmitry Osipenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox