Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25957957rwd; Mon, 3 Jul 2023 03:32:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlH3toshxmzq5mV46RX2ECB5oVlGjzwoRcFo/17E9hoNuZc8koqUNtMb0xeA4nvP/pgCEtaq X-Received: by 2002:a05:6a00:24d1:b0:666:8cbb:6e0f with SMTP id d17-20020a056a0024d100b006668cbb6e0fmr10562104pfv.3.1688380374168; Mon, 03 Jul 2023 03:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688380374; cv=none; d=google.com; s=arc-20160816; b=OD6r64t3IsRY0+1DgRDNYJT8ncs9H5PaQyxuzl+Uw2ZBD+6nei9l8G3q8ZKBKcO4tg 8xJZ7QWkdMEL/5ATTeTGk6rNzsdKl8EJXGCCyoVc0OOIemt1jjfC6Mv8uPUXhcgQV3/C 4J6q6Lhs7O/tp+pPLs9PK8KMI9UF9y/t3xeSU8jbRUnre3ANKWkghIIGxzmWKZ3wjqy0 eP16b1ZnMDNPZ7q3Gp14X7EvWZoPyLaE7VuTt2583wFBZPocoaFsPekFrH+CKxguNnAB DfhQ2uFmpmWoGB50KKUBHbh2k12wfjJSJoRfUtBmC1JiFM/CwBvsZyCUEDfCZ1lLGL39 cEfQ== 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=bxJz0t5bp5GEu+Lq5f6BwBZjyRyJDg2/TVrU9Vjahow=; b=dXAUmcOlovyuqKuQx80illb6U62R4KMF0cTaAs5pyRK2oFcFKiJl3qObSJyU18SXVn fEHYiFrW2qLgtdRnYLOKJOHJowLlAeS6ikjOAAesp3NS5fu4Xetcoks2SC9Pgrm3txi2 m7WkZCudMhR1YZN+eQmkxxQaU2JyE3AJoTaLe2tk4wEO07c3AeanGI5tnJ86P8LjxkKJ aY+WqwyPJq1ZoOTJta1NnvF6A1BBACvth9LcsVppYcaH8/J46FRjAzx7HUCBgSrIFJE0 BLBxscTkVDbH3FDcGuy9/0LHC+y6XWdk1w3gvI3vVxMwuz5bMSGTvCqio+Ks7DZD/K0A okRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ATjwGeEI; 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 a5-20020a056a001d0500b00666b1fb841dsi15148668pfx.7.2023.07.03.03.32.42; Mon, 03 Jul 2023 03:32:54 -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=ATjwGeEI; 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 S230200AbjGCKat (ORCPT + 99 others); Mon, 3 Jul 2023 06:30:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbjGCKaX (ORCPT ); Mon, 3 Jul 2023 06:30:23 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CBF1BC; Mon, 3 Jul 2023 03:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1688380189; x=1719916189; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6+4fXO0Mgsbn0oR0/2jnJO0XttLzGYmDlCcJv+2evZU=; b=ATjwGeEIoXc2N0UPeCWuTd7bdd/DaPaitdchFzlAEkDUZ+/rNIBL299s MsPy8S/3HtCe2C451vwy8M3nGxKT+Flk68fLQXbdBB71VTiHH4y3a2745 UmlV1lz8mtfAohq6+tZcUSQsuzoUajr4sgSr1RacBUibUkrNPPaKLR334 WoslxfbGtMNqlp+F5lgGZ28EVTjToJfj1sVyeWJqGpn2OW3HRJ6/t+81y j6kYoEuotOoB5aLb6k5e/uupRmA2p/MrlcLv/qo2cb1HC6B5PnfNN8L03 sA5Fhkrj12muXIHRCk3U/aqvLiHkvDVr3ybrlV9Jw7vdQhnhW+WZ81cVD Q==; X-IronPort-AV: E=Sophos;i="6.01,177,1684825200"; d="scan'208";a="218684000" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 03 Jul 2023 03:29:30 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 3 Jul 2023 03:29:26 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 3 Jul 2023 03:29:24 -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 v3 10/11] RISC-V: try new extension properties in of_early_processor_hartid() Date: Mon, 3 Jul 2023 11:28:02 +0100 Message-ID: <20230703-reroute-glacier-86c7befb1a13@wendy> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703-repayment-vocalist-e4f3eeac2b2a@wendy> References: <20230703-repayment-vocalist-e4f3eeac2b2a@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=owGbwMvMwCFWscWwfUFT0iXG02pJDCmLFq3ZlDpFRt/L9nzj/hem8ytrnk/12TVfwGZVT9/etXnK e/htOkpZGMQ4GGTFFFkSb/e1SK3/47LDuectzBxWJpAhDFycAjCRKD1Ghkf2XxJm7r3CPfeQ7JTtnx MTHvDffs49L6CGhcVn4pZTP0sY/tcsS6q8YVxSeEeM70KLxQ/zJ+d2n7TfyVBo0HLozC07E14A 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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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