Skip to contentSkip to conversation

usb: gadget: pxa27x: fix suspend callback

PATCH In review Felipe Balbi 2 participants 5 messages Nov 19, 2015

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

PATCH 1/1 usb: gadget: pxa27x: fix suspend callback

pxa27x disconnects pullups on suspend but doesn't notify the gadget driver about it, so gadget driver can't disable the endpoints it was using.

This causes problems on resume because gadget core will think endpoints are still enabled and just ignore the following usb_ep_enable().

Fix this problem by calling
gadget_driver->disconnect().

---
 drivers/usb/gadget/udc/pxa27x_udc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/pxa27x_udc.c +1 -0
index 670ac0b12f00..a08ae19ca410 100644
@@ -2535,6 +2535,7 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state)
 	udc_disable(udc);
 	udc->pullup_resume = udc->pullup_on;
 	dplus_pullup(udc, 0);
+	udc->driver->disconnect(&udc->gadget);
 
 	return 0;
 }
Signature · 1 line
2.6.3
maintainer
#1 lore raw
Quoted 10 lines · Felipe Balbi

pxa27x disconnects pullups on suspend but doesn't notify the gadget driver about it, so gadget driver can't disable the endpoints it was using.

This causes problems on resume because gadget core will think endpoints are still enabled and just ignore the following usb_ep_enable().

Fix this problem by calling
gadget_driver->disconnect().

Thanks for doing this for me.

drivers/usb/gadget/udc/pxa27x_udc.c static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) · line 2538

Quoted 5 lines
drivers/usb/gadget/udc/pxa27x_udc.c +1 -0
@@ -2535,6 +2535,7 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state)
 	udc_disable(udc);
 	udc->pullup_resume = udc->pullup_on;
 	dplus_pullup(udc, 0);
+	udc->driver->disconnect(&udc->gadget);

If no driver is bound, this will segfault, right ? Shouldn't an "if (udc->driver)" protect this line ?

Cheers.

Signature · 1 line
Robert
#2 lore raw

Hi,

Quoted 12 lines · Robert Jarzmik
Quoted 10 lines · Felipe Balbi

pxa27x disconnects pullups on suspend but doesn't notify the gadget driver about it, so gadget driver can't disable the endpoints it was using.

This causes problems on resume because gadget core will think endpoints are still enabled and just ignore the following usb_ep_enable().

Fix this problem by calling
gadget_driver->disconnect().

Quoted 8 lines

Thanks for doing this for me.

drivers/usb/gadget/udc/pxa27x_udc.c static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) · line 2538

Quoted 5 lines
drivers/usb/gadget/udc/pxa27x_udc.c +1 -0
@@ -2535,6 +2535,7 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state)
 	udc_disable(udc);
 	udc->pullup_resume = udc->pullup_on;
 	dplus_pullup(udc, 0);
+	udc->driver->disconnect(&udc->gadget);

If no driver is bound, this will segfault, right ? Shouldn't an "if (udc->driver)" protect this line ?

good catch. v2 coming shortly.

Signature · 1 line
balbi
#3 lore raw

PATCH 1/1 usb: gadget: pxa27x: fix suspend callback

In reply to Robert Jarzmik

pxa27x disconnects pullups on suspend but doesn't notify the gadget driver about it, so gadget driver can't disable the endpoints it was using.

This causes problems on resume because gadget core will think endpoints are still enabled and just ignore the following usb_ep_enable().

Fix this problem by calling
gadget_driver->disconnect().

---
 drivers/usb/gadget/udc/pxa27x_udc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/gadget/udc/pxa27x_udc.c +3 -0
index 670ac0b12f00..001a3b74a993 100644
@@ -2536,6 +2536,9 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state)
 	udc->pullup_resume = udc->pullup_on;
 	dplus_pullup(udc, 0);
 
+	if (udc->driver)
+		udc->driver->disconnect(&udc->gadget);
+
 	return 0;
 }
 
Signature · 1 line
2.6.3
maintainer Tested-by on v1 1/1
#4 lore raw
Quoted 8 lines · Felipe Balbi

pxa27x disconnects pullups on suspend but doesn't notify the gadget driver about it, so gadget driver can't disable the endpoints it was using.

This causes problems on resume because gadget core will think endpoints are still enabled and just ignore the following usb_ep_enable().

Quoted 5 lines

Fix this problem by calling
gadget_driver->disconnect().

Cheers.

--
Robert