2020-03-01 20:48:44

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 0/5] 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: Relocate both pmc_core_slps0_display() and pmc_core_lpm_display()
Patch 2: Remove the duplicate if() condition to create debugfs entry
Patch 3: Add back slp_s0_offset attribute back to tgl_reg_map
Patch 4: Make pmc_core_substate_res_show() generic
Patch 5: Make pmc_core_lpm_display() generic

Changes since v1:
1) Changed the order of the patches i.e., patch 2 in v1 is made first in
the order for v2.
2) Fixed the warnings reported by kbuild test robot.

Changes since v2:
1) Add "Make pmc_core_substate_res_show() generic" patch to v3.
2) Fixed the memory leak issue in pmc_core_lpm_display().
3) Moved patch 2 in v2 to the last in the series in v3.

Gayatri Kammela (5):
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
platform/x86: intel_pmc_core: Make pmc_core_substate_res_show()
generic
platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
for platforms that support sub-states

drivers/platform/x86/intel_pmc_core.c | 148 +++++++++++++++-----------
drivers/platform/x86/intel_pmc_core.h | 3 +-
2 files changed, 85 insertions(+), 66 deletions(-)

base-commit: 7adb1e8aeeb5d4d88012568b2049599c1a247cf2

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


2020-03-01 20:48:52

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 1/5] platform/x86: intel_pmc_core: fix: Relocate pmc_core_slps0_display() and pmc_core_lpm_display() to outside of CONFIG_DEBUG_FS

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]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel_pmc_core.c | 122 +++++++++++++-------------
1 file changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index f4a36fbabf4c..20b2f49726cf 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -612,6 +612,67 @@ 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)
+{
+ u32 lpm_regs[ARRAY_SIZE(tgl_lpm_maps)-1];
+ int index, idx, len = 32, bit_mask;
+
+ for (index = 0; tgl_lpm_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 +905,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,40 +1008,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)
-{
- u32 lpm_regs[ARRAY_SIZE(tgl_lpm_maps)-1];
- int index, idx, len = 32, bit_mask;
-
- for (index = 0; tgl_lpm_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;
--
2.17.1

2020-03-01 20:49:06

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 3/5] platform/x86: intel_pmc_core: fix: Add slp_s0_offset attribute back to tgl_reg_map

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]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel_pmc_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index a36051c2a18c..986fe677d6fe 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -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,
--
2.17.1

2020-03-01 20:49:06

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 2/5] platform/x86: intel_pmc_core: fix: Remove the duplicate if() to create debugfs entry for substate_live_status_registers

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]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel_pmc_core.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index 20b2f49726cf..a36051c2a18c 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -1108,9 +1108,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);
--
2.17.1

2020-03-01 20:49:42

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 5/5] 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 cannot
be re-used 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.

Cc: Chen Zhou <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: David E. Box <[email protected]>
Suggested-by: Andy Shevchenko <[email protected]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel_pmc_core.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index 04ac058b9871..cf3aaace21d5 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -20,6 +20,7 @@
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
+#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/uaccess.h>

@@ -640,15 +641,30 @@ static void pmc_core_slps0_display(struct pmc_dev *pmcdev, struct device *dev,
}
}

+static int pmc_core_lpm_get_arr_size(const struct pmc_bit_map **maps)
+{
+ int idx, arr_size = 0;
+
+ for (idx = 0; maps[idx]; idx++)
+ arr_size++;
+
+ return arr_size;
+}
+
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)
{
- u32 lpm_regs[ARRAY_SIZE(tgl_lpm_maps)-1];
- int index, idx, len = 32, bit_mask;
+ int arr_size = pmc_core_lpm_get_arr_size(maps);
+ int index, idx, bit_mask, len = 32;
+ u32 *lpm_regs;
+
+ lpm_regs = kmalloc_array(arr_size, sizeof(*lpm_regs), GFP_KERNEL);
+ if(!lpm_regs)
+ goto err;

- for (index = 0; tgl_lpm_maps[index]; index++) {
+ for (index = 0; maps[index]; index++) {
lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
offset += 4;
}
@@ -672,6 +688,9 @@ static void pmc_core_lpm_display(struct pmc_dev *pmcdev, struct device *dev,
lpm_regs[idx] & bit_mask ? 1 : 0);
}
}
+
+err:
+ kfree(lpm_regs);
}

#if IS_ENABLED(CONFIG_DEBUG_FS)
--
2.17.1

2020-03-01 20:50:40

by Kammela, Gayatri

[permalink] [raw]
Subject: [PATCH v3 4/5] platform/x86: intel_pmc_core: Make pmc_core_substate_res_show() generic

Currently pmc_core_substate_res_show() uses array of char pointers
i.e., lpm_modes for Tiger Lake directly to iterate through and to get
the number of low power modes which is hardcoded and cannot be re-used
for future platforms that support sub-states. To maintain readability,
make pmc_core_substate_res_show() generic, so that it can re-used for
future platforms.

Cc: Chen Zhou <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: David E. Box <[email protected]>
Signed-off-by: Gayatri Kammela <[email protected]>
---
drivers/platform/x86/intel_pmc_core.c | 2 ++
drivers/platform/x86/intel_pmc_core.h | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel_pmc_core.c b/drivers/platform/x86/intel_pmc_core.c
index 986fe677d6fe..04ac058b9871 100644
--- a/drivers/platform/x86/intel_pmc_core.c
+++ b/drivers/platform/x86/intel_pmc_core.c
@@ -566,6 +566,7 @@ static const struct pmc_reg_map tgl_reg_map = {
.pm_cfg_offset = CNP_PMC_PM_CFG_OFFSET,
.pm_read_disable_bit = CNP_PMC_READ_DISABLE_BIT,
.ltr_ignore_max = TGL_NUM_IP_IGN_ALLOWED,
+ .lpm_modes = tgl_lpm_modes,
.lpm_en_offset = TGL_LPM_EN_OFFSET,
.lpm_residency_offset = TGL_LPM_RESIDENCY_OFFSET,
.lpm_sts = tgl_lpm_maps,
@@ -991,6 +992,7 @@ DEFINE_SHOW_ATTRIBUTE(pmc_core_ltr);
static int pmc_core_substate_res_show(struct seq_file *s, void *unused)
{
struct pmc_dev *pmcdev = s->private;
+ const char **lpm_modes = pmcdev->map->lpm_modes;
u32 offset = pmcdev->map->lpm_residency_offset;
u32 lpm_en;
int index;
diff --git a/drivers/platform/x86/intel_pmc_core.h b/drivers/platform/x86/intel_pmc_core.h
index 1bbdffe80bde..0d50b2402abe 100644
--- a/drivers/platform/x86/intel_pmc_core.h
+++ b/drivers/platform/x86/intel_pmc_core.h
@@ -198,7 +198,7 @@ enum ppfear_regs {
#define TGL_LPM_STATUS_OFFSET 0x1C3C
#define TGL_LPM_LIVE_STATUS_OFFSET 0x1C5C

-const char *lpm_modes[] = {
+const char *tgl_lpm_modes[] = {
"S0i2.0",
"S0i2.1",
"S0i2.2",
@@ -255,6 +255,7 @@ struct pmc_reg_map {
const u32 ltr_ignore_max;
const u32 pm_vric1_offset;
/* Low Power Mode registers */
+ const char **lpm_modes;
const u32 lpm_en_offset;
const u32 lpm_residency_offset;
const u32 lpm_status_offset;
--
2.17.1

2020-03-02 12:55:19

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v3 5/5] platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic for platforms that support sub-states

On Sun, Mar 01, 2020 at 12:44:26PM -0800, Gayatri Kammela wrote:
> 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 cannot
> be re-used 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.

My comments below.

...

> +static int pmc_core_lpm_get_arr_size(const struct pmc_bit_map **maps)
> +{
> + int idx, arr_size = 0;

And why do you need arr_size variable at all?

> +
> + for (idx = 0; maps[idx]; idx++)
> + arr_size++;
> +
> + return arr_size;
> +}

...

> - int index, idx, len = 32, bit_mask;
> + int index, idx, bit_mask, len = 32;

What's the point of shuffling this?

> + int arr_size = pmc_core_lpm_get_arr_size(maps);

This would be better in a split manner, i.e.

int arr_size;

...

arr_size = ...;

...

> + lpm_regs = kmalloc_array(arr_size, sizeof(*lpm_regs), GFP_KERNEL);
> + if(!lpm_regs)

> + goto err;

There is no point to have the label. Simple return will work.

> - for (index = 0; tgl_lpm_maps[index]; index++) {
> + for (index = 0; maps[index]; index++) {

Why not to reuse arr_size here?

> lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
> offset += 4;
> }

--
With Best Regards,
Andy Shevchenko


2020-03-02 12:55:39

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

On Sun, Mar 01, 2020 at 12:44:21PM -0800, Gayatri Kammela wrote:
> Hi,
>
> This patch series consists of bug fixes and code optimization for the
> series https://patchwork.kernel.org/patch/11365325/
>

I had applied first four, the fifth requires additional work.
When send a new version, do it only for last one.

> Patch 1: Relocate both pmc_core_slps0_display() and pmc_core_lpm_display()
> Patch 2: Remove the duplicate if() condition to create debugfs entry
> Patch 3: Add back slp_s0_offset attribute back to tgl_reg_map
> Patch 4: Make pmc_core_substate_res_show() generic
> Patch 5: Make pmc_core_lpm_display() generic
>
> Changes since v1:
> 1) Changed the order of the patches i.e., patch 2 in v1 is made first in
> the order for v2.
> 2) Fixed the warnings reported by kbuild test robot.
>
> Changes since v2:
> 1) Add "Make pmc_core_substate_res_show() generic" patch to v3.
> 2) Fixed the memory leak issue in pmc_core_lpm_display().
> 3) Moved patch 2 in v2 to the last in the series in v3.
>
> Gayatri Kammela (5):
> 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
> platform/x86: intel_pmc_core: Make pmc_core_substate_res_show()
> generic
> platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
> for platforms that support sub-states
>
> drivers/platform/x86/intel_pmc_core.c | 148 +++++++++++++++-----------
> drivers/platform/x86/intel_pmc_core.h | 3 +-
> 2 files changed, 85 insertions(+), 66 deletions(-)
>
> base-commit: 7adb1e8aeeb5d4d88012568b2049599c1a247cf2
>
> Cc: Chen Zhou <[email protected]>
> Cc: Andy Shevchenko <[email protected]>
> Cc: David Box <[email protected]>
> --
> 2.17.1
>

--
With Best Regards,
Andy Shevchenko


2020-03-02 18:31:21

by Kammela, Gayatri

[permalink] [raw]
Subject: RE: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

> -----Original Message-----
> From: Andy Shevchenko <[email protected]>
> Sent: Monday, March 2, 2020 4:54 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 v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or
> code
>
> On Sun, Mar 01, 2020 at 12:44:21PM -0800, Gayatri Kammela wrote:
> > Hi,
> >
> > This patch series consists of bug fixes and code optimization for the
> > series https://patchwork.kernel.org/patch/11365325/
> >
>
> I had applied first four, the fifth requires additional work.
> When send a new version, do it only for last one.

Thanks Andy! I will send the 5th patch alone in new version.

>
> > Patch 1: Relocate both pmc_core_slps0_display() and
> > pmc_core_lpm_display() Patch 2: Remove the duplicate if() condition to
> > create debugfs entry Patch 3: Add back slp_s0_offset attribute back to
> > tgl_reg_map Patch 4: Make pmc_core_substate_res_show() generic Patch
> > 5: Make pmc_core_lpm_display() generic
> >
> > Changes since v1:
> > 1) Changed the order of the patches i.e., patch 2 in v1 is made first in
> > the order for v2.
> > 2) Fixed the warnings reported by kbuild test robot.
> >
> > Changes since v2:
> > 1) Add "Make pmc_core_substate_res_show() generic" patch to v3.
> > 2) Fixed the memory leak issue in pmc_core_lpm_display().
> > 3) Moved patch 2 in v2 to the last in the series in v3.
> >
> > Gayatri Kammela (5):
> > 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
> > platform/x86: intel_pmc_core: Make pmc_core_substate_res_show()
> > generic
> > platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic
> > for platforms that support sub-states
> >
> > drivers/platform/x86/intel_pmc_core.c | 148 +++++++++++++++-----------
> > drivers/platform/x86/intel_pmc_core.h | 3 +-
> > 2 files changed, 85 insertions(+), 66 deletions(-)
> >
> > base-commit: 7adb1e8aeeb5d4d88012568b2049599c1a247cf2
> >
> > Cc: Chen Zhou <[email protected]>
> > Cc: Andy Shevchenko <[email protected]>
> > Cc: David Box <[email protected]>
> > --
> > 2.17.1
> >
>
> --
> With Best Regards,
> Andy Shevchenko
>

2020-03-02 18:57:47

by Kammela, Gayatri

[permalink] [raw]
Subject: RE: [PATCH v3 5/5] platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display() generic for platforms that support sub-states

> -----Original Message-----
> From: Andy Shevchenko <[email protected]>
> Sent: Monday, March 2, 2020 4:54 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 v3 5/5] platform/x86: intel_pmc_core: fix: Make
> pmc_core_lpm_display() generic for platforms that support sub-states
>
> On Sun, Mar 01, 2020 at 12:44:26PM -0800, Gayatri Kammela wrote:
> > 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 cannot
> > be re-used 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.
>
> My comments below.

Thanks Andy! for the comments.

>
> ...
>
> > +static int pmc_core_lpm_get_arr_size(const struct pmc_bit_map **maps)
> > +{
> > + int idx, arr_size = 0;
>
> And why do you need arr_size variable at all?

I could just return idx value at the end of the for loop. I will remove the arr_size variable.

>
> > +
> > + for (idx = 0; maps[idx]; idx++)
> > + arr_size++;
> > +
> > + return arr_size;
> > +}
>
> ...
>
> > - int index, idx, len = 32, bit_mask;
> > + int index, idx, bit_mask, len = 32;
>
> What's the point of shuffling this?

Just wanted to have all uninitialized variables declared before initialized ones. I will just leave this out in v4.

>
> > + int arr_size = pmc_core_lpm_get_arr_size(maps);
>
> This would be better in a split manner, i.e.
>
> int arr_size;
>
> ...
>
> arr_size = ...;

Sure, I will make this change in v4

>
> ...
>
> > + lpm_regs = kmalloc_array(arr_size, sizeof(*lpm_regs), GFP_KERNEL);
> > + if(!lpm_regs)
>
> > + goto err;
>
> There is no point to have the label. Simple return will work.

Thought adding a label will help not to have multiple kfree() in the same function (one here at the check and one at the end of the for loop) I will add a return.

>
> > - for (index = 0; tgl_lpm_maps[index]; index++) {
> > + for (index = 0; maps[index]; index++) {
>
> Why not to reuse arr_size here?

Good point! I missed it. I will use the arr_size here to iterate.

>
> > lpm_regs[index] = pmc_core_reg_read(pmcdev, offset);
> > offset += 4;
> > }
>
> --
> With Best Regards,
> Andy Shevchenko
>

2020-03-19 17:59:55

by Kammela, Gayatri

[permalink] [raw]
Subject: RE: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

> -----Original Message-----
> From: Kammela, Gayatri
> Sent: Monday, March 2, 2020 10:29 AM
> To: Andy Shevchenko <[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 v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or
> code
>
> > -----Original Message-----
> > From: Andy Shevchenko <[email protected]>
> > Sent: Monday, March 2, 2020 4:54 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 v3 0/5] platform/x86: intel_pmc_core: Add bug
> > fixes or code
> >
> > On Sun, Mar 01, 2020 at 12:44:21PM -0800, Gayatri Kammela wrote:
> > > Hi,
> > >
> > > This patch series consists of bug fixes and code optimization for
> > > the series https://patchwork.kernel.org/patch/11365325/
> > >
> >
> > I had applied first four, the fifth requires additional work.
> > When send a new version, do it only for last one.
>
> Thanks Andy! I will send the 5th patch alone in new version.
>

Hi Andy! I see first 3 patches are merged in for-next branch on 2/28 but not 4th patch. Can you please check? http://git.infradead.org/linux-platform-drivers-x86.git/shortlog/refs/heads/for-next

> >
> > > Patch 1: Relocate both pmc_core_slps0_display() and
> > > pmc_core_lpm_display() Patch 2: Remove the duplicate if() condition
> > > to create debugfs entry Patch 3: Add back slp_s0_offset attribute
> > > back to tgl_reg_map Patch 4: Make pmc_core_substate_res_show()
> > > generic Patch
> > > 5: Make pmc_core_lpm_display() generic
> > >
> > > Changes since v1:
> > > 1) Changed the order of the patches i.e., patch 2 in v1 is made first in
> > > the order for v2.
> > > 2) Fixed the warnings reported by kbuild test robot.
> > >
> > > Changes since v2:
> > > 1) Add "Make pmc_core_substate_res_show() generic" patch to v3.
> > > 2) Fixed the memory leak issue in pmc_core_lpm_display().
> > > 3) Moved patch 2 in v2 to the last in the series in v3.
> > >
> > > Gayatri Kammela (5):
> > > 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
> > > platform/x86: intel_pmc_core: Make pmc_core_substate_res_show()
> > > generic
> > > platform/x86: intel_pmc_core: fix: Make pmc_core_lpm_display()
> generic
> > > for platforms that support sub-states
> > >
> > > drivers/platform/x86/intel_pmc_core.c | 148 +++++++++++++++-----------
> > > drivers/platform/x86/intel_pmc_core.h | 3 +-
> > > 2 files changed, 85 insertions(+), 66 deletions(-)
> > >
> > > base-commit: 7adb1e8aeeb5d4d88012568b2049599c1a247cf2
> > >
> > > Cc: Chen Zhou <[email protected]>
> > > Cc: Andy Shevchenko <[email protected]>
> > > Cc: David Box <[email protected]>
> > > --
> > > 2.17.1
> > >
> >
> > --
> > With Best Regards,
> > Andy Shevchenko
> >

2020-03-19 18:08:53

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

On Thu, Mar 19, 2020 at 05:57:06PM +0000, Kammela, Gayatri wrote:
> > -----Original Message-----
> > From: Kammela, Gayatri
> > Sent: Monday, March 2, 2020 10:29 AM
> > To: Andy Shevchenko <[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 v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or
> > code
> >
> > > -----Original Message-----
> > > From: Andy Shevchenko <[email protected]>
> > > Sent: Monday, March 2, 2020 4:54 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 v3 0/5] platform/x86: intel_pmc_core: Add bug
> > > fixes or code
> > >
> > > On Sun, Mar 01, 2020 at 12:44:21PM -0800, Gayatri Kammela wrote:
> > > > Hi,
> > > >
> > > > This patch series consists of bug fixes and code optimization for
> > > > the series https://patchwork.kernel.org/patch/11365325/
> > > >
> > >
> > > I had applied first four, the fifth requires additional work.
> > > When send a new version, do it only for last one.
> >
> > Thanks Andy! I will send the 5th patch alone in new version.
> >
>
> Hi Andy! I see first 3 patches are merged in for-next branch on 2/28 but not 4th patch. Can you please check? http://git.infradead.org/linux-platform-drivers-x86.git/shortlog/refs/heads/for-next


Is it in my review and testing queue?

--
With Best Regards,
Andy Shevchenko


2020-03-19 18:16:42

by Kammela, Gayatri

[permalink] [raw]
Subject: RE: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

> -----Original Message-----
> From: Andy Shevchenko <[email protected]>
> Sent: Thursday, March 19, 2020 11:06 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 v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or
> code
>
> On Thu, Mar 19, 2020 at 05:57:06PM +0000, Kammela, Gayatri wrote:
> > > -----Original Message-----
> > > From: Kammela, Gayatri
> > > Sent: Monday, March 2, 2020 10:29 AM
> > > To: Andy Shevchenko <[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 v3 0/5] platform/x86: intel_pmc_core: Add bug
> > > fixes or code
> > >
> > > > -----Original Message-----
> > > > From: Andy Shevchenko <[email protected]>
> > > > Sent: Monday, March 2, 2020 4:54 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 v3 0/5] platform/x86: intel_pmc_core: Add bug
> > > > fixes or code
> > > >
> > > > On Sun, Mar 01, 2020 at 12:44:21PM -0800, Gayatri Kammela wrote:
> > > > > Hi,
> > > > >
> > > > > This patch series consists of bug fixes and code optimization
> > > > > for the series https://patchwork.kernel.org/patch/11365325/
> > > > >
> > > >
> > > > I had applied first four, the fifth requires additional work.
> > > > When send a new version, do it only for last one.
> > >
> > > Thanks Andy! I will send the 5th patch alone in new version.
> > >
> >
> > Hi Andy! I see first 3 patches are merged in for-next branch on 2/28
> > but not 4th patch. Can you please check?
> > http://git.infradead.org/linux-platform-drivers-x86.git/shortlog/refs/
> > heads/for-next
>
>
> Is it in my review and testing queue?

I think it is archived and superseded https://patchwork.kernel.org/patch/11414379/

>
> --
> With Best Regards,
> Andy Shevchenko
>

2020-03-20 13:51:51

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

On Thu, Mar 19, 2020 at 8:16 PM Kammela, Gayatri
<[email protected]> wrote:
>
> > Is it in my review and testing queue?
>
> I think it is archived and superseded https://patchwork.kernel.org/patch/11414379/

Now everything in for-next, check if something is missed and resend.

--
With Best Regards,
Andy Shevchenko

2020-03-20 17:37:40

by Kammela, Gayatri

[permalink] [raw]
Subject: RE: [PATCH v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or code

> -----Original Message-----
> From: Andy Shevchenko <[email protected]>
> Sent: Friday, March 20, 2020 6:50 AM
> To: Kammela, Gayatri <[email protected]>
> Cc: Andy Shevchenko <[email protected]>; platform-
> [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 v3 0/5] platform/x86: intel_pmc_core: Add bug fixes or
> code
>
> On Thu, Mar 19, 2020 at 8:16 PM Kammela, Gayatri
> <[email protected]> wrote:
> >
> > > Is it in my review and testing queue?
> >
> > I think it is archived and superseded
> > https://patchwork.kernel.org/patch/11414379/
>
> Now everything in for-next, check if something is missed and resend.
Thanks Andy! I just noticed 5th patch in this version is accepted but 4th is still showing superseded. To avoid confusion, I will resend the 4th patch alone.
>
> --
> With Best Regards,
> Andy Shevchenko