From patchwork Thu May 18 17:34:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13247181 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 F26EFC7EE23 for ; Thu, 18 May 2023 17:35:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9636E900017; Thu, 18 May 2023 13:35:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 913CF900003; Thu, 18 May 2023 13:35:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DB96900017; Thu, 18 May 2023 13:35:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6E999900003 for ; Thu, 18 May 2023 13:35:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 37479408FF for ; Thu, 18 May 2023 17:35:13 +0000 (UTC) X-FDA: 80804076906.26.B839D64 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 89E1040005 for ; Thu, 18 May 2023 17:35:11 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.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=1684431311; 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=QH5r4yeZLShWNILLwf1McZXq40oIioPqDsZRYQypELo=; b=Uzy0nedF92scuzHIYchIG2/6nHXL5TYK8rDLHHGwcF5VM6M4Op0Hh0QowsH0yg/sz9fuqM D4zXk6+QrVo4yh9WAY+4lKEjjylB9SIwoeqRXgAduIJmG+P/1Lxk3pRZkYACschxAmi+vU KaZJVRQbDsKZd0KLCb3pUC2cFJ8wr78= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684431311; a=rsa-sha256; cv=none; b=aliout7rSKM9FtFDVj/PFKipIc3GkYRZ3qPDx/mCyEi0bVgenYldqViXtN2LyeZCt8Lrjl A53c9wAIVpga8kFx4Wj2Ur05H4otcSTBho5veRjHzer3LtGUTzR0CBBjM9udAENnkOQ1Sg 21tni0B4sCauZIb7OqbnkXVTnjsinJA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.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 B781265161; Thu, 18 May 2023 17:35:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79802C4339E; Thu, 18 May 2023 17:35:06 +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 15/15] arm64: Enable ARCH_WANT_KMALLOC_DMA_BOUNCE for arm64 Date: Thu, 18 May 2023 18:34:03 +0100 Message-Id: <20230518173403.1150549-16-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: 89E1040005 X-Rspam-User: X-Stat-Signature: hgzkq4yen4nqe94qzrbmy9o4fmc7cbr6 X-Rspamd-Server: rspam03 X-HE-Tag: 1684431311-85732 X-HE-Meta: U2FsdGVkX1+y8+eVb0L8dWfl2YGncPl9+kpFKTVs1FQju52G9MsLn0yz5Si3UqortbbPdl0nYY8qhmgpDwd18SBWE5LDZLDczTdR/kRy/WZPKVngSrP5IWjSjTKmjf7GiPTz3aEvj39utrMq1XF+X+g6cWXGmvxVzU5Up02dqpKili7gBOKfOEPZQy1K/CJ0I4V2ujPZBhMqFHjGmI9hjeBM+YaR2FXJ/SJAuQ1c4V7azRWY7OESP79wAJfdHh8zqi7HAirQOcikmt8pbt4ipkw75TluPsgVrLLN1Tz06qEKAbmocrXr61z0MO5igbgJdVtQdPgGDI+llp+Rmf0IHvIEfucWJPiKewRgcbweo29k1ihTmthz6WrXPt8tFpvLXdeEfDqp0hE5feqkMzOs7KQV+5VqSJXAyLbOBDeYSwUCllfozHuisBgNs7nVDNk4ztZy5Xx5+QA37Du4MRHTiyQGP+XPjLJcNZ8oHuI8c+HnmLIqIs1GsBDJYPd8hlNxRYfxOWcrEnJ9PjV8Ul6leAadoSgmCPPR72JJT0WAodrLH7eYcU0IxTB3Pg9U1VlYT65cxTo5QRGskgUmLOI2mtRmWCDo966u1k/8bdl12EQgZQtnyWgmztax0fM1qMQIGsP0q9aZ3yavX1kUIZoCiiyp7QWJr0RjFCcLYUSM9JpiQxaIOYHg4fdN4pFwNe/HkU6gZGrlrvFGcppgxLqkqs4bZmVflJimelUta9f/tzzDZ/g4ze8/W3CvgXjX5+fKeNMikXFdDXynxyg6maex2RrepZwDTvT3EI+jFc9KX5qe17O06eVNBwqYn/zYuHayES+2Q5431+KttBeF4sBZCgrO5GVYJ4jlZUQp/7b0Icc2mJECEIK3gR9WbqxzNoVNWN+Gtsb+ezaFJlDcDaOXSlVXx764t9jfzowD6LLcUBNnCLqi5InIVw1nyravUnzOaSvDAAIbaMcGFiGtwKm +XrR9qfJ ri9jBC5onfBziMnG20IHQlW2Ibt064+nu8JQP06pYbNelyyBt2u0+pE2suLGj0E9nrLI8nfv8CWVYWUyg2ThXM/75ED7xsuRdtdbwRmxKmy4uZS19qeF0tkDzWQBF9aSAewPY6bFwUbNvPwb1VR9v79nINAm9mPiGGTELfrNclMTjx6VzDSe+0NvxxcFr9SEeUHcxJGKu+3p2N1ev/mcA0Vl/yJlv5jhGpeWzN4q29vEqCbbA7l0gadcapMKgd4aI64nWS3F/HUbEz2V/4NQNGJfRvyh62oQg1XoHW5LCTiJNeYMic/C03YHzXxulZoILKua9ynU0iMB/SoxoU/e9Ag/BoiJ1oPnE7AAYym3pK2AgQ0Spx1rQsfGkdU2MI1XJeutuwBStapeZiR+cmnY9CLof/lI/ua6yZ9cNE1juR3e4k5r6uOWCh86r3bwF0rXt9WswmIqRIHX1j6si2ibFjGzDavqJRO4dlLrQyufSARAnDG5PAiX5bQnLDaKfgGMuCv1QG0S0/EDhqdwM3nZ3ZUA3bh+wsxTjoeUhvbMkW6loZzFiifYXTy4X7AM2imChWjKq 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: With the DMA bouncing of unaligned kmalloc() buffers now in place, enable it for arm64 to allow the kmalloc-{8,16,32,48,96} caches. In addition, always create the swiotlb buffer even when the end of RAM is within the 32-bit physical address range (the swiotlb buffer can still be disabled on the kernel command line). Signed-off-by: Catalin Marinas Cc: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/mm/init.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index d11340b41703..1dcfa78f131f 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -102,6 +102,7 @@ config ARM64 select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT select ARCH_WANT_FRAME_POINTERS select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36) + select ARCH_WANT_KMALLOC_DMA_BOUNCE select ARCH_WANT_LD_ORPHAN_WARN select ARCH_WANTS_NO_INSTR select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 66e70ca47680..3ac2e9d79ce4 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -442,7 +442,12 @@ void __init bootmem_init(void) */ void __init mem_init(void) { - swiotlb_init(max_pfn > PFN_DOWN(arm64_dma_phys_limit), SWIOTLB_VERBOSE); + bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); + + if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC)) + swiotlb = true; + + swiotlb_init(swiotlb, SWIOTLB_VERBOSE); /* this will put all unused low memory onto the freelists */ memblock_free_all();