From patchwork Tue Dec 17 13:00:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13911730 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 867CEE77184 for ; Tue, 17 Dec 2024 13:01:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 755576B00AA; Tue, 17 Dec 2024 08:01:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 704FA6B00AC; Tue, 17 Dec 2024 08:01:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CC776B00B8; Tue, 17 Dec 2024 08:01:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4183F6B00AA for ; Tue, 17 Dec 2024 08:01:12 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1B8101407F1 for ; Tue, 17 Dec 2024 13:01:05 +0000 (UTC) X-FDA: 82904460996.14.2D61EB8 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf04.hostedemail.com (Postfix) with ESMTP id F37C540015 for ; Tue, 17 Dec 2024 13:00:30 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W2+t6vZC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of leon@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=leon@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734440449; 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:references:dkim-signature; bh=LXA8EtJqSt8YMcKAoZw1K1ZsXmQZSiBKF7dQgkzXx1s=; b=Gjl6vgeluO4Hf5B3Yqeoyu+W8xo+eS87asXMCmevn3J+f/eWIosxVksAUk/OglCMeHCqV1 61YOT3/rGg/09XhVzeIr7oru/jBTT+njKZqZjwOUbztXff+PCOd3tg1Vq/Gpo2+LXGFfgd 1uQlXoyXGqP6LkGqW2e7zmydyLEhkuE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734440449; a=rsa-sha256; cv=none; b=djWWd7DR7APN6vE4BVCSQdkcv4Qrl53ZneFgPgIdBfMJBp3oUqwSsidd01CWWLq5CjAdwv v7VZW1+fTlKsGlUpSkW2bAja5Ql8y5rVmRyiK+Nd7yXLAnxDUB2xK67gC+YqL+nLApWysg 1DFWcYbVLqLxd0cKyOzQ5jhVvqNOn8I= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=W2+t6vZC; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of leon@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=leon@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 7103AA40FDD; Tue, 17 Dec 2024 12:59:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4E42C4CED3; Tue, 17 Dec 2024 13:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734440459; bh=WUcPWFcOfeUf/sio4O36o8I8jrOpMF9pl2t7YRV1K7c=; h=From:To:Cc:Subject:Date:From; b=W2+t6vZC3dFZWGD+hxEMeEPE1EEKt40fCuWrdg3SEm/26SFd4QEg0tiIvT2/Wek19 ipbNsM3RLXl0RvFJrTnmhBFYT5MAx6OqnZ/oOKDrKGf32XUg477wAJn6V2jcBjZO/8 Ii8+JaZkyyMGebvolPyBm40JjRdZQhIhr9H3yf5kaiaiXVcPFmwe/C4LJJ4P6impvd 8/hR+n5YTMhKvuP9ew3PL2463hfk0ZudfO9HpYVaOpExaxG4v5E7GWf3f90dIP2oBV GHJCkATLPfGc2ofcLdQ0kQuhsYKz0DBm7jEilkgCea7JLERhDeOtEVUaSSk2h/iHeZ SwmUwQ1h0ckQQ== From: Leon Romanovsky To: Jens Axboe , Jason Gunthorpe , Robin Murphy , Joerg Roedel , Will Deacon , Christoph Hellwig , Sagi Grimberg Cc: Keith Busch , Bjorn Helgaas , Logan Gunthorpe , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , Marek Szyprowski , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , 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: [PATCH v5 00/17] Provide a new two step DMA mapping API Date: Tue, 17 Dec 2024 15:00:18 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Stat-Signature: p6bkbb85ht5gxt7mrxos3jsxi617a4j6 X-Rspamd-Queue-Id: F37C540015 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734440430-168897 X-HE-Meta: U2FsdGVkX1+MUYn0RspqMeWWRLA3A+AVplEf/IkBLxI1prWyT2FlSmfAYbOQ2RxmIxhIjJOYrE5RhW+sgu1imoBo9Yy7+XWdtCvviSv04gdRQ2DWtrOLUf4e+vW763Knz2DCbmesYnY3H4+xxchFADe/e8/g0Q3xPTT0diljxT4hg7W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, 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: Changelog: v5: * Trimmed long lines in all patches. * Squashed "dma-mapping: Add check if IOVA can be used" into "dma: Provide an interface to allow allocate IOVA" patch. * Added tags from Christoph and Will. * Fixed spelling/grammar errors. * Change title from "dma: Provide an ..." to be "dma-mapping: Provide an ...". * Slightly changed hmm patch to set sticky flags in one place. v4: https://lore.kernel.org/all/cover.1733398913.git.leon@kernel.org * Added extra patch to add kernel-doc for iommu_unmap and * iommu_unmap_fast * Rebased to v6.13-rc1 * Added Will's tags v3: https://lore.kernel.org/all/cover.1731244445.git.leon@kernel.org * Added DMA_ATTR_SKIP_CPU_SYNC to p2p pages in HMM. * Fixed error unwind if dma_iova_sync fails in HMM. * Clear all PFN flags which were set in map to make code. more clean, the callers anyway cleaned them. * Generalize sticky PFN flags logic in HMM. * Removed not-needed #ifdef-#endif section. v2: https://lore.kernel.org/all/cover.1730892663.git.leon@kernel.org * Fixed docs file as Randy suggested * Fixed releases of memory in HMM path. It was allocated with kv.. variants but released with kfree instead of kvfree. * Slightly changed commit message in VFIO patch. v1: https://lore.kernel.org/all/cover.1730298502.git.leon@kernel.org * Squashed two VFIO patches into one * Added Acked-by/Reviewed-by tags * Fix docs spelling errors * Simplified dma_iova_sync() API * Added extra check in dma_iova_destroy() if mapped size to make code * more clear * Fixed checkpatch warnings in p2p patch * Changed implementation of VFIO mlx5 mlx5vf_add_migration_pages() to be more general * Reduced the number of changes in VFIO patch v0: https://lore.kernel.org/all/cover.1730037276.git.leon@kernel.org ---------------------------------------------------------------------------- Christoph Hellwig (6): PCI/P2PDMA: Refactor the p2pdma mapping helpers dma-mapping: move the PCI P2PDMA mapping helpers to pci-p2pdma.h iommu: generalize the batched sync after map interface iommu/dma: Factor out a iommu_dma_map_swiotlb helper dma-mapping: add a dma_need_unmap helper docs: core-api: document the IOVA-based API Leon Romanovsky (11): iommu: add kernel-doc for iommu_unmap and iommu_unmap_fast dma-mapping: Provide an interface to allow allocate IOVA dma-mapping: Implement link/unlink ranges API mm/hmm: let users to tag specific PFN with DMA mapped bit mm/hmm: provide generic DMA managing logic RDMA/umem: Store ODP access mask information in PFN RDMA/core: Convert UMEM ODP DMA mapping to caching IOVA and page linkage RDMA/umem: Separate implicit ODP initialization from explicit ODP vfio/mlx5: Explicitly use number of pages instead of allocated length vfio/mlx5: Rewrite create mkey flow to allow better code reuse vfio/mlx5: Enable the DMA link API Documentation/core-api/dma-api.rst | 70 +++++ drivers/infiniband/core/umem_odp.c | 250 +++++---------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 12 +- drivers/infiniband/hw/mlx5/odp.c | 65 ++-- drivers/infiniband/hw/mlx5/umr.c | 12 +- drivers/iommu/dma-iommu.c | 454 +++++++++++++++++++++++---- drivers/iommu/iommu.c | 84 ++--- drivers/pci/p2pdma.c | 38 +-- drivers/vfio/pci/mlx5/cmd.c | 376 +++++++++++----------- drivers/vfio/pci/mlx5/cmd.h | 35 ++- drivers/vfio/pci/mlx5/main.c | 87 +++-- include/linux/dma-map-ops.h | 54 ---- include/linux/dma-mapping.h | 86 +++++ include/linux/hmm-dma.h | 33 ++ include/linux/hmm.h | 21 ++ include/linux/iommu.h | 4 + include/linux/pci-p2pdma.h | 84 +++++ include/rdma/ib_umem_odp.h | 25 +- kernel/dma/direct.c | 44 +-- kernel/dma/mapping.c | 18 ++ mm/hmm.c | 264 ++++++++++++++-- 21 files changed, 1423 insertions(+), 693 deletions(-) create mode 100644 include/linux/hmm-dma.h