Skip to content

Commit 953f4d8

Browse files
committed
Add a new function for event discovery
The supervisor software may need to be aware of which standard or raw events are allowed by the platform. This will help the supervisor software to advertise only those events instead of all standard events. In addition to that, it may just waste time trying to match a counter for each invalid event at runtime which may lead to undesirable results. Currently, this problem is solved by invoking CFG_MATCH call for each event which is not ideal as it may increase the bootime with unnecessary SBI calls at boot time. Introduce a new function that allows to discover support events with a single SBI call which is very efficient. Signed-off-by: Atish Patra <[email protected]>
1 parent 715ef22 commit 953f4d8

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/ext-pmu.adoc

+69
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,74 @@ The possible error codes returned in `sbiret.error` are shown in
624624
reasons.
625625
|===
626626
627+
=== Function: Get PMU Event info (FID #8)
628+
629+
[source, C]
630+
----
631+
struct sbiret sbi_pmu_event_get_info(unsigned long shmem_phys_lo,
632+
unsigned long shmem_phys_hi,
633+
unsigned long num_entries,
634+
unsigned long flags)
635+
----
636+
637+
Get details about any PMU event via shared memory. The supervisor software can
638+
get event specific information for multiple events in one shot by writing an
639+
entry for each event in the shared memory. Each entry in the shared memory
640+
must be encoded as follows:
641+
642+
[#table_event_info_format]
643+
.Event info entry format
644+
[cols="1,2,3,7", width=90%, align="center", options="header"]
645+
|===
646+
| Word | Name | ACCESS(SBI Implementation) | Encoding
647+
| 0 | event_idx | RO | BIT[0:19] - Describes the `event_idx`
648+
BIT[20:31] - Reserved for the future purpose.
649+
Must be zero.
650+
| 1 | output | RW | BIT[0] - Boolean value to indicate `event_idx`
651+
is supported or not. The SBI implmenentation
652+
MUST update this entire 32-bit word if valid
653+
`event_idx` and `event_data` (if applicable) are
654+
specified in the entry. BIT[1:31] - Reserved for
655+
the future purpose. Must be zero
656+
| 2-3 | event_data | RO | BIT[0:63] - Valid when `event_idx.type` is
657+
either `0x2`, `0x3` or `0xf`. It describes the
658+
`event_data` for the specific event specified in
659+
`event_idx` if applicable.
660+
|===
661+
662+
The caller must initialize the shared memory and add `num_entries` of each event
663+
for which it wishes to discover information about. The `shmem_phys_lo` MUST
664+
be 16-byte aligned and the size of the share memory must be
665+
(16 * `num_entries`) bytes.
666+
667+
The `flags` parameter is reserved for future use and MUST be zero.
668+
669+
The SBI implementation MUST NOT touch the shared memory once this call returns
670+
as supervisor software may free the memory at any time.
671+
672+
The possible error codes returned in `sbiret.error` are shown in
673+
<<table_pmu_event_get_info_errors>> below.
674+
675+
[#table_pmu_event_get_info_errors]
676+
.PMU Get Event Info Errors
677+
[cols="2,3", width=90%, align="center", options="header"]
678+
|===
679+
| Error code | Description
680+
| SBI_SUCCESS | The output field is updated for each event.
681+
| SBI_ERR_NOT_SUPPORTED | The SBI PMU event info retrieval function is not
682+
available in the SBI implementation.
683+
| SBI_ERR_INVALID_PARAM | The `flags` parameter is not zero or the
684+
`shmem_phys_lo` parameter is not 16-bytes aligned or
685+
`event_idx` value doesn't conform with the encodings
686+
defined in the specification.
687+
| SBI_ERR_INVALID_ADDRESS | The shared memory pointed to by the `shmem_phys_lo`
688+
and `shmem_phys_hi` parameters is not writable or
689+
does not satisfy other requirements of
690+
<<_shared_memory_physical_address_range_parameter>>.
691+
| SBI_ERR_FAILED | The write failed for unspecified or unknown other
692+
reasons.
693+
|===
694+
627695
=== Function Listing
628696
629697
[#table_pmu_function_list]
@@ -639,4 +707,5 @@ The possible error codes returned in `sbiret.error` are shown in
639707
| sbi_pmu_counter_fw_read | 0.3 | 5 | 0x504D55
640708
| sbi_pmu_counter_fw_read_hi | 2.0 | 6 | 0x504D55
641709
| sbi_pmu_snapshot_set_shmem | 2.0 | 7 | 0x504D55
710+
| sbi_pmu_event_get_info | 3.0 | 8 | 0x504D55
642711
|===

0 commit comments

Comments
 (0)