Skip to contentSkip to conversation

usb: dwc3: meson-g12a: fix shared reset control use

PATCH Applied Dan Robertson 9 participants 31 messages Jul 13, 2020 – Sep 7, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover usb: dwc3: meson-g12a: fix shared reset control use

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Cheers,

- Dan

Dan Robertson (1):
usb: dwc3: meson-g12a: fix shared reset control use

 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#1 lore raw

PATCH 1/1 usb: dwc3: meson-g12a: fix shared reset control use

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +9 -6
index 1f7f4d88ed9d..88b75b5a039c 100644
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#2 lore raw

Hi,

Quoted 75 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +6 -6
index 1f7f4d88ed9d..88b75b5a039c 100644
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 817

Quoted 9 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +3 -0
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);

This should do the trick, I'll need to check first if it doesn't break the GXL/GXM support first.

thanks for the fix

Neil

#3 lore raw
Quoted 80 lines · Neil Armstrong

Hi,

Quoted 77 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +6 -6
index 1f7f4d88ed9d..88b75b5a039c 100644
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
Quoted 11 lines

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 817

Quoted 7 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +3 -0
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);

This should do the trick, I'll need to check first if it doesn't break the GXL/GXM support first.

Awesome. Let me know if you find anything.

Cheers,

- Dan

reviewer
#4 lore raw
In reply to Dan Robertson
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22

This breaks USB on this device. reverting the change brings it back.

Looking at the reset framework code, I don't think drivers sharing the same reset line should mix using reset_control_reset() VS reset_control_assert()/reset_control_deassert()

Quoted 28 lines
WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0
index 1f7f4d88ed9d..88b75b5a039c 100644

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 740

Quoted 5 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);

The change introduced here is significant. If the reset is not initially asserted, it never will be before the life of the device.

This means that Linux will have to deal which whatever state is left by the bootloader. This looks sketchy ...

I think the safer way solve the problem here would be to keep using reset_control_reset() and introduce a new API in the reset framework to decrement the reset line "triggered_count" (reset_control_clear() ??)

That way, if all device using the reset line go to suspend, the line will be "reset-able" again by the first device coming out of suspend ?

Philip, would you be ok with such new API ?

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Quoted 52 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +8 -5
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

maintainer
#5 lore raw
Quoted 58 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22

This breaks USB on this device. reverting the change brings it back.

[...]

Quoted 2 lines

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Fully agree.

Phillip, can you please revert this patch until the right solution is found? Boot failure is much worse than a suspend warning.

Kevin

reviewer
#6 lore raw
Quoted 63 lines · Kevin Hilman
Quoted 58 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22

This breaks USB on this device. reverting the change brings it back.

[...]

Quoted 7 lines
Quoted 2 lines

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Fully agree.

Phillip, can you please revert this patch until the right solution is found? Boot failure is much worse than a suspend warning.

I was asking Philip about the reset API suggestion. I think the maintainer is Felipe for this change :)

Quoted 2 lines

Kevin

maintainer
#7 lore raw
Quoted 68 lines · Jerome Brunet
Quoted 66 lines · Kevin Hilman
Quoted 58 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22

This breaks USB on this device. reverting the change brings it back.

[...]

Quoted 2 lines

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Quoted 7 lines
Quoted 4 lines

Fully agree.

Phillip, can you please revert this patch until the right solution is found? Boot failure is much worse than a suspend warning.

I was asking Philip about the reset API suggestion. I think the maintainer is Felipe for this change :)

Oops, yeah. I meant Felipe too. Names are close enough for my brain to mix up.

@Felipe: can you revert this change please?

Kevin

#8 lore raw
In reply to Jerome Brunet
Quoted 58 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22
Quoted 6 lines

This breaks USB on this device. reverting the change brings it back.

Looking at the reset framework code, I don't think drivers sharing the same reset line should mix using reset_control_reset() VS reset_control_assert()/reset_control_deassert()

Thanks for finding this. I was only able to test on the Odroid N2

Quoted 37 lines
Quoted 28 lines
WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0
index 1f7f4d88ed9d..88b75b5a039c 100644

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 740

Quoted 5 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);

The change introduced here is significant. If the reset is not initially asserted, it never will be before the life of the device.

Quoted 7 lines

This means that Linux will have to deal which whatever state is left by the bootloader. This looks sketchy ...

I think the safer way solve the problem here would be to keep using reset_control_reset() and introduce a new API in the reset framework to decrement the reset line "triggered_count" (reset_control_clear() ??)

I have very limited experience with reset controls, but phy_meson_gxl_usb2_init calls reset_control_reset on a shared reset line, which should not be done according to the reset control docs. Would removing the use of reset_control_reset, or using reset_control_(de)assert in phy_meson_gxl_usb2_init also resolve the issue?

Quoted 7 lines

That way, if all device using the reset line go to suspend, the line will be "reset-able" again by the first device coming out of suspend ?

Philip, would you be ok with such new API ?

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

The reset_control_(de)assert() calls could also be removed from the suspend/resume calls for now.

Quoted 48 lines
Quoted 48 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +8 -5
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);
Quoted 5 lines
Quoted 4 lines

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

reviewer
#9 lore raw
Quoted 113 lines · Dan Robertson
Quoted 58 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150
[    1.876525] Modules linked in:
[    1.879548] CPU: 1 PID: 16 Comm: kworker/1:0 Not tainted 5.9.0-rc1-00167-ga2e4e3a34775 #64
[    1.887737] Hardware name: Libre Computer AML-S905X-CC V2 (DT)
[    1.893525] Workqueue: events deferred_probe_work_func
[    1.898607] pstate: 80000005 (Nzcv daif -PAN -UAO BTYPE=--)
[    1.904126] pc : reset_control_reset+0x130/0x150
[    1.908700] lr : phy_meson_gxl_usb2_init+0x24/0x70
[    1.913439] sp : ffff8000123ebad0
[    1.916717] x29: ffff8000123ebad0 x28: 0000000000000000 
[    1.921978] x27: ffff00007c4b1ac8 x26: ffff00007c4b1ab0 
[    1.927239] x25: ffff00007fc149b0 x24: ffff00007c4b1ab0 
[    1.932500] x23: ffff00007cd03800 x22: ffff800011fb9000 
[    1.937761] x21: ffff00007c60db08 x20: ffff00007c468a80 
[    1.943023] x19: ffff00007c466b00 x18: ffffffffffffffff 
[    1.948284] x17: 0000000000000000 x16: 000000000000000e 
[    1.953545] x15: ffff800011fb9948 x14: ffffffffffffffff 
[    1.958806] x13: ffffffff00000000 x12: ffffffffffffffff 
[    1.964068] x11: 0000000000000020 x10: 7f7f7f7f7f7f7f7f 
[    1.969329] x9 : 78676f2c32617274 x8 : 0000000000000000 
[    1.974590] x7 : ffffffffffffffff x6 : 0000000000000000 
[    1.979851] x5 : 0000000000000000 x4 : 0000000000000000 
[    1.985112] x3 : 0000000000000000 x2 : ffff8000107aa370 
[    1.990374] x1 : 0000000000000001 x0 : 0000000000000001 
[    1.995636] Call trace:
[    1.998054]  reset_control_reset+0x130/0x150
[    2.002279]  phy_meson_gxl_usb2_init+0x24/0x70
[    2.006677]  phy_init+0x78/0xd0
[    2.009784]  dwc3_meson_g12a_probe+0x2c8/0x560
[    2.014182]  platform_drv_probe+0x58/0xa8
[    2.018149]  really_probe+0x114/0x3d8
[    2.021770]  driver_probe_device+0x5c/0xb8
[    2.025824]  __device_attach_driver+0x98/0xb8
[    2.030138]  bus_for_each_drv+0x74/0xd8
[    2.033933]  __device_attach+0xec/0x148
[    2.037726]  device_initial_probe+0x24/0x30
[    2.041868]  bus_probe_device+0x9c/0xa8
[    2.045663]  deferred_probe_work_func+0x7c/0xb8
[    2.050150]  process_one_work+0x1f0/0x4b0
[    2.054115]  worker_thread+0x210/0x480
[    2.057824]  kthread+0x158/0x160
[    2.061017]  ret_from_fork+0x10/0x18
[    2.064550] ---[ end trace 94d737efe593c6f6 ]---
[    2.069158] phy phy-d0078000.phy.0: phy init failed --> -22
[    2.074858] dwc3-meson-g12a: probe of d0078080.usb failed with error -22
Quoted 6 lines

This breaks USB on this device. reverting the change brings it back.

Looking at the reset framework code, I don't think drivers sharing the same reset line should mix using reset_control_reset() VS reset_control_assert()/reset_control_deassert()

Thanks for finding this. I was only able to test on the Odroid N2

Quoted 37 lines
Quoted 28 lines
WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
 pm_suspend+0x198/0x2d4
Fixes 6d9fa35a347a87 ("usb: dwc3: meson-g12a: get the reset as shared")
---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0
index 1f7f4d88ed9d..88b75b5a039c 100644

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 740

Quoted 5 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);

The change introduced here is significant. If the reset is not initially asserted, it never will be before the life of the device.

Quoted 7 lines

This means that Linux will have to deal which whatever state is left by the bootloader. This looks sketchy ...

I think the safer way solve the problem here would be to keep using reset_control_reset() and introduce a new API in the reset framework to decrement the reset line "triggered_count" (reset_control_clear() ??)

Quoted 5 lines

I have very limited experience with reset controls, but phy_meson_gxl_usb2_init calls reset_control_reset on a shared reset line, which should not be done according to the reset control docs. Would removing the use of reset_control_reset, or using reset_control_(de)assert in phy_meson_gxl_usb2_init also resolve the issue?

As pointed out before, using the deassert() in probe does not provide any guarantee that a reset will actually be trigerred on the device. Reset are deasserted on boot on these chips so it actually likely to never be triggered.
This defeats the purpose of using resets in our case.

Quoted 11 lines
Quoted 8 lines

That way, if all device using the reset line go to suspend, the line will be "reset-able" again by the first device coming out of suspend ?

Philip, would you be ok with such new API ?

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

The reset_control_(de)assert() calls could also be removed from the suspend/resume calls for now.

If it is not causing issue, why not.

Quoted 54 lines
Quoted 54 lines
Quoted 53 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +8 -5
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = dwc3_meson_g12a_get_phys(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	ret = priv->drvdata->setup_regmaps(priv, base);
 	if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	if (priv->vbus) {
 		ret = regulator_enable(priv->vbus);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
-		goto err_disable_clks;
+		goto err_assert_reset;
 
 	/* Init PHYs */
 	for (i = 0 ; i < PHY_COUNT ; ++i) {
 		ret = phy_init(priv->phys[i]);
 		if (ret)
-			goto err_disable_clks;
+			goto err_assert_reset;
 	}
 
 	/* Set PHY Power */
@@ -809,6 +809,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 	for (i = 0 ; i < PHY_COUNT ; ++i)
 		phy_exit(priv->phys[i]);
 
+err_assert_reset:
+	reset_control_assert(priv->reset);
+
 err_disable_clks:
 	clk_bulk_disable_unprepare(priv->drvdata->num_clks,
 				   priv->drvdata->clks);

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#10 lore raw
In reply to Jerome Brunet

Hi Jerome,

Quoted 12 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150

[...]

Quoted 5 lines

This breaks USB on this device. reverting the change brings it back.

Looking at the reset framework code, I don't think drivers sharing the same reset line should mix using reset_control_reset() VS reset_control_assert()/reset_control_deassert()

That is correct, users must not mix the assert/deassert and reset calls on shared resets:

/**
* reset_control_reset - reset the controlled device
* @rstc: reset controller
*
* On a shared reset line the actual reset pulse is only triggered once for the
* lifetime of the reset_control instance: for all but the first caller this is
* a no-op.
* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.
*
* If rstc is NULL it is an optional reset and the function will just
* return 0.
*/

[...]

drivers/usb/dwc3/dwc3- renamed from drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0

meson-g12a.c

Quoted 21 lines

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 740

Quoted 9 lines

index 1f7f4d88ed9d..88b75b5a039c 100644

drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);

The change introduced here is significant. If the reset is not initially asserted, it never will be before the life of the device.

This means that Linux will have to deal which whatever state is left by the bootloader. This looks sketchy ...

I think the safer way solve the problem here would be to keep using reset_control_reset() and introduce a new API in the reset framework to decrement the reset line "triggered_count" (reset_control_clear() ??)

Quoted 4 lines

That way, if all device using the reset line go to suspend, the line will be "reset-able" again by the first device coming out of suspend ?

Philip, would you be ok with such new API ?

I'd like to first evaluate whether the already available APIs might be a better fit. There is already the option of handing off exclusive control between multiple drivers via the reset_control_acquire/release APIs on exclusive reset controls.

If all drivers that are now sharing the reset line would switch to requesting resets via devm_reset_control_get_exclusive_released() and then prepend their reset handling with reset_control_acquire() (but ignore -EBUSY) and the driver that got exclusive control releases the reset via reset_control_release() during suspend, this should do exactly what you want. Note that reset_control_release() must not be called on a reset control that has not been successfully acquired by the same driver.

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

Quoted 2 lines

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Agreed.

regards
Philipp

reviewer
#11 lore raw
Quoted 73 lines · Philipp Zabel

Hi Jerome,

Quoted 12 lines · Jerome Brunet
Quoted 4 lines · Dan Robertson

The reset is a shared reset line, but reset_control_reset is still used and reset_control_deassert is not guaranteed to have been called before the first reset_control_assert call. When suspending the following warning may be seen:

And now the same type of warning maybe seen on boot. This is happening for me on the libretech-cc (s905x - gxl).

[    1.863469] ------------[ cut here ]------------
[    1.867914] WARNING: CPU: 1 PID: 16 at drivers/reset/core.c:309 reset_control_reset+0x130/0x150

[...]

Quoted 5 lines

This breaks USB on this device. reverting the change brings it back.

Looking at the reset framework code, I don't think drivers sharing the same reset line should mix using reset_control_reset() VS reset_control_assert()/reset_control_deassert()

That is correct, users must not mix the assert/deassert and reset calls on shared resets:

/**
* reset_control_reset - reset the controlled device
* @rstc: reset controller
*
* On a shared reset line the actual reset pulse is only triggered once for the
* lifetime of the reset_control instance: for all but the first caller this is
* a no-op.
* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.
*
* If rstc is NULL it is an optional reset and the function will just
* return 0.
*/

[...]

drivers/usb/dwc3/dwc3- renamed from drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0

meson-g12a.c

Quoted 21 lines

drivers/usb/dwc3/dwc3-meson-g12a.c static int dwc3_meson_g12a_probe(struct platform_device *pdev) · line 740

Quoted 9 lines

index 1f7f4d88ed9d..88b75b5a039c 100644

drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 		goto err_disable_clks;
 	}
 
-	ret = reset_control_reset(priv->reset);
+	ret = reset_control_deassert(priv->reset);

The change introduced here is significant. If the reset is not initially asserted, it never will be before the life of the device.

This means that Linux will have to deal which whatever state is left by the bootloader. This looks sketchy ...

I think the safer way solve the problem here would be to keep using reset_control_reset() and introduce a new API in the reset framework to decrement the reset line "triggered_count" (reset_control_clear() ??)

Quoted 4 lines

That way, if all device using the reset line go to suspend, the line will be "reset-able" again by the first device coming out of suspend ?

Philip, would you be ok with such new API ?

I'd like to first evaluate whether the already available APIs might be a better fit. There is already the option of handing off exclusive control between multiple drivers via the reset_control_acquire/release APIs on exclusive reset controls.

Quoted 8 lines

If all drivers that are now sharing the reset line would switch to requesting resets via devm_reset_control_get_exclusive_released() and then prepend their reset handling with reset_control_acquire() (but ignore -EBUSY) and the driver that got exclusive control releases the reset via reset_control_release() during suspend, this should do exactly what you want. Note that reset_control_release() must not be called on a reset control that has not been successfully acquired by the same driver.

In practice, I think your proposition would work since the drivers sharing this USB reset line are likely to be probed/suspended/resumed at the same time but ...

If we imagine a situation where 2 device share a reset line, 1 go in suspend, the other does not - if the first device as control of the reset, it could trigger it and break the 2nd device. Same goes for probe/remove()

I agree it could be seen as unlikely but leaving such race condition open looks dangerous to me.

Quoted 4 lines

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

I was thinking of reset_control_clear() as the counter part of reset_control_reset().

When a reset_control_reset() has been called once, "triggered_count" is incremented which signals that the ressource under the reset is "in_use" and the reset should not be done again. reset_control_clear() would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Quoted 8 lines
Quoted 3 lines

In the meantime, I think this change should be reverted. A warning on suspend seems less critical than a regression breaking USB completly.

Agreed.

regards
Philipp

#12 lore raw

On Mon, 2020-08-24 at 16:26 +0200, Jerome Brunet wrote:
[...]

Quoted 11 lines

In practice, I think your proposition would work since the drivers sharing this USB reset line are likely to be probed/suspended/resumed at the same time but ...

If we imagine a situation where 2 device share a reset line, 1 go in suspend, the other does not - if the first device as control of the reset, it could trigger it and break the 2nd device. Same goes for probe/remove()

I agree it could be seen as unlikely but leaving such race condition open looks dangerous to me.

You are right, this is not good enough.

Quoted 6 lines
Quoted 3 lines

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

I was thinking of reset_control_clear() as the counter part of reset_control_reset().

I'm not particularly fond of reset_control_clear as a name, because it is very close to "clearing a reset bit" which usually would deassert a reset line (or the inverse).

Quoted 3 lines

When a reset_control_reset() has been called once, "triggered_count" is incremented which signals that the ressource under the reset is "in_use" and the reset should not be done again.

"triggered_count" would then have to be renamed to something like "trigger_requested_count", or "use_count". I wonder it might be possible to merge this with "deassert_count" as they'd share the same semantics (while the count is > 0, the reset line must stay deasserted).

Quoted 13 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

Quoted 6 lines

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

regards
Philipp

reviewer
#13 lore raw
Quoted 20 lines · Philipp Zabel

On Mon, 2020-08-24 at 16:26 +0200, Jerome Brunet wrote:
[...]

Quoted 11 lines

In practice, I think your proposition would work since the drivers sharing this USB reset line are likely to be probed/suspended/resumed at the same time but ...

If we imagine a situation where 2 device share a reset line, 1 go in suspend, the other does not - if the first device as control of the reset, it could trigger it and break the 2nd device. Same goes for probe/remove()

I agree it could be seen as unlikely but leaving such race condition open looks dangerous to me.

You are right, this is not good enough.

Quoted 4 lines
Quoted 3 lines

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

Quoted 6 lines
Quoted 2 lines

I was thinking of reset_control_clear() as the counter part of reset_control_reset().

I'm not particularly fond of reset_control_clear as a name, because it is very close to "clearing a reset bit" which usually would deassert a reset line (or the inverse).

It was merely a suggestion :) any other name you prefer is fine by me

Quoted 9 lines
Quoted 4 lines

When a reset_control_reset() has been called once, "triggered_count" is incremented which signals that the ressource under the reset is "in_use" and the reset should not be done again.

"triggered_count" would then have to be renamed to something like "trigger_requested_count", or "use_count". I wonder it might be possible to merge this with "deassert_count" as they'd share the same semantics (while the count is > 0, the reset line must stay deasserted).

Sure. Could investigate this as a 2nd step ?
I'd like to bring a solution for our meson-usb use case quickly - even with the revert suggested, we are having an ugly warning around suspend

Quoted 18 lines
Quoted 18 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

I'm not Martin but these devices are the origin of the request/suggestion.

Quoted 3 lines

regards
Philipp

#14 lore raw
Quoted 22 lines · Jerome Brunet
Quoted 20 lines · Philipp Zabel

On Mon, 2020-08-24 at 16:26 +0200, Jerome Brunet wrote:
[...]

Quoted 11 lines

In practice, I think your proposition would work since the drivers sharing this USB reset line are likely to be probed/suspended/resumed at the same time but ...

If we imagine a situation where 2 device share a reset line, 1 go in suspend, the other does not - if the first device as control of the reset, it could trigger it and break the 2nd device. Same goes for probe/remove()

I agree it could be seen as unlikely but leaving such race condition open looks dangerous to me.

You are right, this is not good enough.

Quoted 4 lines
Quoted 3 lines

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I was thinking of reset_control_clear() as the counter part of reset_control_reset().

I'm not particularly fond of reset_control_clear as a name, because it is very close to "clearing a reset bit" which usually would deassert a reset line (or the inverse).

It was merely a suggestion :) any other name you prefer is fine by me

Naming is hard. All metaphors I can think of are either a obscure or clash with other current usage. My instinct would be to call this "resetting the (reset) control", but _reset() is already taken, with the opposite meaning. How about _rewind() or _rearm()? Not sure if those are good metaphors either, but at least there is no obvious but incorrect interpretation. I kind of wish reset_control_reset() would be called reset_control_trigger() instead.

Quoted 10 lines
Quoted 8 lines
Quoted 3 lines

When a reset_control_reset() has been called once, "triggered_count" is incremented which signals that the ressource under the reset is "in_use" and the reset should not be done again.

"triggered_count" would then have to be renamed to something like "trigger_requested_count", or "use_count". I wonder it might be possible to merge this with "deassert_count" as they'd share the same semantics (while the count is > 0, the reset line must stay deasserted).

Sure. Could investigate this as a 2nd step ?

Yes.

Quoted 2 lines

I'd like to bring a solution for our meson-usb use case quickly - even with the revert suggested, we are having an ugly warning around suspend

I understand. Let's still do this carefully :)

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

I'm not Martin but these devices are the origin of the request/suggestion.

So these two phy drivers are used together with dwc3-meson-g12a? Will you change them to use the new API as well?

regards
Philipp

reviewer
#15 lore raw
Quoted 32 lines · Philipp Zabel
Quoted 22 lines · Jerome Brunet
Quoted 20 lines · Philipp Zabel

On Mon, 2020-08-24 at 16:26 +0200, Jerome Brunet wrote:
[...]

Quoted 11 lines

In practice, I think your proposition would work since the drivers sharing this USB reset line are likely to be probed/suspended/resumed at the same time but ...

If we imagine a situation where 2 device share a reset line, 1 go in suspend, the other does not - if the first device as control of the reset, it could trigger it and break the 2nd device. Same goes for probe/remove()

I agree it could be seen as unlikely but leaving such race condition open looks dangerous to me.

You are right, this is not good enough.

Quoted 4 lines
Quoted 3 lines

Is this something that would be feasible for your combination of drivers? Otherwise it is be unclear to me under which condition a driver should be allowed to call the proposed reset_control_clear().

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I was thinking of reset_control_clear() as the counter part of reset_control_reset().

I'm not particularly fond of reset_control_clear as a name, because it is very close to "clearing a reset bit" which usually would deassert a reset line (or the inverse).

It was merely a suggestion :) any other name you prefer is fine by me

Quoted 7 lines

Naming is hard. All metaphors I can think of are either a obscure or clash with other current usage. My instinct would be to call this "resetting the (reset) control", but _reset() is already taken, with the opposite meaning. How about _rewind() or _rearm()? Not sure if those are good metaphors either, but at least there is no obvious but incorrect interpretation. I kind of wish reset_control_reset() would be called reset_control_trigger() instead.

We'll pick something for the v1 ... maybe the inspiration will come later on and we'll make a v2 ;)

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

When a reset_control_reset() has been called once, "triggered_count" is incremented which signals that the ressource under the reset is "in_use" and the reset should not be done again.

"triggered_count" would then have to be renamed to something like "trigger_requested_count", or "use_count". I wonder it might be possible to merge this with "deassert_count" as they'd share the same semantics (while the count is > 0, the reset line must stay deasserted).

Quoted 8 lines
Quoted 1 line

Sure. Could investigate this as a 2nd step ?

Yes.

Quoted 2 lines

I'd like to bring a solution for our meson-usb use case quickly - even with the revert suggested, we are having an ugly warning around suspend

I understand. Let's still do this carefully :)

will do

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

I'm not Martin but these devices are the origin of the request/suggestion.

So these two phy drivers are used together with dwc3-meson-g12a?

Yes, reset is shared by the different usb devices of the SoCs

Quoted 1 line

Will you change them to use the new API as well?

That's the plan, yes.

Quoted 3 lines

regards
Philipp

#16 lore raw
In reply to Philipp Zabel

Hi Philipp,

On Tue, Aug 25, 2020 at 12:20 PM Philipp Zabel <[email protected]> wrote:
[...]

Quoted 17 lines
Quoted 17 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

for the specific use-case (system suspend) this would currently not be useful for the two drivers you have named. This is because the platforms on which they are used currently don't support system suspend.
if other drivers are going to benefit from this change then please go ahead and add the necessary API. Then I can also use it in these drivers. however, (as far as I understand) I won't be able to verify the new "fixed" behavior

Best regards,
Martin

#17 lore raw
Quoted 38 lines · Martin Blumenstingl

Hi Philipp,

On Tue, Aug 25, 2020 at 12:20 PM Philipp Zabel <[email protected]> wrote:
[...]

Quoted 17 lines
Quoted 17 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

for the specific use-case (system suspend) this would currently not be useful for the two drivers you have named. This is because the platforms on which they are used currently don't support system suspend.
if other drivers are going to benefit from this change then please go ahead and add the necessary API. Then I can also use it in these drivers. however, (as far as I understand) I won't be able to verify the new "fixed" behavior

Quoted 2 lines

Best regards,
Martin

Hi Philipp,

Regarding the naming of the new call, since reset_control_clear() is not really representative of the intended behaviour, I have thought of some other metaphors such as:

reset_control_resettable() (sounds the most relevant to me)
reset_control_standby()
reset_control_unseal()
reset_control_untie()
reset_control_loosen()/loose()
reset_control_unfetter()

What do you think?

Regards,
Amjad

Signature · 8 lines
Amjad Ouled-Ameur
Embedded Linux Engineer - Villeneuve Loubet, FR
Engit@BayLibre - At the Heart of Embedded Linux

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
reviewer
#18 lore raw
Quoted 49 lines · Amjad Ouled-Ameur
Quoted 38 lines · Martin Blumenstingl

Hi Philipp,

On Tue, Aug 25, 2020 at 12:20 PM Philipp Zabel <[email protected]> wrote:
[...]

Quoted 17 lines
Quoted 17 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

for the specific use-case (system suspend) this would currently not be useful for the two drivers you have named. This is because the platforms on which they are used currently don't support system suspend.
if other drivers are going to benefit from this change then please go ahead and add the necessary API. Then I can also use it in these drivers. however, (as far as I understand) I won't be able to verify the new "fixed" behavior

Quoted 2 lines

Best regards,
Martin

Hi Philipp,

Regarding the naming of the new call, since reset_control_clear() is not really representative of the intended behaviour, I have thought of some other metaphors such as:

Quoted 8 lines

reset_control_resettable() (sounds the most relevant to me)
reset_control_standby()
reset_control_unseal()
reset_control_untie()
reset_control_loosen()/loose()
reset_control_unfetter()

What do you think?

my suggestion would be reset_control_put()

Quoted 3 lines

Regards,
Amjad

#19 lore raw

reset_control_put() is already used in the reset framework.

Quoted 60 lines · Jerome Brunet
Quoted 56 lines · Amjad Ouled-Ameur
Quoted 38 lines · Martin Blumenstingl

Hi Philipp,

On Tue, Aug 25, 2020 at 12:20 PM Philipp Zabel <[email protected]> wrote:
[...]

Quoted 17 lines
Quoted 17 lines

reset_control_clear()
would be the way to state that the ressource is no longer used and, that from the caller perspective, the reset can fired again if necessary.

If we take the probe / suspend / resume example:
* 1st device using the shared will actually trigger it (as it is now)
* following device just increase triggered_count

If all devices go to suspend (calling reset_control_clear()) then triggered_count will reach zero, allowing the first device resuming to trigger the reset again ... this is important since it might not be the one which would have got the exclusive control

If any device don't go to suspend, meaning the ressource under reset keep on being used, no reset will performed. With exlusive control, there is a risk that the resuming device resets something already in use.

Quoted 6 lines
Quoted 2 lines

Regarding the condition, on shared resets, call reset_control_reset() should be balanced reset_control_clear() - no clear before reset.

Martin, is this something that would be useful for the current users of the shared reset trigger functionality (phy-meson-gxl-usb2 and phy- meson8b-usb2 with reset-meson)?

for the specific use-case (system suspend) this would currently not be useful for the two drivers you have named. This is because the platforms on which they are used currently don't support system suspend.
if other drivers are going to benefit from this change then please go ahead and add the necessary API. Then I can also use it in these drivers. however, (as far as I understand) I won't be able to verify the new "fixed" behavior

Quoted 2 lines

Best regards,
Martin

Hi Philipp,

Regarding the naming of the new call, since reset_control_clear() is not really representative of the intended behaviour, I have thought of some other metaphors such as:

reset_control_resettable() (sounds the most relevant to me)
reset_control_standby()
reset_control_unseal()
reset_control_untie()
reset_control_loosen()/loose()
reset_control_unfetter()

Quoted 8 lines
Quoted 1 line

What do you think?

my suggestion would be reset_control_put()

Quoted 3 lines

Regards,
Amjad

--
Amjad Ouled-Ameur
Embedded Linux Engineer - Villeneuve Loubet, FR
Engit@BayLibre - At the Heart of Embedded Linux

#20 lore raw
In reply to Dan Robertson

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Thanks, I was also looking into this issue
So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Can you try this attached patch?

Best Regards
-Anand

From 841500c784ac5253e9eaf9afecd6ce125e8bf1ad Mon Sep 17 00:00:00 2001
From: Anand Moon <[email protected]>
Date: Tue, 14 Jul 2020 12:13:17 +0530
Subject: [PATCH] usb: dwc3: meson-g12a: drop reset controller call from
suspend and resume

Drop the reset controller call from suspend and resume.

---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +0 -4
index 1f7f4d88ed9d..0c0ea55215cb 100644
@@ -876,8 +876,6 @@ static int __maybe_unused dwc3_meson_g12a_suspend(struct device *dev)
 		phy_exit(priv->phys[i]);
 	}
 
-	reset_control_assert(priv->reset);
-
 	return 0;
 }
 
@@ -886,8 +884,6 @@ static int __maybe_unused dwc3_meson_g12a_resume(struct device *dev)
 	struct dwc3_meson_g12a *priv = dev_get_drvdata(dev);
 	int i, ret;
 
-	reset_control_deassert(priv->reset);
-
 	ret = priv->drvdata->usb_init(priv);
 	if (ret)
 		return ret;
Signature · 1 line
2.25.1
#21 lore raw

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Quoted 2 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 4 lines
Quoted 1 line

Can you try this attached patch?

Best Regards
-Anand

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

Cheers,

- Dan

#22 lore raw

Hi Dan,

Quoted 55 lines · Dan Robertson

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Quoted 5 lines

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Before entering the suspend state the code tries to do following
clk_bulk_disable_unprepare
regulator_disable
phy_power_off
phy_exit

After this operation it's needless to call *reset_control_assert* I tried to move this call before all the above operations but still no success with this.

Similarly on resume we should avoid calling resume *reset_control_deassert* earlier
as the core is just reinitializing the devices.
clk_bulk_prepare_enable
usb_init
phy_init
phy_power_on
regulator_enable

Quoted 11 lines
Quoted 3 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 2 lines
Quoted 1 line

Can you try this attached patch?

Quoted 9 lines
Quoted 2 lines

Best Regards
-Anand

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

As per my knowledge suspend to mem will do complete power down of the devices with support suspend and resume feature sequentially and then it tries to bring the device up one by one.
So it should also take care of reset lines as well.

Quoted 3 lines

Cheers,

- Dan

Best Regards
-Anand

#23 lore raw
Quoted 70 lines · Anand Moon

Hi Dan,

Quoted 55 lines · Dan Robertson

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Quoted 5 lines

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Before entering the suspend state the code tries to do following
clk_bulk_disable_unprepare
regulator_disable
phy_power_off
phy_exit

Quoted 3 lines

After this operation it's needless to call *reset_control_assert* I tried to move this call before all the above operations but still no success with this.

How so? Once the reset() is removed prope() and deassert() is guaranteed to have been called before suspend, like what is in the patch and similar to other uses of shared reset controllers, this is possible.

Quoted 26 lines

Similarly on resume we should avoid calling resume *reset_control_deassert* earlier
as the core is just reinitializing the devices.
clk_bulk_prepare_enable
usb_init
phy_init
phy_power_on
regulator_enable

Quoted 9 lines
Quoted 3 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Can you try this attached patch?

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

Quoted 4 lines

As per my knowledge suspend to mem will do complete power down of the devices with support suspend and resume feature sequentially and then it tries to bring the device up one by one.
So it should also take care of reset lines as well.

So do we only _actually_ care about the reset line in the probe? Seems like we should remove the reset controller from the structure if that is the case.

Cheers,

- Dan

#24 lore raw

Hi Dan,

Quoted 111 lines · Dan Robertson
Quoted 70 lines · Anand Moon

Hi Dan,

Quoted 55 lines · Dan Robertson

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Quoted 5 lines

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Before entering the suspend state the code tries to do following
clk_bulk_disable_unprepare
regulator_disable
phy_power_off
phy_exit

Quoted 3 lines

After this operation it's needless to call *reset_control_assert* I tried to move this call before all the above operations but still no success with this.

How so? Once the reset() is removed prope() and deassert() is guaranteed to have been called before suspend, like what is in the patch and similar to other uses of shared reset controllers, this is possible.

Quoted 26 lines

Similarly on resume we should avoid calling resume *reset_control_deassert* earlier
as the core is just reinitializing the devices.
clk_bulk_prepare_enable
usb_init
phy_init
phy_power_on
regulator_enable

Quoted 9 lines
Quoted 3 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Can you try this attached patch?

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

Quoted 4 lines

As per my knowledge suspend to mem will do complete power down of the devices with support suspend and resume feature sequentially and then it tries to bring the device up one by one.
So it should also take care of reset lines as well.

Quoted 6 lines

So do we only _actually_ care about the reset line in the probe? Seems like we should remove the reset controller from the structure if that is the case.

Cheers,

- Dan

Sorry I am not the _expert_ in suspend/resume feature but I can debug this, Certainly we need to look into whether reset controller calls are needed to suspend or resume for this driver.

First thing we need to get the RTC driver to work on Odroid N2 for suspend wakeup
to work properly.
For this I have created the following patches.

[0] https://patchwork.kernel.org/cover/11665865/

With these patches the RTC feature for wake up is broken right now in my testing.
Once I get something to work further I will update you.

--Anand

#25 lore raw

Hi Dan,

Quoted 131 lines · Anand Moon

Hi Dan,

Quoted 111 lines · Dan Robertson
Quoted 70 lines · Anand Moon

Hi Dan,

Quoted 55 lines · Dan Robertson

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Quoted 5 lines

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Before entering the suspend state the code tries to do following
clk_bulk_disable_unprepare
regulator_disable
phy_power_off
phy_exit

Quoted 3 lines

After this operation it's needless to call *reset_control_assert* I tried to move this call before all the above operations but still no success with this.

How so? Once the reset() is removed prope() and deassert() is guaranteed to have been called before suspend, like what is in the patch and similar to other uses of shared reset controllers, this is possible.

Quoted 26 lines

Similarly on resume we should avoid calling resume *reset_control_deassert* earlier
as the core is just reinitializing the devices.
clk_bulk_prepare_enable
usb_init
phy_init
phy_power_on
regulator_enable

Quoted 9 lines
Quoted 3 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Can you try this attached patch?

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

Quoted 4 lines

As per my knowledge suspend to mem will do complete power down of the devices with support suspend and resume feature sequentially and then it tries to bring the device up one by one.
So it should also take care of reset lines as well.

Quoted 6 lines

So do we only _actually_ care about the reset line in the probe? Seems like we should remove the reset controller from the structure if that is the case.

Cheers,

- Dan

Sorry I am not the _expert_ in suspend/resume feature but I can debug this, Certainly we need to look into whether reset controller calls are needed to suspend or resume for this driver.

First thing we need to get the RTC driver to work on Odroid N2 for suspend wakeup
to work properly.
For this I have created the following patches.

Quoted 7 lines

[0] https://patchwork.kernel.org/cover/11665865/

With these patches the RTC feature for wake up is broken right now in my testing.
Once I get something to work further I will update you.

--Anand

Sorry for the _noise_ :‑(
This feature seems to be working fine with VRTC drivers. I have tested this with a pre-compiled image of Archlinux distro.

[root@alarm alarm]# uname -a
Linux alarm 5.7.8-1-ARCH #1 SMP Sun Jul 12 03:38:28 UTC 2020 aarch64 GNU/Linux [root@alarm alarm]# rtcwake -s 30 -m mem
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:10:14 1970

[  583.591477] PM: suspend entry (deep)
[  583.593737] Filesystems sync: 0.002 seconds
[  583.818967] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  583.825802] OOM killer disabled.
[  583.828966] Freezing remaining freezable tasks ... (elapsed 0.003
seconds) done.
[  583.880280] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  584.020094] PM: suspend devices took 0.190 seconds
[  584.070586] Disabling non-boot CPUs ...
[  584.075037] CPU1: shutdown
[  584.075223] psci: CPU1 killed (polled 0 ms)
[  584.097199] CPU2: shutdown
[  584.098546] psci: CPU2 killed (polled 0 ms)
[  584.115370] CPU3: shutdown
[  584.116500] psci: CPU3 killed (polled 0 ms)
[  584.128116] CPU4: shutdown
[  584.129235] psci: CPU4 killed (polled 10 ms)
[  584.140122] CPU5: shutdown
[  584.147289] psci: CPU5 killed (polled 0 ms)

bl30 get wakeup sources!
process command 00000006
bl30 enter suspend!
Little core clk suspend rate 1896000000
Big core clk suspend rate 24000000
store restore gp0 pll
suspend_counter: 3
Enter ddr suspend
ddr suspend time: 16us
alarm=31S
process command 00000001
GPIOA_11/13 off
cec ver:2018/04/19
CEC cfg:0x0000
WAKEUP GPIO cfg:0x00000000
use vddee new table!
use vddee new table!
exit_reason:0x03
Enter ddr resume
DMC_DRAM_STAT3: 0x544
ddr resume time: 3188us
store restore gp0 pll
cfg15 33b00000
cfg15 33b00000
Li[ 584.148720] Enabling non-boot CPUs ...

[  584.149124] Detected VIPT I-cache on CPU1
[  584.149167] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[  584.149594] CPU1 is up
[  584.160687] Detected VIPT I-cache on CPU2
[  584.160730] arch_timer: CPU2: Trapping CNTVCT access
[  584.160741] CPU2: Booted secondary processor 0x0000000100 [0x410fd092]
[  584.161327] CPU2 is up
[  584.177645] Detected VIPT I-cache on CPU3
[  584.177668] arch_timer: CPU3: Trapping CNTVCT access
[  584.177675] CPU3: Booted secondary processor 0x0000000101 [0x410fd092]
[  584.178036] CPU3 is up
[  584.195338] Detected VIPT I-cache on CPU4
[  584.195361] arch_timer: CPU4: Trapping CNTVCT access
[  584.195368] CPU4: Booted secondary processor 0x0000000102 [0x410fd092]
[  584.195762] CPU4 is up
[  584.213002] Detected VIPT I-cache on CPU5
[  584.213024] arch_timer: CPU5: Trapping CNTVCT access
[  584.213032] CPU5: Booted secondary processor 0x0000000103 [0x410fd092]
[  584.213450] CPU5 is up
ttle core clk resume rate 1896000000
Big core clk resume rate 50000000
[  584.279042] meson8b-dwmac ff3f0000.ethernet eth0: No Safety
Features support found
[  584.281232] meson8b-dwmac ff3f0000.ethernet eth0: configuring for
phy/rgmii link mode
[  584.401216] usb usb1: root hub lost power or was reset
[  584.401470] usb usb2: root hub lost power or was reset
[  584.655446] dwc3-meson-g12a ffe09000.usb: switching to Device Mode
[  584.801108] usb 2-1: reset SuperSpeed Gen 1 USB device number 2
using xhci-hcd
[  584.979632] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[  585.260450] usb 2-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  585.333303] PM: resume devices took 1.100 seconds
[  585.333507] OOM killer enabled.
[  585.335549] Restarting tasks ... done.
[  585.378044] PM: suspend exit

rtcwake: read rtc alarm failed: Invalid argument
[root@alarm alarm]#

-Anand

#26 lore raw

Hi Dan,

Quoted 233 lines · Anand Moon

Hi Dan,

Quoted 131 lines · Anand Moon

Hi Dan,

Quoted 111 lines · Dan Robertson
Quoted 70 lines · Anand Moon

Hi Dan,

Quoted 55 lines · Dan Robertson

Hi Anand!

Quoted 42 lines · Anand Moon

hi Dan,

Quoted 31 lines · Dan Robertson

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc

In my limited experience and knowlege it appears that we hit this because the reset control was switched to shared and the the use of the reset control was not changed.

Quoted 3 lines

* Calling reset_control_assert without first calling reset_control_deassert
* is not allowed on a shared reset control. Calling reset_control_reset is
* also not allowed on a shared reset control.

The above snippet from reset_control_get_shared() seems to indicate that this is due to the use of reset_control_reset() in dwc3_meson_g12a_probe() and reset_control_deassert is not guaranteed to have been called before dwc3_meson_g12a_suspend() and reset_control_assert().

Quoted 8 lines

After some basic tests with the following patch I no longer hit the warning. Comments and critiques on the patch are welcome. If there is a reason for the current use of the reset control, I'd love to learn why! Like I said before, I have not really looked at this driver before and have verify limited experience with reset controls... Was working on another driver, hit the warning, and thought I'd take a shot at the fix :-)

Quoted 1 line

Thanks, I was also looking into this issue

Awesome!

Quoted 4 lines

So best Fix to this issue is to drop the call of reset_control_assert from dwc3_meson_g12a_suspend
and drop the call of reset_control_deassert from dwc3_meson_g12a_resume With these changes we do not see the warning on suspend and resume

Quoted 5 lines

We definitely would avoid hitting the warning without the reset_control_(de)assert calls in suspend and resume. That is a valid use of the reset control, but why would that be best?

From reset_control_reset():

Before entering the suspend state the code tries to do following
clk_bulk_disable_unprepare
regulator_disable
phy_power_off
phy_exit

Quoted 3 lines

After this operation it's needless to call *reset_control_assert* I tried to move this call before all the above operations but still no success with this.

How so? Once the reset() is removed prope() and deassert() is guaranteed to have been called before suspend, like what is in the patch and similar to other uses of shared reset controllers, this is possible.

Quoted 26 lines

Similarly on resume we should avoid calling resume *reset_control_deassert* earlier
as the core is just reinitializing the devices.
clk_bulk_prepare_enable
usb_init
phy_init
phy_power_on
regulator_enable

Quoted 9 lines
Quoted 3 lines

* Consumers must not use reset_control_(de)assert on shared reset lines when
* reset_control_reset has been used.

If we use reset_control_reset() then we can not (de)assert the reset line on suspend/resume or any other time. Wouldn't we want to be able to (de)assert the reset line? And why do we no longer want to (de)assert the reset line on suspend/resume?

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

Can you try this attached patch?

I think I had already tested something similar. Removing the (de)assert calls but keeping reset will definitely remove the warning, but it means we can not (de)assert the line. My guess is that this is not what we want, but I could be wrong. Thoughts, input, or references to documentation on this would be appreciated.

Quoted 4 lines

As per my knowledge suspend to mem will do complete power down of the devices with support suspend and resume feature sequentially and then it tries to bring the device up one by one.
So it should also take care of reset lines as well.

Quoted 6 lines

So do we only _actually_ care about the reset line in the probe? Seems like we should remove the reset controller from the structure if that is the case.

Cheers,

- Dan

Sorry I am not the _expert_ in suspend/resume feature but I can debug this, Certainly we need to look into whether reset controller calls are needed to suspend or resume for this driver.

First thing we need to get the RTC driver to work on Odroid N2 for suspend wakeup
to work properly.
For this I have created the following patches.

Quoted 7 lines

[0] https://patchwork.kernel.org/cover/11665865/

With these patches the RTC feature for wake up is broken right now in my testing.
Once I get something to work further I will update you.

--Anand

Sorry for the _noise_ :‑(
This feature seems to be working fine with VRTC drivers. I have tested this with a pre-compiled image of Archlinux distro.

[root@alarm alarm]# uname -a
Linux alarm 5.7.8-1-ARCH #1 SMP Sun Jul 12 03:38:28 UTC 2020 aarch64 GNU/Linux [root@alarm alarm]# rtcwake -s 30 -m mem
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:10:14 1970

[  583.591477] PM: suspend entry (deep)
[  583.593737] Filesystems sync: 0.002 seconds
[  583.818967] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  583.825802] OOM killer disabled.
[  583.828966] Freezing remaining freezable tasks ... (elapsed 0.003
seconds) done.
[  583.880280] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  584.020094] PM: suspend devices took 0.190 seconds
[  584.070586] Disabling non-boot CPUs ...
[  584.075037] CPU1: shutdown
[  584.075223] psci: CPU1 killed (polled 0 ms)
[  584.097199] CPU2: shutdown
[  584.098546] psci: CPU2 killed (polled 0 ms)
[  584.115370] CPU3: shutdown
[  584.116500] psci: CPU3 killed (polled 0 ms)
[  584.128116] CPU4: shutdown
[  584.129235] psci: CPU4 killed (polled 10 ms)
[  584.140122] CPU5: shutdown
[  584.147289] psci: CPU5 killed (polled 0 ms)

bl30 get wakeup sources!
process command 00000006
bl30 enter suspend!
Little core clk suspend rate 1896000000
Big core clk suspend rate 24000000
store restore gp0 pll
suspend_counter: 3
Enter ddr suspend
ddr suspend time: 16us
alarm=31S
process command 00000001
GPIOA_11/13 off
cec ver:2018/04/19
CEC cfg:0x0000
WAKEUP GPIO cfg:0x00000000
use vddee new table!
use vddee new table!
exit_reason:0x03
Enter ddr resume
DMC_DRAM_STAT3: 0x544
ddr resume time: 3188us
store restore gp0 pll
cfg15 33b00000
cfg15 33b00000
Li[ 584.148720] Enabling non-boot CPUs ...

[  584.149124] Detected VIPT I-cache on CPU1
[  584.149167] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[  584.149594] CPU1 is up
[  584.160687] Detected VIPT I-cache on CPU2
[  584.160730] arch_timer: CPU2: Trapping CNTVCT access
[  584.160741] CPU2: Booted secondary processor 0x0000000100 [0x410fd092]
[  584.161327] CPU2 is up
[  584.177645] Detected VIPT I-cache on CPU3
[  584.177668] arch_timer: CPU3: Trapping CNTVCT access
[  584.177675] CPU3: Booted secondary processor 0x0000000101 [0x410fd092]
[  584.178036] CPU3 is up
[  584.195338] Detected VIPT I-cache on CPU4
[  584.195361] arch_timer: CPU4: Trapping CNTVCT access
[  584.195368] CPU4: Booted secondary processor 0x0000000102 [0x410fd092]
[  584.195762] CPU4 is up
[  584.213002] Detected VIPT I-cache on CPU5
[  584.213024] arch_timer: CPU5: Trapping CNTVCT access
[  584.213032] CPU5: Booted secondary processor 0x0000000103 [0x410fd092]
[  584.213450] CPU5 is up
ttle core clk resume rate 1896000000
Big core clk resume rate 50000000
[  584.279042] meson8b-dwmac ff3f0000.ethernet eth0: No Safety
Features support found
[  584.281232] meson8b-dwmac ff3f0000.ethernet eth0: configuring for
phy/rgmii link mode
[  584.401216] usb usb1: root hub lost power or was reset
[  584.401470] usb usb2: root hub lost power or was reset
[  584.655446] dwc3-meson-g12a ffe09000.usb: switching to Device Mode
[  584.801108] usb 2-1: reset SuperSpeed Gen 1 USB device number 2
using xhci-hcd
[  584.979632] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[  585.260450] usb 2-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  585.333303] PM: resume devices took 1.100 seconds
[  585.333507] OOM killer enabled.
[  585.335549] Restarting tasks ... done.
[  585.378044] PM: suspend exit
Quoted 4 lines

rtcwake: read rtc alarm failed: Invalid argument
[root@alarm alarm]#

-Anand

After confirming that the suspend resume feature is working correctly I found the solution to the reset warning on 5.8.x kernel Please can you try this following patch.

$ cat resetwarn.patch
(quoted diff) +0 -0

b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 1f7f4d88ed9d..60a6f49139fd 100644

drivers/usb/dwc3/dwc3-meson-g12a.c +0 -0
@@ -730,7 +730,7 @@ static int dwc3_meson_g12a_probe(struct

platform_device *pdev)

        platform_set_drvdata(pdev, priv);

- priv->reset = devm_reset_control_get_shared(dev, NULL);

+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");
        if (IS_ERR(priv->reset)) {
                ret = PTR_ERR(priv->reset);
                dev_err(dev, "failed to get device reset, err=%d\n", ret);

-Anand

#27 lore raw

Hi Dan,

Quoted 116 lines
Quoted 90 lines

Sorry for the _noise_ :‑(
This feature seems to be working fine with VRTC drivers. I have tested this with a pre-compiled image of Archlinux distro.

[root@alarm alarm]# uname -a
Linux alarm 5.7.8-1-ARCH #1 SMP Sun Jul 12 03:38:28 UTC 2020 aarch64 GNU/Linux [root@alarm alarm]# rtcwake -s 30 -m mem
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:10:14 1970

[  583.591477] PM: suspend entry (deep)
[  583.593737] Filesystems sync: 0.002 seconds
[  583.818967] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  583.825802] OOM killer disabled.
[  583.828966] Freezing remaining freezable tasks ... (elapsed 0.003
seconds) done.
[  583.880280] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  584.020094] PM: suspend devices took 0.190 seconds
[  584.070586] Disabling non-boot CPUs ...
[  584.075037] CPU1: shutdown
[  584.075223] psci: CPU1 killed (polled 0 ms)
[  584.097199] CPU2: shutdown
[  584.098546] psci: CPU2 killed (polled 0 ms)
[  584.115370] CPU3: shutdown
[  584.116500] psci: CPU3 killed (polled 0 ms)
[  584.128116] CPU4: shutdown
[  584.129235] psci: CPU4 killed (polled 10 ms)
[  584.140122] CPU5: shutdown
[  584.147289] psci: CPU5 killed (polled 0 ms)

bl30 get wakeup sources!
process command 00000006
bl30 enter suspend!
Little core clk suspend rate 1896000000
Big core clk suspend rate 24000000
store restore gp0 pll
suspend_counter: 3
Enter ddr suspend
ddr suspend time: 16us
alarm=31S
process command 00000001
GPIOA_11/13 off
cec ver:2018/04/19
CEC cfg:0x0000
WAKEUP GPIO cfg:0x00000000
use vddee new table!
use vddee new table!
exit_reason:0x03
Enter ddr resume
DMC_DRAM_STAT3: 0x544
ddr resume time: 3188us
store restore gp0 pll
cfg15 33b00000
cfg15 33b00000
Li[ 584.148720] Enabling non-boot CPUs ...

[  584.149124] Detected VIPT I-cache on CPU1
[  584.149167] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[  584.149594] CPU1 is up
[  584.160687] Detected VIPT I-cache on CPU2
[  584.160730] arch_timer: CPU2: Trapping CNTVCT access
[  584.160741] CPU2: Booted secondary processor 0x0000000100 [0x410fd092]
[  584.161327] CPU2 is up
[  584.177645] Detected VIPT I-cache on CPU3
[  584.177668] arch_timer: CPU3: Trapping CNTVCT access
[  584.177675] CPU3: Booted secondary processor 0x0000000101 [0x410fd092]
[  584.178036] CPU3 is up
[  584.195338] Detected VIPT I-cache on CPU4
[  584.195361] arch_timer: CPU4: Trapping CNTVCT access
[  584.195368] CPU4: Booted secondary processor 0x0000000102 [0x410fd092]
[  584.195762] CPU4 is up
[  584.213002] Detected VIPT I-cache on CPU5
[  584.213024] arch_timer: CPU5: Trapping CNTVCT access
[  584.213032] CPU5: Booted secondary processor 0x0000000103 [0x410fd092]
[  584.213450] CPU5 is up
ttle core clk resume rate 1896000000
Big core clk resume rate 50000000
[  584.279042] meson8b-dwmac ff3f0000.ethernet eth0: No Safety
Features support found
[  584.281232] meson8b-dwmac ff3f0000.ethernet eth0: configuring for
phy/rgmii link mode
[  584.401216] usb usb1: root hub lost power or was reset
[  584.401470] usb usb2: root hub lost power or was reset
[  584.655446] dwc3-meson-g12a ffe09000.usb: switching to Device Mode
[  584.801108] usb 2-1: reset SuperSpeed Gen 1 USB device number 2
using xhci-hcd
[  584.979632] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[  585.260450] usb 2-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  585.333303] PM: resume devices took 1.100 seconds
[  585.333507] OOM killer enabled.
[  585.335549] Restarting tasks ... done.
[  585.378044] PM: suspend exit
Quoted 4 lines

rtcwake: read rtc alarm failed: Invalid argument
[root@alarm alarm]#

-Anand

After confirming that the suspend resume feature is working correctly I found the solution to the reset warning on 5.8.x kernel Please can you try this following patch.

$ cat resetwarn.patch
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
index 1f7f4d88ed9d..60a6f49139fd 100644
@@ -730,7 +730,7 @@ static int dwc3_meson_g12a_probe(struct
 platform_device *pdev)
 
        platform_set_drvdata(pdev, priv);
 
-       priv->reset = devm_reset_control_get_shared(dev, NULL);
+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");
        if (IS_ERR(priv->reset)) {
                ret = PTR_ERR(priv->reset);
                dev_err(dev, "failed to get device reset, err=%d\n", ret);
Quoted 1 line

-Anand

Apologize once again above changes break the usb functionality. the correct fix along with these changes should be as below. reset controllers need *resets* and *reset-names* to work correctly.

But the _reset controller_ warning continues on suspend / resume features, I am looking to find a FIX into this issue.

(quoted diff) +0 -0

b/arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi index 593a006f4b7b..6d34dfa9825c 100644

arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +1 -0
@@ -2318,6 +2318,7 @@ usb: usb@ffe09000 {
 
                        clocks = <&clkc CLKID_USB>;
                        resets = <&reset RESET_USB>;
+                       reset-names = "dwc3_meson";
 
                        dr_mode = "otg";
 

-Anand

#28 lore raw

Hi Anand,

Quoted 134 lines · Anand Moon

Hi Dan,

Quoted 116 lines
Quoted 90 lines

Sorry for the _noise_ :‑(
This feature seems to be working fine with VRTC drivers. I have tested this with a pre-compiled image of Archlinux distro.

[root@alarm alarm]# uname -a
Linux alarm 5.7.8-1-ARCH #1 SMP Sun Jul 12 03:38:28 UTC 2020 aarch64 GNU/Linux [root@alarm alarm]# rtcwake -s 30 -m mem
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:10:14 1970

[  583.591477] PM: suspend entry (deep)
[  583.593737] Filesystems sync: 0.002 seconds
[  583.818967] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  583.825802] OOM killer disabled.
[  583.828966] Freezing remaining freezable tasks ... (elapsed 0.003
seconds) done.
[  583.880280] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  584.020094] PM: suspend devices took 0.190 seconds
[  584.070586] Disabling non-boot CPUs ...
[  584.075037] CPU1: shutdown
[  584.075223] psci: CPU1 killed (polled 0 ms)
[  584.097199] CPU2: shutdown
[  584.098546] psci: CPU2 killed (polled 0 ms)
[  584.115370] CPU3: shutdown
[  584.116500] psci: CPU3 killed (polled 0 ms)
[  584.128116] CPU4: shutdown
[  584.129235] psci: CPU4 killed (polled 10 ms)
[  584.140122] CPU5: shutdown
[  584.147289] psci: CPU5 killed (polled 0 ms)

bl30 get wakeup sources!
process command 00000006
bl30 enter suspend!
Little core clk suspend rate 1896000000
Big core clk suspend rate 24000000
store restore gp0 pll
suspend_counter: 3
Enter ddr suspend
ddr suspend time: 16us
alarm=31S
process command 00000001
GPIOA_11/13 off
cec ver:2018/04/19
CEC cfg:0x0000
WAKEUP GPIO cfg:0x00000000
use vddee new table!
use vddee new table!
exit_reason:0x03
Enter ddr resume
DMC_DRAM_STAT3: 0x544
ddr resume time: 3188us
store restore gp0 pll
cfg15 33b00000
cfg15 33b00000
Li[ 584.148720] Enabling non-boot CPUs ...

[  584.149124] Detected VIPT I-cache on CPU1
[  584.149167] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[  584.149594] CPU1 is up
[  584.160687] Detected VIPT I-cache on CPU2
[  584.160730] arch_timer: CPU2: Trapping CNTVCT access
[  584.160741] CPU2: Booted secondary processor 0x0000000100 [0x410fd092]
[  584.161327] CPU2 is up
[  584.177645] Detected VIPT I-cache on CPU3
[  584.177668] arch_timer: CPU3: Trapping CNTVCT access
[  584.177675] CPU3: Booted secondary processor 0x0000000101 [0x410fd092]
[  584.178036] CPU3 is up
[  584.195338] Detected VIPT I-cache on CPU4
[  584.195361] arch_timer: CPU4: Trapping CNTVCT access
[  584.195368] CPU4: Booted secondary processor 0x0000000102 [0x410fd092]
[  584.195762] CPU4 is up
[  584.213002] Detected VIPT I-cache on CPU5
[  584.213024] arch_timer: CPU5: Trapping CNTVCT access
[  584.213032] CPU5: Booted secondary processor 0x0000000103 [0x410fd092]
[  584.213450] CPU5 is up
ttle core clk resume rate 1896000000
Big core clk resume rate 50000000
[  584.279042] meson8b-dwmac ff3f0000.ethernet eth0: No Safety
Features support found
[  584.281232] meson8b-dwmac ff3f0000.ethernet eth0: configuring for
phy/rgmii link mode
[  584.401216] usb usb1: root hub lost power or was reset
[  584.401470] usb usb2: root hub lost power or was reset
[  584.655446] dwc3-meson-g12a ffe09000.usb: switching to Device Mode
[  584.801108] usb 2-1: reset SuperSpeed Gen 1 USB device number 2
using xhci-hcd
[  584.979632] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[  585.260450] usb 2-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  585.333303] PM: resume devices took 1.100 seconds
[  585.333507] OOM killer enabled.
[  585.335549] Restarting tasks ... done.
[  585.378044] PM: suspend exit
Quoted 4 lines

rtcwake: read rtc alarm failed: Invalid argument
[root@alarm alarm]#

-Anand

After confirming that the suspend resume feature is working correctly I found the solution to the reset warning on 5.8.x kernel Please can you try this following patch.

$ cat resetwarn.patch
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
index 1f7f4d88ed9d..60a6f49139fd 100644
@@ -730,7 +730,7 @@ static int dwc3_meson_g12a_probe(struct
 platform_device *pdev)
 
        platform_set_drvdata(pdev, priv);
 
-       priv->reset = devm_reset_control_get_shared(dev, NULL);
+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");
        if (IS_ERR(priv->reset)) {
                ret = PTR_ERR(priv->reset);
                dev_err(dev, "failed to get device reset, err=%d\n", ret);
Quoted 1 line

-Anand

Apologize once again above changes break the usb functionality. the correct fix along with these changes should be as below. reset controllers need *resets* and *reset-names* to work correctly.

But the _reset controller_ warning continues on suspend / resume features, I am looking to find a FIX into this issue.

arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +0 -0
index 593a006f4b7b..6d34dfa9825c 100644

arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi usb: usb@ffe09000 {

Quoted 8 lines
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +1 -1
@@ -2318,6 +2318,7 @@ usb: usb@ffe09000 {
 
                        clocks = <&clkc CLKID_USB>;
                        resets = <&reset RESET_USB>;
+                       reset-names = "dwc3_meson";
 
                        dr_mode = "otg";
 
-Anand

Theses 2 changes :

Quoted 2 lines

drivers/usb/dwc3/dwc3-meson-g12a.c

Quoted 2 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
-       priv->reset = devm_reset_control_get_shared(dev, NULL);
+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");

and

Quoted 1 line

+ reset-names = "dwc3_meson";

are a no-op, since devm_reset_control_get_shared(dev, NULL) takes the first reset, with or without a reset-names.

Neil

#29 lore raw

Hi Neil,

Quoted 153 lines · Neil Armstrong

Hi Anand,

Quoted 134 lines · Anand Moon

Hi Dan,

Quoted 116 lines
Quoted 90 lines

Sorry for the _noise_ :‑(
This feature seems to be working fine with VRTC drivers. I have tested this with a pre-compiled image of Archlinux distro.

[root@alarm alarm]# uname -a
Linux alarm 5.7.8-1-ARCH #1 SMP Sun Jul 12 03:38:28 UTC 2020 aarch64 GNU/Linux [root@alarm alarm]# rtcwake -s 30 -m mem
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Thu Jan 1 00:10:14 1970

[  583.591477] PM: suspend entry (deep)
[  583.593737] Filesystems sync: 0.002 seconds
[  583.818967] Freezing user space processes ... (elapsed 0.005 seconds) done.
[  583.825802] OOM killer disabled.
[  583.828966] Freezing remaining freezable tasks ... (elapsed 0.003
seconds) done.
[  583.880280] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  584.020094] PM: suspend devices took 0.190 seconds
[  584.070586] Disabling non-boot CPUs ...
[  584.075037] CPU1: shutdown
[  584.075223] psci: CPU1 killed (polled 0 ms)
[  584.097199] CPU2: shutdown
[  584.098546] psci: CPU2 killed (polled 0 ms)
[  584.115370] CPU3: shutdown
[  584.116500] psci: CPU3 killed (polled 0 ms)
[  584.128116] CPU4: shutdown
[  584.129235] psci: CPU4 killed (polled 10 ms)
[  584.140122] CPU5: shutdown
[  584.147289] psci: CPU5 killed (polled 0 ms)

bl30 get wakeup sources!
process command 00000006
bl30 enter suspend!
Little core clk suspend rate 1896000000
Big core clk suspend rate 24000000
store restore gp0 pll
suspend_counter: 3
Enter ddr suspend
ddr suspend time: 16us
alarm=31S
process command 00000001
GPIOA_11/13 off
cec ver:2018/04/19
CEC cfg:0x0000
WAKEUP GPIO cfg:0x00000000
use vddee new table!
use vddee new table!
exit_reason:0x03
Enter ddr resume
DMC_DRAM_STAT3: 0x544
ddr resume time: 3188us
store restore gp0 pll
cfg15 33b00000
cfg15 33b00000
Li[ 584.148720] Enabling non-boot CPUs ...

[  584.149124] Detected VIPT I-cache on CPU1
[  584.149167] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[  584.149594] CPU1 is up
[  584.160687] Detected VIPT I-cache on CPU2
[  584.160730] arch_timer: CPU2: Trapping CNTVCT access
[  584.160741] CPU2: Booted secondary processor 0x0000000100 [0x410fd092]
[  584.161327] CPU2 is up
[  584.177645] Detected VIPT I-cache on CPU3
[  584.177668] arch_timer: CPU3: Trapping CNTVCT access
[  584.177675] CPU3: Booted secondary processor 0x0000000101 [0x410fd092]
[  584.178036] CPU3 is up
[  584.195338] Detected VIPT I-cache on CPU4
[  584.195361] arch_timer: CPU4: Trapping CNTVCT access
[  584.195368] CPU4: Booted secondary processor 0x0000000102 [0x410fd092]
[  584.195762] CPU4 is up
[  584.213002] Detected VIPT I-cache on CPU5
[  584.213024] arch_timer: CPU5: Trapping CNTVCT access
[  584.213032] CPU5: Booted secondary processor 0x0000000103 [0x410fd092]
[  584.213450] CPU5 is up
ttle core clk resume rate 1896000000
Big core clk resume rate 50000000
[  584.279042] meson8b-dwmac ff3f0000.ethernet eth0: No Safety
Features support found
[  584.281232] meson8b-dwmac ff3f0000.ethernet eth0: configuring for
phy/rgmii link mode
[  584.401216] usb usb1: root hub lost power or was reset
[  584.401470] usb usb2: root hub lost power or was reset
[  584.655446] dwc3-meson-g12a ffe09000.usb: switching to Device Mode
[  584.801108] usb 2-1: reset SuperSpeed Gen 1 USB device number 2
using xhci-hcd
[  584.979632] usb 1-1: reset high-speed USB device number 2 using xhci-hcd
[  585.260450] usb 2-1.1: reset SuperSpeed Gen 1 USB device number 3
using xhci-hcd
[  585.333303] PM: resume devices took 1.100 seconds
[  585.333507] OOM killer enabled.
[  585.335549] Restarting tasks ... done.
[  585.378044] PM: suspend exit
Quoted 4 lines

rtcwake: read rtc alarm failed: Invalid argument
[root@alarm alarm]#

-Anand

After confirming that the suspend resume feature is working correctly I found the solution to the reset warning on 5.8.x kernel Please can you try this following patch.

$ cat resetwarn.patch
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
index 1f7f4d88ed9d..60a6f49139fd 100644
@@ -730,7 +730,7 @@ static int dwc3_meson_g12a_probe(struct
 platform_device *pdev)
 
        platform_set_drvdata(pdev, priv);
 
-       priv->reset = devm_reset_control_get_shared(dev, NULL);
+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");
        if (IS_ERR(priv->reset)) {
                ret = PTR_ERR(priv->reset);
                dev_err(dev, "failed to get device reset, err=%d\n", ret);
Quoted 1 line

-Anand

Apologize once again above changes break the usb functionality. the correct fix along with these changes should be as below. reset controllers need *resets* and *reset-names* to work correctly.

But the _reset controller_ warning continues on suspend / resume features, I am looking to find a FIX into this issue.

arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +0 -0
index 593a006f4b7b..6d34dfa9825c 100644

arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi usb: usb@ffe09000 {

Quoted 8 lines
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +1 -1
@@ -2318,6 +2318,7 @@ usb: usb@ffe09000 {
 
                        clocks = <&clkc CLKID_USB>;
                        resets = <&reset RESET_USB>;
+                       reset-names = "dwc3_meson";
 
                        dr_mode = "otg";
 
-Anand

Theses 2 changes :

Quoted 2 lines

drivers/usb/dwc3/dwc3-meson-g12a.c

Quoted 2 lines
drivers/usb/dwc3/dwc3-meson-g12a.c +1 -1
-       priv->reset = devm_reset_control_get_shared(dev, NULL);
+       priv->reset = devm_reset_control_get_shared(dev, "dwc3_meson");
Quoted 7 lines

and

Quoted 1 line

+ reset-names = "dwc3_meson";

are a no-op, since devm_reset_control_get_shared(dev, NULL) takes the first reset, with or without a reset-names.

Thanks for resolving my query. Sorry for the noise.

Quoted 1 line

Neil

-Anand

#30 lore raw
In reply to Dan Robertson
This patch was applied to khilman/linux-amlogic.git (refs/heads/for-next).

Hello:

This patch was applied to khilman/linux-amlogic.git (refs/heads/for-next).

Quoted 17 lines · On Mon, 13 Jul 2020 12:05:21 -0400 you wrote:

When testing suspend for another driver I noticed the following warning:

WARNING: CPU: 1 PID: 5530 at drivers/reset/core.c:355 reset_control_assert+0x184/0x19c
Hardware name: Hardkernel ODROID-N2 (DT)
[..]
pc : reset_control_assert+0x184/0x19c
lr : dwc3_meson_g12a_suspend+0x68/0x7c
[..]
Call trace:
 reset_control_assert+0x184/0x19c
 dwc3_meson_g12a_suspend+0x68/0x7c
 platform_pm_suspend+0x28/0x54
 __device_suspend+0x590/0xabc
 dpm_suspend+0x104/0x404
 dpm_suspend_start+0x84/0x1bc
 suspend_devices_and_enter+0xc4/0x4fc
Quoted 1 line

[...]

Here is a summary with links:
- [1/1] usb: dwc3: meson-g12a: fix shared reset control use

    https://git.kernel.org/khilman/linux-amlogic/c/7a410953d1fb4dbe91ffcfdee9cbbf889d19b0d7

You are awesome, thank you!

Signature · 7 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic