Skip to contentSkip to conversation

usb: gadget: tegra-xudc: Fix idle suspend/resume

PATCH In review Thierry Reding 2 participants 3 messages Apr 17, 2020 – May 6, 2020

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

PATCH 1/1 usb: gadget: tegra-xudc: Fix idle suspend/resume

From: Thierry Reding <[email protected]>

When the XUDC device is idle (i.e. powergated), care must be taken not to access any registers because that would lead to a crash.

Move the call to tegra_xudc_device_mode_off() into the same conditional as the tegra_xudc_powergate() call to make sure we only force device mode off if the XUDC is actually powered up.

Fixes 49db427232fe ("usb: gadget: Add UDC driver for tegra XUSB device mode controller")
---
 drivers/usb/gadget/udc/tegra-xudc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +4 -4
index 52a6add961f4..dfabc54cdc27 100644
@@ -3840,11 +3840,11 @@ static int __maybe_unused tegra_xudc_suspend(struct device *dev)
 
 	flush_work(&xudc->usb_role_sw_work);
 
-	/* Forcibly disconnect before powergating. */
-	tegra_xudc_device_mode_off(xudc);
-
-	if (!pm_runtime_status_suspended(dev))
+	if (!pm_runtime_status_suspended(dev)) {
+		/* Forcibly disconnect before powergating. */
+		tegra_xudc_device_mode_off(xudc);
 		tegra_xudc_powergate(xudc);
+	}
 
 	pm_runtime_disable(dev);
 
Signature · 1 line
2.24.1
maintainer Acked-by Tested-by on v1 1/1
#1 lore raw
Quoted 24 lines · Thierry Reding

From: Thierry Reding <[email protected]>

When the XUDC device is idle (i.e. powergated), care must be taken not to access any registers because that would lead to a crash.

Move the call to tegra_xudc_device_mode_off() into the same conditional as the tegra_xudc_powergate() call to make sure we only force device mode off if the XUDC is actually powered up.

Fixes 49db427232fe ("usb: gadget: Add UDC driver for tegra XUSB device mode controller")
---
 drivers/usb/gadget/udc/tegra-xudc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +0 -1
index 52a6add961f4..dfabc54cdc27 100644
@@ -3840,11 +3840,11 @@ static int __maybe_unused tegra_xudc_suspend(struct device *dev)
 
 	flush_work(&xudc->usb_role_sw_work);
 
-	/* Forcibly disconnect before powergating. */

drivers/usb/gadget/udc/tegra-xudc.c static int __maybe_unused tegra_xudc_suspend(struct device *dev) · line 3849

Quoted 10 lines
drivers/usb/gadget/udc/tegra-xudc.c +4 -3
-	tegra_xudc_device_mode_off(xudc);
-
-	if (!pm_runtime_status_suspended(dev))
+	if (!pm_runtime_status_suspended(dev)) {
+		/* Forcibly disconnect before powergating. */
+		tegra_xudc_device_mode_off(xudc);
 		tegra_xudc_powergate(xudc);
+	}
 
 	pm_runtime_disable(dev);

Cheers
Jon

Signature · 1 line
nvpublic
#2 lore raw
In reply to Thierry Reding
Quoted 9 lines · Thierry Reding

From: Thierry Reding <[email protected]>

When the XUDC device is idle (i.e. powergated), care must be taken not to access any registers because that would lead to a crash.

Move the call to tegra_xudc_device_mode_off() into the same conditional as the tegra_xudc_powergate() call to make sure we only force device mode off if the XUDC is actually powered up.

Quoted 5 lines
Fixes 49db427232fe ("usb: gadget: Add UDC driver for tegra XUSB device mode controller")
---
 drivers/usb/gadget/udc/tegra-xudc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Hi Felipe, Greg,

can you guys pick this up for v5.7, please?

Thanks,
Thierry