Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <fabio.estevam@nxp.com>
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Fixes: 03aa12629fc4 ("soc: imx: Add GPCv2 power gating driver")
Signed-off-by: Stefan Agner <stefan@agner.ch>
Acked-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>

authored by

Stefan Agner and committed by
Shawn Guo
9e01e2d5 05969566

+8 -7
+8 -7
drivers/soc/imx/gpcv2.c
··· 200 200 201 201 domain->dev = &pdev->dev; 202 202 203 - ret = pm_genpd_init(&domain->genpd, NULL, true); 204 - if (ret) { 205 - dev_err(domain->dev, "Failed to init power domain\n"); 206 - return ret; 207 - } 208 - 209 203 domain->regulator = devm_regulator_get_optional(domain->dev, "power"); 210 204 if (IS_ERR(domain->regulator)) { 211 205 if (PTR_ERR(domain->regulator) != -ENODEV) { 212 - dev_err(domain->dev, "Failed to get domain's regulator\n"); 206 + if (PTR_ERR(domain->regulator) != -EPROBE_DEFER) 207 + dev_err(domain->dev, "Failed to get domain's regulator\n"); 213 208 return PTR_ERR(domain->regulator); 214 209 } 215 210 } else { 216 211 regulator_set_voltage(domain->regulator, 217 212 domain->voltage, domain->voltage); 213 + } 214 + 215 + ret = pm_genpd_init(&domain->genpd, NULL, true); 216 + if (ret) { 217 + dev_err(domain->dev, "Failed to init power domain\n"); 218 + return ret; 218 219 } 219 220 220 221 ret = of_genpd_add_provider_simple(domain->dev->of_node,