From patchwork Wed May 24 17:19:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13254354 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 BF844C77B7C for ; Wed, 24 May 2023 17:20:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 611A2900012; Wed, 24 May 2023 13:20:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E82E900002; Wed, 24 May 2023 13:20:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FDDB900012; Wed, 24 May 2023 13:20:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3B1B2900002 for ; Wed, 24 May 2023 13:20:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 05AED1A0A58 for ; Wed, 24 May 2023 17:20:15 +0000 (UTC) X-FDA: 80825811990.10.8155722 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 14D3E40013 for ; Wed, 24 May 2023 17:20:12 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf01.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=1684948813; 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=QcxrCBYims99sTaWtbsc4IRs+7tDysGBphQN4oXq1fE=; b=a5wbVOyVu+R42JZwNuASQS11bQegshBwSAeAoOeuUc8/vCBmc2xfH13aC9QAdpthGUiVdl ugfSCsxCpJNtJBsIHn2ZtAUCOhXiJCoG7+j/AKf4EAwE5M/MXJpmp55GApUmpz6/+lrkI6 dQ7dfy0jONdh6zEeegSaYJ2UPK55HRs= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf01.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=1684948813; a=rsa-sha256; cv=none; b=HafLykPaINuKGJhrxXwu7Gyt6QVITY3PICUDNwyA7zkhlZdw6OXXQoZPAI28HUPvoj+rnC BfSF3YWSMK1z8o5+PZh6BiDwf484kuLAJs4pKi4mrr7ieITha36JMvrS2zUDrL8cDEb6kP nnVLnfOGN//wbnuEyMs898PhE2ZhA1I= 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 3CA2E638B6; Wed, 24 May 2023 17:20:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEE70C433AC; Wed, 24 May 2023 17:20:07 +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" , linux-mm@kvack.org, iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 15/15] arm64: Enable ARCH_WANT_KMALLOC_DMA_BOUNCE for arm64 Date: Wed, 24 May 2023 18:19:04 +0100 Message-Id: <20230524171904.3967031-16-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230524171904.3967031-1-catalin.marinas@arm.com> References: <20230524171904.3967031-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 14D3E40013 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: qwfazsn5fa33x6dnkjz7exeycz7xkggj X-HE-Tag: 1684948812-586172 X-HE-Meta: U2FsdGVkX1+M/h3UyWogu9jKfbRcFAK8UtR+eJiKMller1AlqMg+Qgv3T1nXoe+3ZbahWMN7JFTjuDrWqfILjZ8b3zfEVBMVO7CEWciHBl2leDsiuepJYXYTPByaIjPO+lcN36G40aPJACBwppsLyE1MVAW23cjlyDBcaOJf8QtMyup511WbrZSva2/ZBNQSZ+0F3XPtvu1jblyVUtxLfD4NNKCit3SyGX0E4Rm71RQJOatR1RsirCmW5Jr8Z+wXpe+eyZkM/8dU2SyIXytrTc1DDNlct4VP+8Pe6/Y14u7aypn1/9hdGlPlAimbodzj2qXb3TrIMEFK0K4Kshv5h2xaLw3dPkH2l8DinGjPmBfLwjzW6i7pYzmj3A0nhIJWUleJo9j5DzW2PGZaOEsURpdRNpgrbL1JWp9M6r6UFn2b3ugph6+KsQipuDjuQfVXaKw8jmGio1rC7SinCORPe6YyhSEQNkH0RxWHyM0vrz/F16oPLn0X3x7JXmq0tpNKlvrm24N5hwXAdbrtkNXzZGDoN2Iy0drPnUYhD1h4M7cp8kisW0PGLAdulrr8Vyx6Rel7eFO8hp75TO14lKq88Rr/yKWdc+rgUz+24zbcHAhSa6foCYramOgiGi56v62/K/KJlH++IdvCEFoT8e48u4RaanmbDd6VTl81N3xGp34QO8SaYGwt5mAeuSwE44hflNtMRu/tk80VaoJp/JBMdShHdvLU05f6eUL6tld/JHglb6wqVhS8bZk6pGOoDdO72k87n8H/2hIshxrjYC3APLw+/qva4N1Ctd6/liFIu/ACQS0heTkv7vVNCE0J1RwXbPRvPejEfbX3c48zhLDt/9JnPI8EXGBSx6A7jUZxYbbJog58zXbRqdKYKOiVybcpyYSp1+ten8kk074VsUK6+fHtsPWh3IFfsoRSSiD3G17BvY/8R5JmWG3ya9eLxurAwv4f70QDz0BScKqVwLh gJk554qh Lq8QXKC28HDXp3MljCnIJSTRqcRVEQwl6YwCKZlfbz20QQCbW/gBU9KrIaOOU6yoGY6JjpQ3zj1bzmZuh+2DnGIw9ZGkKVW6dHPRbMyE09uzLpBED5t9/RSZzHECCXvr3LJVphWutZvdD0J/gpJuxGZGP9JZq1wJ1IQ/uypcUV5vQMV5mhnd06ulq0JlIJtKEbPKitFd34XUOPI4fVPZy4No8j+iMRYOUpeaVp6yV33VidSwmXRu6yKdU23tzadZq4sbKe0ORwmIGLfhpoZCjykKkkLx/1t0xClf7gJHo/7gMBy7MyOPPAkeSD/GaJcTh0cqF3JbJSn1fQFwhEENjMmsqe0FZ3z7tSh71f3XkvHSg0datuqqphVBn72yy5t1WmZygouAwwoaIf1p57c963IpFDo96ZYwgkX50FfcIhx7hfz5RJNycULAexvnhtKFxVUP8azuWiLnzsJ6yXeNj0YcdVWPBBdZz2dk6f3v2TBUM91+2FODAEMFF3dnbt9fcxIWtqKscZhe4HbNtFX9hg1hCuYUktN1ADZpliGxwSbz/nJv8T14W+Mn5gXEO/Jra6Q6s 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 b1201d25a8a4..af42871431c0 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -120,6 +120,7 @@ config ARM64 select CRC32 select DCACHE_WORD_ACCESS select DYNAMIC_FTRACE if FUNCTION_TRACER + select DMA_BOUNCE_UNALIGNED_KMALLOC select DMA_DIRECT_REMAP select EDAC_SUPPORT select FRAME_POINTER 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();