perf/arm-cmn: Fix {wp_dev_sel2, wp_dev_sel} limited to 0/1 when MXP_MULTIPLE_DTM_EN is TRUE
Subsystems (2)
PATCH 1/1 perf/arm-cmn: Fix {wp_dev_sel2, wp_dev_sel} limited to 0/1 when MXP_MULTIPLE_DTM_EN is TRUE
When MXP_MULTIPLE_DTM_EN is TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2, wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.
Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when MXP_MULTIPLE_DTM_EN is TRUE.
Fix this by applying dev %= 2 to clamp the selection value to the valid range when MXP_MULTIPLE_DTM_EN is TRUE.
--- drivers/perf/arm-cmn.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/perf/arm-cmn.c +4 -0
@@ -1392,6 +1392,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);
@@ -1404,6 +1405,9 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx)if (is_cmn600) grp &=1 ; +if (cmn->multi_dtm) + dev %=2 ; + config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
Signature · 1 line
2.43.0
Hi,
Gentle ping on this patch.
Could someone please review it when time permits?
Thanks!
Allen
Quoted 39 lines · Shouping Wang
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.Fix this by applying
dev %= 2to clamp the selection value to the valid range whenMXP_MULTIPLE_DTM_ENis TRUE.Fixes 60d1504070c2 ("perf/arm-cmn: Support new IP features")Signed-off-by Shouping Wang <[email protected]>--- drivers/perf/arm-cmn.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/perf/arm-cmn.c +4
-0@@ -1392,6 +1392,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);@@ -1404,6 +1405,9 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx)if (is_cmn600) grp &=1 ; +if (cmn->multi_dtm) + dev %=2 ; + config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
Robin Murphy
maintainerQuoted 13 lines · allen.wang
Hi,
Gentle ping on this patch.
Could someone please review it when time permits?
Thanks!
AllenQuoted 3 lines · Shouping Wang
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.
Hmm, I read the "each DTM will only use..." wording[1] as implying that the hardware itself would ignore wp_dev_sel2 (especially since that would seem to be the obvious thing to do) - are you saying that that isn't the case? (I've never had access to any actual multi-DTM hardware...)
Thanks,
Robin.
Quoted 36 lines
Quoted 35 lines
Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.Fix this by applying
dev %= 2to clamp the selection value to the valid range whenMXP_MULTIPLE_DTM_ENis TRUE.Fixes 60d1504070c2 ("perf/arm-cmn: Support new IP features")Signed-off-by Shouping Wang <[email protected]>--- drivers/perf/arm-cmn.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/perf/arm-cmn.c +4
-0@@ -1392,6 +1392,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);@@ -1404,6 +1405,9 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx)if (is_cmn600) grp &=1 ; +if (cmn->multi_dtm) + dev %=2 ; + config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
Hi Robin:
Yes, that's exactly what I'm saying. I've tested this on actual multi-DTM hardware, and the hardware does not ignore wp_dev_sel2 automatically — it must be correctly configured by software.
Thanks!
Allen
Quoted 2 lines · Robin Murphy
https://support.arm.com/documentation/102308/0307/Debug-trace-and-PMU/
Debug-Trace-system-overview/DTM-watchpoint?lang=en
Robin Murphy
maintainerQuoted 22 lines · Shouping Wang
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.Fix this by applying
dev %= 2to clamp the selection value to the valid range whenMXP_MULTIPLE_DTM_ENis TRUE.Fixes 60d1504070c2 ("perf/arm-cmn: Support new IP features")Signed-off-by Shouping Wang <[email protected]>--- drivers/perf/arm-cmn.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/perf/arm-cmn.c +0
-0
drivers/perf/arm-cmn.c static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm, · line 1395
Quoted 4 lines
drivers/perf/arm-cmn.c +1
-0@@ -1392,6 +1392,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);
Nit: may as well refactor the is_cmn600 condition to reference cmn->part directly too.
drivers/perf/arm-cmn.c static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx) · line 1410
Quoted 10 lines
drivers/perf/arm-cmn.c +3
-0u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);@@ -1404,6 +1405,9 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx)if (is_cmn600) grp &=1 ; +if (cmn->multi_dtm) + dev %=2 ; +
Let's just make the whole setting of CMN_DTM_WPn_CONFIG_WP_DEV_SEL2 conditional on !multi_dtm, like for exclusive and combine further down (note that the CMN-600 "grp &= 1" is different, since that's more about sanitising invalid input values rather than the register encoding itself.)
Thanks,
Robin.
Quoted 3 lines
drivers/perf/arm-cmn.c +0
-0config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
PATCH v2 1/1 perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
When MXP_MULTIPLE_DTM_EN is TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2, wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.
Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when MXP_MULTIPLE_DTM_EN is TRUE.
Fix this by only setting CMN_DTM_WPn_CONFIG_WP_DEV_SEL2 when !multi_dtm.
---
Changes in v2:
- Made the setting of CMN_DTM_WPn_CONFIG_WP_DEV_SEL2 conditional on !multi_dtm, instead of clamping with dev %= 2.
- Refactored is_cmn600 to use cmn->part directly.
- Updated the commit message.
Link to v1: https://lore.kernel.org/lkml/[email protected]/
drivers/perf/arm-cmn.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/perf/arm-cmn.c +7 -3
@@ -1393,13 +1393,14 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);u32 grp =CMN_EVENT_WP_GRP (event);u32 exc =CMN_EVENT_WP_EXCLUSIVE (event);u32 combine =CMN_EVENT_WP_COMBINE (event); -bool is_cmn600 =to_cmn (event->pmu)->part ==PART_CMN600 ; +bool is_cmn600 = cmn->part ==PART_CMN600 ;/* CMN-600 supports only primary and secondary matching groups */ if (is_cmn600)
@@ -1407,8 +1408,11 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx) config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp); + +if (!cmn->multi_dtm) + config |=FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +if (exc) config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE : CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH v2] perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.
Quoted 5 lines
Fix this by only setting
CMN_DTM_WPn_CONFIG_WP_DEV_SEL2when !multi_dtm.Fixes 60d1504070c2 ("perf/arm-cmn: Support new IP features")Signed-off-by Shouping Wang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH v2] perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
In reply to Shouping WangQuoted 3 lines · Shouping Wang
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.
Poor documentation strikes again!
Quoted 6 lines
Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.Fix this by only setting
CMN_DTM_WPn_CONFIG_WP_DEV_SEL2when !multi_dtm.
Thanks for the fix!
Robin.
Quoted 49 lines
Fixes 60d1504070c2 ("perf/arm-cmn: Support new IP features")Signed-off-by Shouping Wang <[email protected]>---
Changes in v2:
- Made the setting ofCMN_DTM_WPn_CONFIG_WP_DEV_SEL2conditional on !multi_dtm, instead of clamping with dev %= 2.
- Refactoredis_cmn600to usecmn->partdirectly.
- Updated the commit message.Link to v1: https://lore.kernel.org/lkml/[email protected]/
drivers/perf/arm-cmn.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/perf/arm-cmn.c +7
-3@@ -1393,13 +1393,14 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);u32 grp =CMN_EVENT_WP_GRP (event);u32 exc =CMN_EVENT_WP_EXCLUSIVE (event);u32 combine =CMN_EVENT_WP_COMBINE (event); -bool is_cmn600 =to_cmn (event->pmu)->part ==PART_CMN600 ; +bool is_cmn600 = cmn->part ==PART_CMN600 ;/* CMN-600 supports only primary and secondary matching groups */ if (is_cmn600)@@ -1407,8 +1408,11 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx) config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp); + +if (!cmn->multi_dtm) + config |=FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +if (exc) config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE : CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE;
Re: [PATCH v2] perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
In reply to Shouping WangQuoted 9 lines · Shouping Wang
When
MXP_MULTIPLE_DTM_ENis TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2,wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when
MXP_MULTIPLE_DTM_ENis TRUE.[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
https://git.kernel.org/arm64/c/49daa3d668b6
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev