From patchwork Mon Jun 12 15:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13276868 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 E5ECAC7EE2F for ; Mon, 12 Jun 2023 15:33:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F5498E0008; Mon, 12 Jun 2023 11:33:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A57A8E0005; Mon, 12 Jun 2023 11:33:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 694718E0008; Mon, 12 Jun 2023 11:33:04 -0400 (EDT) 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 59AA98E0005 for ; Mon, 12 Jun 2023 11:33:04 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2D81A1A0256 for ; Mon, 12 Jun 2023 15:33:04 +0000 (UTC) X-FDA: 80894489088.07.BDF2C12 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 3CC3D1C0027 for ; Mon, 12 Jun 2023 15:33:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686583982; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n8jxFfpCZRM4nPaOR8hcZPkWObYK7GNY+z1x0KsyXks=; b=UxdTOLELhUhcQe/bRpGbRZYSis/pRcg4LNjKFV7/2664Iq7NEVNtJaGqCcSDaA+HgdPSHq OP6BdMFR0FLYZc0uzC75MBdZ5qIOv2Wf6fh3z6NIN6DMm3SfpslJp1foxH85Hq0xZ61Eoc 7JL767rbLz1F9EJFeUeUISbeX9c3s5Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686583982; a=rsa-sha256; cv=none; b=WhLaxx+4Un/REAFhLOc+UjmFxCgf8NyhKiFp3NNSoFol4tnl3shH+EBzVJmwFakMkHOIPE 2OnhD44opPdbOx4q0/mPyE4bkLAXSjAzCI6pQOvzeTKKEUeSPwYtyp+YGV8YotUSxRTy0/ wueHZylYaugowZDxN59h0j7/18jDQqE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 606DB62AE9; Mon, 12 Jun 2023 15:33:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA072C4339C; Mon, 12 Jun 2023 15:32:56 +0000 (UTC) From: Catalin Marinas To: Andrew Morton , Linus Torvalds Cc: Christoph Hellwig , Robin Murphy , Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , Vlastimil Babka , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 12/17] scatterlist: Add dedicated config for DMA flags Date: Mon, 12 Jun 2023 16:31:56 +0100 Message-Id: <20230612153201.554742-13-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230612153201.554742-1-catalin.marinas@arm.com> References: <20230612153201.554742-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3CC3D1C0027 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5xrfrtoib3n98c58jttkrwi8g58dur9e X-HE-Tag: 1686583981-269518 X-HE-Meta: U2FsdGVkX1++61vQ9fUm1rZIqWkOXnuaOZFq0KGLZMXjcsapVPk7wVE46PAiY6Itxv5+kvIdhMUqwiApEqy9y88cYOYEh79vwXT8+DJwwSGTkHBNHSlMWEOvj5NIM/sFrqH6ft05f+Nj0nqYCG/dEWrEsCqT8zbobYi7Gj0GuMzWgfNGSzO4MMO/mlUG5NyftObgx2DNPOf4pasC88lVdWNEy/jzzD/Jda/x551w5H/f32rFVzcoST5BjpF+4QUOuiTU5vwUuWBLvemkXlBlfP2AWIR8OfppJ2DfqOCqewCubKJC+Ho63A1r89jF0NlWPfAQ8E/4gg6UI7vulbF4FmBzhPe+5pnp+YViTyu8Cz4tGJeLNzsfx/kkive0a5QjuMS9wdz+CKDXrrwezfFEp57vjJxIbfTOBkMlfU3jP6cLoGU/5V1uBsq80iNe70ADgdv4nK+UQBXIILubDwpYqfKWgyjKUiGe1A+ZpzLE5l4x9LY0ntzINcbkUtOeLfnX0YuVGKdcB05CDK7Z++YuhrwDHZScSGt00jUpPy8d8tsw1BjbuTVzybNMLL2dI9Ykj8wBHqH+sAYZcfHSWcrvLDIKk5fAmFWFBqrXi5nV3Zu18DyybluytWffUwuXOormo8VWGRhS4HGNSXo3GrzV9edwvK619CpSgBpb+gXykp4+IzBdmIK5FiPypGTnjwFUO/ztdRt9IWhGMMR0SuqWGEb0mhR9bM1QgpWvJK57LXOGQG3CaN+Nb7zmA1FC+eITlTQjQhaI8t8ccvf8JzdfhaeEsyNytwoblz5esct69bDfzRf9yG5uBizwFp9Ou2hqVQ+LqF8GD1LJlVp2FXN/9kCKJEt7dgA8fQPO+trChKgemlyXO2IwG2RQRu/w3UznakabsdraJdUra2n/auJ8kh9ymCLOoPz/er/DjE8k7SyxFIgpPD6VijcgvTBcEJTuWEiIrqttqGbuJixEont KNGUtDTr 5CJYbrUBnmIUkImakmCtc0SV/Li7KWItd7v86ZHW596iBuXJ8qVvWjl1DHgnkJh/bwixJFS8B/X0RaZec30c7XwzGmV1cqa1tzxnTqhsrqkJpl+0hX5NdrMjLBzeDhaxdDLUKuwOrNKFIFBW349vmSfBeO+4cZEFLliyX4gTOLx+V2ZesUCM8cqpihlPh9ngAs30Ok/d2SuSWlO08YB6xruqHZ7D/pLcPGmRD7C2Rv5rfkL41fbp551hQKZMe0Its649pHp1ZR/Hpe6Hq201Y0wUv2rLIh97xHmsrexKAG/UUmb9E6S8fK0zJtwLMn+PeNCz69h/SP+5wNltiZrG1B4XTRwPm8G2xItMxIv3BB7NkW7JOESOh7cSN4XPQf93YUejFOlYI2h9RntENZIxwO6lywo6PAgMwU/MIREvetzPmcYiEvvZezjkNSEMLEGp0UFVu6ys9wsgS34dXH2PPPVbM+SVZiEAy1h8I7nwON+Rd6jym6VJQXAKS6Q== 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: From: Robin Murphy The DMA flags field will be useful for users beyond PCI P2P, so upgrade to its own dedicated config option. Signed-off-by: Robin Murphy [catalin.marinas@arm.com: use #ifdef CONFIG_NEED_SG_DMA_FLAGS in scatterlist.h] [catalin.marinas@arm.com: update PCI_P2PDMA dma_flags comment in scatterlist.h] Signed-off-by: Catalin Marinas Reviewed-by: Christoph Hellwig Tested-by: Isaac J. Manjarres --- drivers/pci/Kconfig | 1 + include/linux/scatterlist.h | 13 ++++++------- kernel/dma/Kconfig | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 9309f2469b41..3c07d8d214b3 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -168,6 +168,7 @@ config PCI_P2PDMA # depends on 64BIT select GENERIC_ALLOCATOR + select NEED_SG_DMA_FLAGS help Enableѕ drivers to do PCI peer-to-peer transactions to and from BARs that are exposed in other devices that are the part of diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 375a5e90d86a..19833fd4113b 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -16,7 +16,7 @@ struct scatterlist { #ifdef CONFIG_NEED_SG_DMA_LENGTH unsigned int dma_length; #endif -#ifdef CONFIG_PCI_P2PDMA +#ifdef CONFIG_NEED_SG_DMA_FLAGS unsigned int dma_flags; #endif }; @@ -249,12 +249,11 @@ static inline void sg_unmark_end(struct scatterlist *sg) } /* - * CONFGI_PCI_P2PDMA depends on CONFIG_64BIT which means there is 4 bytes - * in struct scatterlist (assuming also CONFIG_NEED_SG_DMA_LENGTH is set). - * Use this padding for DMA flags bits to indicate when a specific - * dma address is a bus address. + * One 64-bit architectures there is a 4-byte padding in struct scatterlist + * (assuming also CONFIG_NEED_SG_DMA_LENGTH is set). Use this padding for DMA + * flags bits to indicate when a specific dma address is a bus address. */ -#ifdef CONFIG_PCI_P2PDMA +#ifdef CONFIG_NEED_SG_DMA_FLAGS #define SG_DMA_BUS_ADDRESS (1 << 0) @@ -312,7 +311,7 @@ static inline void sg_dma_unmark_bus_address(struct scatterlist *sg) { } -#endif +#endif /* CONFIG_NEED_SG_DMA_FLAGS */ /** * sg_phys - Return physical address of an sg entry diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 6677d0e64d27..acc6f231259c 100644 --- a/kernel/dma/Kconfig +++ b/kernel/dma/Kconfig @@ -24,6 +24,9 @@ config DMA_OPS_BYPASS config ARCH_HAS_DMA_MAP_DIRECT bool +config NEED_SG_DMA_FLAGS + bool + config NEED_SG_DMA_LENGTH bool