Skip to contentSkip to conversation

platform/x86/intel/pmc: Do not decode the summary rows in ltr_show

PATCH In review Paul Menzel 2 participants 5 messages Nov 21 – Nov 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 platform/x86/intel/pmc: Do not decode the summary rows in ltr_show

On an Intel Tiger Lake laptop Dell XPS 13 9310, the first read of /sys/kernel/debug/pmc_core/ltr_show after loading the driver logs:

intel_pmc_core: Invalid LTR scale factor 7 (only 0-5 are valid per PCIe spec)

The value comes from the last row, AGGREGATED_SYSTEM (CNP_PMC_LTR_CUR_ASLT, 0x1b54). In 120 reads over 30 seconds, it read 0x7fffdff, 0x7fffc1f or 0x7fffc23 (117 times), and 0x40201ff or 0x402001f (3 times); another read gave 0x7ffffff. Decoded as an LTR message, the snoop half of the first group has the reserved bits 14:13 set and scale 7, and the second group is CURRENT_PLATFORM (0x40201) shifted left by eight with the low byte filled. So these two PMC registers do not seem to hold the PCIe LTR payload the per-IP rows carry, and decoding them only produces the warning (the decoded value is 0 anyway).

All ltr_show maps end with CURRENT_PLATFORM and AGGREGATED_SYSTEM, which pmc_core_send_ltr_ignore() already relies on. Print only the raw value of these two rows, as for rows without a requirement bit set, and keep the warning for the per-IP rows.

With the change, 200 reads with AGGREGATED_SYSTEM bit 15 set in 199 of them log nothing, and the CNV row is still decoded (0x89fe89fe, 522240 ns).

Fixes 8122e7cd806d ("platform/x86: intel_pmc_core: Decode Snoop / Non Snoop LTR")

---

Notes:
Claude Code (claude-opus-5-5) helped analyse the register values, write the patch, and test it on the Dell XPS 13 9310.

 drivers/platform/x86/intel/pmc/core.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/pmc/core.c +15 -2
index 71be313bdf0e1..e3f7d6bc8ce47 100644
@@ -631,6 +631,18 @@ static u32 convert_ltr_scale(u32 val)
 	return 1U << (5 * val);
 }
 
+/*
+ * Every ltr_show map ends with CURRENT_PLATFORM and AGGREGATED_SYSTEM. Unlike
+ * the per-IP rows, these PMC registers do not hold an LTR message payload as
+ * defined by PCIe; on Tiger Lake, for example, AGGREGATED_SYSTEM has the
+ * reserved bits 14:13 set and reads 0x7fffdff. Do not decode them.
+ */
+static bool pmc_core_ltr_is_summary(const struct pmc_bit_map *map,
+				    unsigned int index)
+{
+	return !map[index + 1].name || !map[index + 2].name;
+}
+
 static int pmc_core_ltr_show(struct seq_file *s, void *unused)
 {
 	struct pmc_dev *pmcdev = s->private;
@@ -654,6 +666,7 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
 		map = pmc->map->ltr_show_sts;
 		for (index = 0; map[index].name; index++) {
 			bool ltr_ign_data;
+			bool summary = pmc_core_ltr_is_summary(map, index);
 
 			if (index > pmc->map->ltr_ignore_max)
 				ltr_ign_data = false;
@@ -666,12 +679,12 @@ static int pmc_core_ltr_show(struct seq_file *s, void *unused)
 			snoop_ltr = ltr_raw_data & ~MTPMC_MASK;
 			nonsnoop_ltr = (ltr_raw_data >> 0x10) & ~MTPMC_MASK;
 
-			if (FIELD_GET(LTR_REQ_NONSNOOP, ltr_raw_data)) {
+			if (!summary && FIELD_GET(LTR_REQ_NONSNOOP, ltr_raw_data)) {
 				scale = FIELD_GET(LTR_DECODED_SCALE, nonsnoop_ltr);
 				val = FIELD_GET(LTR_DECODED_VAL, nonsnoop_ltr);
 				decoded_non_snoop_ltr = val * convert_ltr_scale(scale);
 			}
-			if (FIELD_GET(LTR_REQ_SNOOP, ltr_raw_data)) {
+			if (!summary && FIELD_GET(LTR_REQ_SNOOP, ltr_raw_data)) {
 				scale = FIELD_GET(LTR_DECODED_SCALE, snoop_ltr);
 				val = FIELD_GET(LTR_DECODED_VAL, snoop_ltr);
 				decoded_snoop_ltr = val * convert_ltr_scale(scale);
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/2 platform/x86/intel/pmc: Fix Tiger Lake LTR ignore maximum to 22

ltr_ignore_max is the highest index in ltr_show_sts that has a bit in the LTR_IGNORE register: pmc_core_send_ltr_ignore() accepts indices up to and including it, pmc_core_ltr_ignore_all() sets GENMASK(ltr_ignore_max, 0), and pmc_core_ltr_show() reads the LTR_IGNORE column for those rows. Cannon Lake (19, EMMC), Ice Lake (20, WIGIG), Alder Lake and Meteor Lake set it to the index of their last IP.

Tiger Lake shares cnp_ltr_show_map[], where THC1 is at index 22 and CURRENT_PLATFORM at index 23, but sets TGL_NUM_IP_IGN_ALLOWED to 23, the number of IPs. So debugfs accepts index 23, which is CURRENT_PLATFORM, a row that “cannot be used for LTR_IGNORE”, and the hardware drops the bit. On a Dell XPS 13 9310:

    $ echo 23 | sudo tee /sys/kernel/debug/pmc_core/ltr_ignore
    23
    $ sudo grep CURRENT_PLATFORM /sys/kernel/debug/pmc_core/ltr_show
    23	PMC0:CURRENT_PLATFORM	LTR: RAW: 0x40201	[…]	LTR_IGNORE: 0

whereas index 22 (THC1) reads back LTR_IGNORE: 1.

Set TGL_NUM_IP_IGN_ALLOWED to 22. Now the write of 23 fails with -EINVAL, like 24 before, and 22 still works.

Fixes 43ef6c226a60 ("platform/x86: intel_pmc_core: Add LTR registers for Tiger Lake")

---

Notes:
Claude Code (claude-opus-5-5) helped find the off-by-one, write the patch, and test it on the Dell XPS 13 9310.

 drivers/platform/x86/intel/pmc/core.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.h +1 -1
index e55164e5807fd..3edad5a1f72cd 100644
@@ -214,7 +214,7 @@ enum ppfear_regs {
 #define TGL_PMC_SLP_S0_RES_COUNTER_STEP		0x7A
 #define TGL_PMC_LTR_THC0			0x1C04
 #define TGL_PMC_LTR_THC1			0x1C08
-#define TGL_NUM_IP_IGN_ALLOWED			23
+#define TGL_NUM_IP_IGN_ALLOWED			22
 #define TGL_PMC_LPM_RES_COUNTER_STEP_X2		61	/* 30.5us * 2 */
 
 #define ADL_PMC_LTR_SPF				0x1C00
Signature · 1 line
2.54.0
#2 lore raw
In reply to Paul Menzel
Quoted 15 lines · Paul Menzel

On an Intel Tiger Lake laptop Dell XPS 13 9310, the first read of /sys/kernel/debug/pmc_core/ltr_show after loading the driver logs:

intel_pmc_core: Invalid LTR scale factor 7 (only 0-5 are valid per PCIe spec)

The value comes from the last row, AGGREGATED_SYSTEM (CNP_PMC_LTR_CUR_ASLT, 0x1b54). In 120 reads over 30 seconds, it read 0x7fffdff, 0x7fffc1f or 0x7fffc23 (117 times), and 0x40201ff or 0x402001f (3 times); another read gave 0x7ffffff. Decoded as an LTR message, the snoop half of the first group has the reserved bits 14:13 set and scale 7, and the second group is CURRENT_PLATFORM (0x40201) shifted left by eight with the low byte filled. So these two PMC registers do not seem to hold the PCIe LTR payload the per-IP rows carry, and decoding them only produces the warning (the decoded value is 0 anyway).

Quoted 7 lines

All ltr_show maps end with CURRENT_PLATFORM and AGGREGATED_SYSTEM, which pmc_core_send_ltr_ignore() already relies on. Print only the raw value of these two rows, as for rows without a requirement bit set, and keep the warning for the per-IP rows.

With the change, 200 reads with AGGREGATED_SYSTEM bit 15 set in 199 of them log nothing, and the CNV row is still decoded (0x89fe89fe, 522240 ns).

This paragraph better to be in the comment block, after '---' line below. We will have this information being archived by lore.kernel.org.

Quoted 10 lines
Fixes 8122e7cd806d ("platform/x86: intel_pmc_core: Decode Snoop / Non Snoop LTR")

---

Notes:
Claude Code (claude-opus-5-5) helped analyse the register values, write the patch, and test it on the Dell XPS 13 9310.

 drivers/platform/x86/intel/pmc/core.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

...

drivers/platform/x86/intel/pmc/core.c static u32 convert_ltr_scale(u32 val) · line 643

Quoted 10 lines
drivers/platform/x86/intel/pmc/core.c +10 -0
+/*
+ * Every ltr_show map ends with CURRENT_PLATFORM and AGGREGATED_SYSTEM. Unlike
+ * the per-IP rows, these PMC registers do not hold an LTR message payload as
+ * defined by PCIe; on Tiger Lake, for example, AGGREGATED_SYSTEM has the
+ * reserved bits 14:13 set and reads 0x7fffdff. Do not decode them.
+ */
+static bool pmc_core_ltr_is_summary(const struct pmc_bit_map *map,
+				    unsigned int index)
+{
+	return !map[index + 1].name || !map[index + 2].name;

How do we know that the index is not out-of-boundary?

Quoted 1 line

+}

...

drivers/platform/x86/intel/pmc/core.c static int pmc_core_ltr_show(struct seq_file *s, void *unused) · line 669

Quoted 3 lines
drivers/platform/x86/intel/pmc/core.c +1 -0
 		for (index = 0; map[index].name; index++) {
 			bool ltr_ign_data;
+			bool summary = pmc_core_ltr_is_summary(map, index);

Same question and keep this to be in reversed xmas tree order.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Dear Andy,

Thank you for your review.

Am 23.11.26 um 09:26 schrieb Andy Shevchenko:

Quoted 21 lines · Paul Menzel
Quoted 19 lines

On an Intel Tiger Lake laptop Dell XPS 13 9310, the first read of /sys/kernel/debug/pmc_core/ltr_show after loading the driver logs:

intel_pmc_core: Invalid LTR scale factor 7 (only 0-5 are valid per PCIe spec)

The value comes from the last row, AGGREGATED_SYSTEM (CNP_PMC_LTR_CUR_ASLT, 0x1b54). In 120 reads over 30 seconds, it read 0x7fffdff, 0x7fffc1f or 0x7fffc23 (117 times), and 0x40201ff or 0x402001f (3 times); another read gave 0x7ffffff. Decoded as an LTR message, the snoop half of the first group has the reserved bits 14:13 set and scale 7, and the second group is CURRENT_PLATFORM (0x40201) shifted left by eight with the low byte filled. So these two PMC registers do not seem to hold the PCIe LTR payload the per-IP rows carry, and decoding them only produces the warning (the decoded value is 0 anyway).

All ltr_show maps end with CURRENT_PLATFORM and AGGREGATED_SYSTEM, which pmc_core_send_ltr_ignore() already relies on. Print only the raw value of these two rows, as for rows without a requirement bit set, and keep the warning for the per-IP rows.

Quoted 5 lines
Quoted 2 lines

With the change, 200 reads with AGGREGATED_SYSTEM bit 15 set in 199 of them log nothing, and the CNV row is still decoded (0x89fe89fe, 522240 ns).

This paragraph better to be in the comment block, after '---' line below. We will have this information being archived by lore.kernel.org.

Personally, I prefer it in the commit message, but will move it in v2.

Quoted 13 lines
Quoted 10 lines
Fixes 8122e7cd806d ("platform/x86: intel_pmc_core: Decode Snoop / Non Snoop LTR")

---

Notes:
Claude Code (claude-opus-5-5) helped analyse the register values, write the patch, and test it on the Dell XPS 13 9310.

  drivers/platform/x86/intel/pmc/core.c | 17 +++++++++++++++--
  1 file changed, 15 insertions(+), 2 deletions(-)

...

Quoted 12 lines

drivers/platform/x86/intel/pmc/core.c static u32 convert_ltr_scale(u32 val) · line 643

Quoted 10 lines
drivers/platform/x86/intel/pmc/core.c +10 -0
+/*
+ * Every ltr_show map ends with CURRENT_PLATFORM and AGGREGATED_SYSTEM. Unlike
+ * the per-IP rows, these PMC registers do not hold an LTR message payload as
+ * defined by PCIe; on Tiger Lake, for example, AGGREGATED_SYSTEM has the
+ * reserved bits 14:13 set and reads 0x7fffdff. Do not decode them.
+ */
+static bool pmc_core_ltr_is_summary(const struct pmc_bit_map *map,
+				    unsigned int index)
+{
+	return !map[index + 1].name || !map[index + 2].name;

How do we know that the index is not out-of-boundary?

The maps end with a { } sentinel, and the caller runs only for an index with map[index].name set, so map[index + 1] is the sentinel at the latest. map[index + 2] is only read if map[index + 1].name is set, so it is the sentinel at the latest, too. But indeed, it is not obvious when reading the code, so v2 counts the rows of the map once before the loop and checks index + 2 >= num_rows instead; the helper is gone.

Quoted 9 lines
Quoted 1 line

+}

...

drivers/platform/x86/intel/pmc/core.c static int pmc_core_ltr_show(struct seq_file *s, void *unused) · line 669

Quoted 3 lines
  		for (index = 0; map[index].name; index++) {
  			bool ltr_ign_data;
drivers/platform/x86/intel/pmc/core.c +1 -0
+			bool summary = pmc_core_ltr_is_summary(map, index);

Same question and keep this to be in reversed xmas tree order.

Done in v2.

Kind regards,

Paul

#4 lore raw
Quoted 3 lines · Paul Menzel

Am 23.11.26 um 09:26 schrieb Andy Shevchenko:

Quoted 2 lines · Paul Menzel
Quoted 1 line

On an Intel Tiger Lake laptop Dell XPS 13 9310, the first read of

...

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+/*
+ * Every ltr_show map ends with CURRENT_PLATFORM and AGGREGATED_SYSTEM. Unlike
+ * the per-IP rows, these PMC registers do not hold an LTR message payload as
+ * defined by PCIe; on Tiger Lake, for example, AGGREGATED_SYSTEM has the

Quoted 8 lines
Quoted 8 lines

drivers/platform/x86/intel/pmc/core.c static u32 convert_ltr_scale(u32 val) · line 643

Quoted 6 lines

+ * reserved bits 14:13 set and reads 0x7fffdff. Do not decode them.
+ */

drivers/platform/x86/intel/pmc/core.c +4 -0
+static bool pmc_core_ltr_is_summary(const struct pmc_bit_map *map,
+				    unsigned int index)
+{
+	return !map[index + 1].name || !map[index + 2].name;

How do we know that the index is not out-of-boundary?

(My point was that you are iterating up to the record which has map[index].name == NULL, but when iterating the previous one, map[index + 2] is out of boundary.)

Quoted 6 lines

The maps end with a { } sentinel, and the caller runs only for an index with map[index].name set, so map[index + 1] is the sentinel at the latest. map[index + 2] is only read if map[index + 1].name is set, so it is the sentinel at the latest, too. But indeed, it is not obvious when reading the code, so v2 counts the rows of the map once before the loop and checks index + 2 >= num_rows instead; the helper is gone.

So it heavily relies on a side-effect of || operation. This is fragile approach.

Quoted 1 line
Quoted 1 line
Quoted 1 line

+}

Signature · 2 lines
With Best Regards,
Andy Shevchenko