From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 721B827979A for ; Mon, 26 Jan 2026 20:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769459936; cv=none; b=fbYbHOLTJiBzAbtYi+zLRY8a10Sa81ogXns1B+R0NnqSZeXiqTphNfmc5R2wgjhVPeHpTyZQY1HJH8Q7oJmAMwQ8mYrTyX85gQ+YMyNq2sqezQOw4hH66ixvdPyJoMSaJaiPtKwkPptm1TNoJza4TIuT4cS4bH/r70IUF8i1TR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769459936; c=relaxed/simple; bh=ReePk5ebIABc/04zyOJasPQOtiwxWbIgDXrD19pnIPk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QaEMmPtzZYEQn7bS+C3HwuHYQolK6xzSIR6Pcu+gqB8PpVqv6lEGFnkISlaKYyaf1Qfhx2KfiD1ODwjs6XLME9g6GYnfdy9So3x6d24BLSGwSYiSf92AyXiraWEqK/djQZk+kFdKqLY1ylP4iyBi5wlfYsupM2rnlJziALxZnwQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ENqilvO3; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ENqilvO3" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2a76b39587aso2675ad.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=vger.kernel.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=ENqilvO3yHNYxJOrBt3JSHu/J1ym8/v63iMpFaPstmn1DAgs606o/DB+mBzpFxEeO4 mohiD/SGVtJmpSrM1Um3Uz5WFoMGhwv8VYIvdp9vHnqkLUAiCSwOzDJMdpFvLlQwEawE NyW9CXTGGNWOEbu4Xic/wTW/zxHCU/rTDwazPY8QzsPhaZzwAsSF5cFhP+j2tyetkWG+ IFRScGqMdHZgIk2wdOipjZt8NNqMkKn5+PlhwWoLAmiyDVFtyiHJD4r91ODEuEHKnuZy f/uat5iPozNN1IMlQWUW+KioXuNyTZG/tPWXb7hCNRp4oiEKLBlrW/l/9Pe+iVJCD7Nc WtXg== 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=tF8PiEISoKpyi5Qg65we351uwrj6Jd134LtaNWCLdAyeUJctdKG/ljirCgoLQ4uzge KdplwziuKbZJTr764BA/IiDXP0ZImuSIdio9pJBgBOwFkvFnnEwzWJwvCG1bxNaIW9GL FIxVGKJPo2Lads6hF7Te0M+oqOTSHB40Nn6f47bqHDdwFksnuH+2GIxFhN6JBOWfIqCB id4r7ELXJlAEO0CFWKGMowa9TtdRFw0MX4fVFrPpK3X+41+HnzoFw4j74RvR+CkJn1aP 6yRzvikAfgGjJkNQNeX8lpQIfMDQW1Xgdxc2/rMx9r+fe7i3vxn8MNNr4Kjq69TBiuew nsow== X-Forwarded-Encrypted: i=1; AJvYcCWDp9GKBAf+027s4X4YtoUkeSiFpOw1J8b1rFCcNmHewuHh8rVYgC98gqq63rGr0O/GmUCKOzIiQHN5ww==@vger.kernel.org X-Gm-Message-State: AOJu0YyAJn+yGgQQSRgJ8tJLc6oMIgy1VtY2UQvg8EPuexgef/c427CD lOBVtGj9bn3jAYMg9tF05cKIEc4JGBBFnYDYn1uxDRv8x1alqtpzUh8FlDdV7oRVHg== X-Gm-Gg: AZuq6aKgTZj0gLKH3HirNzr9RxTPzN97MoXA/j8UN22bGNGADku+6/e9obOTH0WSN3q RLOChfnawiI8j63rlmcKaBGIixxqhUa6OekNbT25sRFV3fPa/xJAo1S5YddBMiYgryJ6wyT6LGx +MmQBxO1skAYC2+9YQVUxCaL3UwM+a6SEDjpa2mttUdAaMZuD2kvbAQQe1MPk7zXmUmXORjiT9e DGEI3Km8kgXv+rn7WNdKFprR01CmGikri2Ej4ave1WrVLtCvZel6HKWasY2HfHJ4+C4osKUOqdr EY9165GAsp/SumBPpYghGoRWau+qzXDRa5x6Rcr3gstGw4IQAjAXj0hbkLsjowo3OWtIdTyikOS ZJlVCH/RRNjjwbgAmsDK+CoFxu7un5ZAUMhBTrWgn/AFFRTE5YJP/301iNX9nx/8sIWsFQbf9Hm zz8svJsuNJDCTMdmPvKME2p3vNiHCoH7fdsWpxJluF52+bULmN 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> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> 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