arm_mpam: Fix MPAMCFG_MBW_PBM register setting
Fenghua Yu
reviewerPATCH 1/1 arm_mpam: Fix MPAMCFG_MBW_PBM register setting
MPAMCFG_MBW_PBM is written from cfg if cfg has the MBW partition feature. It is reset when cfg does not have the MBW partition feature.
But the register handling is reversed. This may cause an incorrect register setting. For example, during an MPAM reset, reset_cfg is empty (no MBW partition feature set), and cfg->mbw_pbm is 0. Instead of resetting MPAMCFG_MBW_PBM to all 1's, the current logic will set it to cfg->mbw_pbm, which is 0.
Fix the issue by swapping the if/else branches.
--- drivers/resctrl/mpam_devices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/resctrl/mpam_devices.c +2 -2
@@ -1570,9 +1570,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,if (mpam_has_feature (mpam_feat_mbw_part, rprops)) {if (mpam_has_feature (mpam_feat_mbw_part, cfg)) -mpam_reset_msc_bitmap (msc,MPAMCFG_MBW_PBM , rprops->mbw_pbm_bits); -else mpam_write_partsel_reg (msc,MBW_PBM , cfg->mbw_pbm); +else +mpam_reset_msc_bitmap (msc,MPAMCFG_MBW_PBM , rprops->mbw_pbm_bits); }if (mpam_has_feature (mpam_feat_mbw_min, rprops)) {
Signature · 1 line
2.43.0
Hi Fenghua,
Quoted 9 lines · Fenghua Yu
MPAMCFG_MBW_PBMis written from cfg if cfg has the MBW partition feature. It is reset when cfg does not have the MBW partition feature.But the register handling is reversed. This may cause an incorrect register setting. For example, during an MPAM reset,
reset_cfgis empty (no MBW partition feature set), andcfg->mbw_pbmis 0. Instead of resettingMPAMCFG_MBW_PBMto all 1's, the current logic will set it tocfg->mbw_pbm, which is 0.
Quoted 9 lines
Fix the issue by swapping the if/else branches.
Fixes a1cb6577f575 ("arm_mpam: Reset when feature configuration bit unset")Reported-by Matt Ochs <[email protected]>Signed-off-by Fenghua Yu <[email protected]>--- drivers/resctrl/mpam_devices.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
The fix itself looks reasonable to me, but two questions below.
Quoted 6 lines
drivers/resctrl/mpam_devices.c +0
-0@@ -1570,9 +1570,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
drivers/resctrl/mpam_devices.c static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · line 1578
Quoted 10 lines
drivers/resctrl/mpam_devices.c +2
-2if (mpam_has_feature (mpam_feat_mbw_part, rprops)) {if (mpam_has_feature (mpam_feat_mbw_part, cfg)) -mpam_reset_msc_bitmap (msc,MPAMCFG_MBW_PBM , rprops->mbw_pbm_bits); -else mpam_write_partsel_reg (msc,MBW_PBM , cfg->mbw_pbm); +else +mpam_reset_msc_bitmap (msc,MPAMCFG_MBW_PBM , rprops->mbw_pbm_bits); }if (mpam_has_feature (mpam_feat_mbw_min, rprops)) {
Which machine or system where mpam_feat_mbw_part is set on RIS? As I can remember, this feature isn't available on grace-hopper.
Besides, I don't think this feature is well handled at present because mpam_config::mbw_pbm is only 32-bits in length, which doesn't match with the maximal length of the bit map (4096) as documented in the spec.
Thanks,
Gavin
Fenghua Yu
reviewerHi, Gavin,
Quoted 22 lines · Gavin Shan
Hi Fenghua,
Quoted 9 lines · Fenghua Yu
MPAMCFG_MBW_PBMis written from cfg if cfg has the MBW partition feature. It is reset when cfg does not have the MBW partition feature.But the register handling is reversed. This may cause an incorrect register setting. For example, during an MPAM reset,
reset_cfgis empty (no MBW partition feature set), andcfg->mbw_pbmis 0. Instead of resettingMPAMCFG_MBW_PBMto all 1's, the current logic will set it tocfg->mbw_pbm, which is 0.Quoted 9 lines
Fix the issue by swapping the if/else branches.
Fixes a1cb6577f575 ("arm_mpam: Reset when feature configuration bit unset")Reported-by Matt Ochs <[email protected]>Signed-off-by Fenghua Yu <[email protected]>---
drivers/resctrl/mpam_devices.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines
The fix itself looks reasonable to me, but two questions below.
Reviewed-by Gavin Shan <[email protected]>
Thank you for reviewing the patch!
Quoted 15 lines
Quoted 15 lines
drivers/resctrl/mpam_devices.c +2
-2@@ -1570,9 +1570,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, if (mpam_has_feature(mpam_feat_mbw_part, rprops)) { if (mpam_has_feature(mpam_feat_mbw_part, cfg)) - mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops- >mbw_pbm_bits); - else mpam_write_partsel_reg(msc, MBW_PBM, cfg->mbw_pbm); + else + mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops-
Quoted 6 lines
Quoted 3 lines
drivers/resctrl/mpam_devices.c +0
-0>mbw_pbm_bits); }if (
mpam_has_feature(mpam_feat_mbw_min, rprops)) {Which machine or system where
mpam_feat_mbw_partis set on RIS? As I can remember, this feature isn't available on grace-hopper.
Neither Grace nor Vera supports this feature.
Quoted 4 lines
Besides, I don't think this feature is well handled at present because
mpam_config::mbw_pbmis only 32-bits in length, which doesn't match with the maximal length of the bit map (4096) as documented in the spec.
Right. The current code only can support up to 32 bits of PBM bitmap. If PBM bitmp length is bigger than 32 bits, it's broken. I guess we will need to handle this feature properly when hardware supports more than 32 bits of PBM bitmap.
Ditto for CPBM bitmap.
This patch currently only fixes the regression issue introduced in commit a1cb6577f575 regardless size of PBM bitmap.
Thanks.
-Fenghua
Hi Fenghua,
Thanks for the fix!
Quoted 54 lines · Fenghua Yu
Hi, Gavin,
Quoted 22 lines · Gavin Shan
Hi Fenghua,
Quoted 9 lines · Fenghua Yu
MPAMCFG_MBW_PBMis written from cfg if cfg has the MBW partition feature. It is reset when cfg does not have the MBW partition feature.But the register handling is reversed. This may cause an incorrect register setting. For example, during an MPAM reset,
reset_cfgis empty (no MBW partition feature set), andcfg->mbw_pbmis 0. Instead of resettingMPAMCFG_MBW_PBMto all 1's, the current logic will set it tocfg->mbw_pbm, which is 0.Quoted 9 lines
Fix the issue by swapping the if/else branches.
Fixes a1cb6577f575 ("arm_mpam: Reset when feature configuration bit unset")Reported-by Matt Ochs <[email protected]>Signed-off-by Fenghua Yu <[email protected]>---
drivers/resctrl/mpam_devices.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 3 lines
The fix itself looks reasonable to me, but two questions below.
Reviewed-by Gavin Shan <[email protected]>Thank you for reviewing the patch!
Quoted 11 lines
Quoted 11 lines
drivers/resctrl/mpam_devices.c +0
-2@@ -1570,9 +1570,9 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, if (mpam_has_feature(mpam_feat_mbw_part, rprops)) { if (mpam_has_feature(mpam_feat_mbw_part, cfg)) - mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops- >mbw_pbm_bits); - elseQuoted 8 lines
drivers/resctrl/mpam_devices.c static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · line 1578
Quoted 5 lines
drivers/resctrl/mpam_devices.c +2
-0mpam_write_partsel_reg(msc, MBW_PBM, cfg->mbw_pbm); + else + mpam_reset_msc_bitmap(msc, MPAMCFG_MBW_PBM, rprops- >mbw_pbm_bits); } if (mpam_has_feature(mpam_feat_mbw_min, rprops)) {Which machine or system where
mpam_feat_mbw_partis set on RIS? As I can remember, this feature isn't available on grace-hopper.Neither Grace nor Vera supports this feature.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Besides, I don't think this feature is well handled at present because
mpam_config::mbw_pbmis only 32-bits in length, which doesn't match with the maximal length of the bit map (4096) as documented in the spec. Right. The current code only can support up to 32 bits of PBM bitmap. If PBMbitmp length is bigger than 32 bits, it's broken. I guess we will need to handle this feature properly when hardware supports more than 32 bits of PBM bitmap.
mpam_config::mbw_pbm shouldn't have made it into the driver as nothing ever sets it. Otherwise, there is no attempt to make use of the MBW_PBM other than to reset it to an appropriate value, which this patch fixes. I guess this is a lesson for me on the perils of dead code.
Quoted 2 lines
Ditto for CPBM bitmap.
If the CPBM bitmap has more than 32 bits, as checked by cache_has_usable_cpor(), then we don't attempt to configure it other than to reset. If there is hardware with more than 32 bits we'd first consider extending this to 64bits.
Quoted 3 lines
This patch currently only fixes the regression issue introduced in commit
a1cb6577f575regardless size of PBM bitmap.
Looks good to me.
Thanks,
Ben
Quoted 4 lines
Thanks.
-Fenghua
Will Deacon
AppliedQuoted 10 lines · Fenghua Yu
MPAMCFG_MBW_PBMis written from cfg if cfg has the MBW partition feature. It is reset when cfg does not have the MBW partition feature.But the register handling is reversed. This may cause an incorrect register setting. For example, during an MPAM reset,
reset_cfgis empty (no MBW partition feature set), andcfg->mbw_pbmis 0. Instead of resettingMPAMCFG_MBW_PBMto all 1's, the current logic will set it tocfg->mbw_pbm, which is 0.[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm_mpam: Fix MPAMCFG_MBW_PBM register setting
https://git.kernel.org/arm64/c/021118ce5ea9
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev