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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 0B86FD4415E for ; Tue, 19 Nov 2024 13:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/85gGQzvxqGvFN7bmQIs02pIAjKpDymhT/kwBRKvRwE=; b=ZrMgrE9/bMbMMI3JJuzrsLtRiR IhO974UTwgQd8YuwREy1wp0h6MxiGOZYOqOfa+nPztp4r+9FXKDN+olv7GwzdMPVBJ2B716oPpOsn X0o3ii3dzN3KdtW71ettmlmzdrdknWGb0YOg4rLQc3wIKvn2O6BxjETzfrmNz97D/qJWkZzAIEgdj r4jDCeG1k/EQ2nVrqBQb4yim4+7H163HhnLcO1sgHlpskfuOtuF3U5186hi/Q17rrHKtTPQ2uKhG4 o7DcUyaTM96tYOJm7AJOl9PJBEAtZnPm+s+0ctkofO0WZr0OUCsI+peHYAmTJk8dCUaKTa/h3bnO/ lhalam0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDOjo-0000000CbVa-0OYV; Tue, 19 Nov 2024 13:57:52 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDOjl-0000000CbUL-3VmC for linux-nvme@lists.infradead.org; Tue, 19 Nov 2024 13:57:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 435475C5579; Tue, 19 Nov 2024 13:57:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 395C1C4CECF; Tue, 19 Nov 2024 13:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732024669; bh=LfF6XQBNPDMNIzDjgyfdmHqe1KOsZVJ/usNbXi+DM20=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NTVyHgZ4ej/NoJRr2JYj7UKyQlfR6XGQRr9FmbaNFpYfeUFtD11fXLEeAHp2m4iJL TNBAN5sK8DRrQUrWgPkGrR7fMZ604apkzfT0Ic36gzChdKeAZmYnGvkEl8XWKptUmb cLNb9TKDfRrzmWFzzONZlNZr6dNP6NYg1CTXXFug9/xBgWGnhtkEiSLfQ+groFJnlH IRXJu2sO9iXH53SOKFBbAfQm1E6weEIh2HjM5VaJai843ASOTzrBAJDXWvm4Uzu+Xr v5J5aK66FsIFRyYUnNEIC8pzYfvUFR8Dga4EbAxrFRpgLvgeBvpo3V834wCS/2Gb/X XeQoV828mjx1w== Date: Tue, 19 Nov 2024 15:57:43 +0200 From: Leon Romanovsky To: Will Deacon Cc: Jens Axboe , Jason Gunthorpe , Robin Murphy , Joerg Roedel , Christoph Hellwig , Sagi Grimberg , Keith Busch , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , Marek Szyprowski , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, Randy Dunlap Subject: Re: [PATCH v3 07/17] dma-mapping: Implement link/unlink ranges API Message-ID: <20241119135743.GB26101@unreal> References: <20241118145929.GB27795@willie-the-truck> <20241118185533.GA24154@unreal> <20241119090507.GB28466@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241119090507.GB28466@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241119_055749_960865_F998660C X-CRM114-Status: GOOD ( 25.81 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On Tue, Nov 19, 2024 at 09:05:08AM +0000, Will Deacon wrote: > On Mon, Nov 18, 2024 at 08:55:33PM +0200, Leon Romanovsky wrote: > > On Mon, Nov 18, 2024 at 02:59:30PM +0000, Will Deacon wrote: > > > On Sun, Nov 10, 2024 at 03:46:54PM +0200, Leon Romanovsky wrote: > > > > +static void __iommu_dma_iova_unlink(struct device *dev, > > > > + struct dma_iova_state *state, size_t offset, size_t size, > > > > + enum dma_data_direction dir, unsigned long attrs, > > > > + bool free_iova) > > > > +{ > > > > + struct iommu_domain *domain = iommu_get_dma_domain(dev); > > > > + struct iommu_dma_cookie *cookie = domain->iova_cookie; > > > > + struct iova_domain *iovad = &cookie->iovad; > > > > + dma_addr_t addr = state->addr + offset; > > > > + size_t iova_start_pad = iova_offset(iovad, addr); > > > > + struct iommu_iotlb_gather iotlb_gather; > > > > + size_t unmapped; > > > > + > > > > + if ((state->__size & DMA_IOVA_USE_SWIOTLB) || > > > > + (!dev_is_dma_coherent(dev) && !(attrs & DMA_ATTR_SKIP_CPU_SYNC))) > > > > + iommu_dma_iova_unlink_range_slow(dev, addr, size, dir, attrs); > > > > + > > > > + iommu_iotlb_gather_init(&iotlb_gather); > > > > + iotlb_gather.queued = free_iova && READ_ONCE(cookie->fq_domain); > > > > + > > > > + size = iova_align(iovad, size + iova_start_pad); > > > > + addr -= iova_start_pad; > > > > + unmapped = iommu_unmap_fast(domain, addr, size, &iotlb_gather); > > > > + WARN_ON(unmapped != size); > > > > > > Does the new API require that the 'size' passed to dma_iova_unlink() > > > exactly match the 'size' passed to the corresponding call to > > > dma_iova_link()? I ask because the IOMMU page-table code is built around > > > the assumption that partial unmap() operations never occur (i.e. > > > operations which could require splitting a huge mapping). We just > > > removed [1] that code from the Arm IO page-table implementations, so it > > > would be good to avoid adding it back for this. > > > > dma_iova_link/dma_iova_unlink() don't have any assumptions in addition > > to already existing for dma_map_sg/dma_unmap_sg(). In reality, it means > > that all calls to unlink will have same size as for link. > > Ok, great. Any chance you could call that out in the documentation patch, > please? Can you suggest what should I add there, as it is not specific to new API, but general note applicable to all __iommu_unmap() callers? Thanks