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 A346BD19519 for ; Mon, 26 Jan 2026 20:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 041EB10E492; Mon, 26 Jan 2026 20:38:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="xZP3e+wm"; dkim-atps=neutral Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69DD210E492 for ; Mon, 26 Jan 2026 20:38:54 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2a76b39587aso2635ad.0 for ; Mon, 26 Jan 2026 12:38:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769459934; x=1770064734; darn=lists.freedesktop.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=heQW4XXGxVNpbsMWtr+Uf/Qjg2mRHLgzAq6EBq5z5Gc=; b=xZP3e+wmixcfFD5RDGDndGp+GB2Qjl+1xoLC6Ifz0Vin6LY5oSJLBSZ06UvHnKP30V 4fNIC9PVJ00OKGbcGBmEyx0VshrKFfhW/ZInrnwrTjMSPIUs0PPWxFORcRNBMyckLmiQ weCs6sNlW3W3YwIGyNA9vhRAGxMZeZHbXZGxHjT/q/lA8Qc66Yc8tw1cunWgK9YEavg+ lIUvZCyrEF4NDvrKeIDBQRhtoPZ7IT/EoBoNUow61zFkZ2fcVc5zELpgMbDLDQ0tP6Cf 1WbHI0A2JE4ks6asuZFoyUWYUk3tzHz33ak+1ll6bnj8dPcIys2xAynkS+PAqbFZ1cGu rjjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769459934; x=1770064734; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=heQW4XXGxVNpbsMWtr+Uf/Qjg2mRHLgzAq6EBq5z5Gc=; b=iAsGOVTTQRQjGGoRWekawjZA05my/x+SR/Vb5urpk/spkdEqIJw1UaxSsX6qICd9QH /7r/pVWm08qx7Xcgf0sd8zjcF5h3qer190DR1DUiuF49i5df0NrocxgA9I2wizn+Hemy 6aw9yk+FgbClhEWGjupVmSAZWhvzSPpKdO/KHSWveQVEckh3hFfEIQRuIE59EruFhj5N oc8d5fXCdvjO4vpFZdyh5Tmt3MF/jpE6ACbmpPoxE7n8YFqn+YC3wWxaMNOWun0yiM9Q ceprWhgOwXatPsfbnaAIhXZE00hUVYykllB29+QiNrU20BKNOEisZbVw1J9NCoCC1Mwk ob3Q== X-Forwarded-Encrypted: i=1; AJvYcCXcf4Sr+vpmqC7G9lLBXNEqdoFZtMkPRASzJ/fe68HtGvifIO2mpnkNmrmeFxYfUFHywkqfkHlDhrY=@lists.freedesktop.org X-Gm-Message-State: AOJu0YyN2mW8jx225nkuSWadx74d6Zto+/QYiokPhFMbrOTL2f6i17wi Rgkw3cYxT4YHOHRLuUkGrwPK4e+VwgUikYPqg9CXdWB/dmeXVojPHG8xlRscFVav2A== X-Gm-Gg: AZuq6aJ6P47EGfNMIIpFaz4ufUhpt4/hHinEcwTobvptLCq45tD0xbGn5SgQU4BATPW Ci06GTdBfrXiTIVFrOnKfDmXNADk57/oucK6Jmh4ov9GknlUYgh2jKqmQn6ftBzn7lA7dPQnI3W xhL1WxSgOoeXGZMcKIclwtSTDRp8IUJEFvHa0tMA10NmWqcMQ1GNgK0ujX52RW9qImYC+MJcrAU IJKA5YCnGrvvNWwrfY4ksrqHNM1qn5BrJQ6S0+zyUJaaqSU/dA2FI6JfKqB67OVmk7Bbo8z2we6 kH8Tipe+0l/j/pd/I2x28Z89edkD4F6on/kS+JfW2WmgcJZb5M32tf66MWvvp0pAH1whtRtiaAM jbSMhEV0Lam5yfRjxh0HzZyaMCmNbQXuaB1J3P+G1xelp9kI3Bz33ugsDw5oHgZ8HPGoM/LrfSf Alqr6P/XnStOHr/Q4+Yzz4GBSHEmHX5Jga8SL8fPRYHWmSwDQ/ X-Received: by 2002:a17:903:32d2:b0:2a7:7f07:340e with SMTP id d9443c01a7336-2a844901809mr3288195ad.4.1769459933510; Mon, 26 Jan 2026 12:38:53 -0800 (PST) Received: from google.com (222.245.187.35.bc.googleusercontent.com. [35.187.245.222]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a802fdce1fsm94536115ad.101.2026.01.26.12.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jan 2026 12:38:53 -0800 (PST) Date: Mon, 26 Jan 2026 20:38:44 +0000 From: Pranjal Shrivastava To: Leon Romanovsky Cc: Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , 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 v5 6/8] dma-buf: Add dma_buf_attach_revocable() Message-ID: References: <20260124-dmabuf-revoke-v5-0-f98fca917e96@nvidia.com> <20260124-dmabuf-revoke-v5-6-f98fca917e96@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260124-dmabuf-revoke-v5-6-f98fca917e96@nvidia.com> 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" Hi Leon, On Sat, Jan 24, 2026 at 09:14:18PM +0200, Leon Romanovsky wrote: > From: Leon Romanovsky > > Some exporters need a flow to synchronously revoke access to the DMA-buf > by importers. Once revoke is completed the importer is not permitted to > touch the memory otherwise they may get IOMMU faults, AERs, or worse. > > DMA-buf today defines a revoke flow, for both pinned and dynamic > importers, which is broadly: > > dma_resv_lock(dmabuf->resv, NULL); > // Prevent new mappings from being established > priv->revoked = true; > > // Tell all importers to eventually unmap > dma_buf_invalidate_mappings(dmabuf); > > // Wait for any inprogress fences on the old mapping > dma_resv_wait_timeout(dmabuf->resv, > DMA_RESV_USAGE_BOOKKEEP, false, > MAX_SCHEDULE_TIMEOUT); > dma_resv_unlock(dmabuf->resv, NULL); > > // Wait for all importers to complete unmap > wait_for_completion(&priv->unmapped_comp); > > This works well, and an importer that continues to access the DMA-buf > after unmapping it is very buggy. > > However, the final wait for unmap is effectively unbounded. Several > importers do not support invalidate_mappings() at all and won't unmap > until userspace triggers it. > > This unbounded wait is not suitable for exporters like VFIO and RDMA tha > need to issue revoke as part of their normal operations. > > Add dma_buf_attach_revocable() to allow exporters to determine the > difference between importers that can complete the above in bounded time, > and those that can't. It can be called inside the exporter's attach op to > reject incompatible importers. > > Document these details about how dma_buf_invalidate_mappings() works and > what the required sequence is to achieve a full revocation. > > Signed-off-by: Leon Romanovsky > --- > drivers/dma-buf/dma-buf.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++- > include/linux/dma-buf.h | 9 +++------ > 2 files changed, 50 insertions(+), 7 deletions(-) > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > index 1629312d364a..f0e05227bda8 100644 > --- a/drivers/dma-buf/dma-buf.c > +++ b/drivers/dma-buf/dma-buf.c > @@ -1242,13 +1242,59 @@ void dma_buf_unmap_attachment_unlocked(struct dma_buf_attachment *attach, > } > EXPORT_SYMBOL_NS_GPL(dma_buf_unmap_attachment_unlocked, "DMA_BUF"); > > +/** > + * dma_buf_attach_revocable - check if a DMA-buf importer implements > + * revoke semantics. > + * @attach: the DMA-buf attachment to check > + * > + * Returns true if the DMA-buf importer can support the revoke sequence > + * explained in dma_buf_invalidate_mappings() within bounded time. Meaning the > + * importer implements invalidate_mappings() and ensures that unmap is called as > + * a result. > + */ > +bool dma_buf_attach_revocable(struct dma_buf_attachment *attach) > +{ > + return attach->importer_ops && > + attach->importer_ops->invalidate_mappings; > +} > +EXPORT_SYMBOL_NS_GPL(dma_buf_attach_revocable, "DMA_BUF"); > + I noticed that Patch 5 removes the invalidate_mappings stub from umem_dmabuf.c, effectively making the callback NULL for an RDMA importer. Consequently, dma_buf_attach_revocable() (introduced here) will return false for these importers. Since the cover letter mentions that VFIO will use dma_buf_attach_revocable() to prevent unbounded waits, this appears to effectively block paths like the VFIO-export -> RDMA-import path.. Given that RDMA is a significant consumer of dma-bufs, are there plans to implement proper revocation support in the IB/RDMA core (umem_dmabuf)? It would be good to know if there's a plan for bringing such importers into compliance with the new revocation semantics so they can interop with VFIO OR are we completely ruling out users like RDMA / IB importing any DMABUFs exported by VFIO? Thanks, Praan