From patchwork Mon Dec 23 15:23:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenzhou X-Patchwork-Id: 11308465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7FF9109A for ; Mon, 23 Dec 2019 15:28:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 95D11206B7 for ; Mon, 23 Dec 2019 15:28:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o6mUGOFX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95D11206B7 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=K809pWKJCYiMrWy/wR6QDqed+2BAx/+3X3uWFabR2aQ=; b=o6mUGOFXcwQwT2 6PcytCFIaDML00ph0wY4benkOGm2dyAlwTgx2fCTpRjXWAAbiwzpfd0eJn+K/QBU6mLQpOxwhmjLN eW772aZLVUiWgJatM+dBEoF5NMFCLfq5xa/8P0zIdKxW+sZnPR+95lSnwX6oasuP+jRDSkI+cL4hH lYM+a9iguCGNWPXSiHq5U6Ys3TIlgvH07MUoR4g0+hyvs1twzCIiX6efMpaWh0PaeyWhj9StekNyB chR00wAWR2saY2DRPMXLcc2u1AAm7gwUGMeqB3aMdM5rs8JwezC2MOkne+cvqNFjmc5i10t85nGxn Fpe6Nbv4MhhNd/7+tRgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ijPdA-0007gY-0u; Mon, 23 Dec 2019 15:28:24 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ijPcL-0006yW-LF; Mon, 23 Dec 2019 15:27:36 +0000 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E232833A261A59EE3E5A; Mon, 23 Dec 2019 23:27:24 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 23 Dec 2019 23:27:18 +0800 From: Chen Zhou To: , , , , , , Subject: [PATCH v7 3/4] arm64: kdump: add memory for devices by DT property, low-memory-range Date: Mon, 23 Dec 2019 23:23:48 +0800 Message-ID: <20191223152349.180172-4-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191223152349.180172-1-chenzhou10@huawei.com> References: <20191223152349.180172-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-20191223_072734_274429_0EAF4789 X-CRM114-Status: GOOD ( 11.24 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 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: xiexiuqi@huawei.com, chenzhou10@huawei.com, linux-doc@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, horms@verge.net.au, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If we want to reserve crashkernel above 4G, we could use parameters "crashkernel=X crashkernel=Y,low", in this case, specified size low memory is reserved for crash dump kernel devices and never mapped by the first kernel. This memory range is advertised to crash dump kernel via DT property under /chosen, linux,low-memory-range= Crash dump kernel reads this property at boot time and call memblock_add() after memblock_cap_memory_range() has been called. Signed-off-by: Chen Zhou --- arch/arm64/mm/init.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 0d7afd5..1c4a6ad 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -322,6 +322,26 @@ static int __init early_mem(char *p) } early_param("mem", early_mem); +static int __init early_init_dt_scan_lowmem(unsigned long node, + const char *uname, int depth, void *data) +{ + struct memblock_region *lowmem = data; + const __be32 *reg; + int len; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + reg = of_get_flat_dt_prop(node, "linux,low-memory-range", &len); + if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) + return 1; + + lowmem->base = dt_mem_next_cell(dt_root_addr_cells, ®); + lowmem->size = dt_mem_next_cell(dt_root_size_cells, ®); + + return 1; +} + static int __init early_init_dt_scan_usablemem(unsigned long node, const char *uname, int depth, void *data) { @@ -352,13 +372,21 @@ static void __init fdt_enforce_memory_region(void) if (reg.size) memblock_cap_memory_range(reg.base, reg.size); + + of_scan_flat_dt(early_init_dt_scan_lowmem, ®); + + if (reg.size) + memblock_add(reg.base, reg.size); } void __init arm64_memblock_init(void) { const s64 linear_region_size = BIT(vabits_actual - 1); - /* Handle linux,usable-memory-range property */ + /* + * Handle linux,usable-memory-range and linux,low-memory-range + * properties. + */ fdt_enforce_memory_region(); /* Remove memory above our supported physical address size */