Skip to contentSkip to conversation

platform/x86: intel_pmc: Ignore GBE LTR on Tiger Lake platforms

PATCH Superseded David E. Box 5 participants 12 messages Mar 5, 2021 – Mar 8, 2021 x86 platform drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel_pmc: Ignore GBE LTR on Tiger Lake platforms

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_pmc_core.c +42 -13
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 {
 	struct pmc_dev *pmcdev = &pmc;
 	const struct pmc_reg_map *map = pmcdev->map;
-	u32 val, buf_size, fd;
-	int err;
-
-	buf_size = count < 64 ? count : 64;
-
-	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-	if (err)
-		return err;
+	u32 fd;
+	int err = 0;
 
 	mutex_lock(&pmcdev->lock);
 
-	if (val > map->ltr_ignore_max) {
+	if (fls(value) > map->ltr_ignore_max) {
 		err = -EINVAL;
 		goto out_unlock;
 	}
 
 	fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-	fd |= (1U << val);
+	fd |= value;
 	pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
 	mutex_unlock(&pmcdev->lock);
+
+	return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+					 const char __user *userbuf,
+					 size_t count, loff_t *ppos)
+{
+	u32 buf_size, val;
+	int err;
+
+	buf_size = count < 64 ? count : 64;
+
+	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+	if (err)
+		return err;
+
+	err = pmc_core_write_ltr_ignore(1U << val);
+
 	return err == 0 ? count : err;
 }
 
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id)
 	return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+	int err;
+
+	err = pmc_core_write_ltr_ignore(val);
+
+	return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
 	{
 	.callback = quirk_xtal_ignore,
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
 	pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
 	dmi_check_system(pmc_core_dmi_table);
 
+	/*
+	 * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+	 * a cable is attached. Tell the PMC to ignore it.
+	 */
+	if (pmcdev->map == &tgl_reg_map) {
+		dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+		quirk_ltr_ignore(1U << 3);
+	}
+
 	pmc_core_dbgfs_register(pmcdev);
 
 	device_initialized = true;
Signature · 1 line
2.25.1
#1 lore raw
Quoted 95 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Cc intel-wired-lan at lists.osuosl.org
---
  drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
  1 file changed, 42 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_pmc_core.c +33 -13
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
  }
  DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
  {
  	struct pmc_dev *pmcdev = &pmc;
  	const struct pmc_reg_map *map = pmcdev->map;
-	u32 val, buf_size, fd;
-	int err;
-
-	buf_size = count < 64 ? count : 64;
-
-	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-	if (err)
-		return err;
+	u32 fd;
+	int err = 0;
 
  	mutex_lock(&pmcdev->lock);
 
-	if (val > map->ltr_ignore_max) {
+	if (fls(value) > map->ltr_ignore_max) {
  		err = -EINVAL;
  		goto out_unlock;
  	}
 
  	fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-	fd |= (1U << val);
+	fd |= value;
  	pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
  out_unlock:
  	mutex_unlock(&pmcdev->lock);
+
+	return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+					 const char __user *userbuf,
+					 size_t count, loff_t *ppos)
+{
+	u32 buf_size, val;
+	int err;
+
+	buf_size = count < 64 ? count : 64;
+
+	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+	if (err)
+		return err;
+
+	err = pmc_core_write_ltr_ignore(1U << val);
+
  	return err == 0 ? count : err;
  }
 
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id)
  	return 0;
  }
 
+static int quirk_ltr_ignore(u32 val)
+{
+	int err;
+
+	err = pmc_core_write_ltr_ignore(val);
+
+	return err;
+}
+
  static const struct dmi_system_id pmc_core_dmi_table[]  = {
  	{
  	.callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device *pdev) · line 1271

Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +5 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
  	pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
  	dmi_check_system(pmc_core_dmi_table);
 
+	/*
+	 * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+	 * a cable is attached. Tell the PMC to ignore it.
+	 */
+	if (pmcdev->map == &tgl_reg_map) {

I would suggest: if (pmcdev->map >= &tgl_reg_map)

Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +4 -0
+		dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+		quirk_ltr_ignore(1U << 3);
+	}
+
  	pmc_core_dbgfs_register(pmcdev);
 
  	device_initialized = true;
#2 lore raw

Hi Sasha,

Quoted 112 lines · Sasha
Quoted 111 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow
the platform to enter Package C10, which in turn prevents the platform from
achieving its low power target during suspend-to-idle.? Ignore the GBE LTR
value on Tiger Lake. LTR ignore functionality is currently performed solely
by a debugfs write call. Split out the LTR code into its own function that
can be called by both the debugfs writer and by this work around.

Cc intel-wired-lan at lists.osuosl.org

---
? drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++--
-----
? 1 file changed, 42 insertions(+), 13 deletions(-)

drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file
 *s, void *unused)
 ? }
 ? DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);

?
-static ssize_t pmc_core_ltr_ignore_write(struct file *file, -??????????????????????????????????????? const char __user *userbuf,
-??????????????????????????????????????? size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
? {
????????struct pmc_dev *pmcdev = &pmc; ????????const struct pmc_reg_map *map = pmcdev->map; -???????u32 val, buf_size, fd;
-???????int err;

drivers/platform/x86/intel_pmc_core.c +2 -6
-
-???????buf_size = count < 64 ? count : 64;
-
-???????err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-???????if (err)
-???????????????return err;
+???????u32 fd;
+???????int err = 0;

?
????????mutex_lock(&pmcdev->lock);
?
-???????if (val > map->ltr_ignore_max) {
+???????if (fls(value) > map->ltr_ignore_max) { ????????????????err = -EINVAL;
????????????????goto out_unlock;
????????}
?
????????fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset); -???????fd |= (1U << val);
+???????fd |= value; ????????pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd); ?
? out_unlock:
????????mutex_unlock(&pmcdev->lock);

drivers/platform/x86/intel_pmc_core.c +6 -0
+
+???????return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+??????????????????????????????????????? const char __user

*userbuf,
+??????????????????????????????????????? size_t count, loff_t *ppos)

drivers/platform/x86/intel_pmc_core.c +12 -0
+{
+???????u32 buf_size, val;
+???????int err;
+
+???????buf_size = count < 64 ? count : 64;
+
+???????err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+???????if (err)
+???????????????return err;
+
+???????err = pmc_core_write_ltr_ignore(1U << val);
+

????????return err == 0 ? count : err;
? }
?

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct
 dmi_system_id *id)
 ????????return 0;
 ? }

?

drivers/platform/x86/intel_pmc_core.c +9 -0
+static int quirk_ltr_ignore(u32 val)
+{
+???????int err;
+
+???????err = pmc_core_write_ltr_ignore(val);
+
+???????return err;
+}
+

? static const struct dmi_system_id pmc_core_dmi_table[]? = { ????????{
????????.callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct
 platform_device *pdev)
 ????????pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
 ????????dmi_check_system(pmc_core_dmi_table);
Quoted 8 lines
Quoted 7 lines

?
+???????/*
+??????? * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+??????? * a cable is attached. Tell the PMC to ignore it. +??????? */
+???????if (pmcdev->map == &tgl_reg_map) {

I would suggest: if (pmcdev->map >= &tgl_reg_map)

This will already cover Rocket Lake since it uses Tiger Lake PCH. Those are the newest platforms this driver covers. Otherwise, I don't want to rely on this as the permanent solution. We can evaluate this on a per platform basis while persuing other measures to more properly resolve it.

David

Quoted 9 lines
Quoted 8 lines

+???????????????dev_dbg(&pdev->dev, "ignoring GBE LTR\n"); +???????????????quirk_ltr_ignore(1U << 3); +???????}
+
????????pmc_core_dbgfs_register(pmcdev);
?
????????device_initialized = true;

#3 lore raw
In reply to Neftin, Sasha

Hi,

Quoted 89 lines · Sasha
Quoted 88 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle.? Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Cc intel-wired-lan at lists.osuosl.org

---
? drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++------- ? 1 file changed, 42 insertions(+), 13 deletions(-)

drivers/platform/x86/intel_pmc_core.c +5 -11
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
 ? }
 ? DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 ? -static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-???????????????????? const char __user *userbuf,
-???????????????????? size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 ? {
 ????? struct pmc_dev *pmcdev = &pmc;
 ????? const struct pmc_reg_map *map = pmcdev->map;
-??? u32 val, buf_size, fd;
-??? int err;
-
-??? buf_size = count < 64 ? count : 64;
-
-??? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-??? if (err)
-??????? return err;
+??? u32 fd;
+??? int err = 0;
 ? ????? mutex_lock(&pmcdev->lock);
 ? -??? if (val > map->ltr_ignore_max) {
+??? if (fls(value) > map->ltr_ignore_max) {
 ????????? err = -EINVAL;
 ????????? goto out_unlock;
 ????? }
 ? ????? fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-??? fd |= (1U << val);
+??? fd |= value;
 ????? pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);

? ? out_unlock:
????? mutex_unlock(&pmcdev->lock);

drivers/platform/x86/intel_pmc_core.c +19 -0
+
+??? return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+???????????????????? const char __user *userbuf,
+???????????????????? size_t count, loff_t *ppos)
+{
+??? u32 buf_size, val;
+??? int err;
+
+??? buf_size = count < 64 ? count : 64;
+
+??? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+??? if (err)
+??????? return err;
+
+??? err = pmc_core_write_ltr_ignore(1U << val);
+

????? return err == 0 ? count : err;
? }
? @@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id) ????? return 0;
? }
? +static int quirk_ltr_ignore(u32 val)

drivers/platform/x86/intel_pmc_core.c +8 -0
+{
+??? int err;
+
+??? err = pmc_core_write_ltr_ignore(val);
+
+??? return err;
+}
+

? static const struct dmi_system_id pmc_core_dmi_table[]? = { ????? {
????? .callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
Quoted 8 lines
Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +0 -0
 ????? pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
 ????? dmi_check_system(pmc_core_dmi_table);

? +??? /*
+???? * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when +???? * a cable is attached. Tell the PMC to ignore it.
+???? */
+??? if (pmcdev->map == &tgl_reg_map) {

I would suggest: if (pmcdev->map >= &tgl_reg_map)

Erm, no just no. tgl_reg_map is a global variable you can absolutely NOT rely on the ordering of global variables in memory like this. Moreover using ordered comparisons on pointers generally is a very bad idea, please don't.

Regards,

Hans

#4 lore raw
In reply to David E. Box

Hi David

Overall, it looks like the right thing to do but i have a few comments. See below.

Quoted 9 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

I presume this must be the last resort to use such quirk and you've already considered a user space tuning program or fw patch is not an option on this generation of SOCs.

Quoted 12 lines
Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 866

Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +1 -3
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-                                        const char __user *userbuf,
-                                        size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)

This sounds a bit confusing with pmc_core_ltr_ignore_write.

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 870

Quoted 12 lines
drivers/platform/x86/intel_pmc_core.c +1 -8
 {
        struct pmc_dev *pmcdev = &pmc;
        const struct pmc_reg_map *map = pmcdev->map;
-       u32 val, buf_size, fd;
-       int err;
-
-       buf_size = count < 64 ? count : 64;
-
-       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-       if (err)
-               return err;
+       u32 fd;

lets just call it value

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 875

Quoted 6 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       int err = 0;
 
        mutex_lock(&pmcdev->lock);
 
-       if (val > map->ltr_ignore_max) {
+       if (fls(value) > map->ltr_ignore_max) {

I am not sure why you're considering a bit position here. We rather use absolute value for this and we already preserve (OR) previously programmed LTR while changing to the new desired value. Current modification would allow users to supply even bigger values than the MAX IP ignore allowed. This can be useful when you want to ignore more than 1 IP at a time but that's not how we usually use it for debug. This is more for a user space debug script to deal with.
https://01.org/blogs/rajneesh/2019/using-power-management-controller-drivers-debug-low-power-platform-states

Quoted 50 lines
drivers/platform/x86/intel_pmc_core.c +29 -1
                err = -EINVAL;
                goto out_unlock;
        }
 
        fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-       fd |= (1U << val);
+       fd |= value;
        pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
        mutex_unlock(&pmcdev->lock);
+
+       return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+                                        const char __user *userbuf,
+                                        size_t count, loff_t *ppos)
+{
+       u32 buf_size, val;
+       int err;
+
+       buf_size = count < 64 ? count : 64;
+
+       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+       if (err)
+               return err;
+
+       err = pmc_core_write_ltr_ignore(1U << val);
+
        return err == 0 ? count : err;
 }
 
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id)
        return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+       int err;
+
+       err = pmc_core_write_ltr_ignore(val);
+
+       return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
        {
        .callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device *pdev) · line 1273

Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c +7 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
        pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
        dmi_check_system(pmc_core_dmi_table);
 
+       /*
+        * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+        * a cable is attached. Tell the PMC to ignore it.
+        */
+       if (pmcdev->map == &tgl_reg_map) {
+               dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+               quirk_ltr_ignore(1U << 3);

Can this be made a part of *_reg_map itself if intended to be used for more future platforms? Otherwise we just leave it as a one time quirk.

Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       }
+
        pmc_core_dbgfs_register(pmcdev);
 
        device_initialized = true;
--

2.25.1

Signature · 2 lines
Thanks,
Rajneesh
#5 lore raw
Quoted 43 lines · Rajneesh Bhardwaj

Hi David

Overall, it looks like the right thing to do but i have a few comments. See below.

Quoted 9 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

I presume this must be the last resort to use such quirk and you've already considered a user space tuning program or fw patch is not an option on this generation of SOCs.

Quoted 12 lines
Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 866

Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +1 -3
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-                                        const char __user *userbuf,
-                                        size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)

This sounds a bit confusing with pmc_core_ltr_ignore_write.

Quoted 14 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 870

Quoted 12 lines
drivers/platform/x86/intel_pmc_core.c +1 -8
 {
        struct pmc_dev *pmcdev = &pmc;
        const struct pmc_reg_map *map = pmcdev->map;
-       u32 val, buf_size, fd;
-       int err;
-
-       buf_size = count < 64 ? count : 64;
-
-       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-       if (err)
-               return err;
+       u32 fd;

lets just call it value

I meant a different name than fd is better. I see both value / val are already used here.

Quoted 94 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 875

Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       int err = 0;
 
        mutex_lock(&pmcdev->lock);
 
-       if (val > map->ltr_ignore_max) {
+       if (fls(value) > map->ltr_ignore_max) {

I am not sure why you're considering a bit position here. We rather use absolute value for this and we already preserve (OR) previously programmed LTR while changing to the new desired value. Current modification would allow users to supply even bigger values than the MAX IP ignore allowed. This can be useful when you want to ignore more than 1 IP at a time but that's not how we usually use it for debug. This is more for a user space debug script to deal with.
https://01.org/blogs/rajneesh/2019/using-power-management-controller-drivers-debug-low-power-platform-states

Quoted 50 lines
drivers/platform/x86/intel_pmc_core.c +29 -1
                err = -EINVAL;
                goto out_unlock;
        }
 
        fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-       fd |= (1U << val);
+       fd |= value;
        pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
        mutex_unlock(&pmcdev->lock);
+
+       return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+                                        const char __user *userbuf,
+                                        size_t count, loff_t *ppos)
+{
+       u32 buf_size, val;
+       int err;
+
+       buf_size = count < 64 ? count : 64;
+
+       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+       if (err)
+               return err;
+
+       err = pmc_core_write_ltr_ignore(1U << val);
+
        return err == 0 ? count : err;
 }
 
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id *id)
        return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+       int err;
+
+       err = pmc_core_write_ltr_ignore(val);
+
+       return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
        {
        .callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device *pdev) · line 1273

Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c +7 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
        pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
        dmi_check_system(pmc_core_dmi_table);
 
+       /*
+        * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+        * a cable is attached. Tell the PMC to ignore it.
+        */
+       if (pmcdev->map == &tgl_reg_map) {
+               dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+               quirk_ltr_ignore(1U << 3);

Can this be made a part of *_reg_map itself if intended to be used for more future platforms? Otherwise we just leave it as a one time quirk.

Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       }
+
        pmc_core_dbgfs_register(pmcdev);
 
        device_initialized = true;
--

2.25.1

--
Thanks,
Rajneesh

Signature · 2 lines
Thanks,
Rajneesh
#6 lore raw
In reply to Rajneesh Bhardwaj

Hi Rajneesh,

Quoted 22 lines · Rajneesh Bhardwaj

Hi David

Overall, it looks like the right thing to do but i have a few comments. See below.

Quoted 14 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow
the platform to enter Package C10, which in turn prevents the platform from
achieving its low power target during suspend-to-idle.? Ignore the GBE LTR
value on Tiger Lake. LTR ignore functionality is currently performed solely
by a debugfs write call. Split out the LTR code into its own function that
can be called by both the debugfs writer and by this work around.

Quoted 3 lines

I presume this must be the last resort to use such quirk and you've already considered a user space tuning program or fw patch is not an option on this generation of SOCs.

This was the suggested work around by the LAN team. A FW solution may be considered for future products but is not in the works for TGL.

Quoted 19 lines
Quoted 19 lines
Cc intel-wired-lan at lists.osuosl.org

---
?drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++---
----
?1 file changed, 42 insertions(+), 13 deletions(-)

drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file
 *s, void *unused)
 ?}
 ?DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
Quoted 8 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file · line 869

Quoted 6 lines
drivers/platform/x86/intel_pmc_core.c +1 -3
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-??????????????????????????????????????? const char __user
 *userbuf,
-??????????????????????????????????????? size_t count, loff_t
 *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)

This sounds a bit confusing with pmc_core_ltr_ignore_write.

Ack

Quoted 15 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file · line 873

Quoted 13 lines
drivers/platform/x86/intel_pmc_core.c +1 -8
 ?{
 ??????? struct pmc_dev *pmcdev = &pmc;
 ??????? const struct pmc_reg_map *map = pmcdev->map;
-?????? u32 val, buf_size, fd;
-?????? int err;
-
-?????? buf_size = count < 64 ? count : 64;
-
-?????? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-?????? if (err)
-?????????????? return err;
+?????? u32 fd;

lets just call it value

Yeah, I'll clean it up the names. It was just moved without changing it.

Quoted 8 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file · line 878

Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+?????? int err = 0;
 
 ??????? mutex_lock(&pmcdev->lock);
 
-?????? if (val > map->ltr_ignore_max) {
+?????? if (fls(value) > map->ltr_ignore_max) {
Quoted 8 lines

I am not sure why you're considering a bit position here. We rather use absolute value for this and we already preserve (OR) previously programmed LTR while changing to the new desired value.? Current modification would allow users to supply even bigger values than the MAX IP ignore allowed. This can be useful when you want to ignore more
than 1 IP at a time but that's not how we usually use it for debug. This is more for a user space debug script to deal with.

This was unintentionally added. The line should not have changed at all. Thanks for catching.

Quoted 60 lines

https://01.org/blogs/rajneesh/2019/using-power-management-controller-drivers-debug-low-power-platform-states

Quoted 57 lines
drivers/platform/x86/intel_pmc_core.c +1 -1
 ??????????????? err = -EINVAL;
 ??????????????? goto out_unlock;
 ??????? }
 
 ??????? fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-?????? fd |= (1U << val);
+?????? fd |= value;
 ??????? pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 

?out_unlock:
??????? mutex_unlock(&pmcdev->lock);

drivers/platform/x86/intel_pmc_core.c +6 -0
+
+?????? return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+??????????????????????????????????????? const char __user

*userbuf,
+??????????????????????????????????????? size_t count, loff_t *ppos)

drivers/platform/x86/intel_pmc_core.c +12 -0
+{
+?????? u32 buf_size, val;
+?????? int err;
+
+?????? buf_size = count < 64 ? count : 64;
+
+?????? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+?????? if (err)
+?????????????? return err;
+
+?????? err = pmc_core_write_ltr_ignore(1U << val);
+

??????? return err == 0 ? count : err;
?}

drivers/platform/x86/intel_pmc_core.c +9 -0
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct
 dmi_system_id *id)
 ??????? return 0;
 ?}
 
+static int quirk_ltr_ignore(u32 val)
+{
+?????? int err;
+
+?????? err = pmc_core_write_ltr_ignore(val);
+
+?????? return err;
+}
+
 ?static const struct dmi_system_id pmc_core_dmi_table[]? = {
 ??????? {

??????? .callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct
 platform_device *pdev)
 ??????? pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
 ??????? dmi_check_system(pmc_core_dmi_table);
 
Quoted 13 lines
Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +2 -0
+?????? /*
+??????? * On TGL, due to a hardware limitation, the GBE LTR blocks

PC10 when
+??????? * a cable is attached. Tell the PMC to ignore it. +??????? */
+?????? if (pmcdev->map == &tgl_reg_map) { +?????????????? dev_dbg(&pdev->dev, "ignoring GBE LTR\n"); +?????????????? quirk_ltr_ignore(1U << 3);

Can this be made a part of *_reg_map itself if intended to be used for
more future platforms? Otherwise we just leave it as a one time quirk.

The intent right now is not to use this for future platforms. We'll see if that can happen.

David

Quoted 11 lines
Quoted 9 lines

+?????? }
+
??????? pmc_core_dbgfs_register(pmcdev);

??????? device_initialized = true;
--
2.25.1

#7 lore raw

PATCH 1/1 platform/x86: intel_pmc: Ignore GBE LTR on Tiger Lake platforms

Sounds good. When you send your v2 feel free to add my RB.

Quoted 194 lines · David E. Box

Hi Rajneesh,

Quoted 22 lines · Rajneesh Bhardwaj

Hi David

Overall, it looks like the right thing to do but i have a few comments. See below.

Quoted 14 lines · David E. Box

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow
the platform to enter Package C10, which in turn prevents the platform from
achieving its low power target during suspend-to-idle. Ignore the GBE LTR
value on Tiger Lake. LTR ignore functionality is currently performed solely
by a debugfs write call. Split out the LTR code into its own function that
can be called by both the debugfs writer and by this work around.

Quoted 3 lines

I presume this must be the last resort to use such quirk and you've already considered a user space tuning program or fw patch is not an option on this generation of SOCs.

This was the suggested work around by the LAN team. A FW solution may be considered for future products but is not in the works for TGL.

Quoted 19 lines
Quoted 19 lines
Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++---
----
 1 file changed, 42 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file
 *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
Quoted 8 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file · line 869

Quoted 6 lines
drivers/platform/x86/intel_pmc_core.c +1 -3
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-                                        const char __user
 *userbuf,
-                                        size_t count, loff_t
 *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)

This sounds a bit confusing with pmc_core_ltr_ignore_write.

Ack

Quoted 15 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 870

Quoted 13 lines
drivers/platform/x86/intel_pmc_core.c +1 -8
 {
        struct pmc_dev *pmcdev = &pmc;
        const struct pmc_reg_map *map = pmcdev->map;
-       u32 val, buf_size, fd;
-       int err;
-
-       buf_size = count < 64 ? count : 64;
-
-       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-       if (err)
-               return err;
+       u32 fd;

lets just call it value

Yeah, I'll clean it up the names. It was just moved without changing it.

Quoted 8 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s, void *unused) · line 875

Quoted 7 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       int err = 0;
 
        mutex_lock(&pmcdev->lock);
 
-       if (val > map->ltr_ignore_max) {
+       if (fls(value) > map->ltr_ignore_max) {
Quoted 8 lines

I am not sure why you're considering a bit position here. We rather use absolute value for this and we already preserve (OR) previously programmed LTR while changing to the new desired value. Current modification would allow users to supply even bigger values than the MAX IP ignore allowed. This can be useful when you want to ignore more
than 1 IP at a time but that's not how we usually use it for debug. This is more for a user space debug script to deal with.

This was unintentionally added. The line should not have changed at all. Thanks for catching.

Quoted 2 lines

https://01.org/blogs/rajneesh/2019/using-power-management-controller-drivers-debug-low-power-platform-states

Quoted 58 lines
Quoted 58 lines
drivers/platform/x86/intel_pmc_core.c +7 -1
                err = -EINVAL;
                goto out_unlock;
        }
 
        fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-       fd |= (1U << val);
+       fd |= value;
        pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
        mutex_unlock(&pmcdev->lock);
+
+       return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+                                        const char __user

*userbuf,
+ size_t count, loff_t
*ppos)

drivers/platform/x86/intel_pmc_core.c +21 -0
+{
+       u32 buf_size, val;
+       int err;
+
+       buf_size = count < 64 ? count : 64;
+
+       err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+       if (err)
+               return err;
+
+       err = pmc_core_write_ltr_ignore(1U << val);
+
        return err == 0 ? count : err;
 }
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct
 dmi_system_id *id)
        return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+       int err;
+
+       err = pmc_core_write_ltr_ignore(val);
+
+       return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
        {

.callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct
 platform_device *pdev)
        pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
        dmi_check_system(pmc_core_dmi_table);
 
Quoted 13 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device *pdev) · line 1273

Quoted 8 lines
drivers/platform/x86/intel_pmc_core.c +2 -0
+       /*
+        * On TGL, due to a hardware limitation, the GBE LTR blocks

PC10 when

drivers/platform/x86/intel_pmc_core.c +5 -0
+        * a cable is attached. Tell the PMC to ignore it.
+        */
+       if (pmcdev->map == &tgl_reg_map) {
+               dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+               quirk_ltr_ignore(1U << 3);

Can this be made a part of *_reg_map itself if intended to be used for
more future platforms? Otherwise we just leave it as a one time quirk.

The intent right now is not to use this for future platforms. We'll see if that can happen.

David

Quoted 11 lines
Quoted 9 lines
drivers/platform/x86/intel_pmc_core.c +2 -1
+       }
+
        pmc_core_dbgfs_register(pmcdev);
 
        device_initialized = true;
--

2.25.1

Quoted 1 line

--

Thanks,
Rajneesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20210308/cdb289ff/attachment-0001.html>

#8 lore raw
In reply to David E. Box
Quoted 11 lines

[EXTERNAL EMAIL]

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Quoted 6 lines
Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)

I feel like this driver change causes a weak reference between e1000e and intel_pmc_core. It would mean significantly different behavior if you use e1000e but don't have PMC module available for any reason.

In this case does it maybe make sense to at least use "imply" in the Kconfig for e1000e so that selecting e1000e gets intel-pmc-core enabled too?

Quoted 101 lines
drivers/platform/x86/intel_pmc_core.c +33 -13
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void
 *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-					 const char __user *userbuf,
-					 size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 {
 	struct pmc_dev *pmcdev = &pmc;
 	const struct pmc_reg_map *map = pmcdev->map;
-	u32 val, buf_size, fd;
-	int err;
-
-	buf_size = count < 64 ? count : 64;
-
-	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-	if (err)
-		return err;
+	u32 fd;
+	int err = 0;
 
 	mutex_lock(&pmcdev->lock);
 
-	if (val > map->ltr_ignore_max) {
+	if (fls(value) > map->ltr_ignore_max) {
 		err = -EINVAL;
 		goto out_unlock;
 	}
 
 	fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-	fd |= (1U << val);
+	fd |= value;
 	pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
 	mutex_unlock(&pmcdev->lock);
+
+	return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+					 const char __user *userbuf,
+					 size_t count, loff_t *ppos)
+{
+	u32 buf_size, val;
+	int err;
+
+	buf_size = count < 64 ? count : 64;
+
+	err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+	if (err)
+		return err;
+
+	err = pmc_core_write_ltr_ignore(1U << val);
+
 	return err == 0 ? count : err;
 }
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id
 *id)
 	return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+	int err;
+
+	err = pmc_core_write_ltr_ignore(val);
+
+	return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
 	{
drivers/platform/x86/intel_pmc_core.c +9 -1
 	.callback = quirk_xtal_ignore,
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
 	pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
 	dmi_check_system(pmc_core_dmi_table);
 
+	/*
+	 * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+	 * a cable is attached. Tell the PMC to ignore it.
+	 */
+	if (pmcdev->map == &tgl_reg_map) {
+		dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+		quirk_ltr_ignore(1U << 3);
+	}
+
 	pmc_core_dbgfs_register(pmcdev);
 
 	device_initialized = true;
--

2.25.1

#9 lore raw
Quoted 19 lines · Mario
Quoted 12 lines

[EXTERNAL EMAIL]

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform from achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed solely by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Quoted 6 lines
Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)
Quoted 3 lines

I feel like this driver change causes a weak reference between e1000e and intel_pmc_core. It would mean significantly different behavior if you use e1000e but don't have PMC module available for any reason.

Can you elaborate what would change significantly? This is a FW/HW issue and the driver is just doing a work around to let the platform enter a deep idle state beyond PC10. If the system could enter PC10 and was denied entry by PMC only because of a bad LAN LTR, then that's purely an e1000e driver/GBE fw issue.

Quoted 3 lines

In this case does it maybe make sense to at least use "imply" in the Kconfig for e1000e so that selecting e1000e gets intel-pmc-core enabled too?

This change would tell PMC to ignore GBE LTR, regardless of which GBE driver is selected. This doesn't bind e1000e.

Quoted 103 lines
Quoted 102 lines
drivers/platform/x86/intel_pmc_core.c +33 -13
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s, void
 *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-                                      const char __user *userbuf,
-                                      size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 {
      struct pmc_dev *pmcdev = &pmc;
      const struct pmc_reg_map *map = pmcdev->map;
-     u32 val, buf_size, fd;
-     int err;
-
-     buf_size = count < 64 ? count : 64;
-
-     err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-     if (err)
-             return err;
+     u32 fd;
+     int err = 0;
 
      mutex_lock(&pmcdev->lock);
 
-     if (val > map->ltr_ignore_max) {
+     if (fls(value) > map->ltr_ignore_max) {
              err = -EINVAL;
              goto out_unlock;
      }
 
      fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-     fd |= (1U << val);
+     fd |= value;
      pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
      mutex_unlock(&pmcdev->lock);
+
+     return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+                                      const char __user *userbuf,
+                                      size_t count, loff_t *ppos)
+{
+     u32 buf_size, val;
+     int err;
+
+     buf_size = count < 64 ? count : 64;
+
+     err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+     if (err)
+             return err;
+
+     err = pmc_core_write_ltr_ignore(1U << val);
+
      return err == 0 ? count : err;
 }
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct dmi_system_id
 *id)
      return 0;
 }
 
+static int quirk_ltr_ignore(u32 val)
+{
+     int err;
+
+     err = pmc_core_write_ltr_ignore(val);
+
+     return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
      {

.callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +9 -1
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device *pdev)
      pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
      dmi_check_system(pmc_core_dmi_table);
 
+     /*
+      * On TGL, due to a hardware limitation, the GBE LTR blocks PC10 when
+      * a cable is attached. Tell the PMC to ignore it.
+      */
+     if (pmcdev->map == &tgl_reg_map) {
+             dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+             quirk_ltr_ignore(1U << 3);
+     }
+
      pmc_core_dbgfs_register(pmcdev);
 
      device_initialized = true;
--

2.25.1

Signature · 2 lines
Thanks,
Rajneesh
#10 lore raw
Quoted 41 lines

-----Original Message-----
From: Rajneesh Bhardwaj <[email protected]>
Sent: Monday, March 8, 2021 11:32
To: Limonciello, Mario
Cc: David E. Box; hdegoede at redhat.com; mgross at linux.intel.com; sasha.neftin at intel.com; platform-driver-x86 at vger.kernel.org; linux- kernel at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: Re: [PATCH] platform/x86: intel_pmc: Ignore GBE LTR on Tiger Lake platforms

[EXTERNAL EMAIL]

Quoted 7 lines · Mario
Quoted 7 lines

[EXTERNAL EMAIL]

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value programmed in the Tiger Lake GBE controller is not large enough to allow the platform to enter Package C10, which in turn prevents the platform

from

Quoted 2 lines
Quoted 2 lines

achieving its low power target during suspend-to-idle. Ignore the GBE LTR value on Tiger Lake. LTR ignore functionality is currently performed

solely

Quoted 11 lines
Quoted 9 lines

by a debugfs write call. Split out the LTR code into its own function that can be called by both the debugfs writer and by this work around.

Cc intel-wired-lan at lists.osuosl.org
---
 drivers/platform/x86/intel_pmc_core.c | 55 ++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 13 deletions(-)

I feel like this driver change causes a weak reference between e1000e and

intel_pmc_core.

Quoted 1 line

It would mean significantly different behavior if you use e1000e but don't

Quoted 9 lines

have PMC module

Quoted 1 line

available for any reason.

Can you elaborate what would change significantly? This is a FW/HW issue and the driver is just doing a work around to let the platform enter a deep idle state beyond PC10. If the system could enter PC10 and was denied entry by PMC only because of a bad LAN LTR, then that's purely an e1000e driver/GBE fw issue.

Because the workaround is in pmc driver, the platform behavior becomes tied to whether this driver was enabled. Before this the driver was mostly for debugging purpose and really not necessary. Now it has a functional purpose.

As such I think it should be made apparent that you need it now for some systems.

Quoted 7 lines
Quoted 2 lines

In this case does it maybe make sense to at least use "imply" in the Kconfig

for e1000e so

Quoted 1 line

that selecting e1000e gets intel-pmc-core enabled too?

This change would tell PMC to ignore GBE LTR, regardless of which GBE driver is selected. This doesn't bind e1000e.

Yeah, that's a good point.

Maybe my suggestion can be to take this into documentation somewhere instead.

Quoted 113 lines
Quoted 9 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct seq_file *s,

Quoted 9 lines
drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct seq_file *s,

void

Quoted 59 lines
Quoted 59 lines
drivers/platform/x86/intel_pmc_core.c +24 -13
 *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-                                      const char __user *userbuf,
-                                      size_t count, loff_t *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 {
      struct pmc_dev *pmcdev = &pmc;
      const struct pmc_reg_map *map = pmcdev->map;
-     u32 val, buf_size, fd;
-     int err;
-
-     buf_size = count < 64 ? count : 64;
-
-     err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-     if (err)
-             return err;
+     u32 fd;
+     int err = 0;
 
      mutex_lock(&pmcdev->lock);
 
-     if (val > map->ltr_ignore_max) {
+     if (fls(value) > map->ltr_ignore_max) {
              err = -EINVAL;
              goto out_unlock;
      }
 
      fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-     fd |= (1U << val);
+     fd |= value;
      pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 
 out_unlock:
      mutex_unlock(&pmcdev->lock);
+
+     return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+                                      const char __user *userbuf,
+                                      size_t count, loff_t *ppos)
+{
+     u32 buf_size, val;
+     int err;
+
+     buf_size = count < 64 ? count : 64;
+
+     err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+     if (err)
+             return err;
+
+     err = pmc_core_write_ltr_ignore(1U << val);
+
      return err == 0 ? count : err;
 }
Quoted 1 line

drivers/platform/x86/intel_pmc_core.c static int quirk_xtal_ignore(const struct

Quoted 1 line
drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const struct

dmi_system_id

Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/intel_pmc_core.c +0 -0
 *id)
      return 0;
 }
 
Quoted 13 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device

Quoted 13 lines
drivers/platform/x86/intel_pmc_core.c +9 -0
+static int quirk_ltr_ignore(u32 val)
+{
+     int err;
+
+     err = pmc_core_write_ltr_ignore(val);
+
+     return err;
+}
+
 static const struct dmi_system_id pmc_core_dmi_table[]  = {
      {

.callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct platform_device

*pdev)

Quoted 5 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/platform/x86/intel_pmc_core.c +2 -0
      pmcdev->pmc_xram_read_bit = pmc_core_check_read_lock_bit();
      dmi_check_system(pmc_core_dmi_table);
 
+     /*
+      * On TGL, due to a hardware limitation, the GBE LTR blocks PC10

when

Quoted 9 lines
Quoted 9 lines
drivers/platform/x86/intel_pmc_core.c +7 -0
+      * a cable is attached. Tell the PMC to ignore it.
+      */
+     if (pmcdev->map == &tgl_reg_map) {
+             dev_dbg(&pdev->dev, "ignoring GBE LTR\n");
+             quirk_ltr_ignore(1U << 3);
+     }
+
      pmc_core_dbgfs_register(pmcdev);
 
Quoted 4 lines
Quoted 3 lines
drivers/platform/x86/intel_pmc_core.c +0 -1
      device_initialized = true;
--

2.25.1

--
Thanks,
Rajneesh

#11 lore raw
Quoted 63 lines · Mario
Quoted 55 lines

-----Original Message-----
From: Rajneesh Bhardwaj <[email protected]>
Sent: Monday, March 8, 2021 11:32
To: Limonciello, Mario
Cc: David E. Box; hdegoede at redhat.com; mgross at linux.intel.com; sasha.neftin at intel.com; platform-driver-x86 at vger.kernel.org; linux- kernel at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Subject: Re: [PATCH] platform/x86: intel_pmc: Ignore GBE LTR on Tiger Lake
platforms

[EXTERNAL EMAIL]

Quoted 10 lines · Mario
Quoted 10 lines

[EXTERNAL EMAIL]

Due to a HW limitation, the Latency Tolerance Reporting (LTR) value
programmed in the Tiger Lake GBE controller is not large enough to allow
the platform to enter Package C10, which in turn prevents the platform

from

Quoted 4 lines
Quoted 4 lines

achieving its low power target during suspend-to-idle.? Ignore the GBE LTR
value on Tiger Lake. LTR ignore functionality is currently performed

solely

Quoted 13 lines
Quoted 5 lines

by a debugfs write call. Split out the LTR code into its own function that
can be called by both the debugfs writer and by this work around.

Quoted 7 lines
Cc intel-wired-lan at lists.osuosl.org

---
?drivers/platform/x86/intel_pmc_core.c | 55
++++++++++++++++++++-------
?1 file changed, 42 insertions(+), 13 deletions(-)

Quoted 2 lines

I feel like this driver change causes a weak reference between e1000e and

intel_pmc_core.

Quoted 2 lines

It would mean significantly different behavior if you use e1000e but don't

have PMC module

Quoted 1 line

available for any reason.

Quoted 8 lines

Can you elaborate what would change significantly? This is a FW/HW issue and the driver is just doing a work around to let the platform
enter a deep idle state beyond PC10. If the system could enter PC10 and was denied entry by PMC only because of a bad LAN LTR, then that's
purely an e1000e driver/GBE fw issue.

Quoted 8 lines

Because the workaround is in pmc driver, the platform behavior becomes tied
to whether this driver was enabled.? Before this the driver was mostly for debugging
purpose and really not necessary.? Now it has a functional purpose.

As such I think it should be made apparent that you need it now for some systems.

Agreed. This is not the first fix either. The driver needs to be built for all platforms we add support for. I'll change the Kconfig.

David

Quoted 138 lines
Quoted 10 lines
Quoted 4 lines

In this case does it maybe make sense to at least use "imply" in the Kconfig

for e1000e so

Quoted 1 line

that selecting e1000e gets intel-pmc-core enabled too?

This change would tell PMC to ignore GBE LTR, regardless of which GBE
driver is selected. This doesn't bind e1000e.

Yeah, that's a good point.

Maybe my suggestion can be to take this into documentation somewhere instead.

Quoted 122 lines
Quoted 10 lines

drivers/platform/x86/intel_pmc_core.c static int pmc_core_pll_show(struct · line 863

Quoted 10 lines
drivers/platform/x86/intel_pmc_core.c +0 -0
index ee2f757515b0..ab31eb646a1a 100644
@@ -863,34 +863,45 @@ static int pmc_core_pll_show(struct
 seq_file *s,

void

Quoted 63 lines
Quoted 63 lines
drivers/platform/x86/intel_pmc_core.c +5 -13
 *unused)
 ?}
 ?DEFINE_SHOW_ATTRIBUTE(pmc_core_pll);
 
-static ssize_t pmc_core_ltr_ignore_write(struct file *file,
-????????????????????????????????????? const char __user
 *userbuf,
-????????????????????????????????????? size_t count, loff_t
 *ppos)
+static int pmc_core_write_ltr_ignore(u32 value)
 ?{
 ????? struct pmc_dev *pmcdev = &pmc;
 ????? const struct pmc_reg_map *map = pmcdev->map;
-???? u32 val, buf_size, fd;
-???? int err;
-
-???? buf_size = count < 64 ? count : 64;
-
-???? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
-???? if (err)
-???????????? return err;
+???? u32 fd;
+???? int err = 0;
 
 ????? mutex_lock(&pmcdev->lock);
 
-???? if (val > map->ltr_ignore_max) {
+???? if (fls(value) > map->ltr_ignore_max) {
 ????????????? err = -EINVAL;
 ????????????? goto out_unlock;
 ????? }
 
 ????? fd = pmc_core_reg_read(pmcdev, map->ltr_ignore_offset);
-???? fd |= (1U << val);
+???? fd |= value;
 ????? pmc_core_reg_write(pmcdev, map->ltr_ignore_offset, fd);
 

?out_unlock:
????? mutex_unlock(&pmcdev->lock);

drivers/platform/x86/intel_pmc_core.c +6 -0
+
+???? return err;
+}
+
+static ssize_t pmc_core_ltr_ignore_write(struct file *file,
+????????????????????????????????????? const char __user

*userbuf,
+????????????????????????????????????? size_t count, loff_t *ppos)

drivers/platform/x86/intel_pmc_core.c +12 -0
+{
+???? u32 buf_size, val;
+???? int err;
+
+???? buf_size = count < 64 ? count : 64;
+
+???? err = kstrtou32_from_user(userbuf, buf_size, 10, &val);
+???? if (err)
+???????????? return err;
+
+???? err = pmc_core_write_ltr_ignore(1U << val);
+

????? return err == 0 ? count : err;
?}

Quoted 2 lines
Quoted 2 lines
drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1189,6 +1200,15 @@ static int quirk_xtal_ignore(const

struct

dmi_system_id

Quoted 4 lines
Quoted 4 lines

*id)
????? return 0;
?}

Quoted 14 lines
Quoted 13 lines
drivers/platform/x86/intel_pmc_core.c +9 -0
+static int quirk_ltr_ignore(u32 val)
+{
+???? int err;
+
+???? err = pmc_core_write_ltr_ignore(val);
+
+???? return err;
+}
+

?static const struct dmi_system_id pmc_core_dmi_table[]? = { ????? {
????? .callback = quirk_xtal_ignore,

drivers/platform/x86/intel_pmc_core.c +0 -0
@@ -1244,6 +1264,15 @@ static int pmc_core_probe(struct
Quoted 1 line

platform_device

*pdev)

Quoted 7 lines
Quoted 7 lines

????? pmcdev->pmc_xram_read_bit =
pmc_core_check_read_lock_bit();
????? dmi_check_system(pmc_core_dmi_table);

+???? /*
+????? * On TGL, due to a hardware limitation, the GBE LTR blocks PC10

when

Quoted 9 lines
Quoted 9 lines

+????? * a cable is attached. Tell the PMC to ignore it. +????? */
+???? if (pmcdev->map == &tgl_reg_map) { +???????????? dev_dbg(&pdev->dev, "ignoring GBE LTR\n"); +???????????? quirk_ltr_ignore(1U << 3);
+???? }
+
????? pmc_core_dbgfs_register(pmcdev);

Quoted 4 lines
Quoted 3 lines

????? device_initialized = true;
--
2.25.1

--
Thanks,
Rajneesh