From mboxrd@z Thu Jan 1 00:00:00 1970 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 854EAC88E53 for ; Fri, 11 Sep 2026 21:42:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED68010E2DD; Fri, 11 Sep 2026 21:42:24 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="DBtSyh2T"; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id D176010E40C for ; Fri, 11 Sep 2026 21:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs.org; s=201707; t=1789162930; bh=mP9BImIYMo25bR2U7ro515N53S9BWIjWTdFtXfFoqGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBtSyh2TIcTcReXLFqr0fkMDW+LGSeGiaspIp93+XfoaiRsBo5310iHZRHdGOZr4C zoTFlyflBd3vm//3rr6DknwQ0Utxtrvu4llkTuNGiqM9v7nMcyHRsMHbllRrRHIN1l prscVgDz0Xuhk2EZPcJ9X2JWFWHb/2vNqFZQwn2Mg6tqhUXtP/9+tM2WL9OZ0nzyAg FDULcttYn2bQYANkd0XSl4ZOsyw6JDwIp4/Job4yUIWVkU3gyUoDMtJSKxhJVINpJq Py0ni2U3IOrtTdb6yzY/iavHmKzfBHWqKXeJvwRj29cI1ZAz43EjriS5zwwbyclTe0 lFo9tPMKXlWmg== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4hhSgP6YHtz4wbr; Sat, 12 Sep 2026 07:42:09 +1000 (AEST) From: Matt Evans To: Alex Williamson , Leon Romanovsky , Jason Gunthorpe , Alex Mastro , =?UTF-8?q?Christian=20K=C3=B6nig?= , Bjorn Helgaas , Logan Gunthorpe , Kevin Tian , Pranjal Shrivastava , Longfang Liu Cc: Mahmoud Adam , David Matlack , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Sumit Semwal , Ankit Agrawal , Alistair Popple , Vivek Kasireddy , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kvm@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v6 2/9] vfio/pci: Un-revoke DMABUFs in LOW_POWER_ENTRY_WITH_WAKEUP resume Date: Fri, 11 Sep 2026 22:41:50 +0100 Message-ID: <20260911214200.33793-3-matt@ozlabs.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260911214200.33793-1-matt@ozlabs.org> References: <20260911214200.33793-1-matt@ozlabs.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP correctly revokes DMABUFs on entry and, when paired with a VFIO_DEVICE_FEATURE_LOW_POWER_EXIT, vfio_pci_runtime_pm_exit() correctly un-revokes them. However, when vfio_pci_core_runtime_resume() signals the eventfd on resume, the bare __vfio_pci_runtime_pm_exit() is used (which does not un-revoke). Add a DMABUF move(false) to the resume path, making it similar to vfio_pci_runtime_pm_exit(). This also reorders the eventfd signal after the un-revoke and __vfio_pci_runtime_pm_exit() to guarantee that woken threads observe the new state. Fixes: 5d74781ebc86 ("vfio/pci: Add dma-buf export support for MMIO regions") Signed-off-by: Matt Evans --- drivers/vfio/pci/vfio_pci_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 7d090be8c9c1..3428322efa6e 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -526,8 +526,14 @@ static int vfio_pci_core_runtime_resume(struct device *dev) */ down_write(&vdev->memory_lock); if (vdev->pm_wake_eventfd_ctx) { - eventfd_signal(vdev->pm_wake_eventfd_ctx); + struct eventfd_ctx *ctx = vdev->pm_wake_eventfd_ctx; + + vdev->pm_wake_eventfd_ctx = NULL; __vfio_pci_runtime_pm_exit(vdev); + if (__vfio_pci_memory_enabled(vdev)) + vfio_pci_dma_buf_move(vdev, false); + eventfd_signal(ctx); + eventfd_ctx_put(ctx); } up_write(&vdev->memory_lock); -- 2.50.1 (Apple Git-155)