From patchwork Wed May 31 15:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13262465 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 53812C7EE31 for ; Wed, 31 May 2023 15:49:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E53C28E000C; Wed, 31 May 2023 11:49:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDDBC8E0003; Wed, 31 May 2023 11:49:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA4B38E000C; Wed, 31 May 2023 11:49:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BB6B78E0003 for ; Wed, 31 May 2023 11:49:37 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 54E571A02AC for ; Wed, 31 May 2023 15:49:34 +0000 (UTC) X-FDA: 80850985068.04.761DC01 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 9A8BE1A0028 for ; Wed, 31 May 2023 15:49:32 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685548172; 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=6iELFwMU1BdH//ruMwUvhKCV6FH3nK4Bm5fzg3cJms4=; b=cCskYdOW3MrlS+WNn9BKuQd0n9RMMevlv8Nc3LtPuaqKFO0g/pPbv8zfn9eG2jXnU9mfJ6 qimQldh6OmfSLYWryd7LDrT/OA5fevjBqohO3uEMV+PmpBzcWWVoO3hRoYhO1MWQHmbgP6 0rKicNjnHeb0V9D6nE+iENxgasxKbRY= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685548172; a=rsa-sha256; cv=none; b=nvoUxXCG9I8oe5k9hE9jXBtt5G5zYagmb5rlXVZ/AEyysS4DIeEhz9Ssbbrld2pmMxsj5P D/qBmCPnJRhAZgDCJbg8ZNSEkgKe0ol2ZVB18xihxIP3deX/ENOSofLzHp92Jn/A1YmdKS VMgyIgB+uUg05xtjT2P6ykBS+yacVF8= 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 A59A663D9F; Wed, 31 May 2023 15:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F1CDC433AE; Wed, 31 May 2023 15:49:27 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Christoph Hellwig , Robin Murphy Cc: Arnd Bergmann , Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Isaac Manjarres , Saravana Kannan , Alasdair Kergon , Daniel Vetter , Joerg Roedel , Mark Brown , Mike Snitzer , "Rafael J. Wysocki" , Jonathan Cameron , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 12/17] scatterlist: Add dedicated config for DMA flags Date: Wed, 31 May 2023 16:48:31 +0100 Message-Id: <20230531154836.1366225-13-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531154836.1366225-1-catalin.marinas@arm.com> References: <20230531154836.1366225-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: nrg34sybhx97ymgo5phw4h7kba9fzdbc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9A8BE1A0028 X-HE-Tag: 1685548172-959327 X-HE-Meta: U2FsdGVkX1/WauxI3p8iyKJML7YFKE9PTKb62frnIoeGDhK3vW3TFVg4FpCcOTl2UXns7eqWN4PQjNNcX01nO9/Wdjvq+O2RF4KPOKfJnKtAzNkgxJTaOZAj7CaKwASBHzuP4d7hLQUKTuXjpZIC2M6klJXnr/6D0ErSWWP4TNljpDe/GFPqc6V2uyKkBXzQFkU6eRXMTLqlH5KsMIS9Wu112t0tXBFQF1t+O/eT64pl2r6PeOqiEU+ZbSfwvlFHgExmmjwEoafDMk52bLJJeyhYhCojWsXeh+84rNRNK4Z+xGF5xQ4XhHgbcwigMQsyOoeQrdWeS4/7X+s5Dk+/sWohtLXmCvdhMCQLdR2uhw3Wv5m/Cqx1vrFQCsIXfDnzWXFvlbGcENfq4X0x69yuYrA0ALfUayw1xuwFrKg4p5eEvO3xJ9akfg/gjD2v+3TX5YI7Giov/gRJJ1NLK9JQLkseTLRbAoqBBalBIt+/4xYLYULm/06eARpvA5g4Qg51zk2mXi9cwiVbTY4lVgSB5p6s1NwAfpX6LuRvePQi8djQXHzdeiwwJrDynpxvOXrmJvYWp2XY5XBfFgPyVyry4NcWgDNWRSnyQF4NKLzWvL9BH+tikyJs3mRvWnuWT7/y185tWMgxu3yYlYmTaQ8dMcs6AV3CLFJ4kd/6rBcDummakBiAtXyRcEg1dSQ8kFGpWoREbKk9kqKTnrbN3oTIq70G3CXY6STir/bmqqUa8siCIlCl3ZNclgxYrWD67yN4PyM91Z2PX6VDxC+1a5yRAEzameYRU8u6d4eJiUA3UTAjV9ilEyss//U/s2z18mjkQllSplovvdXRGvdE1Icfh3znge6l/35cqKFfEFx2xcWXIVvvTawFJ6hEmi2o7YsYv/YJWJl0BXV14ulX3LXR7+2WKCAyaYydkk73NBh5nZnnYwtfshcciwHXFXVJ24o1eSQp8BDgWW+gSNV8XBP WbJDPatZ k486RcPLhcP5MxZ73jxsVeco+QDsGE/WEPDbOlf3ylq+nNMIJb4sYN2VTFoKqWfcwDEu7xRL8+v8IeZiPK0pUl4mwmkYNOoqdCYiER9qEl84xEku6xgFzJ0kUXcPw83xjQ8O86b+bYhgugA2y6Hny2f/13+PKNs/w/O9gzIfQMupzOVnhfSVnNheNKAeuSGygoDvrNTLTHSDLRnzG3NHAISm5Oty26ithexxQxPoIWxqZX5qw9zqbn6NEjbqw1uXVUucX9I728JHD2W6UD3lSO//XJ4oGEanU5a1BAbeZCDayYTJKo4CDFnWsQEEAXImBA/MtKo0LxZyIbht8UphJxgHQszZOSWMgpAZssQZvho107ZNlRzt3o3aNSWummVXygLV4Ec11n/9D4EmMrRf2hejyI/IiQX9xY6IN0N10DeFyrei1/txmTHv4clxK/vVmPzkRzVT2Y7ucLre1UhOGjurZYPZzLj01/x6P 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 --- 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