Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35124683rwd; Mon, 10 Jul 2023 03:00:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlEx3tJD9oqCN0HVQuv4iiny5IRb7CS2wST/oCKB32P8p4pKzdgPlEiQXmuSZQVATxzbAg+I X-Received: by 2002:a17:906:77dd:b0:993:d536:3cb8 with SMTP id m29-20020a17090677dd00b00993d5363cb8mr8837645ejn.2.1688983222650; Mon, 10 Jul 2023 03:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688983222; cv=none; d=google.com; s=arc-20160816; b=SyjiyGlqdQJGjxyTR8myUqVofssTsALD8gxRA2QCL+hmu3pX1w8w2sY9Kqf+t/uqVO Jg4Rq3kasfS/udvdgb2eqne6uTijYIn9/jKSfPLo46JOwKWsEi2DOlTO4yzXhgP4I0Xn DciBhvAR3kwmp4SlcKNorFGiiNpTq5sx/sY/sESQFfjahM2Fd8damNBmgH5IkOuQpq8r 8EynreEGAEYp5wAqMTkBe9oDVmzXAGkzpe/jN8Ihv5xrLKAcSgRU28lOIoo+Xed0qQ6I iCoqSkAQul1cW7YF56mCtkRmsHOdjK4/xU/QwFLg+4+UoxM+Ayf5z0UHRRp0tWpM+XGV 5sFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7mRMEMCtqtAeUOhcKcRhtWdUcJLYolxHwb3sQJY5g/Y=; fh=+t+G/OXZaGbelVlx/PAQKy/ssq96RZ9Njlv0n65gx60=; b=wuYkmZz02x9bbxBAwMhnGI87yqshGSd2hWY6Qo5x8SCrqVCSTnkRaegHct3SlnqdgI lm6tBRplW1XM4dvSHvin/JG0lQdoS8OJW82fHDOQ6IPkTIZxxLQKbU/VW4S0op2w3jZ1 DLHbAM3/87TbVzzSxD4OsnAXsZXXfPjibDSmrI606rhj7phb64Yl2DyGACFz2g2HS9z6 BCq8Lmp1d5m21PtDfXKH6lRbX8pFOtJ0nwlz4vBR+agwQ49J066zyUuhm82hL3LYUua2 k70EA6/oL15LEqenF/0O2aCrqonyoE6qex3CqZu5Mt9H3NqoU0n9MzhCM/7pWT2DryRE fCGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=r3P7ayFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a170906694b00b00988919c8a70si8692529ejs.59.2023.07.10.02.59.58; Mon, 10 Jul 2023 03:00:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=r3P7ayFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233008AbjGJJlL (ORCPT + 99 others); Mon, 10 Jul 2023 05:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjGJJjy (ORCPT ); Mon, 10 Jul 2023 05:39:54 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB079272B; Mon, 10 Jul 2023 02:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1688981850; x=1720517850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6+4fXO0Mgsbn0oR0/2jnJO0XttLzGYmDlCcJv+2evZU=; b=r3P7ayFCc7VSFCyHJhjOMbwIuX+iUDOXzPiX+hIzlsQ8Rpxqs4/+QV6i y8/tUGmKeYsviZwN+phnnef6J54EVLctrxJYHS+0bc5FTLtbY+KghrL2X o8rRsoustQlBK40WNrA8JwlX+cSUhcdFf0HNemwdYTJOQQg6FA/qnRh/z p32mscb/l4oSkO8FXm+7dxEsiBTLlz2pBcvHOqhZ8b48vcDB515cuntsT haMV/W0HwxaAvdTSnqtGhxPD3ZSDDDqVjyBvOWwg420WPPR3xry0xWogx v5dS53FHWeOayb45k8Y6swet68V9trmBVB0ZkeD7IRLmslgLM3VrwVufE g==; X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="160600140" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 10 Jul 2023 02:36:57 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 10 Jul 2023 02:36:56 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 10 Jul 2023 02:36:54 -0700 From: Conor Dooley To: CC: , , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Albert Ou , "Jonathan Corbet" , Andrew Jones , "Heiko Stuebner" , Evan Green , Sunil V L , , , , Subject: [PATCH v4 10/11] RISC-V: try new extension properties in of_early_processor_hartid() Date: Mon, 10 Jul 2023 10:35:45 +0100 Message-ID: <20230710-multitude-badly-1c149269766f@wendy> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230710-equipment-stained-dd042d66ba5d@wendy> References: <20230710-equipment-stained-dd042d66ba5d@wendy> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1977; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=6+4fXO0Mgsbn0oR0/2jnJO0XttLzGYmDlCcJv+2evZU=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCmrL9wUYbX9WD13y3kjpZ6UTf6/rI5c3FPLXPWjZuX3dq9n +26zdpSyMIhxMMiKKbIk3u5rkVr/x2WHc89bmDmsTCBDGLg4BWAiZ14z/OHlcuBud/F7OUvh6rOLUz d3drdqfX0TZPrtdeJyvT1H1pcw/GbLiw/LZXpsc0+rUSCqLyLlkafxM5vbJo3P9/tfuvCigBMA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To fully deprecate the kernel's use of "riscv,isa", of_early_processor_hartid() needs to first try using the new properties, before falling back to "riscv,isa". Reviewed-by: Andrew Jones Signed-off-by: Conor Dooley --- Changes in v3: - Add some printouts to explain what went wrong while parsing harts, so that if none are found there's at least a hint before we hit a BUG() --- arch/riscv/kernel/cpu.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 4f1f12f34b63..28d5af21f544 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -61,8 +61,35 @@ int riscv_early_of_processor_hartid(struct device_node *node, unsigned long *har return -ENODEV; } + if (of_property_read_string(node, "riscv,isa-base", &isa)) + goto old_interface; + + if (IS_ENABLED(CONFIG_32BIT) && strncasecmp(isa, "rv32i", 5)) { + pr_warn("CPU with hartid=%lu does not support rv32i", *hart); + return -ENODEV; + } + + if (IS_ENABLED(CONFIG_64BIT) && strncasecmp(isa, "rv64i", 5)) { + pr_warn("CPU with hartid=%lu does not support rv64i", *hart); + return -ENODEV; + } + + if (!of_property_present(node, "riscv,isa-extensions")) + return -ENODEV; + + if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 || + of_property_match_string(node, "riscv,isa-extensions", "m") < 0 || + of_property_match_string(node, "riscv,isa-extensions", "a") < 0) { + pr_warn("CPU with hartid=%lu does not support ima", *hart); + return -ENODEV; + } + + return 0; + +old_interface: if (of_property_read_string(node, "riscv,isa", &isa)) { - pr_warn("CPU with hartid=%lu has no \"riscv,isa\" property\n", *hart); + pr_warn("CPU with hartid=%lu has no \"riscv,isa-base\" or \"riscv,isa\" property\n", + *hart); return -ENODEV; } -- 2.40.1