Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp339527ybl; Fri, 30 Aug 2019 00:10:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWR8d/LHkWv5LDu06gDksBBhWlydWAQmOEPD6yEWQzH/ZnxgFrkBp8WR2cpTHe/JtY4IM0 X-Received: by 2002:a63:5550:: with SMTP id f16mr12295580pgm.426.1567149019844; Fri, 30 Aug 2019 00:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567149019; cv=none; d=google.com; s=arc-20160816; b=r554sxrVRMcFAFLxOj4GSMdglgVx6OIvavkjOcgMxGfjpmUd7+pEgJyXWjfWvrjbHU g6j47Evo9b3hVfDWnj63wGhCo5qazqpETPv98R3E+qD7DhB0NodVwoJoTzu9G9ne+Hz1 IhTPArEyRyYxOtWn3V/lR5HnEemTZFR76EhocylxrySJRCh1BtmVnksZRweSpjWK7xuH s531NmFucClRdDGHz2JkMXjUVBgiS9Q0R32Q1DalW2en5zoSgCURv9Ef0c2CAPBh0SiR 1gkWJA4dryDWa1FpYVqVgd/2dWUA4hg6IKGPIlQnnxjPFJdTjgrawcgnakGlIhR+DbLi lh6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TwcWM8GvQ4h4EGh+Si0H3LXR0XFfo1xqvMeAbB4h+po=; b=hM5I6TpesMI+GDjPSJCJgMj7r/RyFKrQ3qWdVEetOefBPYWlm/MKPIH17/MXX08kn0 ZXO4AovUwBm+c0GdzrUceGd/zcXfiwSChcpknqejFDrkc9bBFc3sUV6oKKLOe42A5Z11 krVy3xi/ElCd8pJVbsgnu4k8oewkgUmmjhmdw3bCfBFAIrGC0awniAlrbsv6DqPIkELD ekpRHcJeGoDCvHnP19B1Rg5Kz1ZFtyaKP7lXBi6+VUirop3Fx1JYBqB9qhxE1jg9/mxc Vlu/Q8dBZ0OKBO59ZhTlrfkur7jxSNjfX1rz5Yc72/+Vij0HWztbaz+LvWtdkmGgAyjq 761Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5si3800447pgm.427.2019.08.30.00.10.04; Fri, 30 Aug 2019 00:10:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbfH3HJG (ORCPT + 99 others); Fri, 30 Aug 2019 03:09:06 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6142 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728088AbfH3HJE (ORCPT ); Fri, 30 Aug 2019 03:09:04 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id EBC49FEB3CFAD5B8A4FE; Fri, 30 Aug 2019 15:09:00 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Fri, 30 Aug 2019 15:08:52 +0800 From: Chen Zhou To: , , , , , , CC: , , , , , Chen Zhou Subject: [PATCH v6 3/4] arm64: kdump: add memory for devices by DT property, low-memory-range Date: Fri, 30 Aug 2019 15:11:59 +0800 Message-ID: <20190830071200.56169-4-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190830071200.56169-1-chenzhou10@huawei.com> References: <20190830071200.56169-1-chenzhou10@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 c99f845..a376b18 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -294,6 +294,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) { @@ -324,13 +344,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 = -(s64)PAGE_OFFSET; - /* 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 */ -- 2.7.4