From patchwork Mon Jan 30 18:22:15 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: 50410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2331672wrn; Mon, 30 Jan 2023 10:28:10 -0800 (PST) X-Google-Smtp-Source: AK7set9xua5aeJzlsou3c9iq4yZolDFqCNCVZ73RRIr/7TUBdrj/dU0/rz4SlM+fVJbClEu+OzXU X-Received: by 2002:a05:6402:2707:b0:4a0:f786:d887 with SMTP id y7-20020a056402270700b004a0f786d887mr467508edd.35.1675103289940; Mon, 30 Jan 2023 10:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675103289; cv=none; d=google.com; s=arc-20160816; b=vtA+cubKJeLjAWSNNjUgz7IHZNkib5UydnISApPU/sCPBwdeyPUdbEkjKTH+c6E0+1 9E9CWmoiSGw0ZjU8yZzO/GhjJrU7FrRDN1w7hW5ZAJ70NgNU+Kyo396dwWAnl4Ag0Zm9 OZ7uHmeMgiF/WuWtERrJxBxW5fIpkz2DAgCHT9diT0qvdZtnEshSGB6MLb3EP8iH/1He uY4AawNvWeyGi5qRVEcncWuOvz+868QT4Z3JUcAVQVEeyp5yR/mXRNdyoLDqF2NzmCoV O/ZQOUWAtK7+2FVfsFujylg94U+YFHWwp++0rhcAgmUIuvY/97AuYN3FybZApuwn4oDe DHgA== 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=RoNsoxjlD8YqMSH0pVqFEhvuCFLj9XoDBF5p4r2NIfw=; b=ShXyVCqx2MxMfrG9LjWDJroENSE5VYgZ2CEZeB+L9uyWdrLargenQXIJObWL+td8Lt B/jJQ2kdkgjYqZrVXRCTfHmEB9Ccb4tR0YooPiTGiKQdXoxkvg5cOEMCur3c+CxaG2kF M6tVhbb2HcT2po5H0oZZq7nlRecfSUaiAByFVgidU19IpEsuXgOmGDuo65CT55YP3LPZ N/BnWl8iiSRxJa4ASxXl6JPl66CyJ6fxAHyAFwM4Li8NbCNVfYqZYUdY2ogIBJcobfLO VJkYkw7MJWQhq9bBRAltYqqUXKfijB9c/OZFDGH1I9Ylhjf+TXXIre4T9+9trWHJTQvv szSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=iDP9c7Ap; 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 fk24-20020a056402399800b0049dfd2a39a8si15282647edb.153.2023.01.30.10.27.36; Mon, 30 Jan 2023 10:28:09 -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=iDP9c7Ap; 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 S238007AbjA3SZQ (ORCPT + 99 others); Mon, 30 Jan 2023 13:25:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238065AbjA3SYd (ORCPT ); Mon, 30 Jan 2023 13:24:33 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95E8845BC7 for ; Mon, 30 Jan 2023 10:23:39 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id e8-20020a17090a9a8800b0022c387f0f93so11348925pjp.3 for ; Mon, 30 Jan 2023 10:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=RoNsoxjlD8YqMSH0pVqFEhvuCFLj9XoDBF5p4r2NIfw=; b=iDP9c7ApKkeB+Xt1IY5/R1iq7FKDBdju6Gcvu0MaOJbVMwIYqvi+FcQp3Rhci/cc5J KoQD04jyy6VO99ZWoK4TcBtQinWwKlBtUXVq3L7bE9PuU/ZVfJG9ZCmXLl+WB4X4i4VW BQpf68cV9//tP+mZrgsx+74mDrgOxMSmF+WLXD/OqoqKebupmq+dwbG9DqtQJs/RxbTS 8jSuMpnxiU8ENHw7dfJQKKAbDN77oYx8eR8SpY8zpqyoTO6+8cAjE6RwhM5HRoLPSZFa LiT0HjazTXTYtwFYqfZkPowj9WignKTXYrWH5vPlbv3ghQ6swvcBM1zRLcTrjOuNKGfX v3rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=RoNsoxjlD8YqMSH0pVqFEhvuCFLj9XoDBF5p4r2NIfw=; b=eYWmUSyzU2ZSBH+eQC7eYLer3UATT837Hu/qJaGUoqkbSJEGP0vXH1G4DPcIKAPAnA J9an8pIG8iCGMI+2wZXIFrmdyXtTyOQejrQhucyA3/NSfWB3WMLYnkoc2Nmot8useTJe agE64D9giOHSlEazqqk+4SuPWecQ7FBZZqj+NK8D5dy7rDvUyTXzvUuZTcnEyPHFftLD sqS4abwnFNcXSBl1sia5H+IHa1eS27A2KMTpkbLU+X4Pmqk0L9cc+fXGESWZa2reIV2V Zl3QOxN6ou+d6pVg0Fmy+mZnEtNTW+eP/bAGIh7gGYc6ZkjsNKOidn40yqiafyIwa2cL HD7w== X-Gm-Message-State: AFqh2krV4IQ8QS/YuAHnj13YwesFvCchahgnBr5dXtZkuX6OPWKQ0rV1 8HOah7cywGm3Ul/Z7dne4xqutw== X-Received: by 2002:a05:6a20:8f02:b0:af:c871:bf4b with SMTP id b2-20020a056a208f0200b000afc871bf4bmr70215553pzk.26.1675103018053; Mon, 30 Jan 2023 10:23:38 -0800 (PST) Received: from kerodipc.Dlink ([49.206.9.96]) by smtp.gmail.com with ESMTPSA id j193-20020a638bca000000b00478162d9923sm7000291pge.13.2023.01.30.10.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 10:23:37 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Thomas Gleixner , Marc Zyngier , Daniel Lezcano , Jonathan Corbet Cc: linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Anup Patel , Andrew Jones , Atish Patra , Sunil V L Subject: [PATCH 14/24] RISC-V: ACPI: smpboot: Add function to retrieve the hartid Date: Mon, 30 Jan 2023 23:52:15 +0530 Message-Id: <20230130182225.2471414-15-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230130182225.2471414-1-sunilvl@ventanamicro.com> References: <20230130182225.2471414-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?1756473107745603354?= X-GMAIL-MSGID: =?utf-8?q?1756473107745603354?= hartid is in RINTC structuire in MADT table. Instead of parsing the ACPI table every time we need for a cpu, cache it and provide a function to read it. This is similar to acpi_get_madt_gicc() in arm64. Signed-off-by: Sunil V L --- arch/riscv/include/asm/acpi.h | 14 +++++++++++++- arch/riscv/kernel/smpboot.c | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index d1f1e53ec657..69a880b7257a 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -65,6 +65,18 @@ int acpi_numa_get_nid(unsigned int cpu); static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } #endif /* CONFIG_ACPI_NUMA */ -#endif +struct acpi_madt_rintc *acpi_get_madt_rintc(int cpu); +struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); +static inline u32 get_acpi_id_for_cpu(int cpu) +{ + return acpi_cpu_get_madt_rintc(cpu)->uid; +} +#else +static inline u32 get_acpi_id_for_cpu(int cpu) +{ + return -1; +} + +#endif /* CONFIG_ACPI */ #endif /*_ASM_ACPI_H*/ diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index e48cf88d0bc1..3a8b7a9eb5ac 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -73,6 +73,25 @@ void __init smp_prepare_cpus(unsigned int max_cpus) #ifdef CONFIG_ACPI static unsigned int cpu_count = 1; +static unsigned int intc_count; +static struct acpi_madt_rintc cpu_madt_rintc[NR_CPUS]; + +struct acpi_madt_rintc *acpi_get_madt_rintc(int cpu) +{ + return &cpu_madt_rintc[cpu]; +} + +struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) +{ + int i; + + for (i = 0; i < NR_CPUS; i++) { + if (riscv_hartid_to_cpuid(cpu_madt_rintc[i].hart_id) == cpu) + return &cpu_madt_rintc[i]; + } + return NULL; +} +EXPORT_SYMBOL_GPL(acpi_cpu_get_madt_rintc); static int __init acpi_parse_rintc(union acpi_subtable_headers *header, @@ -92,6 +111,8 @@ acpi_parse_rintc(union acpi_subtable_headers *header, hart = processor->hart_id; if (hart < 0) return 0; + + cpu_madt_rintc[intc_count++] = *processor; if (hart == cpuid_to_hartid_map(0)) { BUG_ON(found_boot_cpu); found_boot_cpu = 1;