From patchwork Thu Aug 3 17:59:03 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: 13340411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 210E2C001DB for ; Thu, 3 Aug 2023 18:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hHfM36PPTosd5AwUvaC0swoPPOW86woCJMeEz2U/GEs=; b=nJMQV7evV2PUw1 tWCnb2vUNs6/yHCJNiLnkiTrN9YpEml5EQtC+vkVx3QBa5FNSzjS1A7nNtQ9jy6eQzdIrlMW9oTix /fxQjEPCuujnLTFAB04Sw9S64awIWJwG1uZeCgWdsJgy3aXKnNj4jd6mhCwm5N2tnV3g7pjx6Yxou +hAO6Y2I52gUyoSUMNsxu5UxzQtkW2jNtmB7z+ZB16wP9XIaoE6BiHViedQtbbkj4sS1lPvC5h5qF ZZC+DI+wkvtkyqSvBhkMpnw2O5Q8lyq9B59neajF7YKEQR4uaWLyFhDCKHv8juVTSUQNazTQer2YZ saqlM+Hf1d+6OQJTqKQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRccp-00AUzH-2Z; Thu, 03 Aug 2023 18:00:39 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRccn-00AUuX-01 for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 18:00:38 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-686ba97e4feso1110600b3a.0 for ; Thu, 03 Aug 2023 11:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1691085634; x=1691690434; 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=vQhuhHdTYaoWEXKHMdQb/AIiT1M0AyktuFOnKoEYTGc=; b=InAgb86bmzIXD9aMahgzQO9of8OqAMtZa6GKa8YVTVY7PzoIGrnFhABT5iR9yUDpdb eldlLfYqaIJZ0JqKhkz88GT1tI9U1PbaGlbsR4bWfCh1DfbR0ACTXckiDCh17sNzcRLf f2WV3qxyJ/rWBuGW2ue4ffM6KV/QUAchCeozTJs9q5S/XcNQOsvfIpSb1jVFwiZ6oFq3 jlj10cncisuVGqqhaz2WZx3F8TaIGK9I5NjfThtEaXa1XobxVSAqQwN9SPkmA39vlFlT 61lNiezvzG66VfjvuK2JSEbbCShorb/rqB7QdxU1TuTKXQUwQJNjJ66LD7fLCbx8z4t0 5PbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691085634; x=1691690434; 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=vQhuhHdTYaoWEXKHMdQb/AIiT1M0AyktuFOnKoEYTGc=; b=MK27qrwnf52B3HLdF1/vRQk7QhVCyadYErPd6BExGuA2byCs8rj3eKl3qZPC2r1gg6 mAWpmWVh9gAF2WKQDovw79jNbk97qPCL2W8vlV7NjwYVJiPsjkpiWeP/fPaJN+vM02yc QSK4zuDQRlK4RFfZ4qTCDG6jyOkFd5NMxAk3XiIx5uI1KxiCawUajp/sQ1cUnic6jv27 oV1sIT9W2Yw3ZL8JgYHX/zQnL0eutPGZl2V5mUyFlgIxDchYGwi9rFIuLtbYzcMHyxP7 UpPo45SMYD530lSXk1p0cao6WGJ+LHzR8AVEs/a7hhFCW8hWPNKn5p9FSGUF5lkh0YKK +JRA== X-Gm-Message-State: ABy/qLao3juSSgtbgMOejGgaOjda/SYqRVuRLGMENiVanvgZsO03RzK+ L0hhlSUtgT6tabC+Ym9ntut+XA== X-Google-Smtp-Source: APBJJlFH8jQEzxXg6hi15nylBcj+0LbOiklmHj6H9WKQlfFcoVNBUAfYIpWWjK+zKN9M7HAojMJwCw== X-Received: by 2002:a05:6a21:6d95:b0:134:4f86:7966 with SMTP id wl21-20020a056a216d9500b001344f867966mr25365705pzb.9.1691085634213; Thu, 03 Aug 2023 11:00:34 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.190.143]) by smtp.gmail.com with ESMTPSA id s8-20020aa78d48000000b0065a1b05193asm134952pfe.185.2023.08.03.11.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 11:00:33 -0700 (PDT) From: Sunil V L To: linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Cc: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" , Len Brown , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , Daniel Lezcano , Thomas Gleixner , Anup Patel , Marc Zyngier , Bjorn Helgaas , Robert Moore , Haibo Xu , Andrew Jones , Conor Dooley , Atish Kumar Patra , Sunil V L Subject: [RFC PATCH v1 08/21] RISC-V: ACPI: RHCT: Add function to get CBO block sizes Date: Thu, 3 Aug 2023 23:29:03 +0530 Message-Id: <20230803175916.3174453-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230803175916.3174453-1-sunilvl@ventanamicro.com> References: <20230803175916.3174453-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230803_110037_087503_1B4EDCF3 X-CRM114-Status: GOOD ( 17.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) 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..07309525f277 100644 --- a/drivers/acpi/riscv/rhct.c +++ b/drivers/acpi/riscv/rhct.c @@ -81,3 +81,64 @@ 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 *)acpi_get_rhct(); + if (!rhct) + return -ENOENT; + } else { + rhct = (struct acpi_table_rhct *)table; + } + + 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) + *cbom_size = 1 << cmo_node->cbom_size; + + if (cboz_size) + *cboz_size = 1 << cmo_node->cboz_size; + + if (cbop_size) + *cbop_size = 1 << cmo_node->cbop_size; + return 0; + } + } + } + } + + return -ENOENT; +}