On Wed, 23 Nov 2022 16:11:51 +0000 James Morse via Linaro-open-discussions linaro-open-discussions@op-lists.linaro.org wrote:
Hi Hesham,
On 22/11/2022 11:41, Hesham Almatary wrote:
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.
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;
Oops, thanks!
I've included this as is, but If I do any refactoring near here it is likely to get squashed in to the buggy patch. If that happens I'll add you to CC on the patch. (The joke is CC also stands for Celebrate Contribution!)
Glad that was the right fix. No problem about squashing it, please feel free to do whatever makes things go smoother for you.
Thanks,
James