usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
Subsystems (2)
PATCH 1/1 usb: dwc3: gadget: Restart DWC3 gadget when enabling pullup
usb_gadget_deactivate/usb_gadget_activate does not execute the UDC start operation, which may leave EP0 disabled and event IRQs disabled when re-activating the function. Move the enabling/disabling of USB EP0 and device event IRQs to be performed in the pullup routine.
controller")
--- drivers/usb/dwc3/gadget.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/usb/dwc3/gadget.c +3 -11
@@ -1988,6 +1988,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)static void dwc3_gadget_disable_irq (struct dwc3 *dwc);static void __dwc3_gadget_stop (struct dwc3 *dwc); +static int __dwc3_gadget_start (struct dwc3 *dwc);static int dwc3_gadget_pullup (struct usb_gadget *g,int is_on) {
@@ -2050,6 +2051,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->length; } + }else { +__dwc3_gadget_start (dwc); } ret =dwc3_gadget_run_stop (dwc, is_on, false);
@@ -2224,10 +2227,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, } dwc->gadget_driver = driver; - -if (pm_runtime_active (dwc->dev)) -__dwc3_gadget_start (dwc); -spin_unlock_irqrestore (&dwc->lock, flags);return 0 ;
@@ -2253,13 +2252,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)unsigned long flags;spin_lock_irqsave (&dwc->lock, flags); - -if (pm_runtime_suspended (dwc->dev)) - goto out; - -__dwc3_gadget_stop (dwc); - -out: dwc->gadget_driver =NULL ;spin_unlock_irqrestore (&dwc->lock, flags);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 10 lines · Wesley Cheng
usb_gadget_deactivate/usb_gadget_activate does not execute the UDC start operation, which may leave EP0 disabled and event IRQs disabled when re-activating the function. Move the enabling/disabling of USB EP0 and device event IRQs to be performed in the pullup routine.
Fixes ae7e86108b12 ("usb: dwc3: Stop active transfers before halting thecontroller")
Reported-by Michael Tretter <[email protected]>Signed-off-by Wesley Cheng <[email protected]>
Quoted 55 lines
--- drivers/usb/dwc3/gadget.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)drivers/usb/dwc3/gadget.c +3
-11@@ -1988,6 +1988,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)static void dwc3_gadget_disable_irq (struct dwc3 *dwc);static void __dwc3_gadget_stop (struct dwc3 *dwc); +static int __dwc3_gadget_start (struct dwc3 *dwc);static int dwc3_gadget_pullup (struct usb_gadget *g,int is_on) {@@ -2050,6 +2051,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->length; } + }else { +__dwc3_gadget_start (dwc); } ret =dwc3_gadget_run_stop (dwc, is_on, false);@@ -2224,10 +2227,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, } dwc->gadget_driver = driver; - -if (pm_runtime_active (dwc->dev)) -__dwc3_gadget_start (dwc); -spin_unlock_irqrestore (&dwc->lock, flags);return 0 ;@@ -2253,13 +2252,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)unsigned long flags;spin_lock_irqsave (&dwc->lock, flags); - -if (pm_runtime_suspended (dwc->dev)) - goto out; - -__dwc3_gadget_stop (dwc); - -out: dwc->gadget_driver =NULL ;spin_unlock_irqrestore (&dwc->lock, flags);Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 6 lines · Michael Tretter
Quoted 5 lines · Wesley Cheng
usb_gadget_deactivate/usb_gadget_activate does not execute the UDC start operation, which may leave EP0 disabled and event IRQs disabled when re-activating the function. Move the enabling/disabling of USB EP0 and device event IRQs to be performed in the pullup routine.
Quoted 7 lines
Quoted 5 lines
Fixes ae7e86108b12 ("usb: dwc3: Stop active transfers before halting thecontroller")
Reported-by Michael Tretter <[email protected]>Signed-off-by Wesley Cheng <[email protected]>Tested-by Michael Tretter <[email protected]>
Gentle ping. I didn't see this fix being picked up into any of the usb trees.
Michael
Quoted 57 lines
Quoted 56 lines
--- drivers/usb/dwc3/gadget.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)drivers/usb/dwc3/gadget.c +3
-11@@ -1988,6 +1988,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)static void dwc3_gadget_disable_irq (struct dwc3 *dwc);static void __dwc3_gadget_stop (struct dwc3 *dwc); +static int __dwc3_gadget_start (struct dwc3 *dwc);static int dwc3_gadget_pullup (struct usb_gadget *g,int is_on) {@@ -2050,6 +2051,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) % dwc->ev_buf->length; } + }else { +__dwc3_gadget_start (dwc); } ret =dwc3_gadget_run_stop (dwc, is_on, false);@@ -2224,10 +2227,6 @@ static int dwc3_gadget_start(struct usb_gadget *g, } dwc->gadget_driver = driver; - -if (pm_runtime_active (dwc->dev)) -__dwc3_gadget_start (dwc); -spin_unlock_irqrestore (&dwc->lock, flags);return 0 ;@@ -2253,13 +2252,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g)unsigned long flags;spin_lock_irqsave (&dwc->lock, flags); - -if (pm_runtime_suspended (dwc->dev)) - goto out; - -__dwc3_gadget_stop (dwc); - -out: dwc->gadget_driver =NULL ;spin_unlock_irqrestore (&dwc->lock, flags);Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project