From patchwork Sat May 8 16:12:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1475895 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=htyEUxJc; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fcsmm0Mssz9vFX for ; Sun, 9 May 2021 02:13:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A60BB82E69; Sat, 8 May 2021 18:13:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="htyEUxJc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6A07E82E6D; Sat, 8 May 2021 18:13:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 90CD882CDB for ; Sat, 8 May 2021 18:13:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x729.google.com with SMTP id q136so11555743qka.7 for ; Sat, 08 May 2021 09:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=45uxG60NMGqQxhc6QVlEmAtsa5EvO0jf2LG2uxEDsxE=; b=htyEUxJcs/auGEV0smHWfh8QF7UN/O/+h2lg9yQh9NWuZlSGyt+xi+wHK4DmvjsD5y 1PO3KOtW065hNXjpTvDqx9fQ/IlRrmcdf0ZiLwaWeLrC/GEs7uJ8PyFRf01wMgTFDXVT xQOr5VshLOKKzdqfqoDQc3f5UXvKpon8BVHgtxlBzOBCH169djs6Nnrxj4KBv+9sOOn5 ES/swwfk8pXJ0tVBNIrpRHQci8rYjVS9LPsrOtrc60i5a+L034XYR5/mX+S2nPYiKiYS D98vFwCMpBWG0Ls4ghRvUlhjuLOlTWFfqsJrDNd1jAQB2l9nFVtik+/EqYmWNuJJgVaM F5kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=45uxG60NMGqQxhc6QVlEmAtsa5EvO0jf2LG2uxEDsxE=; b=p4qpgrGs5eJXBxVwqFZDcep71SOdRFOfPGf3pc01oDZwAN+icb/rCLaKPBgriUANWL xIsb4gf1594xrE9zaZEX0AP+iZKU2Sm5i44NjQ/G/L9tfsTitZQ5rUamemaENPgwomGC i75JrwhhVxf7RDW5kaoOiIOh0WIIk0CpNZgz9Nc6EoetV45ICQp/1Lh14up71wHAlr1k xSwb+otroWpaNoh6iTdbLtOB4uCwARrSwoQ0TK0odK4lYVD4GOvJu3i8nR69irqxgvS3 Z3BBwFHPu/IamPZ0JyiBV12/ifVmLxTtZhBhUNRALE8OcGQTlGmIYQ8lJRcXk2xkTppG P+IQ== X-Gm-Message-State: AOAM53205DHaLs7lQJCmsS3FH/QlQJD4lnEKpEH1qx5wdPTY7sejjTKq /heWXwJ44cyJWOB1FDV7EaZKasSfORc= X-Google-Smtp-Source: ABdhPJypjs7hYZKppC/GZXvun2aWSv3vyz5leW/HBVtFQxD37GbhzlqaolH+Q3Zf4NaGLWFHt94CqA== X-Received: by 2002:a37:61cd:: with SMTP id v196mr12017843qkb.454.1620490381264; Sat, 08 May 2021 09:13:01 -0700 (PDT) Received: from godwin.fios-router.home (pool-108-51-35-162.washdc.fios.verizon.net. [108.51.35.162]) by smtp.gmail.com with ESMTPSA id j196sm7545025qke.25.2021.05.08.09.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 May 2021 09:13:00 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Rick Chen Cc: Heinrich Schuchardt , Bin Meng , Atish Patra , Sean Anderson Subject: [PATCH] riscv: Fix arch_fixup_fdt always failing without /chosen Date: Sat, 8 May 2021 12:12:54 -0400 Message-Id: <20210508161254.2217178-1-seanga2@gmail.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean If /chosen was missing, chosen_offset would never get updated with the new /chosen node. This would cause fdt_setprop_u32 to fail. This patch fixes this by setting chosen_offset. In addition, log any errors from setting boot-hartid as well. Fixes: 177c53fe6c6 ("riscv: Move all fdt fixups together") Signed-off-by: Sean Anderson Reviewed-by: Bin Meng Reviewed-by: Rick Chen Reviewed-by: Atish Patra --- I have not actually tested this (nor observed the original failure). But this seemed buggy from inspection. arch/riscv/lib/fdt_fixup.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 1f3f23621c..f636b28449 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -151,14 +151,17 @@ int arch_fixup_fdt(void *blob) } chosen_offset = fdt_path_offset(blob, "/chosen"); if (chosen_offset < 0) { - err = fdt_add_subnode(blob, 0, "chosen"); - if (err < 0) { + chosen_offset = fdt_add_subnode(blob, 0, "chosen"); + if (chosen_offset < 0) { log_err("chosen node cannot be added\n"); - return err; + return chosen_offset; } } /* Overwrite the boot-hartid as U-Boot is the last stage BL */ - fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); + err = fdt_setprop_u32(blob, chosen_offset, "boot-hartid", + gd->arch.boot_hart); + if (err < 0) + return log_msg_ret("could not set boot-hartid", err); #endif /* Copy the reserved-memory node to the DT used by OS */