From patchwork Wed Dec 30 10:23:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 11993095 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 3F09AC433E0 for ; Wed, 30 Dec 2020 10:18:56 +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 E5B94221FA for ; Wed, 30 Dec 2020 10:18:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5B94221FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.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:References:In-Reply-To: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:List-Owner; bh=d1VXPCTm/l9cOJVz4JXdVQoGVWGpBR0Dp0Guwwub+M0=; b=iueOJtxyr8Kf5zK3uCNcGb8Ft eZjnEEuqrGgRzEj4qZmTcpOF98BsOG7bUK2GWB70gILjT82OrjS9zVP3uRFt20TAfkuKXdaJfY80O CzviA7lZrnY+2BealavIJRmcM2qM5GJFHTw1m54a4Nc6V7p1mPE56ng3jM9cv9dzXixRkWY7gKJTf rFcUm6Uee8VlitMiIjXhwkWqKgdyhQodUlBEXmvOtUFDsNJ6NoGYP9CI0OOAd2rXpX4mU8+2Z7t10 P3StQe5Pttv9EWH9txHZBOnLCmV4QqEsgsxL7Z3Al3kHcgu7REiaLN34ML3pDWfGu1BrndSjZynCF Q/Q2Sn8rQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXw-0006HM-CP; Wed, 30 Dec 2020 10:17:36 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXk-0006Ew-O5 for linux-arm-kernel@lists.infradead.org; Wed, 30 Dec 2020 10:17:27 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D5Ryb5s2Xz15kbL; Wed, 30 Dec 2020 18:16:23 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 30 Dec 2020 18:17:03 +0800 From: Chen Zhou To: , Subject: [PATCH v2 1/3] arm64: mm: update the comments about ZONE_DMA Date: Wed, 30 Dec 2020 18:23:20 +0800 Message-ID: <20201230102322.176313-2-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230102322.176313-1-chenzhou10@huawei.com> References: <20201230102322.176313-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201230_051725_572104_39063333 X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. 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: chenzhou10@huawei.com, linux-kernel@vger.kernel.org, nsaenzjulienne@suse.de, rppt@kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, akpm@linux-foundation.org, ardb@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Since patchset "arm64: Default to 32-bit wide ZONE_DMA", ZONE_DMA's size is fine-tuned. In the absence of addressing limited masters, ZONE_DMA will span the whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4, it'll only span the 30-bit address space. Update the comments. Signed-off-by: Chen Zhou Reviewed-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 75addb36354a..7b9809e39927 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -53,10 +53,11 @@ s64 memstart_addr __ro_after_init = -1; EXPORT_SYMBOL(memstart_addr); /* - * 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 - * this limited view of the memory. ZONE_DMA32 will cover the rest of the 32 - * bit addressable memory area. + * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA's size is fine-tuned. + * In the absence of addressing limited masters, ZONE_DMA will span the + * whole 32-bit address space, otherwise, in the case of the Raspberry Pi 4, + * it'll only span the 30-bit address space. ZONE_DMA32 will cover the rest + * of the 32 bit addressable memory area. */ phys_addr_t arm64_dma_phys_limit __ro_after_init; static phys_addr_t arm64_dma32_phys_limit __ro_after_init; From patchwork Wed Dec 30 10:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 11993101 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 48050C43381 for ; Wed, 30 Dec 2020 10:18:57 +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 063C6221FA for ; Wed, 30 Dec 2020 10:18:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 063C6221FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.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:References:In-Reply-To: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:List-Owner; bh=6wB3jh7RzrkTcHCwmC0OJ/CbYPqWp+yajsURzlL8y/c=; b=MwEiaUulYX5vgiPKsaA/zQzDn kxa/yZ2IoLSDVwqM3BMusXLvSUualxWe9CTvylnhg0NAVDYme2RUsRBrD/IcstTRiC2gIzG9b+Zb6 LOeWo3U5vjUVD9l2GmZ84rRprI5gJm5eqG62NP+FWAlQDp6xG+kWuD+ZoPo5puuNAcXeazk0Bz7i1 vW+vAITlmOoc8JlnUtoocsZuJFLp7GD3POcScAcghl8Lo/Uy6B/e9hfCmVx77PNN/mlqOvuhP9F8j /ym4MxHKkC2gg0uzLViJ+BQHt9u8o0HKZhwXvz1irFXZQMy3CGP+JVdWe68QNCzaXYmqO9iUW1cqb lbvTSRPgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXy-0006Hc-5b; Wed, 30 Dec 2020 10:17:38 +0000 Received: from szxga04-in.huawei.com ([45.249.212.190]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXm-0006Ex-7Y for linux-arm-kernel@lists.infradead.org; Wed, 30 Dec 2020 10:17:27 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D5Ryb5cjZz15jxr; Wed, 30 Dec 2020 18:16:23 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 30 Dec 2020 18:17:04 +0800 From: Chen Zhou To: , Subject: [PATCH v2 2/3] arm64: mm: move dma_contiguous_reserve() to bootmem_init() Date: Wed, 30 Dec 2020 18:23:21 +0800 Message-ID: <20201230102322.176313-3-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230102322.176313-1-chenzhou10@huawei.com> References: <20201230102322.176313-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201230_051726_550044_BB948F57 X-CRM114-Status: GOOD ( 10.10 ) 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: chenzhou10@huawei.com, linux-kernel@vger.kernel.org, nsaenzjulienne@suse.de, rppt@kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, akpm@linux-foundation.org, ardb@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Like crashkernel, CMA might also reserve memory located in ZONE_DMA, so move dma_contiguous_reserve() to bootmem_init() to make sure that arm64_dma_phys_limit is populated. Just place dma_contiguous_reserve() after reserve_crashkernel() as before. Signed-off-by: Chen Zhou Suggested-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 7b9809e39927..64a0e8f551d6 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -403,8 +403,6 @@ void __init arm64_memblock_init(void) reserve_elfcorehdr(); high_memory = __va(memblock_end_of_DRAM() - 1) + 1; - - dma_contiguous_reserve(arm64_dma32_phys_limit); } void __init bootmem_init(void) @@ -445,6 +443,8 @@ void __init bootmem_init(void) */ reserve_crashkernel(); + dma_contiguous_reserve(arm64_dma32_phys_limit); + memblock_dump_all(); } From patchwork Wed Dec 30 10:23:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 11993097 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 84F82C433E6 for ; Wed, 30 Dec 2020 10:18:56 +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 2DB0422209 for ; Wed, 30 Dec 2020 10:18:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DB0422209 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.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:References:In-Reply-To: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:List-Owner; bh=yzc8fM7nRno78LQv/YqJwUTgIt/kXPd3sNyndEVzgjo=; b=xqcmqKdrWHjgoqCb2ScwnUDO3 3bIHPdQSB4epvXKfGWcm1h7rXn/6m1+lDErJdJEddhD/RPGHjElLAfLpDJZD/au3WA63NfL8GXBg/ P6jePUteDfz0+nLp/DebN5a1TrcNLlSIGSa7ZAPrh011nqBgLQ5Fdkd7MUSz/obmpzRn6s0HEDtwK P7AdcBnHOUIV2BUT+nTKAQIlWphQ0KLxaTjUgac96PvlfTcoWb4lGHPsLxb0j+PCWmkTAOrYyfqGi hemluYruzkTTH9oEm9IZc/8YrYRLQ0Fbko158Zuv2TRZqQNSaerWYL4Evh7hbKkAPG2XVEszLLqqv RZ/CgV8/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXo-0006Gj-5P; Wed, 30 Dec 2020 10:17:28 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kuYXk-0006Ez-NK for linux-arm-kernel@lists.infradead.org; Wed, 30 Dec 2020 10:17:26 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4D5Ryc0ffHzj1Hp; Wed, 30 Dec 2020 18:16:24 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 30 Dec 2020 18:17:05 +0800 From: Chen Zhou To: , Subject: [PATCH v2 3/3] arm64: mm: reserve CMA and crashkernel in ZONE_DMA if enabled Date: Wed, 30 Dec 2020 18:23:22 +0800 Message-ID: <20201230102322.176313-4-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201230102322.176313-1-chenzhou10@huawei.com> References: <20201230102322.176313-1-chenzhou10@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201230_051725_071096_27A5FBAC X-CRM114-Status: GOOD ( 10.72 ) 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: chenzhou10@huawei.com, linux-kernel@vger.kernel.org, nsaenzjulienne@suse.de, rppt@kernel.org, huawei.libin@huawei.com, guohanjun@huawei.com, akpm@linux-foundation.org, ardb@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, CMA and crashkernel are reserved in ZONE_DMA32, which is OK for majority of devices. But the ones that need them in ZONE_DMA need to configure it explicitly. Since patchset "arm64: Default to 32-bit wide ZONE_DMA", ZONE_DMA's size is fine-tuned. So we could directly reserve CMA and crashkernel in ZONE_DMA if CONFIG_ZONE_DMA is enabled, otherwise, reserving in ZONE_DMA32. Signed-off-by: Chen Zhou Suggested-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 64a0e8f551d6..26de149b21c7 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -85,7 +85,8 @@ static void __init reserve_crashkernel(void) if (crash_base == 0) { /* Current arm64 boot protocol requires 2MB alignment */ - crash_base = memblock_find_in_range(0, arm64_dma32_phys_limit, + crash_base = memblock_find_in_range(0, + arm64_dma_phys_limit ? : arm64_dma32_phys_limit, crash_size, SZ_2M); if (crash_base == 0) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n", @@ -443,7 +444,7 @@ void __init bootmem_init(void) */ reserve_crashkernel(); - dma_contiguous_reserve(arm64_dma32_phys_limit); + dma_contiguous_reserve(arm64_dma_phys_limit ? : arm64_dma32_phys_limit); memblock_dump_all(); }