Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp361524pxv; Wed, 14 Jul 2021 05:52:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn8+7ei+X/okBLDFvp+G1tfDM2BH2ZCEp/kkcCVaz09DkTkxvrlCD1YCCNn6j2Bi3Vbe5K X-Received: by 2002:aa7:db50:: with SMTP id n16mr13474850edt.298.1626267139434; Wed, 14 Jul 2021 05:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626267139; cv=none; d=google.com; s=arc-20160816; b=sYJaH7JiPmQQ9H4d0xk9BDt3WfoVYmQX/OIQIBk7oopUudcNZRAMJfTpJqfT1uDKZ9 Aw/w/hQ/NezS/UF8g9GBnhi0wEsyI1BVegyOgJzqQ34iVL0WPAti/Ms2AUE7OIZD4rvV MSKc4nXJ0kA6deCXJVJuBzGgAZuYNgEIsClczD/lapBpC7VQ0jk8iWNSbb1iqadz8ltx 9oIYOn/NQVZ3wvUhJ+HcbtrFqsdHAAtk3QeSXPYWF2Q9jVSIzZ9S9MlMeNcbRov7BBjJ nbzzIXWbO3ye8FkqSgy2zjEUSOWF+heQQAmEyxLaTJ5PfiSMrkAk5QuvZ9jT/+0ePMa5 F4uw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jqhuHbwLiT41syGHb9sPYykw/l/MAAyZ0+YlLziwoGY=; b=G9tELc5ou1H3uMIYo+I6Zgg17Wn5uTq9P4BPvWrodwwsXB4zDo9qhbdJmhhy414qY7 EzKOXtC9AnfT0zqTT94+TV74YJo4QNpGe8UzLyGA4Lb9rs+Ey98cyZFRGPQ7MItkDcJg CMmALY+6PO8wU1fE58K7igbLOkwBR6hc8iE0cClU6uEcBNsJUuLhirDkXj9ZU7H61RhQ z2gXJANdzF9PK39uCkegV4JzPH29qZ6/+WtYRfMg/8GM4unZCifnV3eoO14SWzjgdTtS 0TbHwFZzAaszxo5r9kyUswnxvi6n9ae8qDkaHDmI9WHrvEzvxzo3Hi6aqaLuw+8qJgcA WC4g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si2637147edx.481.2021.07.14.05.51.56; Wed, 14 Jul 2021 05:52:19 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231415AbhGNMxq (ORCPT + 99 others); Wed, 14 Jul 2021 08:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239362AbhGNMxk (ORCPT ); Wed, 14 Jul 2021 08:53:40 -0400 Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C901AC061766 for ; Wed, 14 Jul 2021 05:50:48 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:39cc:190a:2775:cfe7]) by xavier.telenet-ops.be with bizsmtp id V0qX250091ccfby010qX5Y; Wed, 14 Jul 2021 14:50:46 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1m3eLO-0018dP-Vb; Wed, 14 Jul 2021 14:50:30 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1m3eLN-00AaEC-PF; Wed, 14 Jul 2021 14:50:29 +0200 From: Geert Uytterhoeven To: Rob Herring , Russell King , Nicolas Pitre , Ard Biesheuvel , Linus Walleij , Catalin Marinas , Will Deacon , Nick Kossifidis , Paul Walmsley , Palmer Dabbelt , Albert Ou , Frank Rowand , Dave Young , Mike Rapoport Cc: Baoquan He , Vivek Goyal , Andrew Morton , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kexec@lists.infradead.org, linux-mm@kvack.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v4 04/10] of: fdt: Add generic support for parsing usable memory range property Date: Wed, 14 Jul 2021 14:50:14 +0200 Message-Id: <4064ea598a10ea0a4b9043aa771bcea1a00efac3.1626266516.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for parsing the "linux,usable-memory-range" property in the "/chosen" node to the FDT core code. This can co-exist safely with the architecture-specific parsing, until the latter has been removed. Architecture-specific code still has to make sure the resulting memory range limitation is applied, if present. Signed-off-by: Geert Uytterhoeven --- About the change to chosen.txt: I have a similar change for schemas/chosen.yaml in dt-schema. v4: - New. --- Documentation/devicetree/bindings/chosen.txt | 6 ++--- drivers/of/fdt.c | 24 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 5b0b94eb2d04e79d..1cc3aa10dcb10588 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -79,9 +79,9 @@ a different secondary CPU release mechanism) linux,usable-memory-range ------------------------- -This property (arm64 only) holds a base address and size, describing a -limited region in which memory may be considered available for use by -the kernel. Memory outside of this range is not available for use. +This property holds a base address and size, describing a limited region in +which memory may be considered available for use by the kernel. Memory outside +of this range is not available for use. This property describes a limitation: memory within this range is only valid when also described through another mechanism that the kernel diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index f797d52c5b492cb7..1b4dd5418b44b9fb 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -935,6 +935,29 @@ static void __init early_init_dt_check_for_elfcorehdr(unsigned long node) elfcorehdr_addr, elfcorehdr_size); } +/** + * 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) +{ + const __be32 *prop; + int len; + + 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))) + 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); + + pr_debug("cap_mem_start=%pa cap_mem_size=%pa\n", &cap_mem_addr, + &cap_mem_size); +} + #ifdef CONFIG_SERIAL_EARLYCON int __init early_init_dt_scan_chosen_stdout(void) @@ -1083,6 +1106,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, 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); -- 2.25.1