From patchwork Sun Aug 25 04:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1976440 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2oU5Q9Au; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Qkz7X63c; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Ws0Xm1ZCJz1yg5 for ; Sun, 25 Aug 2024 14:03:32 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4+EJEHKHlLt42Bfnz+4bb40kzxIhovGjmc0E8H8cou0=; b=2oU5Q9AuP0eLA0 /c0fu7BAp5xQhpn2W78d7uBGOh8E/2sP/VRX5fJ8K4+i5fDCtkdHM5sNjtYj3hJbTiWU41fCup6NM 6wCEg5Bi4b+mLQgkfbSuHpu9/pBXZxMSeKc/lT8wFuHAS5w6t3oSANbTd4h7Ac3Psx8P2tG+TzTu3 MQEeyNENguw0YyB09mi7JUa1Q3nPBma3UzRKpY4sqOKq9VOY59HXpzkpCaSq0mMSuT8gQrKunvjl0 rzOgDZ+meSUlapai5CiFZyPGfuvQuSS99p0M+GK23m19GEN2sW5HONT6jdxxXBGhKP567uIV5fXJY itN5T0ZdEx4ywSFhU1jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1si4TJ-00000003UrM-38U7; Sun, 25 Aug 2024 04:03:21 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1si4TH-00000003Uqj-1ASf for opensbi@lists.infradead.org; Sun, 25 Aug 2024 04:03:20 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-429e29933aaso26043425e9.0 for ; Sat, 24 Aug 2024 21:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724558597; x=1725163397; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QOPkTDGpgFqfij5dxUATwLebIJdJR1E+x3FAoOOrUqQ=; b=Qkz7X63cH2M5lQ3ETvIj/vrRDsekGzb26L07eIBNz2Eznjb2EM/ZUc6cisOrhODzmv xTmioBQIkGdkNE7X4aPbpiB2hfTofFy3/8cl07h25RMpP7i4SO2i+EWErXn1dNeFHvpY 9e40ouaT+OG5cj3a41tc54mMbyVmhNjJSGvMryQr5PwBvObDTxz3+toUogiEtjJO1qfU T6LnLfrh5Z5NZ0b2Hn9dSq8tJcWtGmvpWBKOx5/B0+s5209eiyv9f8fpd6ZYpFpGVS3c 1pAykFHwBfYngRh9kKrxZ0HxtPWHrmjW3+lEZ6mNcGx1U/46/7qBsjdsng2jGyhVk50N gbww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724558597; x=1725163397; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QOPkTDGpgFqfij5dxUATwLebIJdJR1E+x3FAoOOrUqQ=; b=KslmlD7BB3k1C1QdOmPFSlIbdfUxq1ztYUg7xZJGMHSnuR5g2EFAPGgTnCbryOUBkM P+djPh5TuIAwLHpFSYn7iVbTkR1574L0FO+XlK0/O16/bf65y59n7ZZioIYs5j64INdX QxyfF9bqKzJ2976lqG6q2ffrz+61XxsJYSMITQU+i31rlIFHrHY4qiAdHZxBfrJlkgKF zT2CqoCh+SfrVy8AcOBad3ZRdQRTiPKXCScr79cIXNEIx0znean1lu0sx1Z/FQbWaWNV +xUb2N+QefWcQeKBbCiwp9Z+G6J4tfnyFc3T8YMWI4XciaiCxhY/T+di+LpIA8RFOeMu eanw== X-Forwarded-Encrypted: i=1; AJvYcCUIZu2nLeIC3P8WzF8fvk4YN4Xr7aY8rYI/cIqwdqK+DXZYxKHCsvNx3rv80gQlENopRIA87z+j@lists.infradead.org X-Gm-Message-State: AOJu0YyPyoPYcPWmpKrgYi3VPAWUmGZzkJsTU3/apJYZiKf1bQRk55fT 1/4pbco2Dt9YsLYFp5+wM4UpYLZBrtC9oqOsf6tZh2RgnvE9s6LQWShiKgoqKu8= X-Google-Smtp-Source: AGHT+IEQrkT/uGrvGjk20sH/QI2dlwlooDhOiAX3V2n8U2ZrD03JAiYs3WDVeo+u+A64eeyod3IXfQ== X-Received: by 2002:a05:600c:4e01:b0:426:654e:16da with SMTP id 5b1f17b1804b1-42acd39e07cmr48463455e9.0.1724558596126; Sat, 24 Aug 2024 21:03:16 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abf019dadsm150322695e9.48.2024.08.24.21.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2024 21:03:15 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel Subject: [PATCH] platform: generic: Fix fw_platform_coldboot_harts_init() function Date: Sun, 25 Aug 2024 09:33:05 +0530 Message-Id: <20240825040305.3947940-1-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240824_210319_347497_17619480 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: It is possible that the OpenSBI config DT node is present but the "cold-boot-harts" DT property is not present. In this case, the fw_platform_coldboot_harts_init() will do nothing which in-turn causes [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:333 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org It is possible that the OpenSBI config DT node is present but the "cold-boot-harts" DT property is not present. In this case, the fw_platform_coldboot_harts_init() will do nothing which in-turn causes OpenSBI firmware hang at boot time. To address the above issue, fallback to the default approach when the "cold-boot-harts" DT property is not present. Fixes: 67ce5a763cfb ("platform: generic: Add support for specify coldboot harts in DT") Signed-off-by: Anup Patel --- platform/generic/platform.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 8a0ace83..d1fa84bd 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -102,26 +102,26 @@ static void fw_platform_coldboot_harts_init(const void *fdt) goto default_config; val = fdt_getprop(fdt, config_offset, "cold-boot-harts", &len); - len = len / sizeof(u32); - if (val && len) { - for (int i = 0; i < len; i++) { - cpu_offset = fdt_node_offset_by_phandle(fdt, - fdt32_to_cpu(val[i])); - if (cpu_offset < 0) - goto default_config; + if (!val || !len) + goto default_config; - err = fdt_parse_hart_id(fdt, cpu_offset, &val32); - if (err) - goto default_config; + len = len / sizeof(u32); + for (int i = 0; i < len; i++) { + cpu_offset = fdt_node_offset_by_phandle(fdt, + fdt32_to_cpu(val[i])); + if (cpu_offset < 0) + goto default_config; - if (!fdt_node_is_enabled(fdt, cpu_offset)) - continue; + err = fdt_parse_hart_id(fdt, cpu_offset, &val32); + if (err) + goto default_config; - for (int i = 0; i < platform.hart_count; i++) { - if (val32 == generic_hart_index2id[i]) - bitmap_set(generic_coldboot_harts, i, 1); - } + if (!fdt_node_is_enabled(fdt, cpu_offset)) + continue; + for (int i = 0; i < platform.hart_count; i++) { + if (val32 == generic_hart_index2id[i]) + bitmap_set(generic_coldboot_harts, i, 1); } }