From ee1f83ca848d3639b808e52719bc7111f5a1be7c Mon Sep 17 00:00:00 2001 From: Inochi Amaoto Date: Fri, 11 Aug 2023 08:24:43 +0800 Subject: lib: sbi_pmu: remove mhpm_count field in hart feature After supporting noncontigous hpm event and counters in opensbi, the number of hpm counters can be calculated by the mhpm_mask. So this field is unnecessary and can be removed to save some space. Signed-off-by: Inochi Amaoto Reviewed-by: Anup Patel --- include/sbi/sbi_bitops.h | 16 ++++++++++++++++ include/sbi/sbi_hart.h | 2 -- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/sbi/sbi_bitops.h b/include/sbi/sbi_bitops.h index 2e08947b..48a20901 100644 --- a/include/sbi/sbi_bitops.h +++ b/include/sbi/sbi_bitops.h @@ -112,6 +112,22 @@ static inline unsigned long sbi_fls(unsigned long word) return num; } +/** + * sbi_popcount - find the number of set bit in a long word + * @word: the word to search + */ +static inline unsigned long sbi_popcount(unsigned long word) +{ + unsigned long count = 0; + + while (word) { + word &= word - 1; + count++; + } + + return count; +} + #define for_each_set_bit(bit, addr, size) \ for ((bit) = find_first_bit((addr), (size)); \ (bit) < (size); \ diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 17d3ada9..e60f4150 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -69,7 +69,6 @@ struct sbi_hart_features { unsigned int pmp_count; unsigned int pmp_addr_bits; unsigned long pmp_gran; - unsigned int mhpm_count; unsigned int mhpm_mask; unsigned int mhpm_bits; }; @@ -85,7 +84,6 @@ static inline ulong sbi_hart_expected_trap_addr(void) return (ulong)sbi_hart_expected_trap; } -unsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch); unsigned int sbi_hart_mhpm_mask(struct sbi_scratch *scratch); void sbi_hart_delegation_dump(struct sbi_scratch *scratch, const char *prefix, const char *suffix); -- cgit v1.3.1