diff mbox series

[1/2] dwc3: gadget: fix setting of pending_sgs

Message ID 20210421204837.4185-2-m.grzeschik@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series usb: dwc3: gadget: fix scatter gather support | expand

Commit Message

Michael Grzeschik April 21, 2021, 8:48 p.m. UTC
In the dwc3_prepare_trbs_sg routine, when all data from request was
handled pending_sgs should be set to the number of mapped sgs that are
not queued up.

Currently the code will result in pending_sgs == queued_sgs. That
variables value will likely not be zero and break dwc3_prepare_trbs.

This patch fixes the setting of the variable to its intended purpose.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/usb/dwc3/gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Felipe Balbi April 22, 2021, 10:51 a.m. UTC | #1
Hi,

(subject format, please prepend 'usb:')

Michael Grzeschik <m.grzeschik@pengutronix.de> writes:

> In the dwc3_prepare_trbs_sg routine, when all data from request was
> handled pending_sgs should be set to the number of mapped sgs that are
        ^^
        ,

> not queued up.
>
> Currently the code will result in pending_sgs == queued_sgs. That
> variables value will likely not be zero and break dwc3_prepare_trbs.
  ^^^^^^^^^
  variable's

you say it's 'likely'. Got any minimal reproduction method?

> This patch fixes the setting of the variable to its intended purpose.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

please add Fixes tag and Cc stable
Thinh Nguyen April 22, 2021, 9:28 p.m. UTC | #2
Michael Grzeschik wrote:
> In the dwc3_prepare_trbs_sg routine, when all data from request was
> handled pending_sgs should be set to the number of mapped sgs that are
> not queued up.
> 
> Currently the code will result in pending_sgs == queued_sgs. That
> variables value will likely not be zero and break dwc3_prepare_trbs.
> 
> This patch fixes the setting of the variable to its intended purpose.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
>  drivers/usb/dwc3/gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 6227641f2d318..118b5bcc565d6 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1242,7 +1242,7 @@ static int dwc3_prepare_trbs_sg(struct dwc3_ep *dep,
>  		 * don't include unused SG entries.
>  		 */
>  		if (length == 0) {
> -			req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
> +			req->num_pending_sgs = req->request.num_mapped_sgs - req->num_queued_sgs;
>  			break;
>  		}
>  
> 

We update the req->num_pending_sgs every TRB completion interrupt. Doing
this will break the current logic. If there's a change to the current
logic, it should be part of this patch. Otherwise bisection will fail here.

BR,
Thinh
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 6227641f2d318..118b5bcc565d6 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1242,7 +1242,7 @@  static int dwc3_prepare_trbs_sg(struct dwc3_ep *dep,
 		 * don't include unused SG entries.
 		 */
 		if (length == 0) {
-			req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
+			req->num_pending_sgs = req->request.num_mapped_sgs - req->num_queued_sgs;
 			break;
 		}