All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] usb: cdnsp: Fix lack of removing request from pending list.
@ 2021-04-19  7:53 Pawel Laszczak
  2021-04-20  1:15 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Laszczak @ 2021-04-19  7:53 UTC (permalink / raw)
  To: peter.chen; +Cc: gregkh, linux-usb, linux-kernel, kurahul, Pawel Laszczak

From: Pawel Laszczak <pawell@cadence.com>

Patch fixes lack of removing request from ep->pending_list on failure
of the stop endpoint command. Driver even after failing this command
must remove request from ep->pending_list.
Without this fix driver can stuck in cdnsp_gadget_ep_disable function
in loop:
        while (!list_empty(&pep->pending_list)) {
                preq = next_request(&pep->pending_list);
                cdnsp_ep_dequeue(pep, preq);
        }

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/cdnsp-gadget.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
index 6182c9bc65de..1ca8c1777a5c 100644
--- a/drivers/usb/cdns3/cdnsp-gadget.c
+++ b/drivers/usb/cdns3/cdnsp-gadget.c
@@ -424,17 +424,17 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 int cdnsp_ep_dequeue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
 {
 	struct cdnsp_device *pdev = pep->pdev;
-	int ret;
+	int ret_stop = 0;
+	int ret_rem;
 
 	trace_cdnsp_request_dequeue(preq);
 
-	if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING) {
-		ret = cdnsp_cmd_stop_ep(pdev, pep);
-		if (ret)
-			return ret;
-	}
+	if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING)
+		ret_stop = cdnsp_cmd_stop_ep(pdev, pep);
+
+	ret_rem =  cdnsp_remove_request(pdev, preq, pep);
 
-	return cdnsp_remove_request(pdev, preq, pep);
+	return ret_rem ? ret_rem : ret_stop;
 }
 
 static void cdnsp_zero_in_ctx(struct cdnsp_device *pdev)
-- 
2.25.1


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

* Re: [PATCH 2/2] usb: cdnsp: Fix lack of removing request from pending list.
  2021-04-19  7:53 [PATCH 2/2] usb: cdnsp: Fix lack of removing request from pending list Pawel Laszczak
@ 2021-04-20  1:15 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2021-04-20  1:15 UTC (permalink / raw)
  To: Pawel Laszczak; +Cc: gregkh, linux-usb, linux-kernel, kurahul

On 21-04-19 09:53:11, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
> 
> Patch fixes lack of removing request from ep->pending_list on failure
> of the stop endpoint command. Driver even after failing this command
> must remove request from ep->pending_list.
> Without this fix driver can stuck in cdnsp_gadget_ep_disable function
> in loop:
>         while (!list_empty(&pep->pending_list)) {
>                 preq = next_request(&pep->pending_list);
>                 cdnsp_ep_dequeue(pep, preq);
>         }
> 
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
>  drivers/usb/cdns3/cdnsp-gadget.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/cdnsp-gadget.c b/drivers/usb/cdns3/cdnsp-gadget.c
> index 6182c9bc65de..1ca8c1777a5c 100644
> --- a/drivers/usb/cdns3/cdnsp-gadget.c
> +++ b/drivers/usb/cdns3/cdnsp-gadget.c
> @@ -424,17 +424,17 @@ int cdnsp_ep_enqueue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
>  int cdnsp_ep_dequeue(struct cdnsp_ep *pep, struct cdnsp_request *preq)
>  {
>  	struct cdnsp_device *pdev = pep->pdev;
> -	int ret;
> +	int ret_stop = 0;
> +	int ret_rem;
>  
>  	trace_cdnsp_request_dequeue(preq);
>  
> -	if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING) {
> -		ret = cdnsp_cmd_stop_ep(pdev, pep);
> -		if (ret)
> -			return ret;
> -	}
> +	if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_RUNNING)
> +		ret_stop = cdnsp_cmd_stop_ep(pdev, pep);
> +
> +	ret_rem =  cdnsp_remove_request(pdev, preq, pep);

One more blank space above, and add Fixed-by tag.

>  
> -	return cdnsp_remove_request(pdev, preq, pep);
> +	return ret_rem ? ret_rem : ret_stop;
>  }
>  
>  static void cdnsp_zero_in_ctx(struct cdnsp_device *pdev)
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen


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

end of thread, other threads:[~2021-04-20  1:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19  7:53 [PATCH 2/2] usb: cdnsp: Fix lack of removing request from pending list Pawel Laszczak
2021-04-20  1:15 ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.