From patchwork Tue Mar 5 11:18:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13582172 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 834045C608; Tue, 5 Mar 2024 11:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709637558; cv=none; b=QCaKBBmQ5t/mVSWdm/oG9ha1mAx3QZHrIGr3QF3dDlCYcLLSN2FbReEQW/nRvSWkyE4POccuqrz4bxwyhemV5qVeQY2NmIOakTGgdGTqZcayLrpZy/De6ajip8wGS51HT2pMLWdRN44RFUbhdbHPF5TmJ+yVaH+ikS/PHYFUO6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709637558; c=relaxed/simple; bh=buI8QIvB9qQbf6UKyQhoBlduuXAN0B68Jk0a66fCfeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WDcbHcCFGq1MH+jnWD1fugsxXhL/KTb2RY0235X6kGZB9QipJYHCr/XMmgHGTiGqnuaQSo3HHYM0z/0H/yhhq+6LgSMqOOeDEZPOM4scp+FS2lQDEWu3wzubnL6eh2de1axkk2JdI4A40C9vtaBDYTvMleqtQv/if4QhLH6KnnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VA62QsmE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VA62QsmE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57BD1C433C7; Tue, 5 Mar 2024 11:19:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709637558; bh=buI8QIvB9qQbf6UKyQhoBlduuXAN0B68Jk0a66fCfeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VA62QsmEtqhXBGAK4rN6VNEitTXLkb/2XYlSb4WBudevL9kDdBoh4tifdL/VjRFar 1H+/u30Q6gMUDemnHEK81ZwzsQARd67GB/2fvAmpk2CcjeRwvxKaTYdXgZ6GlVbmJJ 8uClIzWnmd+JyzMwtCHXLFF+u11aUDPMDymVmgmB8ncNrM8PGMvr5oAFCmcsFQ1qHg 1PKhw1asupu8LCj6Rp9jbukxSAp+szjyVb0frvcUjnShx1fXiOT6haE07ec60A46X/ 4KPQMde2Kg01UiKCpNqSAs27L3iCvFAZykPVHDsIOgRFXstkHoDfFwljyvBg+8qvrU PdxEE8VVerc/g== From: Leon Romanovsky To: Christoph Hellwig , Robin Murphy , Marek Szyprowski , Joerg Roedel , Will Deacon , Jason Gunthorpe , Chaitanya Kulkarni Cc: Leon Romanovsky , Jonathan Corbet , Jens Axboe , Keith Busch , Sagi Grimberg , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?utf-8?b?SsOpcsO0bWUgR2xp?= =?utf-8?b?c3Nl?= , Andrew Morton , 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, kvm@vger.kernel.org, linux-mm@kvack.org, Bart Van Assche , Damien Le Moal , Amir Goldstein , "josef@toxicpanda.com" , "Martin K. Petersen" , "daniel@iogearbox.net" , Dan Williams , "jack@suse.com" , Zhu Yanjun Subject: [RFC RESEND 06/16] iommu/dma: Implement link/unlink page callbacks Date: Tue, 5 Mar 2024 13:18:37 +0200 Message-ID: <1d3d26afcdbf95b053a3a44ceff34a4fa5334582.1709635535.git.leon@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Leon Romanovsky Add an implementation of link/unlink interface to perform in map/unmap pages in fast patch for pre-allocated IOVA. Signed-off-by: Leon Romanovsky --- drivers/iommu/dma-iommu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index dbdd373a609a..b683c4a4e9f8 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -1752,6 +1752,21 @@ static void iommu_dma_free_iova(struct device *dev, dma_addr_t iova, __iommu_dma_free_iova(cookie, iova, size, &iotlb_gather); } +static dma_addr_t iommu_dma_link_range(struct device *dev, struct page *page, + unsigned long offset, dma_addr_t iova, + size_t size, enum dma_data_direction dir, + unsigned long attrs) +{ + return __iommu_dma_map_pages(dev, page, offset, iova, size, dir, attrs); +} + +static void iommu_dma_unlink_range(struct device *dev, dma_addr_t addr, + size_t size, enum dma_data_direction dir, + unsigned long attrs) +{ + __iommu_dma_unmap_pages(dev, addr, size, dir, attrs, false); +} + static const struct dma_map_ops iommu_dma_ops = { .flags = DMA_F_PCI_P2PDMA_SUPPORTED, .alloc = iommu_dma_alloc, @@ -1776,6 +1791,8 @@ static const struct dma_map_ops iommu_dma_ops = { .opt_mapping_size = iommu_dma_opt_mapping_size, .alloc_iova = iommu_dma_alloc_iova, .free_iova = iommu_dma_free_iova, + .link_range = iommu_dma_link_range, + .unlink_range = iommu_dma_unlink_range, }; /*