The minimum bandwidth granularity is calculated from MPAMF_MBW_IDR.BWA_WD, which represents the number of bits for a fixed-point fraction (See Section 11.3.8 MPAM Reference Manual).
Right now, the calculation works fine for 1, but is wrong for 2 bits and more. For example, 1 bit will equal 50%. In the current implementation, 2 bits will equal 33% instead of 25%. Similarly, 3 bits will equal 25% instead of 12.5%. This commit corrects the calculation.
Signed-off-by: Hesham Almatary hesham.almatary@huawei.com --- drivers/platform/mpam/mpam_resctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index f9f2bab8365a..6d35b3aea828 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -512,7 +512,7 @@ static u32 get_mba_granularity(struct mpam_props *cprops) * bwa_wd is the number of bits implemented in the 0.xxx * fixed point fraction. 1 bit is 50%, 2 is 25% etc. */ - return MAX_MBA_BW / (cprops->bwa_wd + 1); + return (MAX_MBA_BW / BIT(cprops->bwa_wd)); }
return 0;