From patchwork Tue Mar 17 21:19:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1256965 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=By968chO; 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 48hmKr5jHkz9sPF for ; Wed, 18 Mar 2020 08:20:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2684812D3; Tue, 17 Mar 2020 22:20:16 +0100 (CET) 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="By968chO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE14181528; Tue, 17 Mar 2020 22:20:12 +0100 (CET) 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 esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) (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 31EEE80721 for ; Tue, 17 Mar 2020 22:20:05 +0100 (CET) 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=3382782c6=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=1584480007; x=1616016007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aGRwAHLabl4ETDwU1f15Gse6/o8sYxXuAnbohjK+WzA=; b=By968chOCzvWoOm9xweGJ1JnrxtP6tRvyhcZNOCZf+9XA2COAOJyT+f2 alJz4UIegCRaumP0MT1JRDQ3UhapjCqRXMBpsKSSP9UHHnuAeaOg8puy6 uD6OHu9MkY/9B+isaM3TKliMbivqDRC6pO1Od3F1WorpMCYAcUxD3IiZ5 Ah//f+nh3ydpoA63YGPzVKjehIKGWKKwZwDTnFtJn0rCchoxeCwjQ06rc XzbZRzaYMcjP40sj3L8zpD3be3ootEEL3YLudgX/VmMNO7oJ9t02C+cpC iQ+pyJgIzsk+c0y6HOXKqBg12ts7TklcHSS7bgvClynlLIRci9xfsn+Bd w==; IronPort-SDR: scVauOP9BS5Uq6o1YVqMJzGP9IheGFqtsLbsAj+J3skbFtSXREdqVhY6eRHuiq3dk0wUM0udrp GSEWfemBeQ9ASnQa1dKgop1m41WHXB4t5QeJguN5rMe9wyZ16o4UCHWQM668Ku0KsPN2HuqZza sLQnUOZz8CD5Fztv/weuqTuzqfSG7msmNSUEAIamb3LebzDQQSEZawU0PjKILmMqKOjb6Dwn8F tJTdexuCY8bAUiefEpyeawua25wNT1KemsZf2E09I5h0BZNlo3sUi+8PlVNhqTvnJ6Sp1IwK7C C7Y= X-IronPort-AV: E=Sophos;i="5.70,565,1574092800"; d="scan'208";a="133222678" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Mar 2020 05:19:56 +0800 IronPort-SDR: RvsMqO41N84FFuZq7RHY9pWAMQ3Fk2GsC7dM3hwrzxKri5hv2Eq6pHTtn5C8wWHIhTYnxxaTls z66ykwCTlpPe9kot8wyhQKeVgVlMxifaRUjqM9O47huO+Wr8HQaNt7A5gmom29K9SrB0lX2My7 1ju5wd5O1ljimJIeeASfzhmkGfHdIJiaUIUoHz2QS8Faiq90XXTnR7VBFRm1+JWKftIOTtkht6 3e4aRkUtwzgXhuDVFBd5ewzK5hryTLeD5kNODdnzx2HFWe+vI5lH8yGORH7iRIgv889DVVNmgE K3WCu4HBggzHQDI4Jy+NY4TM Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2020 14:11:23 -0700 IronPort-SDR: VjsdOfRWruvoafC4I4tmQTeF4gEbpFKnixo2+0lhGqNRtdgEK5ycQCBgTZ4eWrl7FtBYkq0K8H taPH2tlfomt+hf+dR+yOcswDp789jeThnnprVepxaBr0YCfr39Tn+COhjRJ6R3TMjzHKqXW8EB c1CR2gFh5bGbeEHUStsUy6ej0o+haomauMDfvoyZ+C3oRtkK4e9Jex47MdyUlWb1DU1ZcYEvRd WAXuoxm/VaFN3FtKUqeirpc4JKz6w8H9ErCsBQqvQGOGljLUXsX6S6j0HsxnVfDysu9lHc364p KVs= WDCIronportException: Internal Received: from mccorma-lt.ad.shared (HELO yoda.hgst.com) ([10.86.54.125]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Mar 2020 14:19:55 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Alexander Graf , Anup Patel , Bin Meng , Heinrich Schuchardt , Lukas Auer , Palmer Dabbelt , abner.chang@hpe.com, daniel.schaefer@hpe.com Subject: [PATCH v3 1/5] riscv: Add boot hartid to Device tree Date: Tue, 17 Mar 2020 14:19:42 -0700 Message-Id: <20200317211946.28062-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200317211946.28062-1-atish.patra@wdc.com> References: <20200317211946.28062-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 --- 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..f927694ae32f 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) { + u32 size; + int chosen_offset, err; + + 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 -1; + } + 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 -1; + } + } + + /* Overwrite the boot-hartid as U-Boot is the last state BL */ + fdt_setprop_u32(blob, chosen_offset, "boot-hartid", + gd->arch.boot_hart); + return 0; }