Skip to contentSkip to conversation

platform/x86: intel_pmc_core: Add bug fixes or code

PATCH Superseded Gayatri Kammela 3 participants 8 messages Feb 27, 2020 x86 platform drivers

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover platform/x86: intel_pmc_core: Add bug fixes or code

Hi,

This patch series consists of bug fixes and code optimization for the series https://patchwork.kernel.org/patch/11365325/

Patch 1: Make pmc_core_lpm_display() generic
Patch 2: Relocate both pmc_core_slps0_display() and pmc_core_lpm_display() Patch 3: Remove the duplicate if() condition to create debugfs entry Patch 4: Add back slp_s0_offset attribute back to tgl_reg_map

Gayatri Kammela (4):
platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
for platforms that support sub-states
platform/x86: intel_pmc_core: fix: Relocate pmc_core_slps0_display()
and pmc_core_lpm_display() to outside of CONFIG_DEBUG_FS
platform/x86: intel_pmc_core: fix: Remove the duplicate if() to create
debugfs entry for substate_live_status_registers
platform/x86: intel_pmc_core: fix: Add slp_s0_offset attribute back to
tgl_reg_map

 drivers/platform/x86/intel_pmc_core.c | 131 +++++++++++++-------------
 1 file changed, 66 insertions(+), 65 deletions(-)
Cc Chen Zhou <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc David Box <[email protected]>
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic for platforms that support sub-states

Currently pmc_core_lpm_display() uses array of struct pointers i.e., tgl_lpm_maps for Tiger Lake directly to iterate through and to get the number of status/live status registers which is hardcoded and will not work for future platforms that support sub-states. To maintain readability, make pmc_core_lpm_display() generic, so that it can re-used for future platforms.

---
 drivers/platform/x86/intel_pmc_core.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/platform/x86/intel_pmc_core.c +7 -3
index f4a36fbabf4c..333c6963d270 100644
@@ -979,10 +979,14 @@ static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
 				 const char *str,
 				 const struct pmc_bit_map **maps)
 {
-	u32 lpm_regs[ARRAY_SIZE(tgl_lpm_maps)-1];
-	int index, idx, len = 32, bit_mask;
+	int index, idx, len = 32, bit_mask, arr_size = 0;
 
-	for (index = 0; tgl_lpm_maps[index]; index++) {
+	for (index = 0; maps[index]; index++)
+		arr_size++;
+
+	u32 lpm_regs[arr_size];
+
+	for (index = 0; maps[index]; index++) {
 		lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
 		offset += 4;
 	}
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v1 1/4] platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic for platforms that support sub-states

Thank you for the patch! Perhaps something to improve:

Hi Gayatri,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on platform-drivers-x86/for-next]
[also build test WARNING on next-20200226]
[cannot apply to tip/auto-latest linux/master linus/master v5.6-rc3] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Gayatri-Kammela/platform-x86-intel_pmc_core-Add-bug-fixes-or-code/20200227-105701
base:   git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git for-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

drivers/platform/x86/intel_pmc_core.c: In function 'pmc_core_lpm_display':

>> drivers/platform/x86/intel_pmc_core.c:987:2: warning: ISO C90 forbids variable length array 'lpm_regs' [-Wvla]
     u32 lpm_regs[arr_size];
     ^~~
>> drivers/platform/x86/intel_pmc_core.c:987:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

vim +/lpm_regs +987 drivers/platform/x86/intel_pmc_core.c

976
977 static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
978 struct seq_file *s, u32 offset,
979 const char *str,
980 const struct pmc_bit_map **maps)
981 {
982 int index, idx, len = 32, bit_mask, arr_size = 0;
983
984 for (index = 0; maps[index]; index++)
985 arr_size++;
986

 > 987		u32 lpm_regs[arr_size];

988
989 for (index = 0; maps[index]; index++) {
990 lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
991 offset += 4;
992 }
993
994 for (idx = 0; maps[idx]; idx++) {
995 if (dev)
996 dev_dbg(dev, "\nLPM_%s_%d:\t0x%x\n", str, idx,
997 lpm_regs[idx]);
998 if (s)
999 seq_printf(s, "\nLPM_%s_%d:\t0x%x\n", str, idx,
1000 lpm_regs[idx]);
1001 for (index = 0; maps[idx][index].name && index < len; index++) {
1002 bit_mask = maps[idx][index].bit_mask;
1003 if (dev)
1004 dev_dbg(dev, "%-30s %-30d\n",
1005 maps[idx][index].name,
1006 lpm_regs[idx] & bit_mask ? 1 : 0);
1007 if (s)
1008 seq_printf(s, "%-30s %-30d\n",
1009 maps[idx][index].name,
1010 lpm_regs[idx] & bit_mask ? 1 : 0);
1011 }
1012 }
1013 }
1014

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#3 lore raw

PATCH 2/4 platform/x86: intel_pmc_core: fix: Relocate pmc_core_slps0_display() and pmc_core_lpm_display() to outside of CONFIG_DEBUG_FS

In reply to Gayatri Kammela

Since pmc_core_slps0_display() and pmc_core_lpm_display() is responsible for dumping as well as displaying debug registers, there is no need for these two functions to be defined under CONFIG_DEBUG_FS.

Hence, relocate these functions from under CONFIG_DEBUG_FS to above the block.

Cc Chen Zhou <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc David E. Box <[email protected]>
---
 drivers/platform/x86/intel_pmc_core.c | 130 +++++++++++++-------------
 1 file changed, 65 insertions(+), 65 deletions(-)
drivers/platform/x86/intel_pmc_core.c +65 -65
index 333c6963d270..37db13ad7d39 100644
@@ -612,6 +612,71 @@ static int pmc_core_check_read_lock_bit(void)
 	return value & BIT(pmcdev->map->pm_read_disable_bit);
 }
 
+static void pmc_core_slps0_display(struct pmc_dev *pmcdev, struct device *dev,
+				   struct seq_file *s)
+{
+	const struct pmc_bit_map **maps = pmcdev->map->slps0_dbg_maps;
+	const struct pmc_bit_map *map;
+	int offset = pmcdev->map->slps0_dbg_offset;
+	u32 data;
+
+	while (*maps) {
+		map = *maps;
+		data = pmc_core_reg_read(pmcdev, offset);
+		offset += 4;
+		while (map->name) {
+			if (dev)
+				dev_dbg(dev, "SLP_S0_DBG: %-32s\tState: %s\n",
+					map->name,
+					data & map->bit_mask ? "Yes" : "No");
+			if (s)
+				seq_printf(s, "SLP_S0_DBG: %-32s\tState: %s\n",
+					   map->name,
+					   data & map->bit_mask ? "Yes" : "No");
+			++map;
+		}
+		++maps;
+	}
+}
+
+static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
+				 struct seq_file *s, u32 offset,
+				 const char *str,
+				 const struct pmc_bit_map **maps)
+{
+	int index, idx, len = 32, bit_mask, arr_size = 0;
+
+	for (index = 0; maps[index]; index++)
+		arr_size++;
+
+	u32 lpm_regs[arr_size];
+
+	for (index = 0; maps[index]; index++) {
+		lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
+		offset += 4;
+	}
+
+	for (idx = 0; maps[idx]; idx++) {
+		if (dev)
+			dev_dbg(dev, "\nLPM_%s_%d:\t0x%x\n", str, idx,
+				lpm_regs[idx]);
+		if (s)
+			seq_printf(s, "\nLPM_%s_%d:\t0x%x\n", str, idx,
+				   lpm_regs[idx]);
+		for (index = 0; maps[idx][index].name && index < len; index++) {
+			bit_mask = maps[idx][index].bit_mask;
+			if (dev)
+				dev_dbg(dev, "%-30s %-30d\n",
+					maps[idx][index].name,
+					lpm_regs[idx] & bit_mask ? 1 : 0);
+			if (s)
+				seq_printf(s, "%-30s %-30d\n",
+					   maps[idx][index].name,
+					   lpm_regs[idx] & bit_mask ? 1 : 0);
+		}
+	}
+}
+
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 static bool slps0_dbg_latch;
 
@@ -844,33 +909,6 @@ static void pmc_core_slps0_dbg_latch(struct pmc_dev *pmcdev, bool reset)
 	mutex_unlock(&pmcdev->lock);
 }
 
-static void pmc_core_slps0_display(struct pmc_dev *pmcdev, struct device *dev,
-				   struct seq_file *s)
-{
-	const struct pmc_bit_map **maps = pmcdev->map->slps0_dbg_maps;
-	const struct pmc_bit_map *map;
-	int offset = pmcdev->map->slps0_dbg_offset;
-	u32 data;
-
-	while (*maps) {
-		map = *maps;
-		data = pmc_core_reg_read(pmcdev, offset);
-		offset += 4;
-		while (map->name) {
-			if (dev)
-				dev_dbg(dev, "SLP_S0_DBG: %-32s\tState: %s\n",
-					map->name,
-					data & map->bit_mask ? "Yes" : "No");
-			if (s)
-				seq_printf(s, "SLP_S0_DBG: %-32s\tState: %s\n",
-					   map->name,
-					   data & map->bit_mask ? "Yes" : "No");
-			++map;
-		}
-		++maps;
-	}
-}
-
 static int pmc_core_slps0_dbg_show(struct seq_file *s, void *unused)
 {
 	struct pmc_dev *pmcdev = s->private;
@@ -974,44 +1012,6 @@ static int pmc_core_substate_res_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_substate_res);
 
-static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
-				 struct seq_file *s, u32 offset,
-				 const char *str,
-				 const struct pmc_bit_map **maps)
-{
-	int index, idx, len = 32, bit_mask, arr_size = 0;
-
-	for (index = 0; maps[index]; index++)
-		arr_size++;
-
-	u32 lpm_regs[arr_size];
-
-	for (index = 0; maps[index]; index++) {
-		lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
-		offset += 4;
-	}
-
-	for (idx = 0; maps[idx]; idx++) {
-		if (dev)
-			dev_dbg(dev, "\nLPM_%s_%d:\t0x%x\n", str, idx,
-				lpm_regs[idx]);
-		if (s)
-			seq_printf(s, "\nLPM_%s_%d:\t0x%x\n", str, idx,
-				   lpm_regs[idx]);
-		for (index = 0; maps[idx][index].name && index < len; index++) {
-			bit_mask = maps[idx][index].bit_mask;
-			if (dev)
-				dev_dbg(dev, "%-30s %-30d\n",
-					maps[idx][index].name,
-					lpm_regs[idx] & bit_mask ? 1 : 0);
-			if (s)
-				seq_printf(s, "%-30s %-30d\n",
-					   maps[idx][index].name,
-					   lpm_regs[idx] & bit_mask ? 1 : 0);
-		}
-	}
-}
-
 static int pmc_core_substate_sts_regs_show(struct seq_file *s, void *unused)
 {
 	struct pmc_dev *pmcdev = s->private;
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/4 platform/x86: intel_pmc_core: fix: Remove the duplicate if() to create debugfs entry for substate_live_status_registers

In reply to Gayatri Kammela

A debugfs entry for substate_live_status_registers is created only if the platform has sub-states, which requires the same condition to create substate_status_registers debugfs entry. Hence remove the redundant condition and re-use the exisiting one.

Cc Chen Zhou <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc David E. Box <[email protected]>
---
 drivers/platform/x86/intel_pmc_core.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/platform/x86/intel_pmc_core.c +0 -3
index 37db13ad7d39..bbd3805f36e1 100644
@@ -1112,9 +1112,6 @@ static void pmc_core_dbgfs_register(struct pmc_dev *pmcdev)
 		debugfs_create_file("substate_status_registers", 0444,
 				    pmcdev->dbgfs_dir, pmcdev,
 				    &pmc_core_substate_sts_regs_fops);
-	}
-
-	if (pmcdev->map->lpm_status_offset) {
 		debugfs_create_file("substate_live_status_registers", 0444,
 				    pmcdev->dbgfs_dir, pmcdev,
 				    &pmc_core_substate_l_sts_regs_fops);
Signature · 1 line
2.17.1
#5 lore raw

PATCH 4/4 platform/x86: intel_pmc_core: fix: Add slp_s0_offset attribute back to tgl_reg_map

In reply to Gayatri Kammela

If platforms such as Tiger Lake has sub-states of S0ix, then attributes such as slps0_dbg_offset become invalid. But slp_s0_offset is still valid as it is used to get the pmcdev_base_addr.

Hence, add back slp_s0_offset and remove slps0_dbg_offset attributes.

Cc Chen Zhou <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc David E. Box <[email protected]>
---
 drivers/platform/x86/intel_pmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel_pmc_core.c +1 -1
index bbd3805f36e1..87a6aa4f43fa 100644
@@ -556,9 +556,9 @@ static const struct pmc_bit_map *tgl_lpm_maps[] = {
 
 static const struct pmc_reg_map tgl_reg_map = {
 	.pfear_sts = ext_tgl_pfear_map,
+	.slp_s0_offset = CNP_PMC_SLP_S0_RES_COUNTER_OFFSET,
 	.ltr_show_sts = cnp_ltr_show_map,
 	.msr_sts = msr_map,
-	.slps0_dbg_offset = CNP_PMC_SLPS0_DBG_OFFSET,
 	.ltr_ignore_offset = CNP_PMC_LTR_IGNORE_OFFSET,
 	.regmap_length = CNP_PMC_MMIO_REG_LEN,
 	.ppfear0_offset = CNP_PMC_HOST_PPFEAR0A,
Signature · 1 line
2.17.1
#6 lore raw
In reply to Gayatri Kammela
Quoted 9 lines · Gayatri Kammela

Hi,

This patch series consists of bug fixes and code optimization for the series https://patchwork.kernel.org/patch/11365325/

Patch 1: Make pmc_core_lpm_display() generic
Patch 2: Relocate both pmc_core_slps0_display() and pmc_core_lpm_display() Patch 3: Remove the duplicate if() condition to create debugfs entry Patch 4: Add back slp_s0_offset attribute back to tgl_reg_map

Let's do other way around, i.e. patch 2 as a first in the series, so I may fix the current (visible) issue.

Then fix the kbuild bot complains and send the rest.

Quoted 20 lines

Gayatri Kammela (4):
platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
for platforms that support sub-states
platform/x86: intel_pmc_core: fix: Relocate pmc_core_slps0_display()
and pmc_core_lpm_display() to outside of CONFIG_DEBUG_FS
platform/x86: intel_pmc_core: fix: Remove the duplicate if() to create
debugfs entry for substate_live_status_registers
platform/x86: intel_pmc_core: fix: Add slp_s0_offset attribute back to
tgl_reg_map

 drivers/platform/x86/intel_pmc_core.c | 131 +++++++++++++-------------
 1 file changed, 66 insertions(+), 65 deletions(-)
Cc Chen Zhou <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc David Box <[email protected]>
Signature · 1 line
2.17.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
Quoted 21 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Thursday, February 27, 2020 1:57 AM
To: Kammela, Gayatri <[email protected]>
Cc: [email protected]; [email protected]; Somayaji, Vishwanath <[email protected]>; [email protected]; Westerberg, Mika <[email protected]>; [email protected]; Prestopine, Charles D <[email protected]>; Chen Zhou <[email protected]>; Box, David E <[email protected]>
Subject: Re: [PATCH v1 0/4] platform/x86: intel_pmc_core: Add bug fixes or code

Quoted 5 lines · Gayatri Kammela

Hi,

This patch series consists of bug fixes and code optimization for the series https://patchwork.kernel.org/patch/11365325/

Quoted 7 lines
Quoted 4 lines

Patch 1: Make pmc_core_lpm_display() generic Patch 2: Relocate both pmc_core_slps0_display() and pmc_core_lpm_display() Patch 3: Remove the duplicate if() condition to create debugfs entry Patch 4: Add back slp_s0_offset attribute back to tgl_reg_map

Let's do other way around, i.e. patch 2 as a first in the series, so I may fix the current (visible) issue.

Hi Andy, sure I will change the order and send the version 2

Quoted 2 lines

Then fix the kbuild bot complains and send the rest.

Sure, I will do that. Thanks!

Quoted 27 lines
Quoted 16 lines

Gayatri Kammela (4):
platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
for platforms that support sub-states
platform/x86: intel_pmc_core: fix: Relocate pmc_core_slps0_display()
and pmc_core_lpm_display() to outside of CONFIG_DEBUG_FS
platform/x86: intel_pmc_core: fix: Remove the duplicate if() to create
debugfs entry for substate_live_status_registers
platform/x86: intel_pmc_core: fix: Add slp_s0_offset attribute back to
tgl_reg_map

 drivers/platform/x86/intel_pmc_core.c | 131
+++++++++++++-------------
 1 file changed, 66 insertions(+), 65 deletions(-)
Quoted 6 lines

Cc: Chen Zhou <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: David Box <[email protected]>
--
2.17.1

--
With Best Regards,
Andy Shevchenko