From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B566AC77B7D for ; Thu, 18 May 2023 17:34:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VrKkY44HBrLXONKlvSkTO8WfS5043j51Iap9eEvkgeU=; b=vkcm00/wJW4Qvz QTRYxgQ8wkxfxEwTiZFQf33e66N6602gD4xy93EZAtSecB8DCRVMCEfuYXPqkAWIiOFryMetOOdgl vA+cmVnurczDwQNhfAHCX6mCR6sYkBnDVwmlONFIGIDrQ3UZNH9APOPdx9we//BbNwjeBkVogAreB nONEl4Qq3veTAXdl9fb4S1AgLhOgqfbeGtuTihXLYj65IbtvL/6AEavxZPqIbMEOCrINc733+O3lG 7odRC87yR9cISao2dAiN6roxfL4hP3LeN4jyKxU8L3Y8H1MskYIMDckvO+BZlLo4IeMfVQ2ytiECA 445LYUuw79O1SPBsD3pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzhWD-00DfKy-1k; Thu, 18 May 2023 17:34:25 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzhW6-00DfG3-0e for linux-arm-kernel@lists.infradead.org; Thu, 18 May 2023 17:34:19 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230518_103418_289848_EECD0E8C X-CRM114-Status: GOOD ( 14.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel