From patchwork Wed Nov 22 07:36:14 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: 1867196 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=FuBBRMde; 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 4SZtTz3BDtz1ySN for ; Wed, 22 Nov 2023 18:41:27 +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=81UVs/fUXsYM4fgQEfsFbZIg/6+CvrnWcQTp9MsLA9c=; b=FuBBRMdeJJdufn ERg/dx8doKz10wJ+HIwW5ra7TVd8Z6WLBNjNtg2f/xs16F+S1uGapbLRBS6eixoyMXI7i3xYCnoND N3G2XfGChd0m+1CmPW53WRA0yDf3VBy9y9bj852mMcmBg0xagX5I7yLNJzC9Ynh0OqV/JZRPWVBB4 oVeKpaDHDzxZgjLpBc3Up61qmkF4C0pMGW17fC7PL+4OFeZzkbIfqf/mVfexvAT2p/2hwNe6VMoho x9rZlmBO/THBt1O7W+mzeu3ps693Q4rkXDZZExIDkb0/RXXD2TzZZ6KDHY/kctMwyN7vpVQPwhL43 x6QbOffs9O0KAx9OE61A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5hrJ-000wDV-0G; Wed, 22 Nov 2023 07:41:17 +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 1r5hrE-000w9Y-1Q for opensbi@lists.infradead.org; Wed, 22 Nov 2023 07:41:15 +0000 Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 3AM7een6091052; Wed, 22 Nov 2023 15:40:40 +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; Wed, 22 Nov 2023 15:40:36 +0800 From: Yu Chien Peter Lin To: CC: , , , , , , , , Yu Chien Peter Lin Subject: [PATCH v3 12/15] lib: utils: fdt_pmu: Make the fdt_pmu_evt_select table global variable Date: Wed, 22 Nov 2023 15:36:14 +0800 Message-ID: <20231122073617.379441-13-peterlin@andestech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231122073617.379441-1-peterlin@andestech.com> References: <20231122073617.379441-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 3AM7een6091052 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_234112_947293_2F429B41 X-CRM114-Status: GOOD ( 10.58 ) 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 --- Changes v2 -> v3: - New patch --- 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;