linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: only prevent new request when power_down is possible
@ 2020-04-10 14:31 Fabrice Gasnier
  2020-04-13  8:56 ` Minas Harutyunyan
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Gasnier @ 2020-04-10 14:31 UTC (permalink / raw)
  To: hminas
  Cc: gregkh, balbi, johnyoun, gregory.herrero, Grigor.Tovmasyan,
	amelie.delaunay, linux-usb, linux-kernel, linux-stm32

When controller is suspended, registers mustn't be touched. This is not
the case when 'power_down' is set to none. In this case, power saving
routines are skipped.

This fixes a case where gadget driver (f_acm) gets opened (cat /dev/ttyGS0)
but the bus has been suspended by the host:
- configfs-gadget gadget: acm ttyGS0 can't notify serial state, -11

Fixes: 7ababa926c66 ("usb: dwc2: gadget: prevent new request submission during suspend")
Fixes: 88b02f2cb1e1 ("usb: dwc2: Add core state checking")

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/usb/dwc2/gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 92ed32e..45a8782 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1375,7 +1375,8 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
 		req->zero, req->short_not_ok);
 
 	/* Prevent new request submission when controller is suspended */
-	if (hs->lx_state != DWC2_L0) {
+	if (hs->params.power_down != DWC2_POWER_DOWN_PARAM_NONE &&
+	    hs->lx_state != DWC2_L0) {
 		dev_dbg(hs->dev, "%s: submit request only in active state\n",
 			__func__);
 		return -EAGAIN;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: dwc2: only prevent new request when power_down is possible
  2020-04-10 14:31 [PATCH] usb: dwc2: only prevent new request when power_down is possible Fabrice Gasnier
@ 2020-04-13  8:56 ` Minas Harutyunyan
  0 siblings, 0 replies; 2+ messages in thread
From: Minas Harutyunyan @ 2020-04-13  8:56 UTC (permalink / raw)
  To: Fabrice Gasnier
  Cc: gregkh, balbi, John Youn, gregory.herrero, Grigor.Tovmasyan,
	amelie.delaunay, linux-usb, linux-kernel, linux-stm32

Hi,

On 4/10/2020 6:31 PM, Fabrice Gasnier wrote:
> When controller is suspended, registers mustn't be touched. This is not
> the case when 'power_down' is set to none. In this case, power saving
> routines are skipped.

If core in suspend mode even with any enabled power saving modes then 
lx_state = DWC2_L2. If power_down != DWC2_POWER_DOWN_PARAM_NONE it 
doesn't mean that core in suspend state (DWC2_L2) and declining request 
is wrong. So, additional checking of params.power_dowm here is not correct.

> 
> This fixes a case where gadget driver (f_acm) gets opened (cat /dev/ttyGS0)
> but the bus has been suspended by the host:
> - configfs-gadget gadget: acm ttyGS0 can't notify serial state, -11
> 
> Fixes: 7ababa926c66 ("usb: dwc2: gadget: prevent new request submission during suspend")
> Fixes: 88b02f2cb1e1 ("usb: dwc2: Add core state checking")
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
> ---
>   drivers/usb/dwc2/gadget.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 92ed32e..45a8782 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -1375,7 +1375,8 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
>   		req->zero, req->short_not_ok);
>   
>   	/* Prevent new request submission when controller is suspended */
> -	if (hs->lx_state != DWC2_L0) {
> +	if (hs->params.power_down != DWC2_POWER_DOWN_PARAM_NONE &&
> +	    hs->lx_state != DWC2_L0) {
>   		dev_dbg(hs->dev, "%s: submit request only in active state\n",
>   			__func__);
>   		return -EAGAIN;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-13  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 14:31 [PATCH] usb: dwc2: only prevent new request when power_down is possible Fabrice Gasnier
2020-04-13  8:56 ` Minas Harutyunyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).