From patchwork Sat Apr 18 19:32:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1272706 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; 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=fjIHjH6m; 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 494NRt4l64z9sRN for ; Sun, 19 Apr 2020 05:33:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AED9E81C6B; Sat, 18 Apr 2020 21:33:18 +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="fjIHjH6m"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6950581C75; Sat, 18 Apr 2020 21:33:08 +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 esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) (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 824C881C59 for ; Sat, 18 Apr 2020 21:33:02 +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=1587238382; x=1618774382; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FfjW8KHbQsOLAHvSwbpw8fZE6GlFVrZL5p//DkhAKR0=; b=fjIHjH6mx7K9UNUDMXM3bcjyfrfoZEN4vJG7kDhOHx9cemWJ3Vl5tbVt VDxm66Inml9+Z1X1bKkAJz+4hwYRlCIChC31eP6Q06bdkcGMQ6X5LC2wV oTA+eCx54GF4qhkWIXoyLYXjPGoxqUVsqacvo7SdJyFrwT8zzfk4X0AtL kCJxcI3F2REC3bQAu3TTLIcTZHXUFRrrW/mpOxl9cBMmQoE/P755OJ8k0 nMk+cXQIO0SBLLzoVFHxHODeWY8L3V1VODAXFAhT9hmUvpARaUQEz+L3g WYL4YR//l6jzkhx5Swsv8SMEGf+S6nEEnRdT53vEYK3ecRtF6byVAMtHk g==; IronPort-SDR: zqWK53hqfgc/o1Y7BM6d1cAGRhH8kNYltut9i3TMmzAHYMBlMtSWwFuNnAU6S+oKyB+dJffKpz xoWO3+X4lyivyLYFq4YOLGB/xipi4++Yz1sb1TYzG5T+WQ5fAhxMUrFeXsUO6ADTTJR51NpToF hsSYc7X9CAULTcYfR8B0vVPKCSBFGAlKFYezDcpssGUr1XkxqwkoYNr4oJELhuT3g1dZAtUCq7 KZiEHQe3e0pcmqz0WMVP0XbVeVt61/5MTfsjPNBb3LyImEdQ0/6Nh4lvZgCg+MQDYg9qMH56G8 z8A= X-IronPort-AV: E=Sophos;i="5.72,400,1580745600"; d="scan'208";a="244312813" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Apr 2020 03:32:40 +0800 IronPort-SDR: jI4fmXWQa9C2w6jcXzjehjFgoxw+/QMjVJBnrov3z+eZx3FtMpCOhc9bVMZEX0QP3nQtUwv6wo lqW5nKumuTPQmR14Nk78c68ab1F7mKp5E= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2020 12:23:37 -0700 IronPort-SDR: kmLmqFR81WLodfZFsEkFay2t63Fg4PMCRKSzuQPadpn5KayNLNVI0tn9r8oQOBAin5006HAycU 6fJFdjiC66GQ== WDCIronportException: Internal Received: from cnf007834.ad.shared (HELO yoda.hgst.com) ([10.86.56.8]) by uls-op-cesaip01.wdc.com with ESMTP; 18 Apr 2020 12:32:41 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Bin Meng , Heinrich Schuchardt , Anup Patel , Lukas Auer , agraf@csgraf.de, ard.biesheuvel@linaro.org, Marcus Comstedt , Paul Walmsley , palmer@dabbelt.com Subject: [PATCH v6 1/6] riscv: Add boot hartid to device tree Date: Sat, 18 Apr 2020 12:32:23 -0700 Message-Id: <20200418193228.44209-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200418193228.44209-1-atish.patra@wdc.com> References: <20200418193228.44209-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 Reviewed-by: Bin Meng Tested-by: Heinrich Schuchardt Tested-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; }