From patchwork Thu Nov 30 12:42:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-Chien Peter Lin X-Patchwork-Id: 1870118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=dn4VP6T8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SgwqX5ljBz1ySd for ; Thu, 30 Nov 2023 23:44:08 +1100 (AEDT) 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=LMFGM2SHkBG9L0ZCxSwZVXr0aadPhEXepPsC6FU/GDo=; b=dn4VP6T8BzE4Lm XVR8wDZOgKDnX284Fwa2h9t9umtlE7aiC94BZTJKYjrHYVY80b8WnRS5TTP6GK5wh7cjI2+plCsrO W2C+dxhztnp6NQFhsWHzGyhMYtQe+Gy/Bzxrlm/HlUDgRrm1YKNoqNsun6m5GnmqInm6ft5sKya0y ZRHocruBJfRF7xWRzbb9q9eeDl+bWjZ/pQS8zsCNAiBRbSLf1XjerDc6yPKLMLCf6Yi+HAh1jE2P+ bmhi3typH/qvssKATxyKT+KSMdcGhPSOxM9krIs5n0+MGQ5manS9QnRRAjhN15Cl78X9IALMljoTm eGtaxRUDlK9YuGH3Eedw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8gOc-00AtiQ-33; Thu, 30 Nov 2023 12:43:58 +0000 Received: from 60-248-80-70.hinet-ip.hinet.net ([60.248.80.70] helo=Atcsqr.andestech.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8gOZ-00Atgf-00 for opensbi@lists.infradead.org; Thu, 30 Nov 2023 12:43:56 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 3AUChO9Q056593; Thu, 30 Nov 2023 20:43:24 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from swlinux02.andestech.com (10.0.15.183) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Thu, 30 Nov 2023 20:43:20 +0800 From: Yu Chien Peter Lin To: CC: , , , , , , , , , Yu Chien Peter Lin Subject: [PATCH v4 12/15] lib: utils: fdt_pmu: Make the fdt_pmu_evt_select table global variable Date: Thu, 30 Nov 2023 20:42:10 +0800 Message-ID: <20231130124213.2590640-13-peterlin@andestech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130124213.2590640-1-peterlin@andestech.com> References: <20231130124213.2590640-1-peterlin@andestech.com> MIME-Version: 1.0 X-Originating-IP: [10.0.15.183] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 3AUChO9Q056593 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_044355_508329_7945EF83 X-CRM114-Status: GOOD ( 10.96 ) X-Spam-Score: 0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: To allow platform override pmu_init() filling the translation table fdt_pmu_evt_select[] when PMU node doesn't provide such information, we need to share the table and its entry counter with other .c [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 TVD_RCVD_IP Message was received from an IP address -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To allow platform override pmu_init() filling the translation table fdt_pmu_evt_select[] when PMU node doesn't provide such information, we need to share the table and its entry counter with other .c file. We also define the structures of PMU property in fdt_helper.h, so we can initialize the mappings in arrays. Signed-off-by: Yu Chien Peter Lin Reviewed-by: Atish Patra Reviewed-by: Anup Patel --- Changes v2 -> v3: - New patch Changes v3 -> v4: - No change --- include/sbi_utils/fdt/fdt_helper.h | 17 +++++++++++++++++ include/sbi_utils/fdt/fdt_pmu.h | 6 ++++++ lib/utils/fdt/fdt_pmu.c | 13 ++++--------- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index 5c928ff..f6f505b 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -34,6 +34,23 @@ struct platform_uart_data { unsigned long reg_offset; }; +struct fdt_pmu_hw_event_select_map { + uint32_t eidx; + uint64_t select; +}; + +struct fdt_pmu_hw_event_counter_map { + uint32_t eidx_start; + uint32_t eidx_end; + uint32_t ctr_map; +}; + +struct fdt_pmu_raw_event_counter_map { + uint64_t select; + uint64_t select_mask; + uint32_t ctr_map; +}; + const struct fdt_match *fdt_match_node(void *fdt, int nodeoff, const struct fdt_match *match_table); diff --git a/include/sbi_utils/fdt/fdt_pmu.h b/include/sbi_utils/fdt/fdt_pmu.h index c65cad7..9a13487 100644 --- a/include/sbi_utils/fdt/fdt_pmu.h +++ b/include/sbi_utils/fdt/fdt_pmu.h @@ -12,6 +12,7 @@ #define __FDT_PMU_H__ #include +#include #ifdef CONFIG_FDT_PMU @@ -45,6 +46,11 @@ int fdt_pmu_setup(void *fdt); */ uint64_t fdt_pmu_get_select_value(uint32_t event_idx); +/** The event index to selector value table instance */ +extern struct fdt_pmu_hw_event_select_map fdt_pmu_evt_select[]; +/** The number of valid entries in fdt_pmu_evt_select[] */ +extern uint32_t hw_event_count; + #else static inline void fdt_pmu_fixup(void *fdt) { } diff --git a/lib/utils/fdt/fdt_pmu.c b/lib/utils/fdt/fdt_pmu.c index a8d7648..cf3220f 100644 --- a/lib/utils/fdt/fdt_pmu.c +++ b/lib/utils/fdt/fdt_pmu.c @@ -17,18 +17,13 @@ #define FDT_PMU_HW_EVENT_MAX (SBI_PMU_HW_EVENT_MAX * 2) -struct fdt_pmu_hw_event_select { - uint32_t eidx; - uint64_t select; -}; - -static struct fdt_pmu_hw_event_select fdt_pmu_evt_select[FDT_PMU_HW_EVENT_MAX] = {0}; -static uint32_t hw_event_count; +struct fdt_pmu_hw_event_select_map fdt_pmu_evt_select[FDT_PMU_HW_EVENT_MAX] = {0}; +uint32_t hw_event_count; uint64_t fdt_pmu_get_select_value(uint32_t event_idx) { int i; - struct fdt_pmu_hw_event_select *event; + struct fdt_pmu_hw_event_select_map *event; for (i = 0; i < SBI_PMU_HW_EVENT_MAX; i++) { event = &fdt_pmu_evt_select[i]; @@ -65,7 +60,7 @@ int fdt_pmu_setup(void *fdt) int i, pmu_offset, len, result; const u32 *event_val; const u32 *event_ctr_map; - struct fdt_pmu_hw_event_select *event; + struct fdt_pmu_hw_event_select_map *event; uint64_t raw_selector, select_mask; u32 event_idx_start, event_idx_end, ctr_map;