From nobody Tue Feb 10 05:10:25 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DED9E449EDA; Tue, 20 Jan 2026 14:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768918057; cv=none; b=RduSmPULgCt1Kz1jVNjVpYBRBkYk0FjEcZEnsAMJB/HPATD1R9F4GrCFjs8oJP/rFxwzlUO2JCVrdwnCuT7b/GAi48LYp6A+tTAKuRhJ3BPDgdi9f8QSz148tjmcpehi340ySyh+3h5AF0bAvGhE+UuhqAAnoeFtk7AfghH72qM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768918057; c=relaxed/simple; bh=bf1696+c5PaSfpBeHHGzA+vmhqIVB4390cXN7pOou2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y7sxCMDG8IpheVII0D/4t+R0oXHiQknz/tJH+FmeWqrSStUW46Zy5GB8C3KN7GlYmADxzNHRMhyXgRbhdKrnyAjq6OJluwyVywgf2PjQoTGuVVb3rQHj2zcKbGkKRO666oOPd0OWSas0dNbfFfCJfGClW5RpckGQkqUht5wdVGo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NBjWhUFV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NBjWhUFV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29C7C2BC86; Tue, 20 Jan 2026 14:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768918056; bh=bf1696+c5PaSfpBeHHGzA+vmhqIVB4390cXN7pOou2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NBjWhUFVYnRzWBwslbwnf3YkcH1nikmzNYEw/PthA0UmL0zyOrClkJko7UTwOtT8v +4VBltLl7uM7PsMb7uiam/Xlx8gM8HDQ0Obb2wlKT4rWiUMa43+tbff3bXupMyeJdx wDxL36aBPCKbdDA4Qb32vtAkYyS48v4pyulCvKBVUiIvLy2k5uZ24Vztos9slrw8H0 iSkU4nGBDZZA9AsTpBEVBFMSylMfN1Vu4UliXAOwjpA735qtqBFEb1JOWHBOkDK9cq +5TQCt8uFqHSC+68xraxCpD7BjZyd+Vwtdp3IkygP2CS0ghFagzaiIted2cqXXfZnB 4HpjhwEhU/B4Q== From: Leon Romanovsky To: Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Rodrigo Vivi , Jason Gunthorpe , Leon Romanovsky , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, virtualization@lists.linux.dev, intel-xe@lists.freedesktop.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org Subject: [PATCH v3 6/7] vfio: Wait for dma-buf invalidation to complete Date: Tue, 20 Jan 2026 16:07:06 +0200 Message-ID: <20260120-dmabuf-revoke-v3-6-b7e0b07b8214@nvidia.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260120-dmabuf-revoke-v3-0-b7e0b07b8214@nvidia.com> References: <20260120-dmabuf-revoke-v3-0-b7e0b07b8214@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev-a6db3 Content-Transfer-Encoding: quoted-printable From: Leon Romanovsky dma-buf invalidation is performed asynchronously by hardware, so VFIO must wait until all affected objects have been fully invalidated. Fixes: 5d74781ebc86 ("vfio/pci: Add dma-buf export support for MMIO regions= ") Signed-off-by: Leon Romanovsky Reviewed-by: Christian K=C3=B6nig --- drivers/vfio/pci/vfio_pci_dmabuf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/vfio/pci/vfio_pci_dmabuf.c b/drivers/vfio/pci/vfio_pci= _dmabuf.c index d4d0f7d08c53..33bc6a1909dd 100644 --- a/drivers/vfio/pci/vfio_pci_dmabuf.c +++ b/drivers/vfio/pci/vfio_pci_dmabuf.c @@ -321,6 +321,9 @@ void vfio_pci_dma_buf_move(struct vfio_pci_core_device = *vdev, bool revoked) dma_resv_lock(priv->dmabuf->resv, NULL); priv->revoked =3D revoked; dma_buf_move_notify(priv->dmabuf); + dma_resv_wait_timeout(priv->dmabuf->resv, + DMA_RESV_USAGE_KERNEL, false, + MAX_SCHEDULE_TIMEOUT); dma_resv_unlock(priv->dmabuf->resv); } fput(priv->dmabuf->file); @@ -342,6 +345,8 @@ void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_devi= ce *vdev) priv->vdev =3D NULL; priv->revoked =3D true; dma_buf_move_notify(priv->dmabuf); + dma_resv_wait_timeout(priv->dmabuf->resv, DMA_RESV_USAGE_KERNEL, + false, MAX_SCHEDULE_TIMEOUT); dma_resv_unlock(priv->dmabuf->resv); vfio_device_put_registration(&vdev->vdev); fput(priv->dmabuf->file); --=20 2.52.0