Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3667641pxb; Mon, 24 Jan 2022 14:54:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu7VC+WS24dDfxlfC2gEWjSgagHSaB1qkXZoagGhTWYI5nx25iec/EzST5BpHr0EPwRNWG X-Received: by 2002:aa7:888e:0:b0:4c4:3ad:9eee with SMTP id z14-20020aa7888e000000b004c403ad9eeemr15679675pfe.13.1643064854526; Mon, 24 Jan 2022 14:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064854; cv=none; d=google.com; s=arc-20160816; b=sIAC+LLiF3zDzaET4iq5TMumPTOsMnaVda8F9MfrNQWdWSXuF/qY0bAsrnNjHcWuAm 1RjjhBT0JV6plk4PHgo5EcTAqhZ6cEJIw2jCuJdOT0bRvd1xBTzcrFd73n0k99XgJMD4 GD87D4A+RNxVMr2G3G+rsuSHXeEYcMPJbVupRwUPmXAd0UX3iWRiTYVXQaSbaCWF7xaH 2gSEUJpChoYxJeEFWJ9nnfVpNy8UApkNs03/Bupe72VXuAZreH9uCD2in7iZJcYWd5Yn 1vtolYerhDGlBmTEoFj963YQbwYDDRCRis/yYVdmYBJCha6qfRBWkzOkpqyTu4l8JPBN XG1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fKD5xJ/FJw9W+1L/Z4bFMc3cvTjQlgTkAKUFjqtMWuc=; b=vAkUCKqn7GutP6PRPHlQjutVAkPgVB64f2oOAWp0cvL+KsLWfe8jH33aRDKWecr0Z3 Gzaxyj+CHi9X/MdWX7zz7Hh0oJiWdOwntmetAb7ve+4RsJggl8qh37X21QRzOgqLYg1v /KgP/hWaRT5HaPehHYKgQy0VNtyGqiwWU9TXPIcBJPDGXDBfUvsHama3m0ITaK1EaJVP u8j2xOSsrpYX0FYV74X2iyBVQdbKItXfG15FdJi59bV7HV/nil6pfs+UfqOEqiybdXae MP09IzKsppOYF0sI9sbFHL4Jxrq4fcSbQY9NA0TeKgMZxm6icQs6w2vrwIWjy8IYFaal rK0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZEC+ROZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si7799119pfi.361.2022.01.24.14.54.01; Mon, 24 Jan 2022 14:54:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZEC+ROZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1839542AbiAXWvQ (ORCPT + 99 others); Mon, 24 Jan 2022 17:51:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1458150AbiAXVmr (ORCPT ); Mon, 24 Jan 2022 16:42:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E4C7C07A959; Mon, 24 Jan 2022 12:31:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CCBE761536; Mon, 24 Jan 2022 20:31:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB8A5C340E5; Mon, 24 Jan 2022 20:31:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056271; bh=31xC9mtUNmT5ViszQgZGChLa+pmB3GlMeXbvgzxJHR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZEC+ROZ5fwELLGQggQwH3O7XtHiu4BKen5E3aew2BR2HA4n/Dw6lLtTpiUEXwCWcW Gjaja2Yx3flS2bBHQFjpUDI6gdvp27rEwJs2W0O7GTkYiwqvZjxEdRY06UgUjavtwv YBbIyX0hmx7rBuv3Z30GBhW2zVkZ4aV8t3YxElwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-efi@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Zhen Lei , Pingfan Liu , Dave Kleikamp , John Donnelly , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Sasha Levin Subject: [PATCH 5.15 427/846] of: fdt: Aggregate the processing of "linux,usable-memory-range" Date: Mon, 24 Jan 2022 19:39:04 +0100 Message-Id: <20220124184115.705813438@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhen Lei [ Upstream commit 8347b41748c3019157312fbe7f8a6792ae396eb7 ] Currently, we parse the "linux,usable-memory-range" property in early_init_dt_scan_chosen(), to obtain the specified memory range of the crash kernel. We then reserve the required memory after early_init_dt_scan_memory() has identified all available physical memory. Because the two pieces of code are separated far, the readability and maintainability are reduced. So bring them together. Suggested-by: Rob Herring Signed-off-by: Zhen Lei (change the prototype of early_init_dt_check_for_usable_mem_range(), in order to use it outside) Signed-off-by: Pingfan Liu Tested-by: Dave Kleikamp Acked-by: John Donnelly Reviewed-by: Rob Herring Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org To: devicetree@vger.kernel.org To: linux-efi@vger.kernel.org Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/of/fdt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 4546572af24bb..105b1a47905ab 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -969,18 +969,22 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) elfcorehdr_addr, elfcorehdr_size); } -static phys_addr_t cap_mem_addr; -static phys_addr_t cap_mem_size; +static unsigned long chosen_node_offset = -FDT_ERR_NOTFOUND; /** * early_init_dt_check_for_usable_mem_range - Decode usable memory range * location from flat tree - * @node: reference to node containing usable memory range location ('chosen') */ -static void __init early_init_dt_check_for_usable_mem_range(unsigned long node) +static 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; + unsigned long node = chosen_node_offset; + + if ((long)node < 0) + return; pr_debug("Looking for usable-memory-range property... "); @@ -993,6 +997,8 @@ static void __init early_init_dt_check_for_usable_mem_range(unsigned long node) pr_debug("cap_mem_start=%pa cap_mem_size=%pa\n", &cap_mem_addr, &cap_mem_size); + + memblock_cap_memory_range(cap_mem_addr, cap_mem_size); } #ifdef CONFIG_SERIAL_EARLYCON @@ -1141,9 +1147,10 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) return 0; + chosen_node_offset = node; + early_init_dt_check_for_initrd(node); early_init_dt_check_for_elfcorehdr(node); - early_init_dt_check_for_usable_mem_range(node); /* Retrieve command line */ p = of_get_flat_dt_prop(node, "bootargs", &l); @@ -1279,7 +1286,7 @@ void __init early_init_dt_scan_nodes(void) of_scan_flat_dt(early_init_dt_scan_memory, NULL); /* Handle linux,usable-memory-range property */ - memblock_cap_memory_range(cap_mem_addr, cap_mem_size); + early_init_dt_check_for_usable_mem_range(); } bool __init early_init_dt_scan(void *params) -- 2.34.1