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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23D6AC433E2 for ; Tue, 15 Sep 2020 15:15:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8451120735 for ; Tue, 15 Sep 2020 15:15:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0MP8xpJH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Kj6kxhbj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8451120735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=O5ADGvvVWCrKWlBILfWVEWQSGPipDBVLMaFwQJ3Ccvc=; b=0MP8xpJH4pTv37UHM0LiNwY6rr awryapu/njx9qPppmurgBPokSG6TlF2shUE93HXDHdVKqTOSsmFW5w5nwwNHKBRmwNMR6qa9qKu5L 0uCJaKnuMu5aqmEMvkpK/FAhS5bUWDYDC+sK8AeQ2qsNMGCi1asb8do2zBWXGnXq51WHHzp1psGM0 t5T21jBDlnbCH6B0GakN6uMoszp9cUI3Rk6Sb7tl8XOO+IPJCT48Jo0pdgUCOVdZqJbnqVgs62QTd P7vYO4YMb+j9bT9E+tJLd9Qr+f4qTvBepF3I9t38CSr7PFbnjHMt7CGlGvxHM11x2cE65tKibJTeS rMzBQuPg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kICeF-0006Cu-9L; Tue, 15 Sep 2020 15:13:35 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kICeA-0006Bf-Ul; Tue, 15 Sep 2020 15:13:32 +0000 X-UUID: 005cd3cd3e924162b9c28fff639c20ad-20200915 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=jhf6yLptTYEHUoTCMmm0pLT8bnD4HjopGFob8vx8D34=; b=Kj6kxhbjLoLLe7pFkjCBrvOicQRpkJpRlZEj3SSLp+6fVHBzABbhrK2/XevAZn0VZWp5HsBmZa11Kol6VEZ+expo+xMd1HkIz5fsCsXCYF/S0BQY+drze08V/lN6r8IDcBB7PwzyYohofHfMk/UwauJbqF4XgRg8YDEkCa9+IAY=; X-UUID: 005cd3cd3e924162b9c28fff639c20ad-20200915 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1474479456; Tue, 15 Sep 2020 07:09:01 -0800 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Sep 2020 08:08:58 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Sep 2020 23:08:59 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 15 Sep 2020 23:08:56 +0800 From: Phil Chang To: Subject: [PATCH] [PATCH] ARM64: Setup DMA32 zone size by bootargs Date: Tue, 15 Sep 2020 23:08:55 +0800 Message-ID: <20200915150855.24825-1-phil.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_111331_118128_37403A64 X-CRM114-Status: GOOD ( 18.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Alix Wu , linux-doc@vger.kernel.org, Anshuman Khandual , Mauro Carvalho Chehab , Catalin Marinas , YJ Chiang , Jonathan Corbet , Phil Chang , linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Will Deacon , Mike Rapoport 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 Allowing the DMA32 zone be configurable in ARM64 but at most 4Gb. Signed-off-by: Alix Wu Signed-off-by: YJ Chiang Signed-off-by: Phil Chang --- .../admin-guide/kernel-parameters.txt | 3 ++ arch/arm64/include/asm/memory.h | 2 + arch/arm64/mm/init.c | 39 +++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index bdc1f33fd3d1..5be6259e9ba8 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -980,6 +980,9 @@ The filter can be disabled or changed to another driver later using sysfs. + dma32_size=nn[MG] [KNL,BOOT,ARM64] + Forces the DMA32 zone size of in MB. + driver_async_probe= [KNL] List of driver names to be probed asynchronously. Format: ,... diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index afa722504bfd..710de08ae8ae 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -175,6 +175,8 @@ extern u64 kimage_vaddr; /* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +extern phys_addr_t dma32_zone_size; + static inline unsigned long kaslr_offset(void) { return kimage_vaddr - KIMAGE_VADDR; diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 481d22c32a2e..c8af53680d46 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -60,6 +60,9 @@ EXPORT_SYMBOL(physvirt_offset); struct page *vmemmap __ro_after_init; EXPORT_SYMBOL(vmemmap); +phys_addr_t dma32_zone_size __ro_after_init; +EXPORT_SYMBOL(dma32_zone_size); + /* * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of * memory as some devices, namely the Raspberry Pi 4, have peripherals with @@ -242,6 +245,29 @@ static int __init early_mem(char *p) } early_param("mem", early_mem); +static int __init setup_dma32_zone(char *p) +{ + u64 size; + + if (!p) + return -EINVAL; + + if (kstrtoull(p, 0, &size)) + return -EINVAL; + + /* DMA32 zone size should never grater than 4G */ + if (size > max_zone_phys(32) / SZ_1M) + return -EINVAL; + + pr_notice("Setup dma32 zone size to %llu Mb\n", size); + + dma32_zone_size = size * SZ_1M; + + return 0; +} + +early_param("dma32_size", setup_dma32_zone); + static int __init early_init_dt_scan_usablemem(unsigned long node, const char *uname, int depth, void *data) { @@ -392,10 +418,17 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit = max_zone_phys(ARM64_ZONE_DMA_BITS); } - if (IS_ENABLED(CONFIG_ZONE_DMA32)) - arm64_dma32_phys_limit = max_zone_phys(32); - else + if (IS_ENABLED(CONFIG_ZONE_DMA32)) { + if (dma32_zone_size) { + arm64_dma32_phys_limit = min(max_zone_phys(32), + dma32_zone_size + memblock_start_of_DRAM()); + } else { + arm64_dma32_phys_limit = max_zone_phys(32); + dma32_zone_size = arm64_dma32_phys_limit; + } + } else { arm64_dma32_phys_limit = PHYS_MASK + 1; + } reserve_crashkernel(); -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel