From patchwork Fri Mar 3 13:36:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 63925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp412492wrd; Fri, 3 Mar 2023 05:39:29 -0800 (PST) X-Google-Smtp-Source: AK7set/zQWT27fv6M2qH9uIN3OFrK7d+yvCQ+C2bAjpmgXtfFwlnZjL/Ib63vZWPNAbO48MFKqD/ X-Received: by 2002:a17:903:11cc:b0:19c:b7da:fbe0 with SMTP id q12-20020a17090311cc00b0019cb7dafbe0mr2145695plh.16.1677850768855; Fri, 03 Mar 2023 05:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677850768; cv=none; d=google.com; s=arc-20160816; b=QhKBYrFwoa8JRTnx0kEXUiS3KJG2cYv8tSMdstsCBqXeDBEc24VC+Sgp+9VSA9ivIK 3dRL3pggORZb1KK2SoMMBdFuC0EMhDvNZ5ST7suV8Ic5BeUT9NfiDOJrOr0UyovmpexL gkP6UevdRs7uAAYx9sUNfKeBhMMpqqLAyqeFXnNBzRtAG4kuZSXSl5eVRJH0wIBAbwiq pWru7wS7cofhxor5JX8/5hIIFuZB2B1JSdjEucn/IjzKRO55jeSMBpRk+kc3TE5GW6E8 0vmRy16hwDf1jsfOa8fcBX+bIESWruYQKE5h400XvX5syIbkWaQIzjx9wkRC6c9j3J5p IhUg== 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=9ZDqAIiQh1iz6zpk7hAy2IsEozk94KbzxqCS/Vkjh5o=; b=G0KbPE0ApZiE3zernawuwwYC1YAvWsAcwbSswLo42EdvuR4OYW5quFQ2zQvqfvNWgZ y+i0D50u9MXVHvB5Kvv15W0emH14inPrAyvdiVA6UotWbSIpiQwtwnoODf72Pq7u7bRi CJx2wRnk1dQWC6j4pidLln+DSb/wAG87rm9wWMiD9sY2ieFsXErBPLxXVXkbNA2oGeG7 tNp3GQqFnzS3dU4SYumfoxVmkgTVdw5m/Uy2QmjkHHBXsC7uqGMJYXkNIM6caS/gepiq E4YboLYJqo58/Ul+L8DkirCC1ik053U5cunZQMBKXEmAgyn5/qU7d02REnO/K2tMHh+e FPJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=n9umgm4X; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b0019e68e3228bsi2399181pll.166.2023.03.03.05.39.15; Fri, 03 Mar 2023 05:39:28 -0800 (PST) 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=@ventanamicro.com header.s=google header.b=n9umgm4X; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231350AbjCCNi5 (ORCPT + 99 others); Fri, 3 Mar 2023 08:38:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231206AbjCCNi0 (ORCPT ); Fri, 3 Mar 2023 08:38:26 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EF530C6 for ; Fri, 3 Mar 2023 05:37:54 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id z2so2633201plf.12 for ; Fri, 03 Mar 2023 05:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1677850673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9ZDqAIiQh1iz6zpk7hAy2IsEozk94KbzxqCS/Vkjh5o=; b=n9umgm4XarNc8gsfjp46IzZiTpAtE1BOvMr6t0GaPEd94V3o+dimvJdd2NYqtOt78O Wk+cZPGvnjxrCP3dVWSfVY9zKY3X8tqXfP3UdsGlTOPWW154spoB+PqEfdHwPD4Qpb/J 7LRu60H/NBGrMRCOkbBn+Dr0fJMKGQRJPePyLQ6anbUECkmPLh70AerRQEj8aUiZrnG5 u5fn27T3NYKQvJGj2iKX0KpqsKqK1amngKRdJ1OkVxEawrTVxLYuoc8z5OBzyFIm9Uwj YfO0Nnzktsu7Kdq4Wb/adAasHPg9ygDntDuGxorrprkG3NkNqIi/oSuy4LdlkhpXJtu0 CcEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677850673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9ZDqAIiQh1iz6zpk7hAy2IsEozk94KbzxqCS/Vkjh5o=; b=Q3OjnpBuKQx5TAyNoCPZ0ecvSX1OdIPqfrKc86xflni597w2POLOkDZ2CRBj3lX/eR 4yaO2L/A7QTWVqbGuhC3NlNT6/pxTg+l8hr0U6Us1Irf9Mu3THC0/aFBUGO4g527twqJ DjDozrjVmswnJFBxyqdVywtVT57bQlDtf4x33gR5Dv2GBY/YomILtlpNSwDvj69grMlK YksFg1dwQLzG2krXMOrn6H3UxE+s4Tm8LESTKwH09Gq2ONT66zAwqr1f7XAKGEYFb+uk kEY+FtaRt7ree5CU8Cy2iWhbynChS+BCVOF+nQvgJkA2VyeSdljckaZ9GE1+Knzpv168 +ScQ== X-Gm-Message-State: AO0yUKWmMcQajHu3xpwWhjyyljLlhW+pZt/R4GvcJf3M+e6kmdyDERTp UwgfL4W040M2bVJteMIm/fFzXw== X-Received: by 2002:a17:90a:db92:b0:237:44ad:5124 with SMTP id h18-20020a17090adb9200b0023744ad5124mr1650183pjv.42.1677850673253; Fri, 03 Mar 2023 05:37:53 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id m9-20020a170902768900b0019ac5d3ee9dsm1533125pll.157.2023.03.03.05.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 05:37:52 -0800 (PST) From: Sunil V L To: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Jonathan Corbet , Anup Patel , Andrew Jones , Atish Patra , 'Conor Dooley ' , Sunil V L , "Rafael J . Wysocki" Subject: [PATCH V3 12/20] RISC-V: cpufeature: Add ACPI support in riscv_fill_hwcap() Date: Fri, 3 Mar 2023 19:06:39 +0530 Message-Id: <20230303133647.845095-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303133647.845095-1-sunilvl@ventanamicro.com> References: <20230303133647.845095-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759354047785404656?= X-GMAIL-MSGID: =?utf-8?q?1759354047785404656?= On ACPI based systems, the information about the hart like ISA is provided by the RISC-V Hart Capabilities Table (RHCT). Enable filling up hwcap structure based on the information in RHCT. Signed-off-by: Sunil V L Acked-by: Rafael J. Wysocki Reviewed-by: Andrew Jones Reviewed-by: Conor Dooley --- arch/riscv/kernel/cpufeature.c | 41 ++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 59d58ee0f68d..478dbf129922 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -6,6 +6,7 @@ * Copyright (C) 2017 SiFive */ +#include #include #include #include @@ -13,6 +14,8 @@ #include #include #include +#include +#include #include #include #include @@ -91,7 +94,9 @@ void __init riscv_fill_hwcap(void) char print_str[NUM_ALPHA_EXTS + 1]; int i, j, rc; unsigned long isa2hwcap[26] = {0}; - unsigned long hartid; + struct acpi_table_header *rhct; + acpi_status status; + unsigned int cpu; isa2hwcap['i' - 'a'] = COMPAT_HWCAP_ISA_I; isa2hwcap['m' - 'a'] = COMPAT_HWCAP_ISA_M; @@ -104,18 +109,33 @@ void __init riscv_fill_hwcap(void) bitmap_zero(riscv_isa, RISCV_ISA_EXT_MAX); - for_each_of_cpu_node(node) { + if (!acpi_disabled) { + status = acpi_get_table(ACPI_SIG_RHCT, 0, &rhct); + if (ACPI_FAILURE(status)) + return; + } + + for_each_possible_cpu(cpu) { unsigned long this_hwcap = 0; DECLARE_BITMAP(this_isa, RISCV_ISA_EXT_MAX); const char *temp; - rc = riscv_of_processor_hartid(node, &hartid); - if (rc < 0) - continue; - - if (of_property_read_string(node, "riscv,isa", &isa)) { - pr_warn("Unable to find \"riscv,isa\" devicetree entry\n"); - continue; + if (acpi_disabled) { + node = of_cpu_device_node_get(cpu); + if (node) { + rc = of_property_read_string(node, "riscv,isa", &isa); + of_node_put(node); + if (rc) { + pr_warn("Unable to find \"riscv,isa\" devicetree entry\n"); + continue; + } + } + } else { + rc = acpi_get_riscv_isa(rhct, get_acpi_id_for_cpu(cpu), &isa); + if (rc < 0) { + pr_warn("Unable to get ISA for the hart - %d\n", cpu); + continue; + } } temp = isa; @@ -248,6 +268,9 @@ void __init riscv_fill_hwcap(void) bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX); } + if (!acpi_disabled && rhct) + acpi_put_table((struct acpi_table_header *)rhct); + /* We don't support systems with F but without D, so mask those out * here. */ if ((elf_hwcap & COMPAT_HWCAP_ISA_F) && !(elf_hwcap & COMPAT_HWCAP_ISA_D)) {