From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (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 45AAE1CAA65 for ; Tue, 20 Jan 2026 13:15:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768914936; cv=none; b=uAwMe261mM82lYb0P3hXl5qdPXN/xUH1VL59c35bvXuNnXXAltFPpLwhlZST85K+bYV4UWZF9a5+W5YWX9PLFsIbC247S/zxbtcBVBnUwit4TcJoC9jhYQdxuwKmGLiHxuIzr03+19MovDGoJ2arcAhP7pGHqQZRU3uel7U3ywU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768914936; c=relaxed/simple; bh=xnk/b5HPpyfNnMbI+XkeyZX1b7NurY2cBOv/ZUy0nkM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fQe21mGTIsg0Mu9qABkapTOU1oPF1+pkHq9SwhR+moVp1JE0qn+pNkM3m354BYoUX15tKc6ytSjjaWUsC5iCY0MqixLolxT7CRRxpB8UAWWc4btN3Wqb/78crOUQBqM4CEH1jVmI9YnQvL/nO3SbccCIS0FLJldsY7OweWndePw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=RFlINO8a; arc=none smtp.client-ip=209.85.222.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="RFlINO8a" Received: by mail-qk1-f196.google.com with SMTP id af79cd13be357-8c537b9fcbfso545060185a.1 for ; Tue, 20 Jan 2026 05:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1768914932; x=1769519732; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Jl2KF0othdvrwDImGzxJcxoX7WKdbBXFC823mMEO8nY=; b=RFlINO8aI/gtHD1iK1qOubIgA1mTdMNPt8iQAYSpLQp2g1TlT+Cx3OQVDA1IGPOeWt f+zeQtvB1AQfxpPyCoN5cF+yC45Y5ePBC+bGWd/kgwNupGi3FD9Q2objOpwPUZbcLs+S 05Jmj3mko0PFL8fWfKlSUNIa76h60tdFktwHUKDXgbodeT/MGcHE+HmSnAxf3aQBmmkQ tLsHSd+DhZo9MiBRJe+m1AAhT+I4EtsBqZNhSZEbaBVa2KQf/EW/n95kTnlNj+m8b5i2 ABLKaQlyxiol14GRTgukxU3TXS+Zn11QO2BDT67ciWNxc2qt1jrU23q/ouRUUL5EOVeO YMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768914932; x=1769519732; h=in-reply-to:content-transfer-encoding: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=Jl2KF0othdvrwDImGzxJcxoX7WKdbBXFC823mMEO8nY=; b=Ucsn7pG6KCL6KnFud0BJzbyTT/Zmvv8vpMSR7anuL4EgMWhLD2dTEQGuercKeNc4kJ wmcK8odXbNN/rhPvleei1LvHgFdVxRcBBmfuZuiGkZn11/kH79hSAAqdBHhec5NoMqC8 eLKPGOO/cQi0Z08hQlBMcQMYJUu0Zs7sVLfvu79ujB1whhvjOC1KeGQ3RSFRL/cIWSRW uKflaYl/An+TsNIF7amwbYRGARhVHRGLmQAsYcCa51oStJPjTAbqbpudlgKOOU5c8kll 5VVuZAxQKC792Rf2Kt0pbGhrczlxNeBPyMh9tilhIUIDVESjHV2WbZqNCsoKAxU+ne6y 0XsQ== X-Forwarded-Encrypted: i=1; AJvYcCWN3hnA9UpKTP77Dr5eGP/rjbk8c3iGGtCeKQF9zO1BfrEen1ep2h1kbRoLDhMW7SwbKmrvkM5ZxY+9KBc=@vger.kernel.org X-Gm-Message-State: AOJu0Yys/djju6lIxEM8QQTeBbwsuLYzDl6627d8WY9AF8tQgu1IPoS6 7hWnS2SGqEOddP5ihSRODbqfTVSvlnboecZUApIkVaxr8Zwy6jo969jsxz01TFwDGbM= X-Gm-Gg: AY/fxX4dEecmOSMosQEbaZp9ROffQ3uyAoy7nOcgCCdgqKXNYxmdpRIlL49XBvNBfwd 0KZva/8wnI87C8BURUsNjG6NjHmX+FtmXikquljpIbP8TbCdklwxq9rqROEwRps5I7mXUnKZy7i JGmeC3JHtNEkmwJsMTFitT476YS7HV/U/wJQDsVHG+SbFR/JiEg+lRdHfGi7Cp/6fuXkLyIA9Hg otOGXgpmTig/tjX7jUZDxAAhKVEEI6V52mW15Go0wLjsR+7jIk13SrMyCOg+8ld0+hloTZdHn8M rFqpuaSDVC5KtP4+s0iv7qQDJyTC5DfX9KD/9qlScIz7MV9gmw35cs/cPCskQIC6u0aWiFFI3fJ uW8lf0bC8SNXjEJQRlP1igWEk3vNEFiIyvZZnyjINLSYNSny13ChTBcv/g88yzRcVV9vKHMqvMk 5iWIEwk+gI5USz0KFX0LhWwotYevdO3/6CyVZGKe/MXWSLQOnXIcE39Y4GIi1dFy2Tn/g= X-Received: by 2002:a05:620a:999:b0:8c6:a68a:bc04 with SMTP id af79cd13be357-8c6a68ac1c8mr1389837085a.7.1768914931884; Tue, 20 Jan 2026 05:15:31 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-112-119.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.112.119]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c6a7292cfbsm1017788585a.50.2026.01.20.05.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 05:15:31 -0800 (PST) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1viBZy-00000005W6K-36CW; Tue, 20 Jan 2026 09:15:30 -0400 Date: Tue, 20 Jan 2026 09:15:30 -0400 From: Jason Gunthorpe To: Leon Romanovsky Cc: Sumit Semwal , Christian =?utf-8?B?S8O2bmln?= , 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 =?utf-8?Q?Hellstr=C3=B6m?= , Rodrigo Vivi , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Alex Williamson , 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 v2 3/4] iommufd: Require DMABUF revoke semantics Message-ID: <20260120131530.GN961572@ziepe.ca> References: <20260118-dmabuf-revoke-v2-0-a03bb27c0875@nvidia.com> <20260118-dmabuf-revoke-v2-3-a03bb27c0875@nvidia.com> <20260119165951.GI961572@ziepe.ca> <20260119182300.GO13201@unreal> <20260119195444.GL961572@ziepe.ca> <20260120131046.GS13201@unreal> 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 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260120131046.GS13201@unreal> On Tue, Jan 20, 2026 at 03:10:46PM +0200, Leon Romanovsky wrote: > On Mon, Jan 19, 2026 at 03:54:44PM -0400, Jason Gunthorpe wrote: > > On Mon, Jan 19, 2026 at 08:23:00PM +0200, Leon Romanovsky wrote: > > > On Mon, Jan 19, 2026 at 12:59:51PM -0400, Jason Gunthorpe wrote: > > > > On Sun, Jan 18, 2026 at 02:08:47PM +0200, Leon Romanovsky wrote: > > > > > From: Leon Romanovsky > > > > > > > > > > IOMMUFD does not support page fault handling, and after a call to > > > > > .invalidate_mappings() all mappings become invalid. Ensure that > > > > > the IOMMUFD DMABUF importer is bound to a revoke‑aware DMABUF exporter > > > > > (for example, VFIO). > > > > > > > > > > Signed-off-by: Leon Romanovsky > > > > > --- > > > > > drivers/iommu/iommufd/pages.c | 9 ++++++++- > > > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c > > > > > index 76f900fa1687..a5eb2bc4ef48 100644 > > > > > --- a/drivers/iommu/iommufd/pages.c > > > > > +++ b/drivers/iommu/iommufd/pages.c > > > > > @@ -1501,16 +1501,22 @@ static int iopt_map_dmabuf(struct iommufd_ctx *ictx, struct iopt_pages *pages, > > > > > mutex_unlock(&pages->mutex); > > > > > } > > > > > > > > > > - rc = sym_vfio_pci_dma_buf_iommufd_map(attach, &pages->dmabuf.phys); > > > > > + rc = dma_buf_pin(attach); > > > > > if (rc) > > > > > goto err_detach; > > > > > > > > > > + rc = sym_vfio_pci_dma_buf_iommufd_map(attach, &pages->dmabuf.phys); > > > > > + if (rc) > > > > > + goto err_unpin; > > > > > + > > > > > dma_resv_unlock(dmabuf->resv); > > > > > > > > > > /* On success iopt_release_pages() will detach and put the dmabuf. */ > > > > > pages->dmabuf.attach = attach; > > > > > return 0; > > > > > > > > Don't we need an explicit unpin after unmapping? > > > > > > Yes, but this patch is going to be dropped in v3 because of this > > > suggestion. > > > https://lore.kernel.org/all/a397ff1e-615f-4873-98a9-940f9c16f85c@amd.com > > > > That's not right, that suggestion is about changing VFIO. iommufd must > > still act as a pinning importer! > > There is no change in iommufd, as it invokes dma_buf_dynamic_attach() > with a valid &iopt_dmabuf_attach_revoke_ops. The check determining whether > iommufd can perform a revoke is handled there. iommufd is a pining importer. I did not add a call to pin because it only worked with VFIO that would not support it. Now that this series fixes it the pin must be added. Don't drop this patch. All the explanations we just gave say this special revoke mode only activates if the buffer is pinned by the importer, so iommufd must pin it. Otherwise it says it is working in the move mode with faulting that it cannot support. Jason