public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: cdns3: fix incorrect handling TRB_SMM flag for ISOC transfer
@ 2022-08-25  6:22 Pawel Laszczak
  2022-08-29  1:57 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Pawel Laszczak @ 2022-08-25  6:22 UTC (permalink / raw)
  To: peter.chen
  Cc: linux-usb, gregkh, felipe.balbi, rogerq, a-govindraju,
	linux-kernel, Pawel Laszczak, stable

The TRB_SMM flag indicates that DMA has completed the TD service with
this TRB. Usually it’s a last TRB in TD. In case of ISOC transfer for
bInterval > 1 each ISOC transfer contains more than one TD associated
with usb request (one TD per ITP). In such case the TRB_SMM flag will
be set in every TD and driver will recognize the end of transfer after
processing the first TD with TRB_SMM. In result driver stops updating
request->actual and returns incorrect actual length.
To fix this issue driver additionally must check TRB_CHAIN which is not
used for isochronous transfers.

Fixes: 249f0a25e8be ("usb: cdns3: gadget: handle sg list use case at completion correctly")
cc: <stable@vger.kernel.org>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/cdns3-gadget.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index fa8263951e63..a6618a922c61 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -1529,7 +1529,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
 						TRB_LEN(le32_to_cpu(trb->length));
 
 				if (priv_req->num_of_trb > 1 &&
-					le32_to_cpu(trb->control) & TRB_SMM)
+					le32_to_cpu(trb->control) & TRB_SMM &&
+					le32_to_cpu(trb->control) & TRB_CHAIN)
 					transfer_end = true;
 
 				cdns3_ep_inc_deq(priv_ep);
-- 
2.25.1


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

* Re: [PATCH] usb: cdns3: fix incorrect handling TRB_SMM flag for ISOC transfer
  2022-08-25  6:22 [PATCH] usb: cdns3: fix incorrect handling TRB_SMM flag for ISOC transfer Pawel Laszczak
@ 2022-08-29  1:57 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2022-08-29  1:57 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: linux-usb, gregkh, felipe.balbi, rogerq, a-govindraju,
	linux-kernel, stable

On 22-08-25 08:22:07, Pawel Laszczak wrote:
> The TRB_SMM flag indicates that DMA has completed the TD service with
> this TRB. Usually it’s a last TRB in TD. In case of ISOC transfer for
> bInterval > 1 each ISOC transfer contains more than one TD associated
> with usb request (one TD per ITP). In such case the TRB_SMM flag will
> be set in every TD and driver will recognize the end of transfer after
> processing the first TD with TRB_SMM. In result driver stops updating
> request->actual and returns incorrect actual length.
> To fix this issue driver additionally must check TRB_CHAIN which is not
> used for isochronous transfers.
> 
> Fixes: 249f0a25e8be ("usb: cdns3: gadget: handle sg list use case at completion correctly")
> cc: <stable@vger.kernel.org>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>

Acked-by: Peter Chen <peter.chen@kernel.org>

> ---
>  drivers/usb/cdns3/cdns3-gadget.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index fa8263951e63..a6618a922c61 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -1529,7 +1529,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
>  						TRB_LEN(le32_to_cpu(trb->length));
>  
>  				if (priv_req->num_of_trb > 1 &&
> -					le32_to_cpu(trb->control) & TRB_SMM)
> +					le32_to_cpu(trb->control) & TRB_SMM &&
> +					le32_to_cpu(trb->control) & TRB_CHAIN)
>  					transfer_end = true;
>  
>  				cdns3_ep_inc_deq(priv_ep);
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen

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

end of thread, other threads:[~2022-08-29  1:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25  6:22 [PATCH] usb: cdns3: fix incorrect handling TRB_SMM flag for ISOC transfer Pawel Laszczak
2022-08-29  1:57 ` Peter Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox