From patchwork Tue Apr 21 18:14:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1274457 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=J/GmQfOB; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 496BZK2TNJz9sSJ for ; Wed, 22 Apr 2020 04:15:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1FF7D80574; Tue, 21 Apr 2020 20:15:31 +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="J/GmQfOB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2D58480574; Tue, 21 Apr 2020 20:15:27 +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 esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (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 BD8D880574 for ; Tue, 21 Apr 2020 20:15:17 +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=37371f929=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=1587492917; x=1619028917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YkRRfGkSs5zCkCaQpTv63vHpjqabQevOVKJYULr0ccM=; b=J/GmQfOBPblT4UlqIeRnflIsiAO3BQlNhM5q/5K3EjNj/ueVIZQCluFs H4w46g4aWEpR49ENLZx2R4zWVs4tJZQ/sNp6pKGrTE8DnBdBz9R/cSVxr MZPtEBAVqcM2robtG6JrWuLpRMhfHvZT8VtQaC3aRBsbUulwXxLEb06lO V6BxqVNupnA9mJuj31/WdXtT4RXU/wnJZDvldxArNE3HG6lV4jcqFGtWJ 8zLbcm/vHUrR69d+rXz9BI3OjYp7zK4L0DYwPCGOGzrUEIISM9eTohHHz 9S7gLVkiPL/U6fsWOpfTHWd5hW4Vs712dbhmbDlMiO2PRf3rgdVw8EJu3 Q==; IronPort-SDR: gJTOLv/t1Lz2QjOCEidGRdSfeid+bZddVZjhEbR5UOHG48UR+mwn1iUKs5VJaE13XTlAZlyaJq OzvyiMMuU1RRnvm46NVcA5AKqG374Km9hkrRW+VVQ6Fa+Yly9mFSxMfLnRhfiQE7W5mBY/AgaK ybdtEJFXvhrB6aQ8MBu9wLWC1GZl6nNMZaZ8zBjfAGdG4SwaCODgdRi54WOWlDDtaCousfmyKT U2C/2yF2xJSO6DIVK4i3H+0GBq+GkYkh+URYOyLehYM8lXsfU8gp5xHT1cVMg77T9s1mn3U49C VII= X-IronPort-AV: E=Sophos;i="5.72,411,1580745600"; d="scan'208";a="135816941" 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; 22 Apr 2020 02:15:14 +0800 IronPort-SDR: HYqbvdxmPqz0/Jjsl4cNvUu8EeNntz1gHbmFw4If/cSsnDOtHHZMXw8heL/7qlyS3r9EF00lzP O2TPExhHGF9uBvm6hloaIZIAhGGd+z1xU= 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; 21 Apr 2020 11:05:33 -0700 IronPort-SDR: fMkDL1Hu+Wo3jZxstuHQNPjU6mb9Kgny381drBqkf9CdsKKuuIOi5f2BKkvHWwelNY0JWizadU Pwrbch9KtaHg== WDCIronportException: Internal Received: from usa001638.ad.shared (HELO yoda.hgst.com) ([10.86.55.248]) by uls-op-cesaip01.wdc.com with ESMTP; 21 Apr 2020 11:15:15 -0700 From: Atish Patra To: u-boot@lists.denx.de Cc: Atish Patra , Rick Chen , Bin Meng , Heinrich Schuchardt , Anup Patel , Lukas Auer , palmer@dabbelt.com Subject: [PATCH v7 1/6] riscv: Add boot hartid to device tree Date: Tue, 21 Apr 2020 11:14:59 -0700 Message-Id: <20200421181504.415822-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200421181504.415822-1-atish.patra@wdc.com> References: <20200421181504.415822-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 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; }