From patchwork Sat Apr 18 06:07:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1272565 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=oZfBr1tR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4942d65KCsz9sP7 for ; Sat, 18 Apr 2020 16:10:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 03FF081A07; Sat, 18 Apr 2020 08:10:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="oZfBr1tR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E2837819FA; Sat, 18 Apr 2020 08:10:26 +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,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 99DB6804CD for ; Sat, 18 Apr 2020 08:10:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=370d05252=atish.patra@wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1587190221; x=1618726221; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kY8cLmyJxLyFW81ExKLtQn7C7wUsOIns8tLya2s4itw=; b=oZfBr1tRhMhgcP4v5/YET8hUNbz83JStDvssX1PyRtxhvCwGQULCLemE VlFiGKEnychtOAPFbNX3WFH3upECiH2LhmeFUE4vzZVP3AOPZHY0xZdTQ +ebwWLbM6Lyh5P/TA5vS/INkJHtmpT5pOWmtRJ9nProhbJtjfWaqIO4UU n4LxcVrvP/2Was7CqLTvAaZafjlV9DFwVsPYjtvAMdfcqn08GCwfx/A0e xi/JNAeyf6X+3vI9EtDjSoduQ83oHkYphIUGt1BcAHnejsWz2RHPeTFW0 nJ9Mwst/KTq/pbcOHXgGOkGK4ZdEc017wfLuHbFe1Zs6jBO79GY9+Db+A A==; IronPort-SDR: j180VuWpYhA4rJYR1M+G5+c1gd8lCE+AnzVcy7gyS3TQdorYt7Pg2JpQ7YJ8s2l7a0MAewLsZp /4CqGYd6lLT6EJuZBy9BJc6K404Ihc7bf70Mt7t7HYyq1YlkA853dsa4UCE3dHNSzDURy47yS0 DviuQ6ompZ+K1tGC+Kk3itvW2Sfj2Ya48rMXkYIJSEKPz2CtJ0cpZx56virPs3olCfpDjSMg1H 8qTgCpyhj8k0Geo+ePf9UxBf5GqT9RMWgSzsE5UTIbQkJwuHzTAnPDVX7fBUmbZIs7qYOmGxSa Gss= X-IronPort-AV: E=Sophos;i="5.72,397,1580745600"; d="scan'208";a="139952070" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Apr 2020 14:10:16 +0800 IronPort-SDR: jgoSZHB1dFbNskfjgxrvSqTxjFUcG10ixnvAiifppXmLaIzmDAdn0l3Rve1w2gHhuzw5KQMnUf w3jQi8TnKeDvjkis333Ih2doV47+Nd93w= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2020 23:00:40 -0700 IronPort-SDR: 3JBCfJikI3ZY299Skf9AVEmdlqdjXm6qZ/zytDYEveDUvDLL0zz61W+LcMqCyxsQeBwbEOtVBn eyYufr3eiR1g== WDCIronportException: Internal Received: from 5s19j72.ad.shared (HELO yoda.hgst.com) ([10.86.56.13]) by uls-op-cesaip01.wdc.com with ESMTP; 17 Apr 2020 23:10:16 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Heinrich Schuchardt , Anup Patel , Bin Meng , Lukas Auer , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , palmer@dabbelt.com Subject: [RESEND PATCH v5 1/6] riscv: Add boot hartid to Device tree Date: Fri, 17 Apr 2020 23:07:53 -0700 Message-Id: <20200418060758.4839-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200418060758.4839-1-atish.patra@wdc.com> References: <20200418060758.4839-1-atish.patra@wdc.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean Linux booting protocol mandates that register "a0" contains the hartid. However, U-boot can not pass the hartid via a0 during via standard UEFI protocol. DT nodes are commonly used to pass such information to the OS. Add a DT node under chosen node to indicate the boot hartid. EFI stub in Linux kernel will parse this node and pass it to the real kernel in "a0" before jumping to it. Signed-off-by: Atish Patra Reviewed-by: Rick Chen Tested-by: Heinrich Schuchardt Reviewed-by: Bin Meng --- arch/riscv/lib/bootm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index fad16901c5f2..87cadad5016d 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -28,6 +28,28 @@ __weak void board_quiesce_devices(void) int arch_fixup_fdt(void *blob) { +#ifdef CONFIG_EFI_LOADER + int err; + u32 size; + int chosen_offset; + + size = fdt_totalsize(blob); + err = fdt_open_into(blob, blob, size + 32); + if (err < 0) { + printf("Device Tree can't be expanded to accommodate new node"); + return err; + } + chosen_offset = fdt_path_offset(blob, "/chosen"); + if (chosen_offset < 0) { + err = fdt_add_subnode(blob, 0, "chosen"); + if (err < 0) { + printf("chosen node can not be added\n"); + return err; + } + } + /* Overwrite the boot-hartid as U-Boot is the last stage BL */ + fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart); +#endif return 0; }