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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C37B7C433EF for ; Fri, 6 May 2022 23:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uwQzDYKj1rX5JN7q5jg5xsQ+GUXsvT0f4zVls8OSc6o=; b=UoVombG8IUdUZ3 l8VvWfyOxkFJdcFiOJ3m/MvsLW+rQygMKrcSLMMOUfUv7SWYEM6jneNjrIqb2w/0j5gpHlxdeirkC Kyp+81114lcpF2kyUnvIoJzxcvpwn6vQh9pg2+tb8serdeq5iLqpJovKpidA5OXvpkvjzne6J4e6v g7DVemxDvkM/1fAV3VCOJ04gUtfh3U966stvzBhDVIMf/0Ga+fCiXrJQeRdCKftGq3DZEUjQ5jVs2 r12lMI3+Iv6JVRUR4iFFN6UjPubeKziw0QguwLTrBgzV0yw9I/fVoITGH36aNaDsjLYGgZHkhiSTK oPSNlHtB6/dGDrt4sQGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nn7BI-005LjJ-Uo; Fri, 06 May 2022 23:16:17 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nn7BF-005Lhb-1Y for linux-arm-kernel@lists.infradead.org; Fri, 06 May 2022 23:16:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651878971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rCa7eNjVeMppq8L/kUv69MDo2c/0xX5B3HNrUpKRUig=; b=ByhAh6xjWv7X7EYCKNS4qHg7AMMEtjlWDhLiAV3Y07xw/dHGKj3Lc2r/s+Uv4/7yqwQLJ5 9OidArPycj5mavhQ8hEX3Ee/jvehB/OeC6Ak+S/KPi4yC7RV9QE9ZoYrbJ+0igD6nAq6af vGETL+xAO9tzCD3J9X6hL+xTFJzwfUw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-290-FjaEmhX_OJa2_SLMPyjh_Q-1; Fri, 06 May 2022 19:16:07 -0400 X-MC-Unique: FjaEmhX_OJa2_SLMPyjh_Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFDAD185A794; Fri, 6 May 2022 23:16:06 +0000 (UTC) Received: from localhost (ovpn-12-33.pek2.redhat.com [10.72.12.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5DE07AE3; Fri, 6 May 2022 23:15:59 +0000 (UTC) Date: Sat, 7 May 2022 07:15:56 +0800 From: Baoquan He To: Zhen Lei Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Dave Young , Vivek Goyal , Eric Biederman , kexec@lists.infradead.org, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org, Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou , John Donnelly , Dave Kleikamp Subject: Re: [PATCH v24 4/6] of: fdt: Add memory for devices by DT property "linux,usable-memory-range" Message-ID: <20220506231556.GC122876@MiWiFi-R3L-srv> References: <20220506114402.365-1-thunder.leizhen@huawei.com> <20220506114402.365-5-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220506114402.365-5-thunder.leizhen@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220506_161613_254649_DC3FB578 X-CRM114-Status: GOOD ( 30.00 ) 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: , 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 On 05/06/22 at 07:44pm, Zhen Lei wrote: > From: Chen Zhou > > When reserving crashkernel in high memory, some 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,usable-memory-range = > > We reused the DT property linux,usable-memory-range and made the low > memory region as the second range "BASE2 SIZE2", which keeps compatibility > with existing user-space and older kdump kernels. > > Crash dump kernel reads this property at boot time and call memblock_add() > to add the low memory region after memblock_cap_memory_range() has been > called. LGTM, Acked-by: Baoquan He > > Signed-off-by: Chen Zhou > Co-developed-by: Zhen Lei > Signed-off-by: Zhen Lei > Reviewed-by: Rob Herring > Tested-by: Dave Kleikamp > --- > drivers/of/fdt.c | 33 +++++++++++++++++++++++---------- > 1 file changed, 23 insertions(+), 10 deletions(-) > > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c > index ec315b060cd50d2..2f248d0acc04830 100644 > --- a/drivers/of/fdt.c > +++ b/drivers/of/fdt.c > @@ -973,16 +973,24 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) > > static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND; > > +/* > + * The main usage of linux,usable-memory-range is for crash dump kernel. > + * Originally, the number of usable-memory regions is one. Now there may > + * be two regions, low region and high region. > + * To make compatibility with existing user-space and older kdump, the low > + * region is always the last range of linux,usable-memory-range if exist. > + */ > +#define MAX_USABLE_RANGES 2 > + > /** > * early_init_dt_check_for_usable_mem_range - Decode usable memory range > * location from flat tree > */ > void __init early_init_dt_check_for_usable_mem_range(void) > { > - const __be32 *prop; > - int len; > - phys_addr_t cap_mem_addr; > - phys_addr_t cap_mem_size; > + struct memblock_region rgn[MAX_USABLE_RANGES] = {0}; > + const __be32 *prop, *endp; > + int len, i; > unsigned long node = chosen_node_offset; > > if ((long)node < 0) > @@ -991,16 +999,21 @@ void __init early_init_dt_check_for_usable_mem_range(void) > pr_debug("Looking for usable-memory-range property... "); > > prop = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); > - if (!prop || (len < (dt_root_addr_cells + dt_root_size_cells))) > + if (!prop || (len % (dt_root_addr_cells + dt_root_size_cells))) > return; > > - cap_mem_addr = dt_mem_next_cell(dt_root_addr_cells, &prop); > - cap_mem_size = dt_mem_next_cell(dt_root_size_cells, &prop); > + endp = prop + (len / sizeof(__be32)); > + for (i = 0; i < MAX_USABLE_RANGES && prop < endp; i++) { > + rgn[i].base = dt_mem_next_cell(dt_root_addr_cells, &prop); > + rgn[i].size = dt_mem_next_cell(dt_root_size_cells, &prop); > > - pr_debug("cap_mem_start=%pa cap_mem_size=%pa\n", &cap_mem_addr, > - &cap_mem_size); > + pr_debug("cap_mem_regions[%d]: base=%pa, size=%pa\n", > + i, &rgn[i].base, &rgn[i].size); > + } > > - memblock_cap_memory_range(cap_mem_addr, cap_mem_size); > + memblock_cap_memory_range(rgn[0].base, rgn[0].size); > + for (i = 1; i < MAX_USABLE_RANGES && rgn[i].size; i++) > + memblock_add(rgn[i].base, rgn[i].size); > } > > #ifdef CONFIG_SERIAL_EARLYCON > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel