* [PATCH v3 1/3] usb: chipidea: udc: handle USB Error Interrupt if IOC not set @ 2024-09-26 2:29 Xu Yang 2024-09-26 2:29 ` [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic Xu Yang 2024-09-26 2:29 ` [PATCH v3 3/3] usb: chipidea: udc: improve error recovery for ISO transfer Xu Yang 0 siblings, 2 replies; 4+ messages in thread From: Xu Yang @ 2024-09-26 2:29 UTC (permalink / raw) To: peter.chen, gregkh; +Cc: linux-usb, imx, jun.li As per USBSTS register description about UEI: When completion of a USB transaction results in an error condition, this bit is set by the Host/Device Controller. This bit is set along with the USBINT bit, if the TD on which the error interrupt occurred also had its interrupt on complete (IOC) bit set. UI is set only when IOC set. Add checking UEI to fix miss call isr_tr_complete_handler() when IOC have not set and transfer error happen. Acked-by: Peter Chen <peter.chen@kernel.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> --- Changes in v2: - modify part commit message - add Ack-by tag - add fix tag and cc stable Changes in v3: - remove fixes tag and stable maillist --- drivers/usb/chipidea/udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 69ef3cd8d4f8..b9ccf62e0a50 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -2063,7 +2063,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) } } - if (USBi_UI & intr) + if ((USBi_UI | USBi_UEI) & intr) isr_tr_complete_handler(ci); if ((USBi_SLI & intr) && !(ci->suspended)) { -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic 2024-09-26 2:29 [PATCH v3 1/3] usb: chipidea: udc: handle USB Error Interrupt if IOC not set Xu Yang @ 2024-09-26 2:29 ` Xu Yang 2024-09-27 1:01 ` Peter Chen 2024-09-26 2:29 ` [PATCH v3 3/3] usb: chipidea: udc: improve error recovery for ISO transfer Xu Yang 1 sibling, 1 reply; 4+ messages in thread From: Xu Yang @ 2024-09-26 2:29 UTC (permalink / raw) To: peter.chen, gregkh; +Cc: linux-usb, imx, jun.li Currently, ATDTW semaphore is used to safety link new dTD to dQH. But this code has a bug when the endpoint is already in error before polling ATDTW or just met error during polling ATDTW. In that cases, ATDTW will never turn to 1 and the cpu will busy loop there. When the endpoint met error, ENDPTSTAT will be cleared by HW. Therefore, ENDPTSTAT should also be considered during this process. In case of endpoint error, the current dTD should not be pushed to the head of dQH since some dTDs may be still not executed. Therefore, the link logic is also improved accordingly. Signed-off-by: Xu Yang <xu.yang_2@nxp.com> --- Changes in v2: - modify comments - fix kernel test robot build warning by using cpu_to_le32 - add fix tag and cc stable Changes in v3: - remove fixes tag and stable maillist --- drivers/usb/chipidea/udc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index b9ccf62e0a50..0132bb25c9b5 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -612,10 +612,17 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) do { hw_write(ci, OP_USBCMD, USBCMD_ATDTW, USBCMD_ATDTW); tmp_stat = hw_read(ci, OP_ENDPTSTAT, BIT(n)); - } while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW)); + } while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW) && tmp_stat); hw_write(ci, OP_USBCMD, USBCMD_ATDTW, 0); if (tmp_stat) goto done; + + /* OP_ENDPTSTAT will be clear by HW when the endpoint met + * err. This dTD don't push to dQH if current dTD point is + * not the last one in previous request. + */ + if (hwep->qh.ptr->curr != cpu_to_le32(prevlastnode->dma)) + goto done; } /* QH configuration */ -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic 2024-09-26 2:29 ` [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic Xu Yang @ 2024-09-27 1:01 ` Peter Chen 0 siblings, 0 replies; 4+ messages in thread From: Peter Chen @ 2024-09-27 1:01 UTC (permalink / raw) To: Xu Yang; +Cc: gregkh, linux-usb, imx, jun.li On 24-09-26 10:29:05, Xu Yang wrote: > Currently, ATDTW semaphore is used to safety link new dTD to dQH. But this > code has a bug when the endpoint is already in error before polling ATDTW > or just met error during polling ATDTW. In that cases, ATDTW will never > turn to 1 and the cpu will busy loop there. > > When the endpoint met error, ENDPTSTAT will be cleared by HW. Therefore, > ENDPTSTAT should also be considered during this process. In case of > endpoint error, the current dTD should not be pushed to the head of dQH > since some dTDs may be still not executed. Therefore, the link logic is > also improved accordingly. > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Acked-by: Peter Chen <peter.chen@kernel.org> > > --- > Changes in v2: > - modify comments > - fix kernel test robot build warning by using cpu_to_le32 > - add fix tag and cc stable > Changes in v3: > - remove fixes tag and stable maillist > --- > drivers/usb/chipidea/udc.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index b9ccf62e0a50..0132bb25c9b5 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -612,10 +612,17 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) > do { > hw_write(ci, OP_USBCMD, USBCMD_ATDTW, USBCMD_ATDTW); > tmp_stat = hw_read(ci, OP_ENDPTSTAT, BIT(n)); > - } while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW)); > + } while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW) && tmp_stat); > hw_write(ci, OP_USBCMD, USBCMD_ATDTW, 0); > if (tmp_stat) > goto done; > + > + /* OP_ENDPTSTAT will be clear by HW when the endpoint met > + * err. This dTD don't push to dQH if current dTD point is > + * not the last one in previous request. > + */ > + if (hwep->qh.ptr->curr != cpu_to_le32(prevlastnode->dma)) > + goto done; > } > > /* QH configuration */ > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] usb: chipidea: udc: improve error recovery for ISO transfer 2024-09-26 2:29 [PATCH v3 1/3] usb: chipidea: udc: handle USB Error Interrupt if IOC not set Xu Yang 2024-09-26 2:29 ` [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic Xu Yang @ 2024-09-26 2:29 ` Xu Yang 1 sibling, 0 replies; 4+ messages in thread From: Xu Yang @ 2024-09-26 2:29 UTC (permalink / raw) To: peter.chen, gregkh; +Cc: linux-usb, imx, jun.li Impove device mode ISO transfer error tolerant by reprime the corresponding endpoint. The recovery steps when error occurs: - Delete the error dTD from dQH and giveback request to user. - Do reprime if dQH is not empty. - Do prime when new dTD is queued if dQH is empty Acked-by: Peter Chen <peter.chen@kernel.org> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> --- Changes in v2: - modify commit message - keep "hwreq->req.status = tmptoken & TD_STATUS" - giveback status 0 to user for isoc error case Changes in v3: - add Acked-by tag --- drivers/usb/chipidea/udc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 0132bb25c9b5..18c1882cf088 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -683,6 +683,7 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) unsigned remaining_length; unsigned actual = hwreq->req.length; struct ci_hdrc *ci = hwep->ci; + bool is_isoc = hwep->type == USB_ENDPOINT_XFER_ISOC; if (hwreq->req.status != -EALREADY) return -EINVAL; @@ -696,7 +697,7 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) int n = hw_ep_bit(hwep->num, hwep->dir); if (ci->rev == CI_REVISION_24 || - ci->rev == CI_REVISION_22) + ci->rev == CI_REVISION_22 || is_isoc) if (!hw_read(ci, OP_ENDPTSTAT, BIT(n))) reprime_dtd(ci, hwep, node); hwreq->req.status = -EALREADY; @@ -715,11 +716,15 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwreq->req.status = -EPROTO; break; } else if ((TD_STATUS_TR_ERR & hwreq->req.status)) { - hwreq->req.status = -EILSEQ; - break; + if (is_isoc) { + hwreq->req.status = 0; + } else { + hwreq->req.status = -EILSEQ; + break; + } } - if (remaining_length) { + if (remaining_length && !is_isoc) { if (hwep->dir == TX) { hwreq->req.status = -EPROTO; break; -- 2.34.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-27 1:02 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-26 2:29 [PATCH v3 1/3] usb: chipidea: udc: handle USB Error Interrupt if IOC not set Xu Yang 2024-09-26 2:29 ` [PATCH v3 2/3] usb: chipidea: udc: improve dTD link logic Xu Yang 2024-09-27 1:01 ` Peter Chen 2024-09-26 2:29 ` [PATCH v3 3/3] usb: chipidea: udc: improve error recovery for ISO transfer Xu Yang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox