Skip to contentSkip to conversation

perf: CXL: fix mismatched number of counters mask

PATCH Applied Jeongtae Park 3 participants 5 messages Sep 5, 2023 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20230905123044epcas2p2b1052956527cf63a03e2895d4b93e7e1@epcas2p2.samsung.com

#1 lore raw

PATCH 1/1 perf: CXL: fix mismatched number of counters mask

The number of Count Units field is described as 6 bits long in the CXL 3.0 specification. However, its mask value was only declared as 5 bits long.

---
 drivers/perf/cxl_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +1 -1
index 0a8f597e695b..365d964b0f6a 100644
@@ -25,7 +25,7 @@
 #include "../cxl/pmu.h"
 
 #define CXL_PMU_CAP_REG			0x0
-#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(4, 0)
+#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(5, 0)
 #define   CXL_PMU_CAP_COUNTER_WIDTH_MSK			GENMASK_ULL(15, 8)
 #define   CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK		GENMASK_ULL(24, 20)
 #define   CXL_PMU_CAP_FILTERS_SUP_MSK			GENMASK_ULL(39, 32)

base-commit: fe77cc2e5a6a7c85f5c6ef8a39d7694ffc7f41c9

Signature · 7 lines
2.34.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#2 lore raw
Quoted 14 lines · Jeongtae Park

The number of Count Units field is described as 6 bits long in the CXL 3.0 specification. However, its mask value was only declared as 5 bits long.

---
 drivers/perf/cxl_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +0 -0
index 0a8f597e695b..365d964b0f6a 100644

drivers/perf/cxl_pmu.c line 31

Quoted 8 lines
drivers/perf/cxl_pmu.c +1 -1
@@ -25,7 +25,7 @@
 #include "../cxl/pmu.h"
 
 #define CXL_PMU_CAP_REG			0x0
-#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(4, 0)
+#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(5, 0)
 #define   CXL_PMU_CAP_COUNTER_WIDTH_MSK			GENMASK_ULL(15, 8)
 #define   CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK		GENMASK_ULL(24, 20)
 #define   CXL_PMU_CAP_FILTERS_SUP_MSK			GENMASK_ULL(39, 32)

I don't have access to the CXL spec, but widening this mask looks like it puts us out-of-whack with CXL_PMU_MAX_COUNTERS.

Did v3.0 of the spec bump the number of counters? If so, can you please check that this is a backwards-compatible change?

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 27 lines · On Tue, 5 Sep 2023 15:28:54 +0100 Will Deacon <[email protected]> wrote:
Quoted 14 lines · Jeongtae Park

The number of Count Units field is described as 6 bits long in the CXL 3.0 specification. However, its mask value was only declared as 5 bits long.

---
 drivers/perf/cxl_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +0 -0
index 0a8f597e695b..365d964b0f6a 100644

drivers/perf/cxl_pmu.c line 31

Quoted 8 lines
drivers/perf/cxl_pmu.c +1 -1
@@ -25,7 +25,7 @@
 #include "../cxl/pmu.h"
 
 #define CXL_PMU_CAP_REG			0x0
-#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(4, 0)
+#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(5, 0)
 #define   CXL_PMU_CAP_COUNTER_WIDTH_MSK			GENMASK_ULL(15, 8)
 #define   CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK		GENMASK_ULL(24, 20)
 #define   CXL_PMU_CAP_FILTERS_SUP_MSK			GENMASK_ULL(39, 32)  

I don't have access to the CXL spec, but widening this mask looks like it puts us out-of-whack with CXL_PMU_MAX_COUNTERS.

Quoted 2 lines

Did v3.0 of the spec bump the number of counters? If so, can you please check that this is a backwards-compatible change?

CXL Performance monitors were only introduced in CXL 3.0 so not that.

The max value that register can take is 0x3f (0 based, so 64 counters == CXL_PMU_MAX_COUNTERS)
So it should be 6 bits wide. I did some history digging and this isn't even a draft spec / final spec issue - simple typo I guess.

Fix seems correct to me.

Quoted 2 lines

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#4 lore raw
Quoted 30 lines · Jonathan Cameron
Quoted 27 lines · On Tue, 5 Sep 2023 15:28:54 +0100 Will Deacon <[email protected]> wrote:
Quoted 14 lines · Jeongtae Park

The number of Count Units field is described as 6 bits long in the CXL 3.0 specification. However, its mask value was only declared as 5 bits long.

---
 drivers/perf/cxl_pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/perf/cxl_pmu.c +0 -0
index 0a8f597e695b..365d964b0f6a 100644

drivers/perf/cxl_pmu.c line 31

Quoted 8 lines
drivers/perf/cxl_pmu.c +1 -1
@@ -25,7 +25,7 @@
 #include "../cxl/pmu.h"
 
 #define CXL_PMU_CAP_REG			0x0
-#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(4, 0)
+#define   CXL_PMU_CAP_NUM_COUNTERS_MSK			GENMASK_ULL(5, 0)
 #define   CXL_PMU_CAP_COUNTER_WIDTH_MSK			GENMASK_ULL(15, 8)
 #define   CXL_PMU_CAP_NUM_EVN_CAP_REG_SUP_MSK		GENMASK_ULL(24, 20)
 #define   CXL_PMU_CAP_FILTERS_SUP_MSK			GENMASK_ULL(39, 32)  

I don't have access to the CXL spec, but widening this mask looks like it puts us out-of-whack with CXL_PMU_MAX_COUNTERS.

Quoted 4 lines
Quoted 2 lines

Did v3.0 of the spec bump the number of counters? If so, can you please check that this is a backwards-compatible change?

CXL Performance monitors were only introduced in CXL 3.0 so not that.

Thanks for the information!

Quoted 4 lines

The max value that register can take is 0x3f (0 based, so 64 counters == CXL_PMU_MAX_COUNTERS)
So it should be 6 bits wide. I did some history digging and this isn't even a draft spec / final spec issue - simple typo I guess.

Heh, I blame the heat as I thought this was extending to 7 bits for some reason. Sorry about that.

Quoted 3 lines

Fix seems correct to me.

I'll pick it up, thanks again!

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Applied
#5 lore raw
In reply to Jeongtae Park
Quoted 5 lines · Jeongtae Park

The number of Count Units field is described as 6 bits long in the CXL 3.0 specification. However, its mask value was only declared as 5 bits long.

Applied to arm64 (for-next/fixes), thanks!

[1/1] perf: CXL: fix mismatched number of counters mask

      https://git.kernel.org/arm64/c/7625df9f4b25

Cheers,

Signature · 10 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel