diff mbox series

[V2] usb: chipidea: udc: make controller hardware endpoint primed

Message ID 20210913140005.955699-1-piyush.mehta@xilinx.com
State New
Headers show
Series [V2] usb: chipidea: udc: make controller hardware endpoint primed | expand

Commit Message

Piyush Mehta Sept. 13, 2021, 2 p.m. UTC
Root-cause:
There is an issue like endpoint is not recognized as primed, when bus
have more pressure and the add dTD tripwire semaphore (ATDTW bit in
USBCMD register) that can cause the controller to ignore a dTD that is
added to a primed endpoint.
This issue observed with the Windows10 host machine.

Workaround:
The software must implement a periodic cycle, and check for each dTD,
if the endpoint is primed. It can do this by reading the corresponding
bits in the ENDPTPRIME and ENDPTSTAT registers. If these bits are read
at 0, the software needs to re-prime the endpoint by writing 1 to the
corresponding bit in the ENDPTPRIME register.

Added conditional revision check of 2.20[CI_REVISION_22].

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>
---
Changes for V2:
- Addressed Peter review comments - Remove unrelated new-line
- Updated commit message

Link: https://lore.kernel.org/linux-usb/SJ0PR02MB8644CBBA848A0F68323F1AA5D4D99@SJ0PR02MB8644.namprd02.prod.outlook.com/
---
 drivers/usb/chipidea/udc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Piyush Mehta Oct. 6, 2021, 4:36 a.m. UTC | #1
Ping ...

Regards,
Piyush Mehta

-----Original Message-----
From: Piyush Mehta <piyush.mehta@xilinx.com> 

Sent: Monday, September 13, 2021 7:30 PM
To: peter.chen@kernel.org; gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; git <git@xilinx.com>; Srinivas Goud <sgoud@xilinx.com>; Michal Simek <michals@xilinx.com>; Piyush Mehta <piyushm@xilinx.com>
Subject: [PATCH V2] usb: chipidea: udc: make controller hardware endpoint primed

Root-cause:
There is an issue like endpoint is not recognized as primed, when bus have more pressure and the add dTD tripwire semaphore (ATDTW bit in USBCMD register) that can cause the controller to ignore a dTD that is added to a primed endpoint.
This issue observed with the Windows10 host machine.

Workaround:
The software must implement a periodic cycle, and check for each dTD, if the endpoint is primed. It can do this by reading the corresponding bits in the ENDPTPRIME and ENDPTSTAT registers. If these bits are read at 0, the software needs to re-prime the endpoint by writing 1 to the corresponding bit in the ENDPTPRIME register.

Added conditional revision check of 2.20[CI_REVISION_22].

Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>

---
Changes for V2:
- Addressed Peter review comments - Remove unrelated new-line
- Updated commit message

Link: https://lore.kernel.org/linux-usb/SJ0PR02MB8644CBBA848A0F68323F1AA5D4D99@SJ0PR02MB8644.namprd02.prod.outlook.com/
---
 drivers/usb/chipidea/udc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 8834ca6..f9ca501 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -49,6 +49,8 @@ ctrl_endpt_in_desc = {
 	.wMaxPacketSize  = cpu_to_le16(CTRL_PAYLOAD_MAX),  };
 
+static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep,
+		       struct td_node *node);
 /**
  * hw_ep_bit: calculates the bit number
  * @num: endpoint number
@@ -599,6 +601,12 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
 
 		prevlastnode->ptr->next = cpu_to_le32(next);
 		wmb();
+
+		if (ci->rev == CI_REVISION_22) {
+			if (!hw_read(ci, OP_ENDPTSTAT, BIT(n)))
+				reprime_dtd(ci, hwep, prevlastnode);
+		}
+
 		if (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
 			goto done;
 		do {
--
2.7.4
Peter Chen Oct. 7, 2021, 4:27 a.m. UTC | #2
On 21-10-06 04:36:59, Piyush Mehta wrote:
> 

> Root-cause:

> There is an issue like endpoint is not recognized as primed, when bus have more pressure and the add dTD tripwire semaphore (ATDTW bit in USBCMD register) that can cause the controller to ignore a dTD that is added to a primed endpoint.

> This issue observed with the Windows10 host machine.

> 

> Workaround:

> The software must implement a periodic cycle, and check for each dTD, if the endpoint is primed. It can do this by reading the corresponding bits in the ENDPTPRIME and ENDPTSTAT registers. If these bits are read at 0, the software needs to re-prime the endpoint by writing 1 to the corresponding bit in the ENDPTPRIME register.

> 

> Added conditional revision check of 2.20[CI_REVISION_22].

> 

> Signed-off-by: Piyush Mehta <piyush.mehta@xilinx.com>

> ---

> Changes for V2:

> - Addressed Peter review comments - Remove unrelated new-line

> - Updated commit message

> 

> Link: https://lore.kernel.org/linux-usb/SJ0PR02MB8644CBBA848A0F68323F1AA5D4D99@SJ0PR02MB8644.namprd02.prod.outlook.com/

> ---

>  drivers/usb/chipidea/udc.c | 8 ++++++++

>  1 file changed, 8 insertions(+)

> 

> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 8834ca6..f9ca501 100644

> --- a/drivers/usb/chipidea/udc.c

> +++ b/drivers/usb/chipidea/udc.c

> @@ -49,6 +49,8 @@ ctrl_endpt_in_desc = {

>  	.wMaxPacketSize  = cpu_to_le16(CTRL_PAYLOAD_MAX),  };

>  

> +static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep,

> +		       struct td_node *node);

>  /**

>   * hw_ep_bit: calculates the bit number

>   * @num: endpoint number

> @@ -599,6 +601,12 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)

>  

>  		prevlastnode->ptr->next = cpu_to_le32(next);

>  		wmb();

> +

> +		if (ci->rev == CI_REVISION_22) {

> +			if (!hw_read(ci, OP_ENDPTSTAT, BIT(n)))

> +				reprime_dtd(ci, hwep, prevlastnode);

> +		}

> +

>  		if (hw_read(ci, OP_ENDPTPRIME, BIT(n)))

>  			goto done;

>  		do {

> --


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


-- 

Thanks,
Peter Chen
diff mbox series

Patch

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 8834ca6..f9ca501 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -49,6 +49,8 @@  ctrl_endpt_in_desc = {
 	.wMaxPacketSize  = cpu_to_le16(CTRL_PAYLOAD_MAX),
 };
 
+static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep,
+		       struct td_node *node);
 /**
  * hw_ep_bit: calculates the bit number
  * @num: endpoint number
@@ -599,6 +601,12 @@  static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
 
 		prevlastnode->ptr->next = cpu_to_le32(next);
 		wmb();
+
+		if (ci->rev == CI_REVISION_22) {
+			if (!hw_read(ci, OP_ENDPTSTAT, BIT(n)))
+				reprime_dtd(ci, hwep, prevlastnode);
+		}
+
 		if (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
 			goto done;
 		do {