All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v3 4/8] lib: sbi_pmu: Rename fw_counter_value
Date: Thu,  9 Mar 2023 11:21:08 +0530	[thread overview]
Message-ID: <20230309055112.1516581-5-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20230309055112.1516581-1-mchitale@ventanamicro.com>

Rename and reuse fw_counter_value arrary to save both the counter values
for the SBI firmware events and event data for the SBI platform specific
firmware events.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 lib/sbi/sbi_pmu.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index a99c045..1a3c44d 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -65,8 +65,12 @@ static uint32_t active_events[SBI_HARTMASK_MAX_BITS][SBI_PMU_HW_CTR_MAX + SBI_PM
 #endif
 static unsigned long fw_counters_started[SBI_HARTMASK_MAX_BITS];
 
-/* Values of firmwares counters on each HART */
-static uint64_t fw_counters_value[SBI_HARTMASK_MAX_BITS][SBI_PMU_FW_CTR_MAX] = {0};
+/*
+ * Counter values for SBI firmware events and event codes for platform
+ * firmware events. Both are mutually exclusive and hence can optimally share
+ * the same memory.
+ */
+static uint64_t fw_counters_data[SBI_HARTMASK_MAX_BITS][SBI_PMU_FW_CTR_MAX] = {0};
 
 /* Maximum number of hardware events available */
 static uint32_t num_hw_events;
@@ -185,10 +189,10 @@ int sbi_pmu_ctr_fw_read(uint32_t cidx, uint64_t *cval)
 
 	if (SBI_PMU_FW_MAX <= event_code &&
 	    pmu_dev && pmu_dev->fw_counter_read_value)
-		fw_counters_value[hartid][cidx - num_hw_ctrs] =
+		fw_counters_data[hartid][cidx - num_hw_ctrs] =
 			pmu_dev->fw_counter_read_value(cidx - num_hw_ctrs);
 
-	*cval = fw_counters_value[hartid][cidx - num_hw_ctrs];
+	*cval = fw_counters_data[hartid][cidx - num_hw_ctrs];
 
 	return 0;
 }
@@ -372,7 +376,7 @@ static int pmu_ctr_start_fw(uint32_t cidx, uint32_t event_code,
 	}
 
 	if (ival_update)
-		fw_counters_value[hartid][cidx - num_hw_ctrs] = ival;
+		fw_counters_data[hartid][cidx - num_hw_ctrs] = ival;
 	fw_counters_started[hartid] |= BIT(cidx - num_hw_ctrs);
 
 	return 0;
@@ -711,13 +715,13 @@ skip_match:
 			pmu_ctr_start_hw(ctr_idx, 0, false);
 	} else if (event_type == SBI_PMU_EVENT_TYPE_FW) {
 		if (flags & SBI_PMU_CFG_FLAG_CLEAR_VALUE)
-			fw_counters_value[hartid][ctr_idx - num_hw_ctrs] = 0;
+			fw_counters_data[hartid][ctr_idx - num_hw_ctrs] = 0;
 		if (flags & SBI_PMU_CFG_FLAG_AUTO_START) {
 			if (SBI_PMU_FW_MAX <= event_code &&
 			    pmu_dev && pmu_dev->fw_counter_start) {
 				ret = pmu_dev->fw_counter_start(
 					ctr_idx - num_hw_ctrs, event_code,
-					fw_counters_value[hartid][ctr_idx - num_hw_ctrs],
+					fw_counters_data[hartid][ctr_idx - num_hw_ctrs],
 					true);
 				if (ret)
 					return ret;
@@ -743,7 +747,7 @@ int sbi_pmu_ctr_incr_fw(enum sbi_pmu_fw_event_code_id fw_id)
 	for (cidx = num_hw_ctrs; cidx < total_ctrs; cidx++) {
 		if (get_cidx_code(active_events[hartid][cidx]) == fw_id &&
 		    (fw_counters_started[hartid] & BIT(cidx - num_hw_ctrs))) {
-			fcounter = &fw_counters_value[hartid][cidx - num_hw_ctrs];
+			fcounter = &fw_counters_data[hartid][cidx - num_hw_ctrs];
 			break;
 		}
 	}
@@ -803,7 +807,7 @@ static void pmu_reset_event_map(u32 hartid)
 	for (j = 3; j < total_ctrs; j++)
 		active_events[hartid][j] = SBI_PMU_EVENT_IDX_INVALID;
 	for (j = 0; j < SBI_PMU_FW_CTR_MAX; j++)
-		fw_counters_value[hartid][j] = 0;
+		fw_counters_data[hartid][j] = 0;
 	fw_counters_started[hartid] = 0;
 }
 
-- 
2.34.1



  parent reply	other threads:[~2023-03-09  5:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  5:51 [PATCH v3 0/8] SBI PMU firmware counters and events improvement Mayuresh Chitale
2023-03-09  5:51 ` [PATCH v3 1/8] lib: sbi_pmu: add callback for counter width Mayuresh Chitale
2023-03-09  6:18   ` Anup Patel
2023-03-09  5:51 ` [PATCH v3 2/8] lib: sbi_pmu: Implement sbi_pmu_counter_fw_read_hi Mayuresh Chitale
2023-03-09  6:18   ` Anup Patel
2023-03-09  5:51 ` [PATCH v3 3/8] lib: sbi_pmu: Reserve space for implementation specific firmware events Mayuresh Chitale
2023-03-09  6:19   ` Anup Patel
2023-03-09  9:16   ` Andrew Jones
2023-03-09 12:30     ` mchitale
2023-03-09  5:51 ` Mayuresh Chitale [this message]
2023-03-09  6:19   ` [PATCH v3 4/8] lib: sbi_pmu: Rename fw_counter_value Anup Patel
2023-03-09  9:19   ` Andrew Jones
2023-03-09  5:51 ` [PATCH v3 5/8] lib: sbi_pmu: Update sbi_pmu dev ops Mayuresh Chitale
2023-03-09  6:21   ` Anup Patel
2023-03-09  5:51 ` [PATCH v3 6/8] lib: sbi_pmu: Use dedicated event code for platform firmware events Mayuresh Chitale
2023-03-09  6:28   ` Anup Patel
2023-03-09 12:33     ` mchitale
2023-03-09  5:51 ` [PATCH v3 7/8] lib: sbi_pmu: Introduce fw_counter_write_value API Mayuresh Chitale
2023-03-09  6:31   ` Anup Patel
2023-03-09  5:51 ` [PATCH v3 8/8] lib: sbi_pmu: Add hartid parameter PMU device ops Mayuresh Chitale
2023-03-09  6:32   ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230309055112.1516581-5-mchitale@ventanamicro.com \
    --to=mchitale@ventanamicro.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.