From patchwork Thu May 18 17:33:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13247150 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 A7721C77B7D for ; Thu, 18 May 2023 17:34:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C2DC900008; Thu, 18 May 2023 13:34:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14C7C900003; Thu, 18 May 2023 13:34:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2EF4900008; Thu, 18 May 2023 13:34:21 -0400 (EDT) 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 E3ADF900003 for ; Thu, 18 May 2023 13:34:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7A17780904 for ; Thu, 18 May 2023 17:34:21 +0000 (UTC) X-FDA: 80804074722.27.D24AB96 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 9C7E1180012 for ; Thu, 18 May 2023 17:34:18 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf16.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=1684431258; 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; bh=GFrMa2owsewxfwyo+ZMqMWw5mqNbHDxBwlBBT0yhJWE=; b=eRUZyfRQjzGR/zCTezJmzDML1W/yCwOo94YJvS+jZOP5vzV4o6EO/7FwUJWvY06EUO+2dV r0lzYX5rkiOH/T0g2S64f4dr7v1sRZsQMy83PNmHRtUqgHGR5W5aaBd7EM2djm2Vee7GSE UhnZkMkdkp7qNA58gbXyQYQxmGqLKoQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf16.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=1684431258; a=rsa-sha256; cv=none; b=4tmIJxFOMQPM+kqcDAteyXjhL5UIPR8jzO8+nQ4VKIJ4ARD5v98Lp2/wgQupak+2EX7TkP N6dvCLfIA2+eAZcFMVk8ClT6eGCjgecn5wv8+La+jh82uqQM6Jj+ifxctop4yIT7gbfDGP CxzE8bxnnQm5IkB9rljKOOJqE8hX5xI= 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 A6B25642F3; Thu, 18 May 2023 17:34:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71A72C4339C; Thu, 18 May 2023 17:34:13 +0000 (UTC) From: Catalin Marinas To: Linus Torvalds , Arnd Bergmann , Christoph Hellwig , Greg Kroah-Hartman Cc: 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" , Robin Murphy , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 02/15] dma: Allow dma_get_cache_alignment() to return the smaller cache_line_size() Date: Thu, 18 May 2023 18:33:50 +0100 Message-Id: <20230518173403.1150549-3-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518173403.1150549-1-catalin.marinas@arm.com> References: <20230518173403.1150549-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9C7E1180012 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: o45qetyicwkq5c73qpfamn7tdrqr3s4m X-HE-Tag: 1684431258-979533 X-HE-Meta: U2FsdGVkX19l0GMroA95+DmXvfxl7kEnNF1EUACG/263RD6kPvU90SFpx5y7cQEi+MhJPOQ43qfiXPp6NR8w4VJdYvnj9w11XCUTDHQMV6FMNcuDQEo/4fY/RIunssinKJ7ZS1PnQlKWoJM638wAkA/P2WrE60Ru5TzPE3Vl6ZfAFQlBm+EygzRFSCaMZ3kOrcThfnHqtBNhmZyCSU0USAnPowTPBhksBh75hcVgYvt5n0XTbMoq/bYxBWbhoDtZkr6PlOjaPybHZDv9aoQ/2CBA6Vb2RyxPZfVYFjlVEYiys8nP+Sfi3D1U+UWMCChI232siU3AAajbaiOVRzQAW6SDU2131u5tdXB8mP1mVhwbyu3yN1aYa39SB759EEFiQsz5sRBRF/4sFk8R9G0+kR6YhXEjbHLVbseRoasBAqgEf5iufJnogu0oFKxQxcDzKCL0f24gE9tQLpoFq9LnL5KdexcHaT1U4Lb7ENK5fkWsfkUhEGD7OWkymCGh54fgU//rEfTWaM79J7RXGJ+plXuC87j9JpLOn5R8ZRKWR0FONDVc8gnO4HC4+Wgj0lrHVGiPcNMT6hER5GN9isilAjcHKwBarKC+6g9bd7AWib4k1mN0f8L1ctOut9mif8lY/2IfqR/S+kyKGJpnGNOGSscH9iIHWf8PRwj5oLO9NLiImRTHk3hmln685PVENGwpHpc+kAYoTZ37mtlzJBb3piTlaGv92ZnnGDbWYKgZIrMMPVkDjPqh4rSDsOotDZnlIKs3cIhKweBGjMmWDlfw2Du7lVktO04MYZZBWyY8RjkYNXAZUJkkdjRI/1qD4+m3QLxI4C+D+k61kXWQBcl13m1cn3Yzz9v4AcBdbxT0N5/5zPs4tlo/kPaiN9jpyhdcR9J4FsBaGVg6ghRgl7UpK+Lj+lMjcjx6dxiHQcMNlpAOaRJP7e7jCrK3matCsl7/g2UKWdw5lNoKrORY7wc XzwLo5yP YLfiUXSmvKDMkclqA+De31eGlkqnZhhkVTHToEgDIrvDaTE9GQU3AA2rxChIzS0Qa15FMkmAKDCEmyuAGIgUzO+5y/rGnQ3kFZci049hNIz8NHbDFFeHTDXWidi9qsxXYDZChwqD8Io7gZ/YcvMb0YG0sbsPg7YSH3eb/l+dcOpJ+dbcTN+3lb0Oc16BzPjRh4EzehFcgC7HKzayuleD3XyU6nJD/5TeyGL7lyqZAqskEqg5RtEYTPI6GMAkw1nM3ZNY4286B8lYrXfXpfqaP1KhUXjWgzeHCtVSayDREsEhyLab3qJn9SefaFiZ1aHRdVt36dD8OhmZBNAAaTkUWRenTK/IYidajcO77YIrQLxh3nZ45FhV91MS+gutNcoBHjG+hF3z3izcQPtTXL0FUK3ITMxY7uomsdl4zOu/bvl/7cCEz38u1Y8ui8TtkKPfS67Zws7KpM42mpEgOupYT2mXjGGX/XWBizvOkfOVUudTISEaWCQKop+5J737gC20+kL5/aSFkXV0LpzW88WshJ6ZNZQmxn9YrRgeS9O/iSQ1hyvIgrCNQO5K+ZuvIluzi71Na 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: On architectures like arm64, ARCH_DMA_MINALIGN is larger than most cache line size configurations deployed. However, the single kernel binary requirement doesn't allow the smaller ARCH_DMA_MINALIGN. Permit an architecture to opt in to dma_get_cache_alignment() returning cache_line_size() which can be probed at run-time. Signed-off-by: Catalin Marinas Cc: Christoph Hellwig Cc: Robin Murphy Cc: Will Deacon --- include/linux/dma-mapping.h | 2 ++ kernel/dma/Kconfig | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 3288a1339271..b29124341317 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -545,6 +545,8 @@ static inline int dma_set_min_align_mask(struct device *dev, static inline int dma_get_cache_alignment(void) { + if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_CACHE_LINE_SIZE)) + return cache_line_size(); #ifdef ARCH_HAS_DMA_MINALIGN return ARCH_DMA_MINALIGN; #endif diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 6677d0e64d27..cc750062c412 100644 --- a/kernel/dma/Kconfig +++ b/kernel/dma/Kconfig @@ -76,6 +76,13 @@ config ARCH_HAS_DMA_PREP_COHERENT config ARCH_HAS_FORCE_DMA_UNENCRYPTED bool +config ARCH_HAS_DMA_CACHE_LINE_SIZE + bool + help + Select if the architecture has non-coherent DMA and + defines ARCH_DMA_MINALIGN larger than a run-time + cache_line_size(). + # # Select this option if the architecture assumes DMA devices are coherent # by default.