public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints
@ 2024-09-30  9:34 Siddharth Vadapalli
  2024-09-30 13:50 ` Roger Quadros
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Siddharth Vadapalli @ 2024-09-30  9:34 UTC (permalink / raw)
  To: trini, lukma, mkorpershoek, marex, rogerq, vigneshr, jjhiblot
  Cc: u-boot, srk, s-vadapalli

Transfer initiation and completion for the non-zero Endpoints are
handled by cdns3_ep_run_transfer() and cdns3_transfer_completed()
respectively.

Failing to flush the cache associated with the TRB Pool within
cdns3_ep_run_transfer() results in the transfers never being initiated.
Similarly, failing to invalidate the cache associated with the TRB pool
within cdns3_transfer_completed() results in the transfers never being
completed.

Fix this.

Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver")
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---

Hello,

This patch is based on commit
56b47b8b6a Merge tag 'u-boot-stm32-20240926' of https://source.denx.de/u-boot/custodians/u-boot-stm
of the master branch of U-Boot.

This patch has been validated on AM642-EVM in the context of Fastboot.
Fastboot is non-functional without this patch. EP1 is configured in
Bulk Mode for Fastboot and is non-responsive. This patch addresses the
issue, thereby enabling Fastboot.

Regards,
Siddharth.

 drivers/usb/cdns3/gadget.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 32b2c41206..ac7e469469 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -965,6 +965,12 @@ int cdns3_ep_run_transfer(struct cdns3_endpoint *priv_ep,
 	if (priv_dev->dev_ver <= DEV_VER_V2)
 		cdns3_wa1_tray_restore_cycle_bit(priv_dev, priv_ep);
 
+	/* Flush TRBs */
+	flush_dcache_range((unsigned long)priv_ep->trb_pool,
+			   (unsigned long)priv_ep->trb_pool +
+			   ROUND(sizeof(struct cdns3_trb) * priv_ep->num_trbs,
+				 CONFIG_SYS_CACHELINE_SIZE));
+
 	trace_cdns3_prepare_trb(priv_ep, priv_req->trb);
 
 	/*
@@ -1153,6 +1159,13 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
 				priv_ep->endpoint.desc->bEndpointAddress);
 #endif
 
+		/* Invalidate TRBs */
+		invalidate_dcache_range((unsigned long)priv_ep->trb_pool,
+					(unsigned long)priv_ep->trb_pool +
+					ROUND(sizeof(struct cdns3_trb) *
+					      priv_ep->num_trbs,
+					      CONFIG_SYS_CACHELINE_SIZE));
+
 		if (!cdns3_request_handled(priv_ep, priv_req))
 			goto prepare_next_td;
 
-- 
2.40.1


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

* Re: [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints
  2024-09-30  9:34 [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints Siddharth Vadapalli
@ 2024-09-30 13:50 ` Roger Quadros
  2024-09-30 14:10 ` Marek Vasut
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Roger Quadros @ 2024-09-30 13:50 UTC (permalink / raw)
  To: Siddharth Vadapalli, trini, lukma, mkorpershoek, marex, vigneshr,
	jjhiblot
  Cc: u-boot, srk



On 30/09/2024 12:34, Siddharth Vadapalli wrote:
> Transfer initiation and completion for the non-zero Endpoints are
> handled by cdns3_ep_run_transfer() and cdns3_transfer_completed()
> respectively.
> 
> Failing to flush the cache associated with the TRB Pool within
> cdns3_ep_run_transfer() results in the transfers never being initiated.
> Similarly, failing to invalidate the cache associated with the TRB pool
> within cdns3_transfer_completed() results in the transfers never being
> completed.
> 
> Fix this.
> 
> Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

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

* Re: [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints
  2024-09-30  9:34 [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints Siddharth Vadapalli
  2024-09-30 13:50 ` Roger Quadros
@ 2024-09-30 14:10 ` Marek Vasut
  2024-09-30 15:46 ` Mattijs Korpershoek
  2024-09-30 16:31 ` Tom Rini
  3 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2024-09-30 14:10 UTC (permalink / raw)
  To: Siddharth Vadapalli, trini, lukma, mkorpershoek, rogerq, vigneshr,
	jjhiblot
  Cc: u-boot, srk

On 9/30/24 11:34 AM, Siddharth Vadapalli wrote:
> Transfer initiation and completion for the non-zero Endpoints are
> handled by cdns3_ep_run_transfer() and cdns3_transfer_completed()
> respectively.
> 
> Failing to flush the cache associated with the TRB Pool within
> cdns3_ep_run_transfer() results in the transfers never being initiated.
> Similarly, failing to invalidate the cache associated with the TRB pool
> within cdns3_transfer_completed() results in the transfers never being
> completed.
> 
> Fix this.
> 
> Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Reviewed-by: Marek Vasut <marex@denx.de>

Tom, can you pick this directly for current release ?

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

* Re: [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints
  2024-09-30  9:34 [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints Siddharth Vadapalli
  2024-09-30 13:50 ` Roger Quadros
  2024-09-30 14:10 ` Marek Vasut
@ 2024-09-30 15:46 ` Mattijs Korpershoek
  2024-09-30 16:31 ` Tom Rini
  3 siblings, 0 replies; 5+ messages in thread
From: Mattijs Korpershoek @ 2024-09-30 15:46 UTC (permalink / raw)
  To: Siddharth Vadapalli, trini, lukma, marex, rogerq, vigneshr,
	jjhiblot
  Cc: u-boot, srk, s-vadapalli

Hi Siddharth,

Thank you for the patch.

On lun., sept. 30, 2024 at 15:04, Siddharth Vadapalli <s-vadapalli@ti.com> wrote:

> Transfer initiation and completion for the non-zero Endpoints are
> handled by cdns3_ep_run_transfer() and cdns3_transfer_completed()
> respectively.
>
> Failing to flush the cache associated with the TRB Pool within
> cdns3_ep_run_transfer() results in the transfers never being initiated.
> Similarly, failing to invalidate the cache associated with the TRB pool
> within cdns3_transfer_completed() results in the transfers never being
> completed.
>
> Fix this.
>
> Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>


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

* Re: [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints
  2024-09-30  9:34 [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints Siddharth Vadapalli
                   ` (2 preceding siblings ...)
  2024-09-30 15:46 ` Mattijs Korpershoek
@ 2024-09-30 16:31 ` Tom Rini
  3 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2024-09-30 16:31 UTC (permalink / raw)
  To: lukma, mkorpershoek, marex, rogerq, vigneshr, jjhiblot,
	Siddharth Vadapalli
  Cc: u-boot, srk

On Mon, 30 Sep 2024 15:04:07 +0530, Siddharth Vadapalli wrote:

> Transfer initiation and completion for the non-zero Endpoints are
> handled by cdns3_ep_run_transfer() and cdns3_transfer_completed()
> respectively.
> 
> Failing to flush the cache associated with the TRB Pool within
> cdns3_ep_run_transfer() results in the transfers never being initiated.
> Similarly, failing to invalidate the cache associated with the TRB pool
> within cdns3_transfer_completed() results in the transfers never being
> completed.
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



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

end of thread, other threads:[~2024-09-30 16:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30  9:34 [PATCH] usb: gadget: cdns3: Fix missing cache operations for non-zero Endpoints Siddharth Vadapalli
2024-09-30 13:50 ` Roger Quadros
2024-09-30 14:10 ` Marek Vasut
2024-09-30 15:46 ` Mattijs Korpershoek
2024-09-30 16:31 ` Tom Rini

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