From patchwork Wed May 31 15:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13262480 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 0340BC77B73 for ; Wed, 31 May 2023 15:49:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94C248E0007; Wed, 31 May 2023 11:49:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FB068E0006; Wed, 31 May 2023 11:49:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C2B18E0007; Wed, 31 May 2023 11:49:55 -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 6A9EE8E0006 for ; Wed, 31 May 2023 11:49:55 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2EB2BA023F for ; Wed, 31 May 2023 15:49:55 +0000 (UTC) X-FDA: 80850985950.05.A8C36F1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 77A30A0016 for ; Wed, 31 May 2023 15:49:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf25.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=1685548193; 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=6aBG2ZZwYC+t4YCaDdBYplmUF8K5hUOMNLAYxXIGkVyhNAGXVw8NvV6Ps8sQVxK3EyCTsC YCBRY5bXDpJf4Noe8z9xJdiodtdfYeDG8beLPSJNUZQXoh2fOcdVUsIni9ZCcxwftodusF m5oPT9SPLE8FwN8Ktn0RO3lNHeREa+g= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf25.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=1685548193; a=rsa-sha256; cv=none; b=Cav062TCxkj1bOMxXjciD5KwcnsGHUb1i6AMPCt3mDBCg/7E8aLpXaehmSOdjPW0svvyW2 v6ZGPOshFeE1y/nx5356GROhHZU1CKfvyp6e96jd7c7PiGglvIj9js+2y7m4EBMVzcxFWA fzMvGESkRx5VHZX2GMNmcCaMVUrXqd8= 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 A144F6380B; Wed, 31 May 2023 15:49:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 677E6C433A0; Wed, 31 May 2023 15:49:48 +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 17/17] arm64: Enable ARCH_WANT_KMALLOC_DMA_BOUNCE for arm64 Date: Wed, 31 May 2023 16:48:36 +0100 Message-Id: <20230531154836.1366225-18-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-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 77A30A0016 X-Stat-Signature: can86yaz8pfgx1gra5wmusfotabhr1px X-HE-Tag: 1685548193-213493 X-HE-Meta: U2FsdGVkX1+XGfc26OptAO8IUk9nJ45RvzwuGthgxxz6YDLWe/vX5bRIUlzCnPQxhZDz+7JdBy+BR3wCEE+n+/53FUXXwt/Jxi5Y1NOBSFNLMRpBbcUm+3MvEM/eG54B25E1id1ttPHOdZeup1sVzwn+XretCoRYGIK7BupKAgPlzmEB267cLXF1gdaIMm7rpjatSqqje9NjB+/vjdgVmrnX3i0RimbT30Ay22mS5RJgBmFfVi7nQj3hd6xK3LnFponu6A5UzEX9urg2Jjj6Sam5SPLiBfs1fzltJ671xQbtEF7f43D2Ow7LRTH+IQt/peFrmAZzmFUAMXd123jOQBAyZAlWQyGcpTK3phLPhS6p7fGp0tAJ3dlZGzUkQdkz3rrMhQcvk2Ac2FflYJFj/xmpLmEGfE0Y+anuZCKGAi1a4wGuv9YWvORiMrU74y3j38eC2S7A+LN8h/uL3IjLojVz7HZOun2UXOLtNv4WZyHD1TbqweZbOwzFVGogOQp9NPffoiZgrhSzADBRnb4L55jEnkYpy1P4fdmbDCB+H9hhNz5oNhc0w/DL1D/6vdE16eYcqCC6EwWfFzLT1HbqZY4dp+gwRG/Twa1dGErtsn7ounzdh86C5jnouxMZ4SkeF3vG3AylIrnC1OkMg1Wk14WvXAfo2FViKK51TKLes2V0nbOPqkQl/Gep9/0lddR8m9XHiUX62EFpCpIgCkhCCgCJXOWYbgqzI064YN5uKH6ZeE2mMzv9v/bAW+cy8gHSMTNpLi0FCcMh/B5DzQLAGfyqRHfyqpZKGLOuKYTHF2vPlDpeZeL9zB4GM/Cl7GUwqkbE8XbDjsP8nEOK+alSEV1Vt5HCED2yw2TOwVZdMsDEB5iBKxPSXuGIrtNoyOLrsRK8Q2AvPGsDhonarun5D7Qts5Ma3AU1hIdnJc5XkaNK2Ss1K6oJuzCR8/VgMdBdf6SESRSCoxo7Rs9//UL uGctM+7i OAXFwWbwb2/b+qb54DE59gqRFwglkK/2oQwYtY8BUndBgfXzdPnzUokdqTox74JCO1ZcfGLJqSz6Graj86qM1z2lDUlYfWh/FhvMRcKaB4kWNg5kgr/1nDktAM9XCrfHhRCPFjTyAMtYJsAFrSZBzypikJ2pvX2O7HWqwrKJ+z1GTdBHmvDNV6hVKrb0wQxUNQLsdTIeNlikCSipaL96s8PB/8ocF4XRBUt2z1k9s5s8gnZIMbBu6Cuetxpm7GdddoBMbo/wKfbfTCVAF+dyY/2MFFKMwW2cMM7LgvRK4Rany2bTAXYbS5RpPnJECypJ6HxzEfgIkiHoxR/HZZvelVHaPz2v0kqgpaly+/nB02YiIoKixlVV6iY6OCSHK3WjfLFvZ27/ESHbB6uc4uRAcFvxPygp6BV5bKB/MpvJCP/8iNAFaUd8HGN38QSnfW0+B1dkBWL9ig4Q8wJRzPmNgrGWtE8AuG8iWkx9LlhQ1qIz/olHuNo64KN1ZjetMbmrCguwxAMmWxL5JqUAg8tnWqZ+HBdt0naAGHeZIqtn8jNLUlsrUsE2OHqzV/crsymFy32Mi 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();