mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-03 21:48:45 +00:00 
			
		
		
		
	lib: sbi: Counter info width should be zero indexed
The mhpm bits represent the number of bits available in mhpmcounter
while counter width describes a zero indexed value. Fix the counter width
calculation.
Fixes: 13d40f21d588 ("lib: sbi: Add PMU support")
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
			
			
This commit is contained in:
		
							parent
							
								
									1e147324f0
								
							
						
					
					
						commit
						b628cfd6a0
					
				@ -649,7 +649,7 @@ int sbi_pmu_ctr_get_info(uint32_t cidx, unsigned long *ctr_info)
 | 
			
		||||
		if (cidx == 0 || cidx == 2)
 | 
			
		||||
			cinfo.width = 63;
 | 
			
		||||
		else
 | 
			
		||||
			cinfo.width = sbi_hart_mhpm_bits(scratch);
 | 
			
		||||
			cinfo.width = sbi_hart_mhpm_bits(scratch) - 1;
 | 
			
		||||
	} else {
 | 
			
		||||
		/* it's a firmware counter */
 | 
			
		||||
		cinfo.type = SBI_PMU_CTR_TYPE_FW;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user