From patchwork Tue Mar 5 10:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13581933 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 912F2C54798 for ; Tue, 5 Mar 2024 10:16:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C365B94000A; Tue, 5 Mar 2024 05:16:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BBE0F940007; Tue, 5 Mar 2024 05:16:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A354C940009; Tue, 5 Mar 2024 05:16:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 893B3940007 for ; Tue, 5 Mar 2024 05:16:02 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6436C40DC8 for ; Tue, 5 Mar 2024 10:16:02 +0000 (UTC) X-FDA: 81862579764.30.F339C28 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id DA30D14000E for ; Tue, 5 Mar 2024 10:16:00 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hD0RcuJh; spf=pass (imf09.hostedemail.com: domain of leon@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=leon@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709633761; a=rsa-sha256; cv=none; b=dJQjpWjUsgziTMDiUrqyxMyJRK0koxhQ3sQr0Pksfp42HtOiK48hzpLE8mu8iWwekqskGL Kdv473d1aBgdxvLJN2dK9SWszxl6mU0BlglknaogtlmZ3EHbr7XCowthuZKZsR5bid67Ii mJecUyf/sgIg+JbKK9zjFCuDJe/wt2s= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hD0RcuJh; spf=pass (imf09.hostedemail.com: domain of leon@kernel.org designates 139.178.84.217 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=1709633761; 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=QVlle0R5IYeDjjBZozSFTOPI2CNcxvUCpg9nwNGpaaY+nxJX6x01o7UEo69p3Z5+U+mc9B uy6/UX5ZD71IatTA6iQ2JKe28NFZHAHCkVD1E20bcJ0OpM60sW8TNsneY3ECbIy41984kv XY6YrxtFOZQ51vmFh02vuJlusgnI7vM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0330961486; Tue, 5 Mar 2024 10:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05EE4C433B1; Tue, 5 Mar 2024 10:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709633759; bh=buI8QIvB9qQbf6UKyQhoBlduuXAN0B68Jk0a66fCfeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hD0RcuJh00bicYhn0Ta6Ju9jPnBJ6gf5WneHPY3WuSGytfQ3Rc+DL/DoEICP3FM75 TX/RbpezM81fbB7g0M+/pUDbb5pBwp/U/cmchQIoNl1PajmoWeXVhqKZvBxR2j5GQ/ Xdi601RNr9cazQkefNIGomp16HunWfV85J/ruCFKJmmEcwPO6ApMTZcJ4UuZr1UsdF IMcAM0aIzs2G0O2qY8xakXVQgmneCmZ8NqSMafyLl2qF/5B13f9WQleGpTBPKI7GT6 DWWSpgNOxOOcGpvNc8RrhGDXjyzyq5YkBJQZFkgzf+EGBUNHt2uhxv49wDRBLex/sm mq/GhRcT5gfAA== 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 06/16] iommu/dma: Implement link/unlink page callbacks Date: Tue, 5 Mar 2024 12:15:16 +0200 Message-ID: <1d3d26afcdbf95b053a3a44ceff34a4fa5334582.1709631413.git.leon@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: DA30D14000E X-Stat-Signature: y4uuqiabcpnczd3mc3zt73anxeebt3fg X-Rspam-User: X-HE-Tag: 1709633760-292589 X-HE-Meta: U2FsdGVkX1/eEXsWXeUgA2mD1nuXbF+YnXZd2gv15F1ppmh6hQ8pFmpMUVLgfQ2Zby6pGOifgaiLOI3kjbzgvyQ74aJE5b0rHZUlaJBUGGsLurTyyio5OhJlYvjk6yKC4ojxvEHpx33/0cqjauw49STHqZ7w4Ntskh89sECEsqiHQ+70wJkpYgKflqHHV1QrQlilOrshTWfSjajrhZn/0XkxfRzPeS/vc+wxro8fQ9aOEcm463fzJ5pABrcDju/en7Zh+wRQsnbejyzgBS0WHjENwwrGcoqqLZ7N0q9LxXB8FAu9NNIMI/LocYxUL0G50oiVKCdf+uLV38Glp/uWYa6YfTZVMbFL8a73fgQq6lgOWIbGkQ9WPoF541tSqlmtNImUiV1EPcpJe2DX1pH622q5wQVMMYQR2ltyltTjpzMytnH6gxL0Oo3Fy8tT5PXdvvTSXKrwUjQOd5WzCn/hb8ob/57z+LOgL+z836W/MKAVg8VX2xDJ5ExGmfMjmmglFGBWlVimAwDKWjfBIc6q3XY4rmdEamVjiOtS7oJBD3BIS3ZupWr8kqHJ6ugC37+6jd3smF1nH5dxSSlQOu+fYdRI29rZ2p5EN/Ci6HZkd9sKT5DvdC6y57fE1iiNhBsKsdIaW1qurfECylZ618FH4yUSo+cSR0op4aUREXd4qMoJQZ0KDTlFr+76ylv2uh3xy0Dw0jnNWyLWhYapf9KFq08wLCBBzhEYUu4HFdYPCviTVoa5Jle1yNDjZIzqcTXo4N65QH/BIOlpwC7U2roNV6RfAZBXWv0X2S6BFyZnZmn+Cx5Nx0CsibMcnOwAoeCWv6EgxGlkuIv1sEZCpUHa9ctT2rbC1WWNmLnB82wD4RrEicMDjLSlCFPYT/6dLu0yeVTt3WPOUB7EObwHhcPpOEK0mYCZD3PTCEZBXcP+UBc9GlQmGDp8P/PTq2QCGT390QEa7bEjb2n5oR6qHiY T4By0YmF 0rKax 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, }; /*