Skip to contentSkip to conversation

soc: imx: gpcv2: fix regulator deferred probe

PATCH Applied Stefan Agner 4 participants 7 messages Aug 2, 2017 – Aug 15, 2017 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: imx: gpcv2: fix regulator deferred probe

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")

---
Hi Shawn,

Since this leads to a Kernel hang in v4.13-rc3, can you get this into v4.13 still?

--
Stefan

 drivers/soc/imx/gpcv2.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/soc/imx/gpcv2.c +8 -7
index 3039072911a5..afc7ecc3c187 100644
@@ -200,16 +200,11 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
 
 	domain->dev = &pdev->dev;
 
-	ret = pm_genpd_init(&domain->genpd, NULL, true);
-	if (ret) {
-		dev_err(domain->dev, "Failed to init power domain\n");
-		return ret;
-	}
-
 	domain->regulator = devm_regulator_get_optional(domain->dev, "power");
 	if (IS_ERR(domain->regulator)) {
 		if (PTR_ERR(domain->regulator) != -ENODEV) {
-			dev_err(domain->dev, "Failed to get domain's regulator\n");
+			if (PTR_ERR(domain->regulator) != -EPROBE_DEFER)
+				dev_err(domain->dev, "Failed to get domain's regulator\n");
 			return PTR_ERR(domain->regulator);
 		}
 	} else {
@@ -217,6 +212,12 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
 				      domain->voltage, domain->voltage);
 	}
 
+	ret = pm_genpd_init(&domain->genpd, NULL, true);
+	if (ret) {
+		dev_err(domain->dev, "Failed to init power domain\n");
+		return ret;
+	}
+
 	ret = of_genpd_add_provider_simple(domain->dev->of_node,
 					   &domain->genpd);
 	if (ret) {
Signature · 1 line
2.13.3
#1 lore raw
Quoted 16 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")
Quoted 5 lines

---
Hi Shawn,

Since this leads to a Kernel hang in v4.13-rc3, can you get this into v4.13 still?

Sure. But before doing that, I would like to get an ACK from Andrey on this fix.

Shawn

Acked-by Tested-by on v1 1/1
#2 lore raw
In reply to Stefan Agner
Quoted 10 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Quoted 6 lines
Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")

As the author of original bug:

I also went ahead and tested PCIe on my SabreSD with Intel Gigabit adapter, so

Thanks for debugging and fixing this!

Andrey Smirnov

Applied
#3 lore raw
In reply to Stefan Agner
Quoted 10 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Quoted 6 lines
Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")

Applied, thanks.

#4 lore raw

Hi Shawn,

Quoted 11 lines · Shawn Guo
Quoted 10 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Quoted 8 lines
Quoted 6 lines
Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")

Applied, thanks.

As of 4.13-rc5 this did not make it upstream yet, I guess still on its way?

--
Stefan

#5 lore raw
Quoted 21 lines · Stefan Agner

Hi Shawn,

Quoted 18 lines · Shawn Guo
Quoted 16 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")
Quoted 4 lines
Quoted 1 line

Applied, thanks.

As of 4.13-rc5 this did not make it upstream yet, I guess still on its way?

Yes, Stefan. It's on the way to arm-soc [1], but not yet responded.

Shawn

[1] https://www.spinics.net/lists/arm-kernel/msg598634.html

#6 lore raw
Quoted 24 lines · Shawn Guo
Quoted 23 lines · Stefan Agner

Hi Shawn,

Quoted 19 lines · Shawn Guo
Quoted 10 lines · Stefan Agner

If a regulator requests a deferred probe, the power domain gets initialized twice. This leads to a list double add (without list debugging the kernel hangs due to the double add later):

  WARNING: CPU: 0 PID: 19 at lib/list_debug.c:31 __list_add_valid+0xbc/0xc4
  list_add double add: new=c1229754, prev=c12383b4, next=c1229754.

Initialize the power domain after we get the regulator. Also do not print an error in case the regulator defers probing.

Quoted 6 lines
Cc Fabio Estevam <[email protected]>
Cc Andrey Smirnov <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
Fixes 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")

Applied, thanks.

Quoted 8 lines
Quoted 2 lines

As of 4.13-rc5 this did not make it upstream yet, I guess still on its way?

Yes, Stefan. It's on the way to arm-soc [1], but not yet responded.

Shawn

[1] https://www.spinics.net/lists/arm-kernel/msg598634.html

Merged into arm-soc now with Shawn's pull request.

Arnd