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 32D36CFC50A for ; Fri, 21 Nov 2025 21:03:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46A8510E902; Fri, 21 Nov 2025 21:03:40 +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="A3BHKhbF"; dkim-atps=neutral Received: from sender3-pp-f112.zoho.com (sender3-pp-f112.zoho.com [136.143.184.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB73410E902 for ; Fri, 21 Nov 2025 21:03:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1763759015; cv=none; d=zohomail.com; s=zohoarc; b=Xm5hPSCReZzIWXjXbqxcj/EuVkmmMi41eT34rNdZymD27RisKyJL9iYZ4fspTTNVKGt+dXrFE3IlpG/KDkmpaXUBDmegmi1b/RI6I+baMeAEdXxCBRyb8SK26Ckd0e9MQm1JejqlXu2hYNVcyZY6Kn/m+BpfGNF18ICZ5YT+FBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1763759015; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=cO3jzHHVM4zgTK7Lmm9UpK4asdWl+g69Wllbi4p8Z1Q=; b=NDJPyhQgQgDteYit8pSRJ0WSfDKuxRw+U5zj+DnpjKTyMW0Noyht+UgaWdI+JSM/GgTOw+aQX3jQDYdniI/SWrx2ZLy+DNFFwKUf3YZ8VEOwZwMZWM+Fh/PGzSwKBSAVkpUPL/GCdT231fSMT+zXRnu2QolOfqOYvcQnHEKh0vM= 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=1763759015; s=zohomail; d=collabora.com; i=dmitry.osipenko@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:From:From:To:To:Cc:Cc:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=cO3jzHHVM4zgTK7Lmm9UpK4asdWl+g69Wllbi4p8Z1Q=; b=A3BHKhbFhBlBc8n0LQKiSjMdTpzqN5ynz634M+U7pzh4QBTTQayEBw7qRcmmVJQD SNG6n3r7jzyyQ52Px6KqWxwgGuBW3VEyFw8dlJ1tGC+es+6wPSmZ4aN51t8OeMxpTfc /egzK9Mg31KblP8wTp+NyC45hkqFq6ZaknJj/Wmw= Received: by mx.zohomail.com with SMTPS id 176375901351589.46675248097893; Fri, 21 Nov 2025 13:03:33 -0800 (PST) Message-ID: Date: Sat, 22 Nov 2025 00:03:30 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 3/3] drm/virtio: Add PM notifier to restore objects after hibernation From: Dmitry Osipenko To: "Kim, Dongwon" , "dri-devel@lists.freedesktop.org" Cc: "airlied@redhat.com" , "kraxel@redhat.com" , "nirmoyd@nvidia.com" References: <20251027205323.491349-1-dongwon.kim@intel.com> <20251027205323.491349-4-dongwon.kim@intel.com> <90f9c416-05d6-45f4-8205-027fc36e88e0@collabora.com> <55556365-4c6e-450c-89aa-9c49ede53b00@collabora.com> <66183a1b-c724-41fe-ae90-4d73e5f2aa67@collabora.com> <9df778af-76bf-439b-a66e-a4e9b809176a@collabora.com> Content-Language: en-US In-Reply-To: <9df778af-76bf-439b-a66e-a4e9b809176a@collabora.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 11/21/25 21:12, Dmitry Osipenko wrote: > Hi, > > On 11/20/25 04:41, Kim, Dongwon wrote: >> Hi Dmitry, >> >>> -----Original Message----- >>> From: Dmitry Osipenko >>> Sent: Friday, November 14, 2025 5:16 AM >>> To: Kim, Dongwon ; dri- >>> devel@lists.freedesktop.org >>> Cc: airlied@redhat.com; kraxel@redhat.com; nirmoyd@nvidia.com >>> Subject: Re: [PATCH v6 3/3] drm/virtio: Add PM notifier to restore objects >>> after hibernation >>> >>> On 11/13/25 23:47, Kim, Dongwon wrote: >>>>> One option could be to explicitly destroy all stored objs upon >>>>> hibernation, that way the restoring will always work. >>>> Yes, we can do it to avoid that corner case. Or maybe we can just let it just >>> run. >>>> In this case, virtio_gpu_object_restore_all won't fail as shmem init >>>> will still work but QEMU will justsend back errored replies as all of >>>> those resources for BOs are still there in QEMU side but I think it >>>> won't break anything. Do you see any issues in doing this that I might >>>> be missing?? My assumption here is that the QEMU hasn't done any of >>> virtio-gpu resets here as hibernation failed. >>> >>> Correct, QEMU will emit a ton of "resource already exists" errors on aborted >>> hibernation. There should be no errors neither from guest, nor from host. >>> Note that QEMU is not the only VMM using VirtIO-GPU. >>> >>> Two options here: >>> >>> 1. Destroy stored host resources upon hibernation 2. Extend hibernation >>> core [1] with addition of PM_HIBERNATION_UNPREPARE event that will be >>> invoked when hibernation fails, while PM_POST_HIBERNATION will be >>> invoked only after a successful hibernation >>> >>> You may start with implementing the first option right away and later >>> implement the second. >> >> I am testing the first method - send unref message to QEMU so that connected >> resources can be all removed from QEMU. But I found out there is cb that clean up >> the object once this unref is processed and response is received. It means that >> we can't just remove the resource/bo only in QEMU side. There is a way to do this >> though. We can simply add one more fuction in virtgpu_vq.c that handles unref >> but with cb = NULL. Is this what you want to try or do you have any better ideas? > The cb certainly shall not be invoked. You only need to send the > "DETACH" cmd to host. This should be akin to what I did in my older > patches adding memory shmem shrinker support to virtio-gpu, please see > [1] for inspiration. > > [1] > https://lore.kernel.org/dri-devel/20231029230205.93277-26-dmitry.osipenko@collabora.com/ Actually, in your case it will be the "UNREF" cmd, not "DETACH". But the idea in the same, you need to destroy resource only on host on suspend. -- Best regards, Dmitry