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: 13582155 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2BE0C54E41 for ; Tue, 5 Mar 2024 11:19:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5582B6B00C5; Tue, 5 Mar 2024 06:19:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E04C6B00C6; Tue, 5 Mar 2024 06:19:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 358DA6B00C7; Tue, 5 Mar 2024 06:19:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 19A3F6B00C5 for ; Tue, 5 Mar 2024 06:19:24 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C3C6C40E56 for ; Tue, 5 Mar 2024 11:19:23 +0000 (UTC) X-FDA: 81862739406.23.EEB13EE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id A9095A0020 for ; Tue, 5 Mar 2024 11:19:21 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VA62QsmE; spf=pass (imf15.hostedemail.com: domain of leon@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709637562; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nX2hAFEH1HSNcc2953eD/Rf6lJqonK3MWEmZQ3VuDkE=; b=Gb5ISNaFdwwgj+xNHPDoCe0eotkzgvlhNAoh/y93g7SqCItkBkUdGAr0itUdoBsK3dz+np Cg3U6VaBmUN/W00j5H4vDQwTqBA+zn4DQhZumx+h1aqydvt+rvbkUWYbLuw4Uvou2wdVvA u6SG5U39N91yo/pQiyTy1MXqgry4Xl0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709637562; a=rsa-sha256; cv=none; b=Gxc8NvorB8t6CoTkkFAmdNnNHQRZYPR1dYP4C5XR2aV42FCoElpQpx4j/kZ02RoJhCZnLR d7sLhBLtIUTB9UnfvAMA3NwVFlNu4ks3M7iC7f9df4qalaGMtexOwTSdI4+5hj11BTVjEs DDt8neBkBH71Ihbac0ztYxOYckVrIQk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VA62QsmE; spf=pass (imf15.hostedemail.com: domain of leon@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B78DBCE02C1; Tue, 5 Mar 2024 11:19:18 +0000 (UTC) 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: MIME-Version: 1.0 X-Stat-Signature: kpnsadyunjn7nzunjcaf1ho3a6puuz6c X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A9095A0020 X-Rspam-User: X-HE-Tag: 1709637561-121044 X-HE-Meta: U2FsdGVkX1/hrCwqQPvjntouxPa6sK7u1mMJvf0cDUZVuQeJN9Wtx8dyt8j9jv5PTw4SenaDwKnk2sQ6XzhSJSPsBENWoYIF98wl0msRrASYJ1hheGKtJ5lXA6p25fvLpWyXce+rrCxSQ9u4SdDSUZB7wF8sd/2XgCMXPFDdSkgl4XOK5MkEFfwSMNH0XhzuuF1WqyZ5E+jv6Q/yeiMY4DKnB3FKYzacFOEDRzH/lnTaeFWnBGL6JmyA05vvUNWnx/shNaENUVB8FKqnd3K1TCrcd/Q6CVgWYeT6pDIbrB0vtaqzSE2lCRtNz7p4tirNQzEJwiH7SYyK+k7Xov7x9ANGqdUOlkBWEff4f9FNk2xRI4qnuppHNCSu8hoqWWWG1jz0vs7+qccL4VNX/a4szgYb5M0tbZ1YQX36HTk9Pak64akQwnX2URavBtkkHvUTifrBDiyoO1lBKgWs1XGiL6FQBOLhl6TdLAQXTl0/OpYepr5jIa1kj5sJOGVSAXACmcUANfMoVDOUHNkK6ALAkTxvug9ItXwF74L6V6JYfIh4PHtXHgKMMDpuLx0/bpFh2V1KmKc7K3boGZJfd6JbcQ+LZN+i/+MC9pYMM7u8N74mGtP8fTU6vehagVhAHze54IVS6Yz8p5lHRONeRIxC11u2gnwCr/sK3C2B44a2uI9GL/vGf2yITNIjK7Nc03iOqyVVo1B0t4L06AdUtTaCzdfD8tyQ+zokxUKVeQQR49ofGTxoA7+9c1tGFxb4HWXt5W2pMXKXOGMOVAlVT4Ba/Tf3/ylgnhRIWxiYIbTsmX7Cblb73C7/KdSWMSrVGlY9OGGVfcIL0WflLjGeEVwWLd/tOwi9QJvESrCW9rggDlEbaOI7MbhEO7hgz0p+OY6Xd5RuTYF+Nygc2f3vEChpAnl3C4c/biQFh354OKBpW/e9eJTTW+vXmZu9MXCMPOml7N77lbT30g/+rLnSJRi MZg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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, }; /*