From nobody Sun Apr 12 15:06:14 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 768DBC4332F for ; Fri, 23 Dec 2022 11:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235982AbiLWL2J (ORCPT ); Fri, 23 Dec 2022 06:28:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235805AbiLWL2F (ORCPT ); Fri, 23 Dec 2022 06:28:05 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 766946578 for ; Fri, 23 Dec 2022 03:28:03 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id x22so11388275ejs.11 for ; Fri, 23 Dec 2022 03:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rammhold-de.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lFeknuNwkrG7RSqHcx+1XNwP++s/iRA1VEaVxTgmg4g=; b=hBbGx/sx0Xtj3qyO2DnwolsWWeXvKKEA29FnQw2uFnuLWUqZyGEpIfLpeWpV5eFEyH HnvlBU4V1TXDCd5xvURIoA5VkDtmPHJRz7lpADizpMIQVg13g9TmNN0ynsnj2dvANv0r lFdto2x+Zx78dAFxjFeyokkwCapQ6p9krN0nzxWGqRkR+aOZIs+jlLlVPEKT4goFw2VS fOO+zEEeKYzFog9V1fNbWRx9i9doTd966dDU8OLs5Wwci0rCIOQbCLQIdpcOGYzvG41i n70HL3EZVXV998EVqgv/IBFVODy3wTN1a0neae1iRlrsQHoAZf09UrrBMPIc6oVlTV0a dwAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lFeknuNwkrG7RSqHcx+1XNwP++s/iRA1VEaVxTgmg4g=; b=stdxBDikQVfdPIa/fYGIy3zdNEeQUuKOkIf2QCyYsJUejTWKjcRxHoeuFaWaA8IwM8 VdBit8FCY93u83lwx+7/eH7C+rSvJTlZ4u78IJGvWWAt8i+bnFwjTK8oeEyGGC9QLq6G UYdNsJ9NqcMxqcbcVtLU+0HZ59jP6GL2uEMrHOf2iIApyrKLg8TbTCgECQMk92HHtdbB qjXhaGDwP8WTZHaGpxOyEKDKDF51q8vCbyYXBKP3pqyAWSMAwQebm0oZZWm26WptrDXb Muc4aSbRXPbR5cB4sh1DheP0Du/7W/lDUcEvyoxqwMnF/yEP4Ic5DwOTFncE1DxAZiTT RrhA== X-Gm-Message-State: AFqh2kqKjnNVwyOfuFQYC/UN13nUyUzsSDSJccRve4Wm6HAdUbgfjtZZ 1fWvktf7fAaDOshWA2/AAh3bkg== X-Google-Smtp-Source: AMrXdXvezyb09TyK7KItP1R8P9rE/8Gjzwdr9cT8Z3YJHnqevqYEgHk0QLQW1O9Ph7jpPT2nb1ImMA== X-Received: by 2002:a17:906:5048:b0:7c0:b770:df94 with SMTP id e8-20020a170906504800b007c0b770df94mr7701482ejk.63.1671794881943; Fri, 23 Dec 2022 03:28:01 -0800 (PST) Received: from localhost ([2a00:e67:3f2:a:a55e:fcc9:ef69:52ff]) by smtp.gmail.com with ESMTPSA id q9-20020a170906770900b0078ddb518a90sm1267202ejm.223.2022.12.23.03.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Dec 2022 03:28:00 -0800 (PST) From: andreas@rammhold.de To: John Crispin , Thomas Bogendoerfer , Rob Herring , Frank Rowand Cc: Andreas Rammhold , stable@vger.kernel.org, Rob Herring , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH] of/fdt: run soc memory setup when early_init_dt_scan_memory fails Date: Fri, 23 Dec 2022 12:27:47 +0100 Message-Id: <20221223112748.2935235-1-andreas@rammhold.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andreas Rammhold If memory has been found early_init_dt_scan_memory now returns 1. If it hasn't found any memory it will return 0, allowing other memory setup mechanisms to carry on. Previously early_init_dt_scan_memory always returned 0 without distinguishing between any kind of memory setup being done or not. Any code path after the early_init_dt_scan memory call in the ramips plat_mem_setup code wouldn't be executed anymore. Making early_init_dt_scan_memory the only way to initialize the memory. Some boards, including my mt7621 based Cudy X6 board, depend on memory initialization being done via the soc_info.mem_detect function pointer. Those wouldn't be able to obtain memory and panic the kernel during early bootup with the message "early_init_dt_alloc_memory_arch: Failed to allocate 12416 bytes align=3D0x40". Fixes: 1f012283e936 ("of/fdt: Rework early_init_dt_scan_memory() to call di= rectly") Cc: stable@vger.kernel.org Signed-off-by: Andreas Rammhold --- arch/mips/ralink/of.c | 2 +- drivers/of/fdt.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c index ea8072acf8d94..6873b02634219 100644 --- a/arch/mips/ralink/of.c +++ b/arch/mips/ralink/of.c @@ -63,7 +63,7 @@ void __init plat_mem_setup(void) dtb =3D get_fdt(); __dt_setup_arch(dtb); =20 - if (!early_init_dt_scan_memory()) + if (early_init_dt_scan_memory()) return; =20 if (soc_info.mem_detect) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 7b571a6316397..4f88e8bbdd279 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1099,7 +1099,7 @@ u64 __init dt_mem_next_cell(int s, const __be32 **cel= lp) */ int __init early_init_dt_scan_memory(void) { - int node; + int node, found_memory =3D 0; const void *fdt =3D initial_boot_params; =20 fdt_for_each_subnode(node, fdt, 0) { @@ -1139,6 +1139,8 @@ int __init early_init_dt_scan_memory(void) =20 early_init_dt_add_memory_arch(base, size); =20 + found_memory =3D 1; + if (!hotpluggable) continue; =20 @@ -1147,7 +1149,7 @@ int __init early_init_dt_scan_memory(void) base, base + size); } } - return 0; + return found_memory; } =20 int __init early_init_dt_scan_chosen(char *cmdline) --=20 2.38.1