From patchwork Wed Sep 27 17:00:13 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: 145550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2849916vqu; Wed, 27 Sep 2023 12:21:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGG6L4XOvl7KjWghHRVUrHmgKcwxRhQVXRpmQ3wqCPd434LFwP04JtEDihdgnA5hFUZN50y X-Received: by 2002:a17:903:22d1:b0:1c7:1eb7:82cd with SMTP id y17-20020a17090322d100b001c71eb782cdmr3300832plg.60.1695842487263; Wed, 27 Sep 2023 12:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695842487; cv=none; d=google.com; s=arc-20160816; b=lU0fOwx/zkSM6kVOzxSzAHhY5cAmqlfFTt3pVivM9YAxa7d3a2POhQIXaWRBORPCO3 4prC0zCZQWWcKJ62DbzjK/X9LQO/2aW7NDS1u1mUrXoRtNjAYxdiCzvcyNxoeRcHh32R hb5wkqa9V6rruJJ1WNlN/p9yP9m/QQ6T6h2mNYNHH7rvV/SHMNXtumH73fgVMJFbnJlZ JcIZprprcyYUBENFJBvRAnLSh+Vk0dExnQx2BJOk4yD9Xd1yySTh5pv8ujYL97nEiJBg IvTqy/73bpL4uI8s1KqiBDdaS26OXO5uDtZl1xkOzyTGKAQ5nq//8pGQo3St/wOcI7dK i7Dw== 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=g9sLv+V8gGTdOjGyr5tjbv9gRJE2ViFoNFxWNgg6Hz8=; fh=sfgdT0UZ8CYMELEEedGcAjPKookfa29m+O/tEazxSkQ=; b=M/Vh9ecm7IFLiCVnHKqGcKJV5HLYL34a1UmX3Ykf6UT6gBMH5iQsCSB1+CF+7UViEP uyu2uKNF6fygUq27/1Plqdntyk0xerLw7VJ6rWm9FHL+6xlFqaMJDcm9ZzZTlF3sMbIq MerwLUONfoBdiSqBFUHh09vwjxtwifo6K81MjrfvL+EaofzDSaTqwJPIU82bH489sWNF RAGTiQjRfANNVAGxNOk/WaQO7sZ38Hxn3ZbWIsdM5dcuhWgaUuMW4TsbrUmi07tVIAFq pG0XgkXkSj1lSv8dyRiC1y78BTmMxe4y1rr/f/VitZ6OAq+CV6vsl0De23sYbUv4F8r4 qgiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ImEM1Z7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id c4-20020a170902d48400b001b9ffda162csi17586520plg.441.2023.09.27.12.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ImEM1Z7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 04C47832C36C; Wed, 27 Sep 2023 10:01:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjI0RAi (ORCPT + 19 others); Wed, 27 Sep 2023 13:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjI0RAf (ORCPT ); Wed, 27 Sep 2023 13:00:35 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AF3F5 for ; Wed, 27 Sep 2023 10:00:33 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-578d0d94986so8323809a12.2 for ; Wed, 27 Sep 2023 10:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1695834033; x=1696438833; darn=vger.kernel.org; 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=g9sLv+V8gGTdOjGyr5tjbv9gRJE2ViFoNFxWNgg6Hz8=; b=ImEM1Z7qQWJ9pWvjGfmPTZ6MedwTOlrrGPtiX5vsmQ3sUZ7MJxNJfy0baVKQiTMuZl n/sixhJG7Bna30gD0zlbk4h+NX5oTGDQedW9KHdC+WhNtxs9q0WlpdMBXlkFGbAl8zUU jEaelMhEX430FdiP0oWUkku+aI4HWNpzlt9xfMRC3Ck5/e1yPtPbbTyo6PDpn66S04KG 2xfbey3SI0sMFsVbY7xEyQCz75FwnVeIL05esfhexrsbdU9pdpfu5A8V33YkVVfUF/vY bRdnxr0SYls53DcWGj/ghuNSKzPmgkuCaw9bA0vna1E6gttCE/gvsAkoj/B7HLtwufqt qy2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695834033; x=1696438833; 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=g9sLv+V8gGTdOjGyr5tjbv9gRJE2ViFoNFxWNgg6Hz8=; b=jTdo79s/3W1d4yNP/uZ42LvvM5DdxrSNnGjiAP5MO0C1NISGyZDge3n8YUHiXyVbhu iTq+dlqt0z3RQEv9QUncPE2lWUwN8IDYZ2ajwEOoWrCIeS8kklPGvNkPPK65TKiX+92I /Pc/2MSMW+pB5o6tTgaqYdZEZmre89sqRxqnvUzQn3ci21d9IjXR24f0/nwZXam0HIFY hKAL95K5Hpe5d4J5J5zrF4TQMgmvYQzWxIl/+qJXkk6pR1I8q1M3CbvKukRWYNyL6OMN vQsFPWUNxJ+cSvYc1eijFrgHitAXkEARaIP1+eSu8BUCGHISXpEYQNyMX5t8h5sNkQZE QVfg== X-Gm-Message-State: AOJu0YyQnRdNhFwUQrlYn+T7sxmd/R7NGbNQVgjSPwYl5iaaUmoc+zHl 0b1k2Kgb4r1ql45Q+u+CEGRQyQ== X-Received: by 2002:a05:6a20:7d95:b0:14c:daa9:5e22 with SMTP id v21-20020a056a207d9500b0014cdaa95e22mr2978244pzj.45.1695834033151; Wed, 27 Sep 2023 10:00:33 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.190.42]) by smtp.gmail.com with ESMTPSA id u7-20020a637907000000b00584b293d157sm3279396pgc.80.2023.09.27.10.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:00:32 -0700 (PDT) From: Sunil V L To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , "Rafael J . Wysocki" , Len Brown , Daniel Lezcano , Thomas Gleixner , Andrew Jones , Conor Dooley , Anup Patel , Ard Biesheuvel , Alexandre Ghiti , Andy Shevchenko , Atish Kumar Patra , Sunil V L Subject: [PATCH v2 -next 2/4] RISC-V: ACPI: RHCT: Add function to get CBO block sizes Date: Wed, 27 Sep 2023 22:30:13 +0530 Message-Id: <20230927170015.295232-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230927170015.295232-1-sunilvl@ventanamicro.com> References: <20230927170015.295232-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:01:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778219731606721192 X-GMAIL-MSGID: 1778219731606721192 Cache Block Operation (CBO) related block size in ACPI is provided by RHCT. Add support to read the CMO node in RHCT to get this information. Signed-off-by: Sunil V L --- arch/riscv/include/asm/acpi.h | 9 +++++ drivers/acpi/riscv/rhct.c | 72 ++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index d5604d2073bc..0c4e8b35103e 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -66,6 +66,8 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } +int acpi_get_cbo_block_size(struct acpi_table_header *table, unsigned int cpu, u32 *cbom_size, + u32 *cboz_size, u32 *cbop_size); #else static inline void acpi_init_rintc_map(void) { } static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) @@ -79,6 +81,13 @@ static inline int acpi_get_riscv_isa(struct acpi_table_header *table, return -EINVAL; } +static inline int acpi_get_cbo_block_size(struct acpi_table_header *table, + unsigned int cpu, u32 *cbom_size, + u32 *cboz_size, u32 *cbop_size) +{ + return -EINVAL; +} + #endif /* CONFIG_ACPI */ #endif /*_ASM_ACPI_H*/ diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c index b280b3e9c7d9..9042949277f8 100644 --- a/drivers/acpi/riscv/rhct.c +++ b/drivers/acpi/riscv/rhct.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "ACPI: RHCT: " fmt #include +#include static struct acpi_table_header *acpi_get_rhct(void) { @@ -56,7 +57,6 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const } end = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->header.length); - for (node = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->node_offset); node < end; node = ACPI_ADD_PTR(struct acpi_rhct_node_header, node, node->length)) { @@ -81,3 +81,73 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const return -1; } + +/* + * During early boot, the caller should call acpi_get_table() and pass its pointer to + * these functions(and free up later). At run time, since this table can be used + * multiple times, pass NULL so that the table remains in memory + */ +int acpi_get_cbo_block_size(struct acpi_table_header *table, unsigned int cpu, + u32 *cbom_size, u32 *cboz_size, u32 *cbop_size) +{ + struct acpi_rhct_node_header *node, *ref_node, *end; + u32 size_hdr = sizeof(struct acpi_rhct_node_header); + u32 size_hartinfo = sizeof(struct acpi_rhct_hart_info); + struct acpi_rhct_hart_info *hart_info; + struct acpi_rhct_cmo_node *cmo_node; + struct acpi_table_rhct *rhct; + u32 *hart_info_node_offset; + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + + BUG_ON(acpi_disabled); + + if (table) { + rhct = (struct acpi_table_rhct *)table; + } else { + rhct = (struct acpi_table_rhct *)acpi_get_rhct(); + if (!rhct) + return -ENOENT; + } + + end = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->header.length); + for (node = ACPI_ADD_PTR(struct acpi_rhct_node_header, rhct, rhct->node_offset); + node < end; + node = ACPI_ADD_PTR(struct acpi_rhct_node_header, node, node->length)) { + if (node->type == ACPI_RHCT_NODE_TYPE_HART_INFO) { + hart_info = ACPI_ADD_PTR(struct acpi_rhct_hart_info, node, size_hdr); + hart_info_node_offset = ACPI_ADD_PTR(u32, hart_info, size_hartinfo); + if (acpi_cpu_id != hart_info->uid) + continue; + + for (int i = 0; i < hart_info->num_offsets; i++) { + ref_node = ACPI_ADD_PTR(struct acpi_rhct_node_header, + rhct, hart_info_node_offset[i]); + if (ref_node->type == ACPI_RHCT_NODE_TYPE_CMO) { + cmo_node = ACPI_ADD_PTR(struct acpi_rhct_cmo_node, + ref_node, size_hdr); + if (cbom_size && cmo_node->cbom_size <= 30) + *cbom_size = BIT(cmo_node->cbom_size); + + if (cboz_size && cmo_node->cboz_size <= 30) + *cboz_size = BIT(cmo_node->cboz_size); + + if (cbop_size && cmo_node->cbop_size <= 30) + *cbop_size = BIT(cmo_node->cbop_size); + + return 0; + } + } + } + } + + if (cbom_size) + *cbom_size = 0; + + if (cboz_size) + *cboz_size = 0; + + if (cbop_size) + *cbop_size = 0; + + return -ENOENT; +}