Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB8B3CD5BD2 for ; Fri, 29 May 2026 10:23:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3ECFF10FC98; Fri, 29 May 2026 10:23:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=dmitry.osipenko@collabora.com header.b="ASfqEzYR"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6C8E10FC98 for ; Fri, 29 May 2026 10:23:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1780050232; cv=none; d=zohomail.com; s=zohoarc; b=Dyk1QT+361cVBFMSOqSiOro2qhOMxuCVvQ7R00p8YHjbwwVHr0bawWCy2g4wQ1XzvHAFy0nkKpmXErtL0YwY+j4OcudC/+PVFFsoBlKCwrBe1GW2X5r1f5HVJKEQx8H5B185S+pIXbUJvf9yXMp1O3rconvCWWOf+H9xbEJHugI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780050232; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Z7rNUCAEGScMwFc5gyKgYkHU5rEnSfXGbO4wIXD7YMA=; b=BMkf850Czt8NWVzaBQctR/d5tIfbKYdmyE8Fc3rfkUhjdulDmRZLKw40ruOqjGj4WzyTSqX+7NP7pJFtBrrGMFfZ/h/04vaes2geSpMMljV9pmc+qCHJgcr4R3r//RXNxY7tjre6j4TdHYSlQsD2Omf5lvrGMkSqLKyjPrjrJqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=dmitry.osipenko@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1780050232; s=zohomail; d=collabora.com; i=dmitry.osipenko@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To:Cc; bh=Z7rNUCAEGScMwFc5gyKgYkHU5rEnSfXGbO4wIXD7YMA=; b=ASfqEzYRhukSIVr6shG7ISNq8xI8gr6LiUM0GXTcuzDCMMzulKD0zT2lT1vcq7lh ZAxrE8rnDhiyf+d3jkyssKKCJN4Sr2LhtfCplhRBAn/kPNGE4OIe/4H6gfy4VKMZgWa egEGA23MbM5VRnZq3rz2srZ0NpwClQNwz5g8IxVc= Received: by mx.zohomail.com with SMTPS id 1780050229411150.7880417884635; Fri, 29 May 2026 03:23:49 -0700 (PDT) Message-ID: Date: Fri, 29 May 2026 13:23:45 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 0/3] Virtio-GPU S4 support To: dongwon.kim@intel.com, dri-devel@lists.freedesktop.org, airlied@redhat.com, kraxel@redhat.com References: <20260526192814.179673-1-dongwon.kim@intel.com> Content-Language: en-US From: Dmitry Osipenko In-Reply-To: <20260526192814.179673-1-dongwon.kim@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ZohoMailClient: External X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 5/26/26 22:28, dongwon.kim@intel.com wrote: > From: Dongwon Kim > > This patch series implements the .freeze and .restore hooks for the virtio-gpu > driver, alongside a PM notifier to properly handle object tracking and > restoration for S4 (hibernation) scenarios. > > The first patch adds the `virtgpu_freeze` and `virtgpu_restore` functions. > These functions orchestrate flushing pending work, safely deleting virtio > queues before suspension once they are empty, and recreating them during > the restoration process. > > The second patch implements a tracking and recreation mechanism for active > `virtio_gpu_object` instances. This is necessary because the host hypervisor > (e.g., QEMU) terminates or resets the backend during a full hibernation cycle, > wiping out all previously established graphics resources and causing post-resume > errors in the guest. > > The third patch integrates a PM notifier block into the driver. It captures > the PM_HIBERNATION_PREPARE phase to check compatibility (blocking S4 if Virgl > 3D is active) and sets a state flag. This flag instructs `virtgpu_restore` to > fully re-submit and restore active GPU objects immediately after the fresh > virtqueues are reconfigured. > > These changes ensure that the virtio-gpu driver can cleanly survive guest > hibernation without experiencing host-side resource loss. > > v2: 10ms sleep is added in virtgpu_freeze to avoid the situation > the driver is locked up during resumption. > > v3: Plain 10ms delay (v2) is replaced with wait calls which wait until > the virtio queue is empty. > (Dmitry Osipenko) > > v4: New version of patchset only covers S4 case because loss of resources in S3 > case can be avoided by skipping virtio-gpu-reset in QEMU (hw/display/virtio-gpu.c). > To skip virtio-gpu-reset (soft-reset), virtio-gpu-pci device should be attached to > PCIE bus AND a PCIE option, 'x-pcie-pm-no-soft-reset' should added and set to 'true'. > (e.g. -device virtio-gpu-pci,bus=port,x-pcie-pm-no-soft-reset=true) > > v5: Remove virtio_gpu_object from the restore list before freeing the object > to prevent an use-after-free situation. > (Nirmoy Das) > > Protect restore list operations with a spinlock > (Nirmoy Das) > > Move restore list node into virtio_gpu_bo struct to reduce memory usage > (Dmitry Osipenko) > > Remove unused header - drm_atomic_helper.h > (Dmitry Osipenko) > > v6: Include object backed by imported dmabuf > (Dmitry Osipenko) > > Not storing virgl objects in the restore_list as virgl 3D objects are not > recoverable. > (Dmitry Osipenko) > > Change the name 'list',a node in restore_list to 'restore_node' > (Nirmoy Das) > > Use mutex instead of spinlock when updating restore_list > (Nirmoy Das) > > Initialize restore_node when virtio_gpu_object is created - this is to > check if the node is in the list with 'list_empty' before removing it. > > Restoring objects in the PM notifier is too late, as virtio-gpu > message communication begins in virtgpu_restore once virtqueues > are re-established. To address this, a 'hibernation' flag is set > during the PM_HIBERNATION_PREPARE phase in the notifier. This flag > is then used in virtgpu_restore to detect if the system is resuming > from S4, allowing objects to be recovered immediately after virtqueues > are reconfigured. > > v7: Add a helper, virtio_gpu_add_object_to_restore_list > (Dmitry Osipenko) > > Unreference all objects before hibernation so they can be removed > on the host side, since they will be fully restored anyway. This > prevents the situation where host-side hibernation fails (leaving > all associated resources still alive) while the virtio-gpu driver > still attempts to restore those objects. > (Dmitry Osipenko) > > v8: Add drm_print.h to virtgpu_prime.c > > v9: Move duplicate wait_event_timeout blocks into a single > virtio_gpu_wait_queue helper function. > (Dmitry Osipenko) > > Handle timeouts gracefully by returning -ETIMEDOUT to abort > the freeze operation if the host hangs. > (Dmitry Osipenko) > > Dongwon Kim (3): > drm/virtio: Freeze and restore hooks to support suspend and resume > drm/virtio: Add support for saving and restoring virtio_gpu_objects > drm/virtio: Add PM notifier to restore objects after hibernation > > drivers/gpu/drm/virtio/virtgpu_drv.c | 80 ++++++++++++++++++++++- > drivers/gpu/drm/virtio/virtgpu_drv.h | 25 ++++++- > drivers/gpu/drm/virtio/virtgpu_kms.c | 54 +++++++++++++-- > drivers/gpu/drm/virtio/virtgpu_object.c | 87 ++++++++++++++++++++++++- > drivers/gpu/drm/virtio/virtgpu_prime.c | 45 ++++++++++++- > drivers/gpu/drm/virtio/virtgpu_vq.c | 30 ++++++++- > drivers/gpu/drm/virtio/virtgpu_vram.c | 5 +- > 7 files changed, 312 insertions(+), 14 deletions(-) > Applied to misc next, thanks! Addressed and inlined fixes for issues reported on [1], plus made misc minor improvements and fixes: - added missing drm_mode_config_helper_resume() - use proper types for vars - remove extra blank line - rename hibernation -> hibernated - improved error messages, telling more what failed - removed inclusion of pm_runtime.h - properly handle register_pm_notifier failure [1] https://lore.gitlab.freedesktop.org/drm-ai-reviews/review-overall-20260526192814.179673-1-dongwon.kim@intel.com/T/#u -- Best regards, Dmitry