Skip to contentSkip to conversation

Two phy-twl4030-usb fixes for unloading the module

PATCH In review Tony Lindgren 2 participants 6 messages Dec 1, 2015 – Feb 9, 2016 Generic PHY framework

lore
Share & tools
lore
#0 lore raw

cover Two phy-twl4030-usb fixes for unloading the module

Hi,

Here are two fixes for rmmod and PM. These can be merged separately after the review from the MUSB related changes.

Regards,

Tony

Tony Lindgren (2):
phy: twl4030-usb: Relase usb phy on unload
phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload

 drivers/phy/phy-twl4030-usb.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/2 phy: twl4030-usb: Relase usb phy on unload

Otherwise rmmod omap2430; rmmod phy-twl4030-usb; modprobe omap2430 will try to use a non-existing phy and oops:

Unable to handle kernel paging request at virtual address b6f7c1f0

...
[<c048a284>] (devm_usb_get_phy_by_node) from [<bf0758ac>] (omap2430_musb_init+0x44/0x2b4 [omap2430]) [<bf0758ac>] (omap2430_musb_init [omap2430]) from [<bf055ec0>] (musb_init_controller+0x194/0x878 [musb_hdrc])

Cc Bin Liu <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc NeilBrown <neil-+NVA1uvv1dVBDLzU/[email protected]>
---
 drivers/phy/phy-twl4030-usb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/phy-twl4030-usb.c +1 -0
index 3a707dd..79870c4 100644
@@ -750,6 +750,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
 	struct twl4030_usb *twl = platform_get_drvdata(pdev);
 	int val;
 
+	usb_remove_phy(&twl->phy);
 	pm_runtime_get_sync(twl->dev);
 	cancel_delayed_work(&twl->id_workaround_work);
 	device_remove_file(twl->dev, &dev_attr_vbus);
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 2/2 phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload

In reply to Tony Lindgren

If we reload phy-twl4030-usb, we get a warning about unbalanced pm_runtime_enable. Let's fix the issue and also fix idling of the device on unload before we attempt to shut it down.

If we don't properly idle the PHY before shutting it down on removal, the twl4030 ends up consuming about 62mW of extra power compared to running idle with the module loaded.

Cc Bin Liu <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Kishon Vijay Abraham I <[email protected]>
Cc NeilBrown <[email protected]>
---
 drivers/phy/phy-twl4030-usb.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/phy/phy-twl4030-usb.c +8 -5
index 79870c4..f96065a 100644
@@ -715,6 +715,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
 	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_sync(&pdev->dev);
 
 	/* Our job is to use irqs and status from the power module
 	 * to keep the transceiver disabled when nothing's connected.
@@ -758,6 +759,13 @@ static int twl4030_usb_remove(struct platform_device *pdev)
 	/* set transceiver mode to power on defaults */
 	twl4030_usb_set_mode(twl, -1);
 
+	/* idle ulpi before powering off */
+	if (cable_present(twl->linkstat))
+		pm_runtime_put_noidle(twl->dev);
+	pm_runtime_mark_last_busy(twl->dev);
+	pm_runtime_put_sync_suspend(twl->dev);
+	pm_runtime_disable(twl->dev);
+
 	/* autogate 60MHz ULPI clock,
 	 * clear dpll clock request for i2c access,
 	 * disable 32KHz
@@ -772,11 +780,6 @@ static int twl4030_usb_remove(struct platform_device *pdev)
 	/* disable complete OTG block */
 	twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
 
-	if (cable_present(twl->linkstat))
-		pm_runtime_put_noidle(twl->dev);
-	pm_runtime_mark_last_busy(twl->dev);
-	pm_runtime_put(twl->dev);
-
 	return 0;
 }
 
Signature · 1 line
2.6.2
#3 lore raw
In reply to Tony Lindgren

Hi Kishon,

Quoted 4 lines · Tony Lindgren

Hi,

Here are two fixes for rmmod and PM. These can be merged separately after the review from the MUSB related changes.

Looks like these two fixes never got merged. Care to merge these for v4.5-rc cycle with Cc stable v4.4?

Without these omap3 PM is blocked as the USB modules can never be unloaded.

I can also merge these via the ARM SoC tree if you ack and have no other fixes for the -rc cycle.

Regards,

Tony

Quoted 15 lines

Tony Lindgren (2):
phy: twl4030-usb: Relase usb phy on unload
phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload

 drivers/phy/phy-twl4030-usb.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Hi Tony,

Quoted 8 lines · Tony Lindgren

Hi Kishon,

Quoted 4 lines · Tony Lindgren

Hi,

Here are two fixes for rmmod and PM. These can be merged separately after the review from the MUSB related changes.

Quoted 8 lines

Looks like these two fixes never got merged. Care to merge these for v4.5-rc cycle with Cc stable v4.4?

Without these omap3 PM is blocked as the USB modules can never be unloaded.

I can also merge these via the ARM SoC tree if you ack and have no other fixes for the -rc cycle.

merged this to linux-phy now. I have a couple of other fixes for this -rc cycle. Will send this along with the other fixes.

Thanks
Kishon

Quoted 20 lines

Regards,

Tony

Quoted 15 lines

Tony Lindgren (2):
phy: twl4030-usb: Relase usb phy on unload
phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload

 drivers/phy/phy-twl4030-usb.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 14 lines · Kishon Vijay Abraham I

Hi Tony,

Quoted 11 lines · Tony Lindgren

Hi Kishon,

Quoted 4 lines · Tony Lindgren

Hi,

Here are two fixes for rmmod and PM. These can be merged separately after the review from the MUSB related changes.

Looks like these two fixes never got merged. Care to merge these for v4.5-rc cycle with Cc stable v4.4?

Quoted 8 lines
Quoted 5 lines

Without these omap3 PM is blocked as the USB modules can never be unloaded.

I can also merge these via the ARM SoC tree if you ack and have no other fixes for the -rc cycle.

merged this to linux-phy now. I have a couple of other fixes for this -rc cycle. Will send this along with the other fixes.

OK thanks!

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html