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 3B189C44503 for ; Wed, 21 Jan 2026 10:44:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E38A910E74C; Wed, 21 Jan 2026 10:44:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ahf9kV1w"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6CC910E1B3; Wed, 21 Jan 2026 10:44:57 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 72EE643DE5; Wed, 21 Jan 2026 10:44:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A48E4C19422; Wed, 21 Jan 2026 10:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768992297; bh=RigXg4DjlKaa6QSDWIT9y5XHQBoImXr5kkVisbqD/oo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ahf9kV1wXXoMLiaqKsEIG/UGwy2yJvAEXz5UxYeAn6pkL831lX1ZtGjzdM4txxSl1 +pazqTL82uZnQR/lq02Yn0CUkkNx6m62sJz3qFQSjt3RIKYoYgKzUpz5lHm96KWki2 lmsN5dz7M653itHr9/W+0ss34jWO2MVE8dhc3c/FeCtc5OBbvW5B+k0z0x7Smb10PS VwfwFR44T9j4X0/96SNufS4CdrK0pHdr3x0K0nzSLYdvqVKJsFLhcJuJ55fqOJHgg5 qtCGWFawYOKxqtFbbgwBon7CZ1Vxj1ZFn3irlF7uz7KqZV/1nipJWzsYg1FuwX9EH3 B0W/jyyKakLIQ== Date: Wed, 21 Jan 2026 12:44:51 +0200 From: Leon Romanovsky To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Matthew Brost , Sumit Semwal , Alex Deucher , David Airlie , Simona Vetter , Gerd Hoffmann , Dmitry Osipenko , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Lucas De Marchi , Thomas =?iso-8859-1?Q?Hellstr=F6m?= , Rodrigo Vivi , Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Felix Kuehling , Alex Williamson , Ankit Agrawal , Vivek Kasireddy , 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: Re: [PATCH v3 6/7] vfio: Wait for dma-buf invalidation to complete Message-ID: <20260121104451.GB13201@unreal> References: <20260120-dmabuf-revoke-v3-0-b7e0b07b8214@nvidia.com> <20260120-dmabuf-revoke-v3-6-b7e0b07b8214@nvidia.com> <015b25e6-cfe1-4110-963f-5f8dc4720d1b@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <015b25e6-cfe1-4110-963f-5f8dc4720d1b@amd.com> X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Wed, Jan 21, 2026 at 11:41:48AM +0100, Christian König wrote: > On 1/20/26 21:44, Matthew Brost wrote: > > On Tue, Jan 20, 2026 at 04:07:06PM +0200, Leon Romanovsky wrote: > >> 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 > >> --- > >> 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 = revoked; > >> dma_buf_move_notify(priv->dmabuf); > >> + dma_resv_wait_timeout(priv->dmabuf->resv, > >> + DMA_RESV_USAGE_KERNEL, false, > >> + MAX_SCHEDULE_TIMEOUT); > > > > Should we explicitly call out in the dma_buf_move_notify() / > > invalidate_mappings kernel-doc that KERNEL slots are the mechanism > > for communicating asynchronous dma_buf_move_notify / > > invalidate_mappings events via fences? > > Oh, I missed that! And no that is not correct. > > This should be DMA_RESV_USAGE_BOOKKEEP so that we wait for everything. Will change. > > Regards, > Christian. > > > > > Yes, this is probably implied, but it wouldn’t hurt to state this > > explicitly as part of the cross-driver contract. > > > > Here is what we have now: > > > > * - Dynamic importers should set fences for any access that they can't > > * disable immediately from their &dma_buf_attach_ops.invalidate_mappings > > * callback. > > > > Matt > > > >> dma_resv_unlock(priv->dmabuf->resv); > >> } > >> fput(priv->dmabuf->file); > >> @@ -342,6 +345,8 @@ void vfio_pci_dma_buf_cleanup(struct vfio_pci_core_device *vdev) > >> priv->vdev = NULL; > >> priv->revoked = 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); > >> > >> -- > >> 2.52.0 > >> > >