Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1590094rwl; Wed, 5 Apr 2023 20:53:09 -0700 (PDT) X-Google-Smtp-Source: AKy350bm4NSQOC4RC+32Ee0TV9PoYYGFcRBBm62tVY2vLm202chRCz20GK9iDwgCvWsNSd7BuYgx X-Received: by 2002:a05:6a00:4188:b0:62e:1896:6fb3 with SMTP id ca8-20020a056a00418800b0062e18966fb3mr4589681pfb.3.1680753189590; Wed, 05 Apr 2023 20:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680753189; cv=none; d=google.com; s=arc-20160816; b=OKKl+LdtkdUAXOwH9U/5ovhfwcgYfdDzCo5XfgJ7nxLKpMSzNSfrdiqTkXz96v+2PR +EkKefGbiHezekon3npyuAdVFjUKoJdz1OL75Ymva5dl7sdJ0mR02crXneiiMfNLvFou jCmpTM50H+87BGyRga7wNjAzfpuqDw5qA4OjCWHg9GZ9mT++wqlrfwI2PLTM/ZyFUcC2 LAcP/x5zZwhGbFuzWjW77NikretuKOV3SuS+PXju5+XXZOMXyejZy0hk4nBdtBABUeYc ygajSGGpi5vkNFugflUm7OOTZ4WtV3xzqyun0V4aBYBFAUJdXUMmnwpE+gJs3WrJorpz fh/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e2HC8P/hmf80QzMRLst56jAGHCnOy19Nb1SfXkyKnng=; b=uB5HVZlNofbvOdxT9zKDvVPYT2TnmvVis53LwISASVxCr0U0+4GmyeB+M6houTGUDh Fha2m5VIbUgKonj95V67Kw4K7DoPT5etSaINXUVBmC4tow8dUbjntpMC1eoHe+O8MrDg 32NkAtvFlhDZ5OoSi/PUK7tcL2ekLk2Q70YHXtCdzeEz194DXQ5TcJjv3Mxev5SzHOWw LPSj9Xw8N1dJ5Ek3e2NIBOgOG76UwXdgzC0lqa1bFK0Kpsm0lRydzIh3ti55eljKRBu7 8tfh5F2Rneus2vkJKyFAMLvV4kU41pNrAiyfRYsJXn2Mr1zOogfWf6yS2ox6vuuPidxC oIjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=OdCYn4+V; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a634517000000b004cc67cfc92bsi309180pga.97.2023.04.05.20.52.49; Wed, 05 Apr 2023 20:53:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=OdCYn4+V; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235310AbjDFDqu (ORCPT + 99 others); Wed, 5 Apr 2023 23:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235291AbjDFDqr (ORCPT ); Wed, 5 Apr 2023 23:46:47 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 795DE9769 for ; Wed, 5 Apr 2023 20:46:44 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id w13so16816877oik.2 for ; Wed, 05 Apr 2023 20:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1680752803; x=1683344803; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=e2HC8P/hmf80QzMRLst56jAGHCnOy19Nb1SfXkyKnng=; b=OdCYn4+VByG1SRoySM17nK1AXgMbZVRXlJ5uIqR+tfwGuKggZw222F7duYA9Vb89YK 27pnFjed1vkAWjIH3w9kqNNxzyvrRs3I40xpJc8gABvfqFbm84Ah6fCAVV+EpDcHKNEM T6LqevGxh7v6QeMq8lX+Fn0O2uSvDEMaPjduq6COs02ZgwWQq7TWFyzEWjpUoxp8g7/W HeDHWwDs5YlngSYn9Y4eEcJFWPL1d9LCI5B4h6ljv4T9xfXx5ZEmdJDMYKPLEVyc5Sh4 e44ljucW2T/N/BZX5bfGqLHRrTCgxLP8TCM5oFflHLmQC3TPZL8Zpd5lDO1iSTWcWsjf DH2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680752803; x=1683344803; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e2HC8P/hmf80QzMRLst56jAGHCnOy19Nb1SfXkyKnng=; b=RtaPPaBhSXGhPyDzNCUrd33tYpfOvN0GZF57ivHQmecOs0pebMJY8Mjg8x7pFk+RAp Qqa3v17lrMTfugrXC+OeDDCrBFIwAFV3rMC1lEXFZ+6+BfFigd7yqpc3cp5K9eXHg5ux r4y2BX7z63odybID29YlruNFV6+i9eiiMjXrb8julzqxGn8HAfQvfSdgfEBOCDB5MAzg RhP/EOz4xiF992WWyhKoq2oUTZVkKnE5KFeHUpqiuA/KJ6fyKfVHBCxfuH9ByLlusBar mwddcfk+TMWhJanOo603dmTvAlEw/s00dyDIWaVybxS2ZhSnpCV0eT7CC6TJbVbEJ1wJ Oxig== X-Gm-Message-State: AAQBX9d3ci277lQJlrC96dQcw3Mrv6Fb3AA4aJdm1KwRA9qSO8IZRnyI /NK1VnSCKWO8GxOox4iqbRgQ8g== X-Received: by 2002:aca:d17:0:b0:388:f4de:1ed7 with SMTP id 23-20020aca0d17000000b00388f4de1ed7mr3555483oin.1.1680752803481; Wed, 05 Apr 2023 20:46:43 -0700 (PDT) Received: from sunil-laptop ([106.51.83.242]) by smtp.gmail.com with ESMTPSA id en12-20020a056808394c00b003898ebb8be0sm215967oib.48.2023.04.05.20.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 20:46:43 -0700 (PDT) Date: Thu, 6 Apr 2023 09:16:31 +0530 From: Sunil V L To: Andrew Jones Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-crypto@vger.kernel.org, platform-driver-x86@vger.kernel.org, llvm@lists.linux.dev, Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Len Brown , Daniel Lezcano , Thomas Gleixner , Weili Qian , Zhou Wang , Herbert Xu , Marc Zyngier , Maximilian Luz , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , "Rafael J . Wysocki" , "David S . Miller" , "Rafael J . Wysocki" Subject: Re: [PATCH V4 08/23] RISC-V: ACPI: Cache and retrieve the RINTC structure Message-ID: References: <20230404182037.863533-1-sunilvl@ventanamicro.com> <20230404182037.863533-9-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=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-crypto@vger.kernel.org On Wed, Apr 05, 2023 at 05:17:48PM +0200, Andrew Jones wrote: > On Tue, Apr 04, 2023 at 11:50:22PM +0530, Sunil V L wrote: > > RINTC structures in the MADT provide mapping between the hartid > > and the CPU. This is required many times even at run time like > > cpuinfo. So, instead of parsing the ACPI table every time, cache > > the RINTC structures and provide a function to get the correct > > RINTC structure for a given cpu. > > > > Signed-off-by: Sunil V L > > Acked-by: Rafael J. Wysocki > > --- > > arch/riscv/include/asm/acpi.h | 2 ++ > > arch/riscv/kernel/acpi.c | 60 +++++++++++++++++++++++++++++++++++ > > 2 files changed, 62 insertions(+) > > > > diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h > > index 9be52b6ffae1..1606dce8992e 100644 > > --- a/arch/riscv/include/asm/acpi.h > > +++ b/arch/riscv/include/asm/acpi.h > > @@ -59,6 +59,8 @@ static inline bool acpi_has_cpu_in_madt(void) > > > > static inline void arch_fix_phys_package_id(int num, u32 slot) { } > > > > +struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); > > +u32 get_acpi_id_for_cpu(int cpu); > > #endif /* CONFIG_ACPI */ > > > > #endif /*_ASM_ACPI_H*/ > > diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c > > index 81d448c41714..40ab55309c70 100644 > > --- a/arch/riscv/kernel/acpi.c > > +++ b/arch/riscv/kernel/acpi.c > > @@ -24,6 +24,66 @@ EXPORT_SYMBOL(acpi_disabled); > > int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */ > > EXPORT_SYMBOL(acpi_pci_disabled); > > > > +static struct acpi_madt_rintc cpu_madt_rintc[NR_CPUS]; > > + > > +static int acpi_parse_madt_rintc(union acpi_subtable_headers *header, const unsigned long end) > > +{ > > + struct acpi_madt_rintc *rintc = (struct acpi_madt_rintc *)header; > > + int cpuid; > > + > > + if (!(rintc->flags & ACPI_MADT_ENABLED)) > > + return 0; > > + > > + cpuid = riscv_hartid_to_cpuid(rintc->hart_id); > > + /* > > + * When CONFIG_SMP is disabled, mapping won't be created for > > + * all cpus. > > + * CPUs more than NR_CPUS, will be ignored. > > + */ > > + if (cpuid >= 0 && cpuid < NR_CPUS) > > + cpu_madt_rintc[cpuid] = *rintc; > > + > > + return 0; > > +} > > + > > +static int acpi_init_rintc_array(void) > > +{ > > + if (acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, acpi_parse_madt_rintc, 0) > 0) > > + return 0; > > + > > + return -ENODEV; > > As Conor pointed out, the errors could be propagated from > acpi_table_parse_madt(), which could reduce this function to > > return acpi_table_parse_madt(ACPI_MADT_TYPE_RINTC, acpi_parse_madt_rintc, 0); > > where the '< 0' check would be in the caller below. That sounds good to > me, but then I'd take that a step further and just drop this helper > altogether. > Thanks, Conor, Drew. I used similar to how others have used acpi_table_parse_madt(). But your suggestion makes sense. Will remove the wrapper function also. Thanks, Sunil