usb: dwc2: gadget: fix stm32mp1 hang on barebox shutdown
cover usb: dwc2: gadget: fix stm32mp1 hang on barebox shutdown
This applies on top of Jules' and Michael's latest dwc2 series. With them, the dwc2 is usable in gadget mode on the stm32mp157c-dk2, but boot/reset didn't work as barebox froze on shutdown.
This is fixed here.
Ahmad Fatoum (2):
fixup! usb: dwc2: Add support for optional usb phy
regulator: stm32-pwr: don't propagate regulator turn-off to supply
drivers/regulator/stm32-pwr.c | 6 ++---- drivers/usb/dwc2/dwc2.c | 13 +++++++------ 2 files changed, 9 insertions(+), 10 deletions(-)
Signature · 7 lines
2.29.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 fixup! usb: dwc2: Add support for optional usb phy
Linux doesn't seem to enforce a fixed order between phy_init and phy_power_on. The Linux dwc2 driver does power_on and then phy_init, which is the inverse of what barebox is currently doing.
The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5
Because Linux does exit -> power_off, but barebox does power_off -> exit.
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#t
Until this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
--- drivers/usb/dwc2/dwc2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/dwc2/dwc2.c +7 -6
@@ -78,12 +78,13 @@ static int dwc2_probe(struct device_d *dev) goto clk_disable; } - ret =phy_init (dwc2->phy); + ret =phy_power_on (dwc2->phy);if (ret) goto clk_disable; - ret =phy_power_on (dwc2->phy); + + ret =phy_init (dwc2->phy);if (ret) - goto err_phy_power; + goto phy_power_off; ret =dwc2_check_core_version (dwc2);if (ret)
@@ -119,9 +120,9 @@ static int dwc2_probe(struct device_d *dev)return 0 ; error: -phy_power_off (dwc2->phy); -err_phy_power:phy_exit (dwc2->phy); +phy_power_off: +phy_power_off (dwc2->phy); clk_disable:clk_disable (dwc2->clk); clk_put:
@@ -139,8 +140,8 @@ static void dwc2_remove(struct device_d *dev)dwc2_host_uninit (dwc2);dwc2_gadget_uninit (dwc2); -phy_power_off (dwc2->phy);phy_exit (dwc2->phy); +phy_power_off (dwc2->phy); }static const struct of_device_id dwc2_platform_dt_ids[] = {
Signature · 7 lines
2.29.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.
Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of phy_init and phy_power_on to what Linux does
and applied it as a separate patch.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Hi Ahmad!
Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
WARNING: dwc2 [email protected]: dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed out
When I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now? How can I reproduce the case this was fixing in the first place?
Rergards,
Michael
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Hello Michael,
Quoted 36 lines · Michael Grzeschik
Hi Ahmad!
Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
Quoted 6 lines
WARNING: dwc2 [email protected]:
dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed outWhen I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now?
Since 0e37f94fbe1b ("phy: stm32: sync with upstream"), the phy-stm32-usbphyc now has no poweron/poweroff callbacks, so a revert seems to only slightly change timing. I'd suggest you dig some more.
Quoted 1 line
How can I reproduce the case this was fixing in the first place?
The case was that barebox calls poweron/init in a different order than Linux. This point is moot now though because poweron is no longer provided by the driver.
Cheers,
Ahmad
Quoted 9 lines
Rergards,
Michael_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Quoted 38 lines · Ahmad Fatoum
Quoted 37 lines · Michael Grzeschik
Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
WARNING: dwc2 [email protected]:
dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed out
Quoted 7 lines
Quoted 3 lines
When I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now?
Since
0e37f94fbe1b("phy: stm32: sync with upstream"), the phy-stm32-usbphyc now has no poweron/poweroff callbacks, so a revert seems to only slightly change timing. I'd suggest you dig some more.
That is not true. phy_power_on also enables the phy_regulator. Changing this order has the effect that the regulator is enabled after or before phy_init call.
Quoted 5 lines
Quoted 1 line
How can I reproduce the case this was fixing in the first place?
The case was that barebox calls poweron/init in a different order than Linux. This point is moot now though because poweron is no longer provided by the driver.
Still not true, though.
Regards,
Michael
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Hello Michael,
Quoted 43 lines · Michael Grzeschik
Quoted 42 lines · Ahmad Fatoum
Quoted 40 lines · Michael Grzeschik
Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
WARNING: dwc2 [email protected]:
dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed outWhen I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now?
Quoted 7 lines
Quoted 3 lines
Since
0e37f94fbe1b("phy: stm32: sync with upstream"), the phy-stm32-usbphyc now has no poweron/poweroff callbacks, so a revert seems to only slightly change timing. I'd suggest you dig some more.That is not true.
phy_power_onalso enables thephy_regulator. Changing this order has the effect that the regulator is enabled after or beforephy_initcall.
Oh, good point.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
How can I reproduce the case this was fixing in the first place?
The case was that barebox calls poweron/init in a different order than Linux. This point is moot now though because poweron is no longer provided by the driver.
Still not true, though.
Isn't this the same order Linux uses? Powering on regulator and then phy_init? Why does it lead to issues in barebox, but not in Linux?
Cheers,
Ahmad
Quoted 4 lines
Regards,
Michael
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Quoted 56 lines · Ahmad Fatoum
Quoted 43 lines · Michael Grzeschik
Quoted 42 lines · Ahmad Fatoum
Quoted 40 lines · Michael Grzeschik
Quoted 23 lines · Sascha Hauer
Quoted 13 lines · Ahmad Fatoum
Linux doesn't seem to enforce a fixed order between
phy_initandphy_power_on. The Linux dwc2 driver doespower_onand thenphy_init, which is the inverse of what barebox is currently doing.The PHYs normally used with dwc2 are written with this in mind. For example, our stm32-usbphyc driver fails to disable:
ERROR: stm32-usbphyc [email protected]: PLL not reset
ERROR: phy1: phy exit failed --> -5Because Linux does exit ->
power_off, but barebox doespower_off-> exit.Quoted 8 lines
Issue was raised upstream:
https://lore.kernel.org/lkml/[email protected]/T/#tUntil this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
WARNING: dwc2 [email protected]:
dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed outWhen I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now?
Quoted 7 lines
Quoted 3 lines
Since
0e37f94fbe1b("phy: stm32: sync with upstream"), the phy-stm32-usbphyc now has no poweron/poweroff callbacks, so a revert seems to only slightly change timing. I'd suggest you dig some more.That is not true.
phy_power_onalso enables thephy_regulator. Changing this order has the effect that the regulator is enabled after or beforephy_initcall.Oh, good point.
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
How can I reproduce the case this was fixing in the first place?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
The case was that barebox calls poweron/init in a different order than Linux. This point is moot now though because poweron is no longer provided by the driver.
Still not true, though.
Isn't this the same order Linux uses? Powering on regulator and then
phy_init? Why does it lead to issues in barebox, but not in Linux?
I have no clue so far. Especially as this seems to have implications on the platform I am working on but not on the dk2. Although both use the same st,stpmic1 node vdd_usb for the phy_regulator.
Regards,
Michael
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 1/2] fixup! usb: dwc2: Add support for optional usb phy
Hi,
Quoted 39 lines
Quoted 39 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 6 lines
Quoted 5 lines
Until this is settled, swap the order to follow what Linux does. This is suboptimal, because it means controller drivers have different order of the operations and that you can't combine arbitrary PHYs and controllers, but it seems unlikely we will support combinations that aren't supported by Linux in the first place anyway.
Quoted 6 lines
This is valuable information and I don't want it to be lost, so instead of applying this as a fixup I rewrote the subject to:
usb: dwc2: swap order of
phy_initandphy_power_onto what Linux doesand applied it as a separate patch.
With this patch applied, some stm32mp1 do seem to timeout when addressing the core.
WARNING: dwc2 [email protected]:
dwc2_core_reset: Timeout! Waiting for Core Soft Reset
ERROR: dwc2 [email protected]: probe failed: Connection timed outWhen I revert this patch. Everything works fine again.
Is it possible that we can revert it in mainline now?
Quoted 7 lines
Quoted 3 lines
Since
0e37f94fbe1b("phy: stm32: sync with upstream"), the phy-stm32-usbphyc now has no poweron/poweroff callbacks, so a revert seems to only slightly change timing. I'd suggest you dig some more.That is not true.
phy_power_onalso enables thephy_regulator. Changing this order has the effect that the regulator is enabled after or beforephy_initcall.Oh, good point.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
How can I reproduce the case this was fixing in the first place?
The case was that barebox calls poweron/init in a different order than Linux. This point is moot now though because poweron is no longer provided by the driver.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Still not true, though.
Isn't this the same order Linux uses? Powering on regulator and then
phy_init? Why does it lead to issues in barebox, but not in Linux?I have no clue so far. Especially as this seems to have implications on the platform I am working on but not on the dk2. Although both use the same st,stpmic1 node
vdd_usbfor thephy_regulator.
In linux driver dwc2 (and dwc3) call phy_poweron then phy_init, which I believe is not the right order, it should be init -> poweron. The thing is that's a two part issue, first the usb drivers using phy must use the correct call order, secondly the phy drivers must implement the correct "flow"
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 regulator: stm32-pwr: don't propagate regulator turn-off to supply
In reply to Ahmad FatoumLinux walks up the regulator supply chain in the core code, which we don't do in barebox. Instead the stm32-pwr driver did enable/disable its parent manually. This is problematic, because it doesn't respect the regulator-always-on flag the parent supply may have, leading to prohibited disabling of regulators. Work around this by dropping the regulator disable altogether and just enable the parent supply unconditionally.
When we gain proper regulator supply chain handling, this patch can be reverted.
--- drivers/regulator/stm32-pwr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/regulator/stm32-pwr.c +2 -4
@@ -86,8 +86,6 @@ static int stm32_pwr_reg_enable(struct regulator_dev *rdev)int ret;u32 val; -regulator_enable (priv->supply); - val =readl (priv->base +REG_PWR_CR3 ); val |= rdev->desc->enable_mask;writel (val, priv->base +REG_PWR_CR3 );
@@ -120,8 +118,6 @@ static int stm32_pwr_reg_disable(struct regulator_dev *rdev)dev_err (rdev->dev,"%s: regulator disable timed out!\n" , desc->name); -regulator_disable (priv->supply); -return ret; }
@@ -194,6 +190,8 @@ static int stm32_pwr_regulator_probe(struct device_d *dev) desc->name, ret); goto release_region; } + +regulator_enable (priv->supply); }return 0 ;
Signature · 7 lines
2.29.2 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox