Linux virtualization list
 help / color / mirror / Atom feed
From: "Morris Pan (潘泰為)" <Morris.Pan@mediatek.com>
To: "airlied@redhat.com" <airlied@redhat.com>,
	"kraxel@redhat.com" <kraxel@redhat.com>,
	"dmitry.osipenko@collabora.com" <dmitry.osipenko@collabora.com>,
	"tzimmermann@suse.de" <tzimmermann@suse.de>
Cc: "virtualization@lists.linux.dev" <virtualization@lists.linux.dev>,
	"srv_heupstream@mediatek.com" <srv_heupstream@mediatek.com>,
	"simona@ffwll.ch" <simona@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"olvaffe@gmail.com" <olvaffe@gmail.com>,
	"gurchetansingh@chromium.org" <gurchetansingh@chromium.org>,
	"maarten.lankhorst@linux.intel.com"
	<maarten.lankhorst@linux.intel.com>,
	"mripard@kernel.org" <mripard@kernel.org>
Subject: Re: [PATCH] drm/virtgpu: Add PM support for suspend/resume
Date: Wed, 8 Apr 2026 07:04:36 +0000	[thread overview]
Message-ID: <efdb6b9debcb5bb71d6161f70a619d0e11d0c5db.camel@mediatek.com> (raw)
In-Reply-To: <47e26c77-4efe-414e-a851-67791bde3a8c@suse.de>

On Wed, 2026-04-01 at 08:24 +0200, Thomas Zimmermann wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Hi
> 
> Am 01.04.26 um 08:10 schrieb Morris Pan:
> > Add freeze/restore callbacks to handle system suspend/resume.
> > During freeze, delete virtqueues and reset device.
> > During restore, reinitialize virtqueues and mark device ready.
> > 
> > Signed-off-by: Morris Pan <morris.pan@mediatek.com>
> > ---
> >   drivers/gpu/drm/virtio/virtgpu_drv.c | 40
> > +++++++++++++++++++++++++++-
> >   1 file changed, 39 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > index a5ce96fb8a1d..fbca0a82958c 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > @@ -145,6 +145,40 @@ static void virtio_gpu_config_changed(struct
> > virtio_device *vdev)
> >       schedule_work(&vgdev->config_changed_work);
> >   }
> > 
> > +#ifdef CONFIG_PM_SLEEP
> > +static int virtgpu_freeze(struct virtio_device *vdev)
> > +{
> 
> I think you first need to call drm_mode_config_helper_suspend() [1]
> to
> stop DRM and save the current state.
> 
> [1]
> https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.19.10/source/drivers/gpu/drm/drm_modeset_helper.c*L179__;Iw!!CTRNKA9wMg0ARbw!j0dxkuooYYkTXqgRzLyo558VesWoTL84VgkwhRczVxZ-PZlBeLg0vnY4B36rtYVRDVpGmTqVjGKJoFh7KnVelak$
> 
> > +     vdev->config->del_vqs(vdev);
> > +     virtio_reset_device(vdev);
> > +
> > +     return 0;
> > +}
> > +
> > +static int virtgpu_restore(struct virtio_device *vdev)
> > +{
> > +     int ret;
> > +     struct virtqueue *vqs[2];
> > +     struct drm_device *dev = vdev->priv;
> > +     struct virtio_gpu_device *vgdev = dev->dev_private;
> > +     struct virtqueue_info vqs_info[] = {
> > +             { "control", virtio_gpu_ctrl_ack },
> > +             { "cursor", virtio_gpu_cursor_ack },
> > +     };
> > +
> > +     ret = virtio_find_vqs(vdev, 2, vqs, vqs_info, NULL);
> > +     if (ret) {
> > +             DRM_ERROR("failed to find virtio queues\n");
> > +             return ret;
> > +     }
> > +
> > +     vgdev->ctrlq.vq = vqs[0];
> > +     vgdev->cursorq.vq = vqs[1];
> > +     virtio_device_ready(vdev);
> 
> And here you have to call drm_mode_config_helper_resume() [2] to
> restore
> the DRM state from before the freeze.
> 
> [2]
> https://urldefense.com/v3/__https://elixir.bootlin.com/linux/v6.19.10/source/drivers/gpu/drm/drm_modeset_helper.c*L227__;Iw!!CTRNKA9wMg0ARbw!j0dxkuooYYkTXqgRzLyo558VesWoTL84VgkwhRczVxZ-PZlBeLg0vnY4B36rtYVRDVpGmTqVjGKJoFh7cv1EDgQ$
> 
> Best regards
> Thomas
> 
> > +
> > +     return 0;
> > +}
> > +#endif
> > +
> >   static struct virtio_device_id id_table[] = {
> >       { VIRTIO_ID_GPU, VIRTIO_DEV_ANY_ID },
> >       { 0 },
> > @@ -172,7 +206,11 @@ static struct virtio_driver virtio_gpu_driver
> > = {
> >       .probe = virtio_gpu_probe,
> >       .remove = virtio_gpu_remove,
> >       .shutdown = virtio_gpu_shutdown,
> > -     .config_changed = virtio_gpu_config_changed
> > +     .config_changed = virtio_gpu_config_changed,
> > +#ifdef CONFIG_PM_SLEEP
> > +     .freeze = virtgpu_freeze,
> > +     .restore = virtgpu_restore
> > +#endif
> >   };
> > 
> >   static int __init virtio_gpu_driver_init(void)
> 
> --
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Frankenstr. 146, 90461 Nürnberg, Germany,
> https://urldefense.com/v3/__http://www.suse.com__;!!CTRNKA9wMg0ARbw!j0dxkuooYYkTXqgRzLyo558VesWoTL84VgkwhRczVxZ-PZlBeLg0vnY4B36rtYVRDVpGmTqVjGKJoFh74dj3x1M$
> GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG
> Nürnberg)
> 
> 

Hi Thomas,

Thank you very much for your detailed review and the constructive
feedback on my patch.

I am currently working on the revisions based on your comments.

Thanks again for your time and guidance.

Best regards,
Morris


  reply	other threads:[~2026-04-08  7:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  6:10 [PATCH] drm/virtgpu: Add PM support for suspend/resume Morris Pan
2026-04-01  6:24 ` Thomas Zimmermann
2026-04-08  7:04   ` Morris Pan (潘泰為) [this message]
2026-04-08 12:59 ` Dmitry Osipenko
2026-04-17  9:40   ` Morris Pan (潘泰為)
2026-04-30 22:49     ` Dmitry Osipenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=efdb6b9debcb5bb71d6161f70a619d0e11d0c5db.camel@mediatek.com \
    --to=morris.pan@mediatek.com \
    --cc=airlied@redhat.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gurchetansingh@chromium.org \
    --cc=kraxel@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=olvaffe@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=srv_heupstream@mediatek.com \
    --cc=tzimmermann@suse.de \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox