Skip to contentSkip to conversation

mfd: Fix RTS5227 (and others) powermanagement

PATCH Applied Hans de Goede 3 participants 8 messages Dec 6, 2017 – Dec 7, 2017 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: Fix RTS5227 (and others) powermanagement

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the old behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching the old default behavior, fixing the pm regression with the other device-ids.

---
 include/linux/mfd/rtsx_pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rtsx_pci.h +1 -1
index a2a1318a3d0c..c3d3f04d8cc6 100644
@@ -915,10 +915,10 @@ enum PDEV_STAT  {PDEV_STAT_IDLE, PDEV_STAT_RUN};
 #define LTR_L1SS_PWR_GATE_CHECK_CARD_EN	BIT(6)
 
 enum dev_aspm_mode {
-	DEV_ASPM_DISABLE = 0,
 	DEV_ASPM_DYNAMIC,
 	DEV_ASPM_BACKDOOR,
 	DEV_ASPM_STATIC,
+	DEV_ASPM_DISABLE,
 };
 
 /*
Signature · 1 line
2.14.3
#1 lore raw

Hi,

Quoted 17 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the old behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

Quoted 5 lines

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching the old default behavior, fixing the pm regression with the other device-ids.

p.s.

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

2. This bit of the original commit also looks weird, but I don't have the hardware in case, Rui Feng should probably take a look at this:

@@ -1063,6 +1185,16 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
if (err < 0)
return err;

+ switch (PCI_PID(pcr)) {
+ case PID_5250:
+ case PID_524A:
+ case PID_525A:
+ rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 1, 1);
+ break;
+ default:
+ break;
+ }
+
/* Enable clk_request_n to enable clock power management */ rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1); /* Enter L1 when host tx idle */

The PID5250 looks weird here, the rtsx_pci_ids table does not contain it; and neither does the switch (PCI_PID(pcr)) in rtsx_pci_init_chip() at the same time the commit does make changes to the codepaths for the 5249... ?

Regards,

Hans

Quoted 21 lines
---
  include/linux/mfd/rtsx_pci.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rtsx_pci.h +1 -1
index a2a1318a3d0c..c3d3f04d8cc6 100644
@@ -915,10 +915,10 @@ enum PDEV_STAT  {PDEV_STAT_IDLE, PDEV_STAT_RUN};
  #define LTR_L1SS_PWR_GATE_CHECK_CARD_EN	BIT(6)
 
  enum dev_aspm_mode {
-	DEV_ASPM_DISABLE = 0,
  	DEV_ASPM_DYNAMIC,
  	DEV_ASPM_BACKDOOR,
  	DEV_ASPM_STATIC,
+	DEV_ASPM_DISABLE,
  };
 
  /*
#2 lore raw
Quoted 26 lines · Hans de Goede

Hi,

Quoted 17 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the old behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

Quoted 5 lines

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching the old default behavior, fixing the pm regression with the other device-ids.

Quoted 7 lines

p.s.

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

If this is aimed at -the rcs, you should apply a Fixes: tag.

Happy to do it for you this time.

Be good to get at Ack from Rui before I apply it.

Signature · 4 lines
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

Hi,

Quoted 30 lines · Lee Jones
Quoted 28 lines · Hans de Goede

Hi,

Quoted 17 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the old behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

Quoted 5 lines

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching the old default behavior, fixing the pm regression with the other device-ids.

p.s.

Quoted 7 lines
Quoted 5 lines

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

If this is aimed at -the rcs, you should apply a Fixes: tag.

Right, I should have thought of that myself.

Quoted 1 line

Happy to do it for you this time.

Thanks you.

Regards,

Hans

#4 lore raw
In reply to Hans de Goede
Quoted 57 lines

Hi,

Quoted 8 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

Quoted 5 lines

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the

old

Quoted 5 lines

behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching

the

Quoted 4 lines

old default behavior, fixing the pm regression with the other device-ids.

p.s.

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

2. This bit of the original commit also looks weird, but I don't have the hardware in case, Rui Feng should probably take a look at this:

(quoted diff) +10 -0
@@ -1063,6 +1185,16 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
  	if (err < 0)
  		return err;
 
+	switch (PCI_PID(pcr)) {
+	case PID_5250:
+	case PID_524A:
+	case PID_525A:
+		rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 1, 1);
+		break;
+	default:
+		break;
+	}
+
  	/* Enable clk_request_n to enable clock power management */
  	rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1);
  	/* Enter L1 when host tx idle */
Quoted 4 lines

The PID5250 looks weird here, the rtsx_pci_ids table does not contain it; and neither does the switch (PCI_PID(pcr)) in rtsx_pci_init_chip() at the same time the commit does make changes to the codepaths for the 5249... ?

Thank you for pointing out the problem. The old driver isn't written by me, 5249, 524a and 525a are in the same file, I didn't notice that rtsx_pci_ids table does not contain 5250. But the power saving function for 5250 and 525a is the same, PID_5250 here will not effect the power saving function.

Quoted 34 lines

Regards,

Hans

include/linux/mfd/rtsx_pci.h enum PDEV_STAT {PDEV_STAT_IDLE,

Quoted 9 lines
---
  include/linux/mfd/rtsx_pci.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/linux/mfd/rtsx_pci.h index a2a1318a3d0c..c3d3f04d8cc6 100644

include/linux/mfd/rtsx_pci.h +0 -0
@@ -915,10 +915,10 @@ enum PDEV_STAT  {PDEV_STAT_IDLE,

PDEV_STAT_RUN};

include/linux/mfd/rtsx_pci.h enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; · line 924

Quoted 12 lines
include/linux/mfd/rtsx_pci.h +1 -1
  #define LTR_L1SS_PWR_GATE_CHECK_CARD_EN	BIT(6)
 
  enum dev_aspm_mode {
-	DEV_ASPM_DISABLE = 0,
  	DEV_ASPM_DYNAMIC,
  	DEV_ASPM_BACKDOOR,
  	DEV_ASPM_STATIC,
+	DEV_ASPM_DISABLE,
  };
 
  /*

------Please consider the environment before printing this e-mail.

#5 lore raw
Quoted 57 lines · 冯锐
Quoted 57 lines

Hi,

Quoted 8 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

Quoted 5 lines

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the

old

Quoted 5 lines

behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching

the

Quoted 4 lines

old default behavior, fixing the pm regression with the other device-ids.

p.s.

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

2. This bit of the original commit also looks weird, but I don't have the hardware in case, Rui Feng should probably take a look at this:

(quoted diff) +10 -0
@@ -1063,6 +1185,16 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
  	if (err < 0)
  		return err;
 
+	switch (PCI_PID(pcr)) {
+	case PID_5250:
+	case PID_524A:
+	case PID_525A:
+		rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 1, 1);
+		break;
+	default:
+		break;
+	}
+
  	/* Enable clk_request_n to enable clock power management */
  	rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1);
  	/* Enter L1 when host tx idle */
Quoted 9 lines
Quoted 4 lines

The PID5250 looks weird here, the rtsx_pci_ids table does not contain it; and neither does the switch (PCI_PID(pcr)) in rtsx_pci_init_chip() at the same time the commit does make changes to the codepaths for the 5249... ?

Thank you for pointing out the problem. The old driver isn't written by me, 5249, 524a and 525a are in the same file,
I didn't notice that rtsx_pci_ids table does not contain 5250. But the power saving function for 5250 and 525a is the same, PID_5250 here will not effect the power saving function.

Is that an Ack or a NAck?

Signature · 4 lines
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by
#6 lore raw
Quoted 68 lines · 冯锐
Quoted 7 lines
Quoted 7 lines

Hi,

Quoted 3 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other

device-ids.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but

the

Quoted 6 lines
Quoted 6 lines

old

Quoted 5 lines

behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC

matching

Quoted 21 lines
Quoted 21 lines

the

Quoted 4 lines

old default behavior, fixing the pm regression with the other device-ids.

p.s.

2 remarks:

1. As this is a regression in 4.15, please queue this up as a fix for 4.15 (I prioritized bisecting this, which took me a whole day to get a fix ready in time for 4.15).

2. This bit of the original commit also looks weird, but I don't have the hardware in case, Rui Feng should probably take a look at this:

(quoted diff) +0 -0
@@ -1063,6 +1185,16 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)
  	if (err < 0)
  		return err;
 
Quoted 12 lines

Review static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) · line 1199

Quoted 12 lines
(quoted diff) +10 -0
+	switch (PCI_PID(pcr)) {
+	case PID_5250:
+	case PID_524A:
+	case PID_525A:
+		rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 1, 1);
+		break;
+	default:
+		break;
+	}
+
  	/* Enable clk_request_n to enable clock power management */
  	rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1,

1);

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
  	/* Enter L1 when host tx idle */

The PID5250 looks weird here, the rtsx_pci_ids table does not contain it; and neither does the switch (PCI_PID(pcr)) in rtsx_pci_init_chip() at the same time the commit does make changes to the

codepaths for the 5249... ?

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines

Thank you for pointing out the problem. The old driver isn't written by me, 5249, 524a and 525a are in the same file, I didn't notice that rtsx_pci_ids table does not contain 5250. But the power saving function for 5250 and 525a is the same,
PID_5250 here will not effect the power saving function.

Is that an Ack or a NAck?

Thanks.

Quoted 7 lines

--
Lee Jones
Linaro Services Technical Lead

Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook |
Twitter | Blog

------Please consider the environment before printing this e-mail.

Applied
#7 lore raw
In reply to Hans de Goede
Quoted 17 lines · Hans de Goede

Commit 8275b77a1513 ("mfd: rts5249: Add support for RTS5250S power saving") adds powersaving support for device-ids 5249 524a and 525a.

But as a side effect it breaks ASPM support for all the other device-ids, causing e.g. the Haswell CPU on a Lenovo T440s to not go into a higher c-state then PC3, while previously it would go to PC7, causing the machine to idle at 7.4W instead of 6.6W!

The problem here is the new option.dev_aspm_mode field, which only gets explicitly initialized in the new code for the device-ids 5249 524a and 525a. Leaving the dev_aspm_mode 0 for the other device-ids.

The default dev_aspm_mode 0 is mapped to DEV_ASPM_DISABLE, but the old behavior of calling rtsx_pci_enable_aspm() when idle and rtsx_pci_disable_aspm() when busy happens when dev_aspm_mode == DEV_ASPM_DYNAMIC.

Quoted 8 lines

This commit changes the enum so that 0 = DEV_ASPM_DYNAMIC matching the old default behavior, fixing the pm regression with the other device-ids.

---
 include/linux/mfd/rtsx_pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Lee Jones
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog