From patchwork Wed Mar 3 07:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114129 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,URIBL_BLOCKED, 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 0E40BC433E6 for ; Wed, 3 Mar 2021 19:17:41 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 0BAD164ED7 for ; Wed, 3 Mar 2021 19:17:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BAD164ED7 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3iMwOJlcqtxOI5BcRAdAAqBeXS8gPgiY5qkdp4ndlKw=; b=VX/29gUdJQs1BshH4qawq+clD uzxRMtjnwmHhRXU4f/u7tLNFz4jqgr/3NQ00zZoZ0xdTkFKx2uznUdXDJk9Drgtn8ZDQ0+XivNvkK 6PqK+AIfLBvBelaY+eRjFIgKpCQSePFAlaUAnPRLgP5rFwNWHH+4D02Q8XngLj9bnd1m4cfvB4cz/ DKEPpoxjGJfay/wndKN5R5hBa2dTBXRqOb0A5EnRdkFcuUZZzPaSIuOujaKE0i0APwCYTiF/nGLU+ EyOoNiJArrjlsEKMAaLOUQVOtr4B/1TMR2XO2jTowYR1+JWp1lXly9RzYZi/a67ZXgkQyH2eqeQBS jlPPHfniA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHWxN-006AMO-16; Wed, 03 Mar 2021 19:14:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT2l-005HpZ-A0; Wed, 03 Mar 2021 15:04:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=vZq08XFluVeBbsiP+7mRCueb5nV+n/mkDNmKMEKYBVY=; b=LxBXQlVnkh5KweT1ZcH6wFL1Yp H3543JYBHnP7fvQq2mClcshBHkiaM1utZgsg1zNjPvN0It4YjMCsazafFnCfb67nUBfoTdpJXn1M4 8jlf25jT1UNZayD9v0wyj03JUJjFT9nfy1jV7yV2+vnHrIt9bD3E9OA+AY4q0cio/eJadEDsHdwR/ 2HFedFVMJPfSlwYckkOn+kNZmOEKlv/wmJxEHf4rcMycfg5NRfo4zcEehaRKESIUwNdBmI9tFM6X2 VDMa808GUWTjjMiX0reFOHiGArAWdcZOReobi+bO29lAPDmWtsr9T6w/ujkSXUfZCF7ZR32ssziPt UHCAH8lA==; Received: from szxga07-in.huawei.com ([45.249.212.35]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoJ-001eYl-VV; Wed, 03 Mar 2021 07:20:44 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Dr52Y2dg7z7rYg; Wed, 3 Mar 2021 15:18:45 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:20 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Jeremy Linton Subject: [PATCH stable v5.10 1/7] arm64: mm: Move reserve_crashkernel() into mem_init() Date: Wed, 3 Mar 2021 15:33:13 +0800 Message-ID: <20210303073319.2215839-2-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072044_572226_F12FDB99 X-CRM114-Status: UNSURE ( 7.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 0a30c53573b07d5561457e41fb0ab046cd857da5 upstream crashkernel might reserve memory located in ZONE_DMA. We plan to delay ZONE_DMA's initialization after unflattening the devicetree and ACPI's boot table initialization, so move it later in the boot process. Specifically into bootmem_init() since request_standard_resources() depends on it. Signed-off-by: Nicolas Saenz Julienne Tested-by: Jeremy Linton Link: https://lore.kernel.org/r/20201119175400.9995-2-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- arch/arm64/mm/init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 00576a960f11..686653e33250 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -386,8 +386,6 @@ void __init arm64_memblock_init(void) else arm64_dma32_phys_limit = PHYS_MASK + 1; - reserve_crashkernel(); - reserve_elfcorehdr(); high_memory = __va(memblock_end_of_DRAM() - 1) + 1; @@ -427,6 +425,12 @@ void __init bootmem_init(void) sparse_init(); zone_sizes_init(min, max); + /* + * request_standard_resources() depends on crashkernel's memory being + * reserved, so do it here. + */ + reserve_crashkernel(); + memblock_dump_all(); } From patchwork Wed Mar 3 07:33:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114283 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,URIBL_BLOCKED, 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 4A388C433E0 for ; Wed, 3 Mar 2021 21:27:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 35A0564EDF for ; Wed, 3 Mar 2021 21:27:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35A0564EDF 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4QnjQRQ6+96peNz5w5lx+90mAeNsX+QrEQbAuKL9CuI=; b=XU1aKnoe6UWcewcbWiT0veMt1 Gz7aduxIqkBqxf2+Cqwgpf8nujuLNOxgEXL1M7vn1P7wqgK6pVmPArsC2OO3AmTd7ap0JHHD1edHR lPSL+CmAupXMce9eWc55NKs2YfySJ3mES9Q/DMAVv2o8NNSQX79ghm2/8hpIpMuxHSBKQdjVd+VRw UoEcsBsA+LGO8m5SzoEtw/Ek/EOalImhS0Xu9t5ZfU2rgwcRNGa2dY0krHifNQsk87BHcZxgV08Rh RgOSNkX7IDVitPn5Midt4Dqhllz55F9nk3xvBcxMtcWeRIQUvTOsPZVqCvYG+MfP2VuGmjbaEr+sy oCHx49uTA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHYvl-006Zw4-Mk; Wed, 03 Mar 2021 21:21:18 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT84-005JgH-P3; Wed, 03 Mar 2021 15:09:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=Jp/OXSfDHcE3DEhgApYyDeWhrKmGNnSy9//d/qwR/ok=; b=WYybx7Qh9dfOCAIBqJ7hqZSU2I SdOw+zf1A5u4G4xTxwXLnx72Rr3K1I6umV0y11BOojvlELmkXY9FuMhK0R8yTPP/DdNj7uvg7rgjI mEJ/0UrDzqDiU6XseFOkEYLif/nWW8H01mci46aTw/TFOIMCRRgXKn37sQgVM29AXKcmxb+g0Cw+t 0PsTK+DTVOqg1aprQ2NlKFGjP1GOVHRZePEi5wCebKjQ02psM+LVR/2Re4xxLvABELm5Onqr20L/Z +3wv0WXj2zDWAKGStcsO0ozzoFjfbdcUId0aQXeaEYc3hKwvZz5SHT+05kThQFguhQ+/8hnGiVaY1 4PmOomfg==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoL-001eYm-G4; Wed, 03 Mar 2021 07:20:46 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dr52725XbzMhGj; Wed, 3 Mar 2021 15:18:23 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:21 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Jeremy Linton Subject: [PATCH stable v5.10 2/7] arm64: mm: Move zone_dma_bits initialization into zone_sizes_init() Date: Wed, 3 Mar 2021 15:33:14 +0800 Message-ID: <20210303073319.2215839-3-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072046_339402_41BB70BC X-CRM114-Status: UNSURE ( 7.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 9804f8c69b04a39d0ba41d19e6bdc6aa91c19725 upstream zone_dma_bits's initialization happens earlier that it's actually needed, in arm64_memblock_init(). So move it into the more suitable zone_sizes_init(). Signed-off-by: Nicolas Saenz Julienne Tested-by: Jeremy Linton Link: https://lore.kernel.org/r/20201119175400.9995-3-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- arch/arm64/mm/init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 686653e33250..7da912bf4222 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -190,6 +190,8 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; #ifdef CONFIG_ZONE_DMA + zone_dma_bits = ARM64_ZONE_DMA_BITS; + arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); #endif #ifdef CONFIG_ZONE_DMA32 @@ -376,11 +378,6 @@ void __init arm64_memblock_init(void) early_init_fdt_scan_reserved_mem(); - if (IS_ENABLED(CONFIG_ZONE_DMA)) { - zone_dma_bits = ARM64_ZONE_DMA_BITS; - 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 From patchwork Wed Mar 3 07:33:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114189 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,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 A84AEC433E0 for ; Wed, 3 Mar 2021 20:27:38 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 BA48A64EF3 for ; Wed, 3 Mar 2021 20:27:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA48A64EF3 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qC2caDuyXXICOHnitfEzC6pyDRO6qHtCOgXqiDo3wq8=; b=EsTIuVDs3h+OJBLp6tTiN9Cke bCqRjh/anP+jB1Uny9FCxvEKM1TMIaxheJcgVQ9ouTtAEbaoYJaMwc/7HrmJ6i+qplEj8JUpYFfRV Jcrbcc/kUT7vFAXiAzBi4ezhCvvpPeBQ1GIODGWXyoIwXwqGN9y0v1OOY5CVAeb9ySYXeKM++JkQd tc9iX6Au85nw0dulG3I/0yUUfRogJAkpIbyjKaIQ5EAuNOX7bfv+Obf9YlOzcpz/5zGudNYBaR0mB W2OZBOlGn2wQGt7jCgdrXIDH0OLvNdRIUOXYu8Amgguy9G8/6F1srZK+N90MQeUZkecHBc9IEU/J7 uxxnjjGgg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHY0f-006OuX-2y; Wed, 03 Mar 2021 20:22:17 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT5U-005IkO-6X; Wed, 03 Mar 2021 15:06:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=pNK4phnjccVmfpoWfcAn4AA/bLEa3a3eoyZlvB7DlsY=; b=lcZcKx6w6Sc0KN3K+v4sbAwK3N Ab7Xwjdn83Djx57X1tLlQvp/1Od89jAH7pyfjACPGOzd8rkWWtS65raHYQs1/hO12ClV+qcFcxTqM BgWBJuCUNuE1S197egLkKgS2hTCRAu6u6aEokpNy8YslYrG76fnbfqema0EvfLa5WZkvJPxj3ZdKo 1ShoLS9aR/Q3cctWuPj8X9DQmd7Sk9tlyZR6Cmq9wVSc5Lhn1Rk9WqiZH5XmoeHcPtzBPky7oCsFv vuzQVWhl2Bj2wXSBq1Vrf02qjNmgeG+LQ7SRBSM3FJN603q3/QTyJrhJygQmZZunH3aN3H2l+NDgC blbQK4fA==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoL-001eYk-GC; Wed, 03 Mar 2021 07:20:46 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dr5271QYvzMh3S; Wed, 3 Mar 2021 15:18:23 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:22 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Rob Herring Subject: [PATCH stable v5.10 3/7] of/address: Introduce of_dma_get_max_cpu_address() Date: Wed, 3 Mar 2021 15:33:15 +0800 Message-ID: <20210303073319.2215839-4-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072046_650858_B2D6A0D0 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 964db79d6c186cc2ecc6ae46f98eed7e0ea8cf71 upstream Introduce of_dma_get_max_cpu_address(), which provides the highest CPU physical address addressable by all DMA masters in the system. It's specially useful for setting memory zones sizes at early boot time. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201119175400.9995-4-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- drivers/of/address.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 7 +++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/of/address.c b/drivers/of/address.c index 1c3257a2d4e3..73ddf2540f3f 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -1024,6 +1024,48 @@ int of_dma_get_range(struct device_node *np, const struct bus_dma_region **map) } #endif /* CONFIG_HAS_DMA */ +/** + * of_dma_get_max_cpu_address - Gets highest CPU address suitable for DMA + * @np: The node to start searching from or NULL to start from the root + * + * Gets the highest CPU physical address that is addressable by all DMA masters + * in the sub-tree pointed by np, or the whole tree if NULL is passed. If no + * DMA constrained device is found, it returns PHYS_ADDR_MAX. + */ +phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np) +{ + phys_addr_t max_cpu_addr = PHYS_ADDR_MAX; + struct of_range_parser parser; + phys_addr_t subtree_max_addr; + struct device_node *child; + struct of_range range; + const __be32 *ranges; + u64 cpu_end = 0; + int len; + + if (!np) + np = of_root; + + ranges = of_get_property(np, "dma-ranges", &len); + if (ranges && len) { + of_dma_range_parser_init(&parser, np); + for_each_of_range(&parser, &range) + if (range.cpu_addr + range.size > cpu_end) + cpu_end = range.cpu_addr + range.size - 1; + + if (max_cpu_addr > cpu_end) + max_cpu_addr = cpu_end; + } + + for_each_available_child_of_node(np, child) { + subtree_max_addr = of_dma_get_max_cpu_address(child); + if (max_cpu_addr > subtree_max_addr) + max_cpu_addr = subtree_max_addr; + } + + return max_cpu_addr; +} + /** * of_dma_is_coherent - Check if device is coherent * @np: device node diff --git a/include/linux/of.h b/include/linux/of.h index af655d264f10..0f4e81e6fb23 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -558,6 +558,8 @@ int of_map_id(struct device_node *np, u32 id, const char *map_name, const char *map_mask_name, struct device_node **target, u32 *id_out); +phys_addr_t of_dma_get_max_cpu_address(struct device_node *np); + #else /* CONFIG_OF */ static inline void of_core_init(void) @@ -995,6 +997,11 @@ static inline int of_map_id(struct device_node *np, u32 id, return -EINVAL; } +static inline phys_addr_t of_dma_get_max_cpu_address(struct device_node *np) +{ + return PHYS_ADDR_MAX; +} + #define of_match_ptr(_ptr) NULL #define of_match_node(_matches, _node) NULL #endif /* CONFIG_OF */ From patchwork Wed Mar 3 07:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114449 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,URIBL_BLOCKED, 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 41315C433E0 for ; Wed, 3 Mar 2021 22:35:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 E05A364EEE for ; Wed, 3 Mar 2021 22:35:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E05A364EEE 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kMuP8vTAt8ENTgX03FynLbmKQhj3kgMeMe1EmSXqvrk=; b=oMHSFETL5rI+Ji09Qtxhsqom0 g4LrHrhQZNS9e5Kstmh9PNRvygZk2r/Q0UuBDcQr8qKgDagKdTQ18r66iuXplhm8z0SU0LnOhcNWn B264FqyeWRNZfBq1ynjuKJCNaaepLz6Rj5UczXnAwc3q2alIvKXd98VM/A5JCk/DgfRHUNQEObjBA 4hkQ0w7VSCFA8QQbzUEnkvOdqzMUF2b4AlIjHD1KMCu9Y27JI9vvMQwf2RHEO/5ef1gCLIzSFBAPy NxygT/VcvoGmnkmmXvmsWTxyxH8gxaCyasIBvC11GntHWKrS1aWopz448bGY9G4hfbe2cN7sWiYMB qzIzxwanQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHZwx-006kjv-FD; Wed, 03 Mar 2021 22:26:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHTAz-005Kn4-KG; Wed, 03 Mar 2021 15:12:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=OyBUGy1JvVG2FfVS+8WUNejhry9Y6dTtVf8qk90wxcQ=; b=jSHxgB6x2xoI36sKYC4i7ZqO0o uIMBylD5j4o9gJeu+cyk99dBN5k1HZ5wnBTY3n3hZ8kJEaTUVcNOIGP8BZksX6z+n4WqJX/rvjYMa xGeo++RbHpeDnLd5nMp2p+7yDqcZyV/jxLKhq8k2qRt5KoRUOMEwejMEY7O6j5gU+fYPqHnEGLzJ3 oCG+kgN/CHmRuzR7veNKjrfHtxsZjSrdrI7ffmFoAiX0tcnzIyPGfyaQt+m9RvsiZfvYShHsQjRyQ Idf5aHMANzN1WxD7ujqMgRWkKGOpDZRP4v7IyU7HjKy1ScccRu4iWvp6/KloS7u+PlcSfZIEoLUdF 5ZGoWl6Q==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoI-001eYj-OX; Wed, 03 Mar 2021 07:20:43 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dr5270f0CzMgPf; Wed, 3 Mar 2021 15:18:23 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:23 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Rob Herring Subject: [PATCH stable v5.10 4/7] of: unittest: Add test for of_dma_get_max_cpu_address() Date: Wed, 3 Mar 2021 15:33:16 +0800 Message-ID: <20210303073319.2215839-5-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072043_680932_F98F0B56 X-CRM114-Status: UNSURE ( 8.50 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 07d13a1d6120d453c3c1f020578693d072deded5 upstream Introduce a test for of_dma_get_max_cup_address(), it uses the same DT data as the rest of dma-ranges unit tests. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201119175400.9995-5-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- drivers/of/unittest.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 06cc988faf78..98cc0163301b 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -869,6 +869,23 @@ static void __init of_unittest_changeset(void) #endif } +static void __init of_unittest_dma_get_max_cpu_address(void) +{ + struct device_node *np; + phys_addr_t cpu_addr; + + np = of_find_node_by_path("/testcase-data/address-tests"); + if (!np) { + pr_err("missing testcase data\n"); + return; + } + + cpu_addr = of_dma_get_max_cpu_address(np); + unittest(cpu_addr == 0x4fffffff, + "of_dma_get_max_cpu_address: wrong CPU addr %pad (expecting %x)\n", + &cpu_addr, 0x4fffffff); +} + static void __init of_unittest_dma_ranges_one(const char *path, u64 expect_dma_addr, u64 expect_paddr) { @@ -3266,6 +3283,7 @@ static int __init of_unittest(void) of_unittest_changeset(); of_unittest_parse_interrupts(); of_unittest_parse_interrupts_extended(); + of_unittest_dma_get_max_cpu_address(); of_unittest_parse_dma_ranges(); of_unittest_pci_dma_ranges(); of_unittest_match_node(); From patchwork Wed Mar 3 07:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114453 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,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 DC325C433DB for ; Wed, 3 Mar 2021 22:41:44 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 93C0864ED4 for ; Wed, 3 Mar 2021 22:41:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93C0864ED4 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Evoa1GsbgA/ix/Wvjgk45dWHf4rwBggdeEoRxMY+sRI=; b=Q6MuLrbg5yNiEv0m16w5Hz/xw qzOJydKM5rHEymo8SY3Mg51SytmPK1HcxqKa7Wq2Pp/hP2/3q3ledVWr2a3i3B00EK8LFxcGKf/NK XUBJ3Xco1qh5ArIL0Jv5dtvyp3/lBAAdwU//3PCrH6jGSbSBfqza3s7GEJdtYvV7KRm32kB70cbcf WxkneP1CsY6kAmuhZTi8vkc19MmYwRpUkx/TwMGRd2LupeN8gHXCpL/KpRdlDL7SNUSxNsi/2esXp tZAInqIUfSGh6GSK5Lg0mTZnlSWjq8lNHYQ7TuNEzHGMHr0uT0hZjljsWCxWKIHoTdHk337TalDpk 6pXdq4i7Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHa2T-006lQd-2I; Wed, 03 Mar 2021 22:32:17 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHTB3-005Koe-IP; Wed, 03 Mar 2021 15:12:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=4Zy9OY6fx2/oU4L2eni2q/jcefF37OJjrso/hpuWwQw=; b=f0SBDMnOPuGwU3d630hPDoyVC1 QITEag+dIIq/J/h4YDdxh/4XN4sNEljbiydkYmJ8HCgydVSe4DFR2Nnmnrjw3DaKQZ5XcDjz2P/a9 Pzx6DWoRE8EzBO+JQZMwOhavCnZzPAQT1cRR2PPF7XshhlkzF77uoWZk9bEaa+hkaMb5JOH1PLTns Am9Oq55RRaZ8JQIILFDGd1OSzWb/78tR9d/5bRQ5f0KHwGW6xyStdklKjxXyF5vJVmCgG1aGIbE4O aA8A9mz2YQvcEaXJ+tm0KGSsJETqpLsTu0omXKNZMv1P1cKAzFtzG8zdbAzhj96/YwdxNLgY7WS/7 U8QhSgfw==; Received: from szxga05-in.huawei.com ([45.249.212.191]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoI-001eYn-OS; Wed, 03 Mar 2021 07:20:43 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dr5272kJlzMhPF; Wed, 3 Mar 2021 15:18:23 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:24 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , Subject: [PATCH stable v5.10 5/7] arm64: mm: Set ZONE_DMA size based on devicetree's dma-ranges Date: Wed, 3 Mar 2021 15:33:17 +0800 Message-ID: <20210303073319.2215839-6-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072043_684109_34BA4FA4 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 8424ecdde7df99d5426e1a1fd9f0fb36f4183032 upstream We recently introduced a 1 GB sized ZONE_DMA to cater for platforms incorporating masters that can address less than 32 bits of DMA, in particular the Raspberry Pi 4, which has 4 or 8 GB of DRAM, but has peripherals that can only address up to 1 GB (and its PCIe host bridge can only access the bottom 3 GB) The DMA layer also needs to be able to allocate memory that is guaranteed to meet those DMA constraints, for bounce buffering as well as allocating the backing for consistent mappings. This is why the 1 GB ZONE_DMA was introduced recently. Unfortunately, it turns out the having a 1 GB ZONE_DMA as well as a ZONE_DMA32 causes problems with kdump, and potentially in other places where allocations cannot cross zone boundaries. Therefore, we should avoid having two separate DMA zones when possible. So, with the help of of_dma_get_max_cpu_address() get the topmost physical address accessible to all DMA masters in system and use that information to fine-tune ZONE_DMA's size. 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, and have ZONE_DMA32 cover the rest of the 32-bit address space. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20201119175400.9995-6-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- arch/arm64/mm/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 7da912bf4222..05a1c2773629 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -42,8 +42,6 @@ #include #include -#define ARM64_ZONE_DMA_BITS 30 - /* * We need to be able to catch inadvertent references to memstart_addr * that occur (potentially in generic code) before arm64_memblock_init() @@ -188,9 +186,11 @@ static phys_addr_t __init max_zone_phys(unsigned int zone_bits) static void __init zone_sizes_init(unsigned long min, unsigned long max) { unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; + unsigned int __maybe_unused dt_zone_dma_bits; #ifdef CONFIG_ZONE_DMA - zone_dma_bits = ARM64_ZONE_DMA_BITS; + dt_zone_dma_bits = fls64(of_dma_get_max_cpu_address(NULL)); + zone_dma_bits = min(32U, dt_zone_dma_bits); arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); #endif From patchwork Wed Mar 3 07:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114249 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,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 D3937C433E0 for ; Wed, 3 Mar 2021 21:16:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 71F32600EF for ; Wed, 3 Mar 2021 21:16:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71F32600EF 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wep9KEiaTqUP4oNxj6iu/++XhRTzqapU4ENX2Zl/BPM=; b=bu1okXkzmu3+TqtPmEWJA5Fmz RW828QYIF7X7LBEsnxjskFblD6JtswBjyfbIqVOrw4kEaXiAgImduH9kcRPOpI3tVkBRtDjPFYv3Z GyqSMT2dw0zN47cVBuwjzL803Jt9HePbdhqej0OtgSAhImObG1aT2Q5g5Dawi8QAPJCPaDxyaM5+P WkzOnnGgdXnAXtUrbES2XTbTK/NsW0FiYYk/5Evqg2qelWDdeDQ8FRLuRpROGzEg3MVZjKahgfek6 SV1F3Lu5059c93oepk+6lmNPaW4fmwDuvzqfJH2GuFLcYpO16b6KeWxMjPWNbRUK/x2v7dHX2RAaE +prTvzYKw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHYmI-006YNq-Es; Wed, 03 Mar 2021 21:11:30 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT7u-005Jb6-56; Wed, 03 Mar 2021 15:09:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=VMpnL25cUEI8izcW0KPJXRc8cMVJmCNujLvzFfDPdiI=; b=JTuNShPJfmZwTxANPt5yXiizLI aWLOp6CiZqxohddbNPIQCjyEUOWG+55RrB6ABGDyPHwRdWRyVDbsstb+pMCiSHj51Ulg6gZFbf4Gk TUzrFj81ZrFaKW1rLbocskrrRW/0jwyLNeiBNVf7sYLOsUwMpIKl75NtbVz4AnXz4CFBIHGldgKpr FgK7vZTRH5iLMK0H/k1QEgNUHK5C1YfIENYMhr51lTioTHIj6PXKQKlF8hlTmodct+oXd2u8/kPz8 GEKSICqXZnDijENaRxuMstrxZRcIAN3NhKZQqTjKJcAHNvBu7tLi9wDHuoGt9sJcgSNa3o3z5533g +Zu5znHQ==; Received: from szxga06-in.huawei.com ([45.249.212.32]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoL-001eZE-Vq; Wed, 03 Mar 2021 07:20:47 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Dr5360CqdzjT8c; Wed, 3 Mar 2021 15:19:14 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:26 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Jeremy Linton , Christoph Hellwig , Robin Murphy Subject: [PATCH stable v5.10 6/7] arm64: mm: Set ZONE_DMA size based on early IORT scan Date: Wed, 3 Mar 2021 15:33:18 +0800 Message-ID: <20210303073319.2215839-7-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072047_477788_BBEB0D5B X-CRM114-Status: GOOD ( 20.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ard Biesheuvel commit 2b8652936f0ca9ca2e6c984ae76c7bfcda1b3f22 upstream We recently introduced a 1 GB sized ZONE_DMA to cater for platforms incorporating masters that can address less than 32 bits of DMA, in particular the Raspberry Pi 4, which has 4 or 8 GB of DRAM, but has peripherals that can only address up to 1 GB (and its PCIe host bridge can only access the bottom 3 GB) Instructing the DMA layer about these limitations is straight-forward, even though we had to fix some issues regarding memory limits set in the IORT for named components, and regarding the handling of ACPI _DMA methods. However, the DMA layer also needs to be able to allocate memory that is guaranteed to meet those DMA constraints, for bounce buffering as well as allocating the backing for consistent mappings. This is why the 1 GB ZONE_DMA was introduced recently. Unfortunately, it turns out the having a 1 GB ZONE_DMA as well as a ZONE_DMA32 causes problems with kdump, and potentially in other places where allocations cannot cross zone boundaries. Therefore, we should avoid having two separate DMA zones when possible. So let's do an early scan of the IORT, and only create the ZONE_DMA if we encounter any devices that need it. This puts the burden on the firmware to describe such limitations in the IORT, which may be redundant (and less precise) if _DMA methods are also being provided. However, it should be noted that this situation is highly unusual for arm64 ACPI machines. Also, the DMA subsystem still gives precedence to the _DMA method if implemented, and so we will not lose the ability to perform streaming DMA outside the ZONE_DMA if the _DMA method permits it. [nsaenz: unified implementation with DT's counterpart] Signed-off-by: Ard Biesheuvel Signed-off-by: Nicolas Saenz Julienne Tested-by: Jeremy Linton Acked-by: Lorenzo Pieralisi Acked-by: Hanjun Guo Cc: Jeremy Linton Cc: Lorenzo Pieralisi Cc: Nicolas Saenz Julienne Cc: Rob Herring Cc: Christoph Hellwig Cc: Robin Murphy Cc: Hanjun Guo Cc: Sudeep Holla Cc: Anshuman Khandual Link: https://lore.kernel.org/r/20201119175400.9995-7-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- arch/arm64/mm/init.c | 5 +++- drivers/acpi/arm64/iort.c | 55 +++++++++++++++++++++++++++++++++++++++ include/linux/acpi_iort.h | 4 +++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 05a1c2773629..b913844ab740 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -186,11 +187,13 @@ static phys_addr_t __init max_zone_phys(unsigned int zone_bits) static void __init zone_sizes_init(unsigned long min, unsigned long max) { unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; + unsigned int __maybe_unused acpi_zone_dma_bits; unsigned int __maybe_unused dt_zone_dma_bits; #ifdef CONFIG_ZONE_DMA + acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address()); dt_zone_dma_bits = fls64(of_dma_get_max_cpu_address(NULL)); - zone_dma_bits = min(32U, dt_zone_dma_bits); + zone_dma_bits = min3(32U, dt_zone_dma_bits, acpi_zone_dma_bits); arm64_dma_phys_limit = max_zone_phys(zone_dma_bits); max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit); #endif diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 94f34109695c..2494138a6905 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -1730,3 +1730,58 @@ void __init acpi_iort_init(void) iort_init_platform_devices(); } + +#ifdef CONFIG_ZONE_DMA +/* + * Extract the highest CPU physical address accessible to all DMA masters in + * the system. PHYS_ADDR_MAX is returned when no constrained device is found. + */ +phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void) +{ + phys_addr_t limit = PHYS_ADDR_MAX; + struct acpi_iort_node *node, *end; + struct acpi_table_iort *iort; + acpi_status status; + int i; + + if (acpi_disabled) + return limit; + + status = acpi_get_table(ACPI_SIG_IORT, 0, + (struct acpi_table_header **)&iort); + if (ACPI_FAILURE(status)) + return limit; + + node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset); + end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length); + + for (i = 0; i < iort->node_count; i++) { + if (node >= end) + break; + + switch (node->type) { + struct acpi_iort_named_component *ncomp; + struct acpi_iort_root_complex *rc; + phys_addr_t local_limit; + + case ACPI_IORT_NODE_NAMED_COMPONENT: + ncomp = (struct acpi_iort_named_component *)node->node_data; + local_limit = DMA_BIT_MASK(ncomp->memory_address_limit); + limit = min_not_zero(limit, local_limit); + break; + + case ACPI_IORT_NODE_PCI_ROOT_COMPLEX: + if (node->revision < 1) + break; + + rc = (struct acpi_iort_root_complex *)node->node_data; + local_limit = DMA_BIT_MASK(rc->memory_address_limit); + limit = min_not_zero(limit, local_limit); + break; + } + node = ACPI_ADD_PTR(struct acpi_iort_node, node, node->length); + } + acpi_put_table(&iort->header); + return limit; +} +#endif diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index 20a32120bb88..1a12baa58e40 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -38,6 +38,7 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *size); const struct iommu_ops *iort_iommu_configure_id(struct device *dev, const u32 *id_in); int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head); +phys_addr_t acpi_iort_dma_get_max_cpu_address(void); #else static inline void acpi_iort_init(void) { } static inline u32 iort_msi_map_id(struct device *dev, u32 id) @@ -55,6 +56,9 @@ static inline const struct iommu_ops *iort_iommu_configure_id( static inline int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) { return 0; } + +static inline phys_addr_t acpi_iort_dma_get_max_cpu_address(void) +{ return PHYS_ADDR_MAX; } #endif #endif /* __ACPI_IORT_H__ */ From patchwork Wed Mar 3 07:33:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Xiangfeng X-Patchwork-Id: 12114193 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,URIBL_BLOCKED, 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 7384AC433DB for ; Wed, 3 Mar 2021 20:32:42 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 DEFE264EFD for ; Wed, 3 Mar 2021 20:32:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEFE264EFD 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GoREIEa6FvYWDarEitvX1QGLc5TwHgf5zv6KUCZ5fM0=; b=Bg3ba0O3OR7N+YopwwXc5W8z/ vc4iN+F/B+Yh4do0+Exe+ddxNnb8wS0GkE8xueX6Fk0yX7TS0sm+w9WvphvKufaTcGlhYkbtTOrmG jXEPwx6OPzvYC+j0HYFQHH4NP00/LBTUQ/zXXIN91JE+v+of84pzLrF7Ui8d9LvlFSb8uCSXAgDxm XS1tH3lc4sAk6cypkJ7M2i/6O6G9LwkuTpLhgZmNifbI/LSv0zn+fG5DFyqQLinL7NwSdVqOnQFGu yTHjKd4NaGC9ZHcRBYsgzgDRWx50kQJXSPwV0mldrP0t1jLNcll75HOJo3oVQdQszbb9RUcl9jHTA Ip5am8tdg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHY60-006PmK-5F; Wed, 03 Mar 2021 20:27:49 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT5b-005IoA-C9; Wed, 03 Mar 2021 15:07:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=lwG8rNchQ7g+iAJHSOjXlAevdi8/PajULSmg4+o0Ork=; b=WkMCwkdTnTJ2+6XpF0sXYwWkkf B8Qe/mLm3E6jVbDqpAFFGPZ5Mov/7zdWQ5E5MSlLpoms5FMRkXlwzwZr5S5GyUYwtTMFiFI90E0fz +D2PcWutdP5oblQ6oS2fhZRc3emTSLV+5wK999Ay4c4SDWxoSH72F80QdvlbZ1K9SnJBlCkXr4GRP KGNulm1211mVN5xd57+BN5qFkN3hV8oU5LMh7bci9jgP3rgMQpTGxQsWIZniW20+6oT2c9km16dbM ok/iVNPdoR6+GYvHihECiT+dEIeP29+yiW4Ce/rMW5EGFyh7KCyCQgGOHXXR7H+mfb6re0JkC2MVg gBJhVc4Q==; Received: from szxga06-in.huawei.com ([45.249.212.32]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHLoL-001eZF-G4; Wed, 03 Mar 2021 07:20:46 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Dr5361dK8zjTJM; Wed, 3 Mar 2021 15:19:14 +0800 (CST) Received: from ubuntu-82.huawei.com (10.175.104.82) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Wed, 3 Mar 2021 15:20:27 +0800 From: Jing Xiangfeng To: , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , Christoph Hellwig Subject: [PATCH stable v5.10 7/7] mm: Remove examples from enum zone_type comment Date: Wed, 3 Mar 2021 15:33:19 +0800 Message-ID: <20210303073319.2215839-8-jingxiangfeng@huawei.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20210303073319.2215839-1-jingxiangfeng@huawei.com> References: <20210303073319.2215839-1-jingxiangfeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.82] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_072046_339681_FF420375 X-CRM114-Status: UNSURE ( 7.10 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Nicolas Saenz Julienne commit 04435217f96869ac3a8f055ff68c5237a60bcd7e upstream We can't really list every setup in common code. On top of that they are unlikely to stay true for long as things change in the arch trees independently of this comment. Suggested-by: Christoph Hellwig Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20201119175400.9995-8-nsaenzjulienne@suse.de Signed-off-by: Catalin Marinas Cc: Signed-off-by: Jing Xiangfeng --- include/linux/mmzone.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fb3bf696c05e..9d0c454d23cd 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -354,26 +354,6 @@ enum zone_type { * DMA mask is assumed when ZONE_DMA32 is defined. Some 64-bit * platforms may need both zones as they support peripherals with * different DMA addressing limitations. - * - * Some examples: - * - * - i386 and x86_64 have a fixed 16M ZONE_DMA and ZONE_DMA32 for the - * rest of the lower 4G. - * - * - arm only uses ZONE_DMA, the size, up to 4G, may vary depending on - * the specific device. - * - * - arm64 has a fixed 1G ZONE_DMA and ZONE_DMA32 for the rest of the - * lower 4G. - * - * - powerpc only uses ZONE_DMA, the size, up to 2G, may vary - * depending on the specific device. - * - * - s390 uses ZONE_DMA fixed to the lower 2G. - * - * - ia64 and riscv only use ZONE_DMA32. - * - * - parisc uses neither. */ #ifdef CONFIG_ZONE_DMA ZONE_DMA,