From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v3 8/8] lib: sbi_pmu: Add hartid parameter PMU device ops
Date: Thu, 9 Mar 2023 11:21:12 +0530 [thread overview]
Message-ID: <20230309055112.1516581-9-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20230309055112.1516581-1-mchitale@ventanamicro.com>
Platform specific firmware event handler may leverage the hartid to program
per hart specific registers for a given counter.
Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
---
include/sbi/sbi_pmu.h | 14 ++++++++------
lib/sbi/sbi_pmu.c | 25 +++++++++++++++----------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/include/sbi/sbi_pmu.h b/include/sbi/sbi_pmu.h
index 53f2700..16f6877 100644
--- a/include/sbi/sbi_pmu.h
+++ b/include/sbi/sbi_pmu.h
@@ -31,13 +31,14 @@ struct sbi_pmu_device {
/**
* Validate event code of custom firmware event
*/
- int (*fw_event_validate_encoding)(uint64_t event_data);
+ int (*fw_event_validate_encoding)(uint32_t hartid, uint64_t event_data);
/**
* Match custom firmware counter with custom firmware event
* Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX
*/
- bool (*fw_counter_match_encoding)(uint32_t counter_index,
+ bool (*fw_counter_match_encoding)(uint32_t hartid,
+ uint32_t counter_index,
uint64_t event_data);
/**
@@ -49,27 +50,28 @@ struct sbi_pmu_device {
* Read value of custom firmware counter
* Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX
*/
- uint64_t (*fw_counter_read_value)(uint32_t counter_index);
+ uint64_t (*fw_counter_read_value)(uint32_t hartid,
+ uint32_t counter_index);
/**
* Write value to custom firmware counter
* Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX
*/
- void (*fw_counter_write_value)(uint32_t counter_index,
+ void (*fw_counter_write_value)(uint32_t hartid, uint32_t counter_index,
uint64_t value);
/**
* Start custom firmware counter
* Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX
*/
- int (*fw_counter_start)(uint32_t counter_index,
+ int (*fw_counter_start)(uint32_t hartid, uint32_t counter_index,
uint64_t event_data);
/**
* Stop custom firmware counter
* Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX
*/
- int (*fw_counter_stop)(uint32_t counter_index);
+ int (*fw_counter_stop)(uint32_t hartid, uint32_t counter_index);
/**
* Custom enable irq for hardware counter
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index 00a2c3e..74d6912 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -116,6 +116,7 @@ static int pmu_event_validate(unsigned long event_idx, uint64_t edata)
uint32_t event_idx_code = get_cidx_code(event_idx);
uint32_t event_idx_code_max = -1;
uint32_t cache_ops_result, cache_ops_id, cache_id;
+ u32 hartid = current_hartid();
switch(event_idx_type) {
case SBI_PMU_EVENT_TYPE_HW:
@@ -129,7 +130,8 @@ static int pmu_event_validate(unsigned long event_idx, uint64_t edata)
if (SBI_PMU_FW_PLATFORM == event_idx_code &&
pmu_dev && pmu_dev->fw_event_validate_encoding)
- return pmu_dev->fw_event_validate_encoding(edata);
+ return pmu_dev->fw_event_validate_encoding(hartid,
+ edata);
else
event_idx_code_max = SBI_PMU_FW_MAX;
break;
@@ -199,7 +201,8 @@ int sbi_pmu_ctr_fw_read(uint32_t cidx, uint64_t *cval)
if (SBI_PMU_FW_PLATFORM == event_code) {
if (pmu_dev && pmu_dev->fw_counter_read_value)
- *cval = pmu_dev->fw_counter_read_value(cidx -
+ *cval = pmu_dev->fw_counter_read_value(hartid,
+ cidx -
num_hw_ctrs);
else
*cval = 0;
@@ -391,10 +394,11 @@ static int pmu_ctr_start_fw(uint32_t cidx, uint32_t event_code,
}
if (ival_update)
- pmu_dev->fw_counter_write_value(cidx - num_hw_ctrs,
+ pmu_dev->fw_counter_write_value(hartid,
+ cidx - num_hw_ctrs,
ival);
- return pmu_dev->fw_counter_start(cidx - num_hw_ctrs,
+ return pmu_dev->fw_counter_start(hartid, cidx - num_hw_ctrs,
event_data);
} else {
if (ival_update)
@@ -467,6 +471,7 @@ static int pmu_ctr_stop_hw(uint32_t cidx)
static int pmu_ctr_stop_fw(uint32_t cidx, uint32_t event_code)
{
+ u32 hartid = current_hartid();
int ret;
if ((event_code >= SBI_PMU_FW_MAX &&
@@ -476,7 +481,7 @@ static int pmu_ctr_stop_fw(uint32_t cidx, uint32_t event_code)
if (SBI_PMU_FW_PLATFORM == event_code &&
pmu_dev && pmu_dev->fw_counter_stop) {
- ret = pmu_dev->fw_counter_stop(cidx - num_hw_ctrs);
+ ret = pmu_dev->fw_counter_stop(hartid, cidx - num_hw_ctrs);
if (ret)
return ret;
}
@@ -697,8 +702,9 @@ static int pmu_ctr_find_fw(unsigned long cbase, unsigned long cmask,
continue;
if (SBI_PMU_FW_PLATFORM == event_code &&
pmu_dev && pmu_dev->fw_counter_match_encoding) {
- if (!pmu_dev->fw_counter_match_encoding(cidx - num_hw_ctrs,
- edata))
+ if (!pmu_dev->fw_counter_match_encoding(hartid,
+ cidx - num_hw_ctrs,
+ edata))
continue;
}
@@ -764,9 +770,8 @@ skip_match:
if (flags & SBI_PMU_CFG_FLAG_AUTO_START) {
if (SBI_PMU_FW_PLATFORM == event_code &&
pmu_dev && pmu_dev->fw_counter_start) {
- ret = pmu_dev->fw_counter_start(ctr_idx -
- num_hw_ctrs,
- event_data);
+ ret = pmu_dev->fw_counter_start(hartid,
+ ctr_idx - num_hw_ctrs, event_data);
if (ret)
return ret;
}
--
2.34.1
next prev 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 ` [PATCH v3 4/8] lib: sbi_pmu: Rename fw_counter_value Mayuresh Chitale
2023-03-09 6:19 ` 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 ` Mayuresh Chitale [this message]
2023-03-09 6:32 ` [PATCH v3 8/8] lib: sbi_pmu: Add hartid parameter PMU device ops 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-9-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.