From patchwork Mon Jul 10 09:35:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 117772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4904480vqx; Mon, 10 Jul 2023 02:50:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcMDN3BQTRWMlObay033CRjI/GlX35kvCfa7EBmMejzTbeMnBTRbtH0pHMXHByvzbPPtzK X-Received: by 2002:a05:6358:702:b0:134:e41a:9227 with SMTP id e2-20020a056358070200b00134e41a9227mr9757025rwj.5.1688982638861; Mon, 10 Jul 2023 02:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688982638; cv=none; d=google.com; s=arc-20160816; b=jSE8ZaT87/igw5qlGnkGjnjP+EbaEca+QfPCL0CpOAM6y38yswNzACBywz2uUVdN9b mAUKQwbsA0AP3xnC+yfbeFGeJTg+HcMXlCHYBAlsZCG49b95CFbTjpnJT/G+Pu4JeWnR M0+QWNp2J6uNYGAyPZpT0s9KdpUeR48YNbO8x0gjbaiv3N5Q/TxE949la1WOLlrPvAEY RWVGrkroS714t2hlUtfAV0Aqb58Tb3siV5sVQzuwlAWuZyqVdWvFFWf3bAbqoBW4X4EP ryLSQNiIGf6YgO1VIxKu/LXqk1cuLFS5ehEeT2iMa+ajb2Olu8vZXLyxh7PnHsoMM1EN JTPw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a056a0015d300b0068259969675si3656520pfu.297.2023.07.10.02.50.26; Mon, 10 Jul 2023 02:50:38 -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 S233081AbjGJJlM (ORCPT + 99 others); Mon, 10 Jul 2023 05:41:12 -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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771026659612541911 X-GMAIL-MSGID: 1771026659612541911 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; }