linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: gadget: Fix ISOC flow for elapsed frames
@ 2021-11-04  7:36 Minas Harutyunyan
  2021-11-05 17:27 ` John Keeping
  0 siblings, 1 reply; 2+ messages in thread
From: Minas Harutyunyan @ 2021-11-04  7:36 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Minas Harutyunyan, linux-usb
  Cc: John Youn, Minas Harutyunyan, stable

Added updating of request frame number for elapsed frames,
otherwise frame number will remain as previous use of request.
This will allow function driver to correctly track frames in
case of Missed ISOC occurs.

Added setting request actual length to 0 for elapsed frames.
In Slave mode when pushing data to RxFIFO by dwords, request
actual length incrementing accordingly. But before whole packet
will be pushed into RxFIFO and send to host can occurs Missed
ISOC and data will not send to host. So, in this case request
actual length should be reset to 0.

Fixes: 91bb163e1e4f ("usb: dwc2: gadget: Fix ISOC flow for BDMA and Slave")
Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
---
 drivers/usb/dwc2/gadget.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 11d85a6e0b0d..2190225bf3da 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1198,6 +1198,8 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
 			}
 			ctrl |= DXEPCTL_CNAK;
 		} else {
+			hs_req->req.frame_number = hs_ep->target_frame;
+			hs_req->req.actual = 0;
 			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
 			return;
 		}
@@ -2857,9 +2859,12 @@ static void dwc2_gadget_handle_ep_disabled(struct dwc2_hsotg_ep *hs_ep)
 
 	do {
 		hs_req = get_ep_head(hs_ep);
-		if (hs_req)
+		if (hs_req) {
+			hs_req->req.frame_number = hs_ep->target_frame;
+			hs_req->req.actual = 0;
 			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req,
 						    -ENODATA);
+		}
 		dwc2_gadget_incr_frame_num(hs_ep);
 		/* Update current frame number value. */
 		hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg);
@@ -2912,8 +2917,11 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
 
 	while (dwc2_gadget_target_frame_elapsed(ep)) {
 		hs_req = get_ep_head(ep);
-		if (hs_req)
+		if (hs_req) {
+			hs_req->req.frame_number = ep->target_frame;
+			hs_req->req.actual = 0;
 			dwc2_hsotg_complete_request(hsotg, ep, hs_req, -ENODATA);
+		}
 
 		dwc2_gadget_incr_frame_num(ep);
 		/* Update current frame number value. */
@@ -3002,8 +3010,11 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
 
 	while (dwc2_gadget_target_frame_elapsed(hs_ep)) {
 		hs_req = get_ep_head(hs_ep);
-		if (hs_req)
+		if (hs_req) {
+			hs_req->req.frame_number = hs_ep->target_frame;
+			hs_req->req.actual = 0;
 			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
+		}
 
 		dwc2_gadget_incr_frame_num(hs_ep);
 		/* Update current frame number value. */

base-commit: c26f1c109d21f2ea874e4a85c0c76c385b8f46cb
-- 
2.11.0


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

* Re: [PATCH] usb: dwc2: gadget: Fix ISOC flow for elapsed frames
  2021-11-04  7:36 [PATCH] usb: dwc2: gadget: Fix ISOC flow for elapsed frames Minas Harutyunyan
@ 2021-11-05 17:27 ` John Keeping
  0 siblings, 0 replies; 2+ messages in thread
From: John Keeping @ 2021-11-05 17:27 UTC (permalink / raw)
  To: Minas Harutyunyan
  Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, John Youn, stable

On Thu, Nov 04, 2021 at 11:36:01AM +0400, Minas Harutyunyan wrote:
> Added updating of request frame number for elapsed frames,
> otherwise frame number will remain as previous use of request.
> This will allow function driver to correctly track frames in
> case of Missed ISOC occurs.
> 
> Added setting request actual length to 0 for elapsed frames.
> In Slave mode when pushing data to RxFIFO by dwords, request
> actual length incrementing accordingly. But before whole packet
> will be pushed into RxFIFO and send to host can occurs Missed
> ISOC and data will not send to host. So, in this case request
> actual length should be reset to 0.
> 
> Fixes: 91bb163e1e4f ("usb: dwc2: gadget: Fix ISOC flow for BDMA and Slave")
> Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>

Reviewed-by: John Keeping <john@metanate.com>

> ---
>  drivers/usb/dwc2/gadget.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 11d85a6e0b0d..2190225bf3da 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -1198,6 +1198,8 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
>  			}
>  			ctrl |= DXEPCTL_CNAK;
>  		} else {
> +			hs_req->req.frame_number = hs_ep->target_frame;
> +			hs_req->req.actual = 0;
>  			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
>  			return;
>  		}
> @@ -2857,9 +2859,12 @@ static void dwc2_gadget_handle_ep_disabled(struct dwc2_hsotg_ep *hs_ep)
>  
>  	do {
>  		hs_req = get_ep_head(hs_ep);
> -		if (hs_req)
> +		if (hs_req) {
> +			hs_req->req.frame_number = hs_ep->target_frame;
> +			hs_req->req.actual = 0;
>  			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req,
>  						    -ENODATA);
> +		}
>  		dwc2_gadget_incr_frame_num(hs_ep);
>  		/* Update current frame number value. */
>  		hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg);
> @@ -2912,8 +2917,11 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
>  
>  	while (dwc2_gadget_target_frame_elapsed(ep)) {
>  		hs_req = get_ep_head(ep);
> -		if (hs_req)
> +		if (hs_req) {
> +			hs_req->req.frame_number = ep->target_frame;
> +			hs_req->req.actual = 0;
>  			dwc2_hsotg_complete_request(hsotg, ep, hs_req, -ENODATA);
> +		}
>  
>  		dwc2_gadget_incr_frame_num(ep);
>  		/* Update current frame number value. */
> @@ -3002,8 +3010,11 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
>  
>  	while (dwc2_gadget_target_frame_elapsed(hs_ep)) {
>  		hs_req = get_ep_head(hs_ep);
> -		if (hs_req)
> +		if (hs_req) {
> +			hs_req->req.frame_number = hs_ep->target_frame;
> +			hs_req->req.actual = 0;
>  			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
> +		}
>  
>  		dwc2_gadget_incr_frame_num(hs_ep);
>  		/* Update current frame number value. */
> 
> base-commit: c26f1c109d21f2ea874e4a85c0c76c385b8f46cb
> -- 
> 2.11.0
> 

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

end of thread, other threads:[~2021-11-05 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04  7:36 [PATCH] usb: dwc2: gadget: Fix ISOC flow for elapsed frames Minas Harutyunyan
2021-11-05 17:27 ` John Keeping

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).