riscv-non-isa/riscv-sbi-doc

`sbi_pmu_*` functions take the `counter_mask` arguments in opposite order compared to functions that use `hart_mask`

repnop opened this issue · 1 comments

The sbi_pmu functions take the counter_mask and counter_base parameters in the opposite order than the other functions in the spec that operate on hart ID masks, which take hart_mask first and then the hart_mask_base after:

struct sbiret sbi_send_ipi(unsigned long hart_mask,
                           unsigned long hart_mask_base)
struct sbiret sbi_pmu_counter_config_matching(unsigned long counter_idx_base,
					      unsigned long counter_idx_mask,
					      unsigned long config_flags,
					      unsigned long event_idx,
					      uint64_t event_data)

This is a really unfortunate inconsistency and something that's probably quite easy to accidentally get wrong if you're familiar with the ordering from the other functions.

Those are two different extensions and can define the order of the arguments independently. However, I agree with you. Having a consistent order through out the spec would have been good. Unfortunately, those extension are ratified and changing them is not possible without side effects.
We should make sure that the future extensions are consistent though.