summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-05-19 13:32:49 +0700
committerhathach <[email protected]>2023-05-19 13:32:49 +0700
commit5dae5e12928ba789cd7e248edd9fa91376902925 (patch)
tree19c1585bd7f6c6da0124bef4749d3c3261e54460 /src/portable
parentf26a93908ef9dcde6818c9b271727ed6c77e87d8 (diff)
ehci fix dcache clean when control endpoint failed
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/ehci/ehci.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/portable/ehci/ehci.c b/src/portable/ehci/ehci.c
index cc825d549..10e2db7b5 100644
--- a/src/portable/ehci/ehci.c
+++ b/src/portable/ehci/ehci.c
@@ -577,7 +577,7 @@ void qhd_xfer_complete_isr(ehci_qhd_t * qhd) {
uint32_t const xferred_bytes = qtd->expected_bytes - qtd->total_bytes;
// invalidate dcache if IN transfer
- if (dir == 1 && qhd->attached_buffer != 0) {
+ if (dir == 1 && qhd->attached_buffer != 0 && xferred_bytes > 0) {
hcd_dcache_invalidate((void*) qhd->attached_buffer, xferred_bytes);
}
@@ -660,7 +660,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
if (qtd_overlay->halted) {
xfer_result_t xfer_result;
- if (qtd_overlay->err_count == 0 || qtd_overlay->buffer_err || qtd_overlay->babble_err || qtd_overlay->xact_err) {
+ if (qtd_overlay->xact_err || qtd_overlay->err_count == 0 || qtd_overlay->buffer_err || qtd_overlay->babble_err) {
// Error count = 0 often occurs when device disconnected, or other bus-related error
xfer_result = XFER_RESULT_FAILED;
}else {
@@ -671,7 +671,6 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
// if (XFER_RESULT_FAILED == xfer_result ) {
// TU_LOG1(" QHD xfer err count: %d\n", qtd_overlay->err_count);
// TU_BREAKPOINT(); // TODO skip unplugged device
-// while(1){}
// }
ehci_qtd_t * volatile qtd = (ehci_qtd_t * volatile) qhd->attached_qtd;
@@ -683,7 +682,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
uint32_t const xferred_bytes = qtd->expected_bytes - qtd->total_bytes;
// invalidate dcache if IN transfer
- if (dir == 1 && qhd->attached_buffer != 0) {
+ if (dir == 1 && qhd->attached_buffer != 0 && xferred_bytes > 0) {
hcd_dcache_invalidate((void*) qhd->attached_buffer, xferred_bytes);
}
@@ -698,8 +697,7 @@ void qhd_xfer_error_isr(ehci_qhd_t * qhd)
qhd->qtd_overlay.alternate.terminate = 1;
qhd->qtd_overlay.halted = 0;
- ehci_qtd_t *p_setup = qtd_control(qhd->dev_addr);
- p_setup->used = 0;
+ hcd_dcache_clean(qhd, sizeof(ehci_qhd_t));
}
// notify usbh