From be3ce6d7e933247a442841f1f0291d4926ff5b88 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 31 Jan 2024 13:54:53 -0500 Subject: [PATCH] USB: Make "buffer error" reporting consistent. This error means that the controller failed to read or write data to/from system memory fast enough. As a result, we should report it as READ_ERROR/WRITE_ERROR, rather than something that sounds like an error with the device itself. Then, make BABBLE reporting consistent: this is a data overrun/underrun of the device itself, not the buffers passed to the controller. This then leaves B_DEV_FIFO_OVERRUN/UNDERRUN unused, and thus usable for reporting ring overrun/underrun on isochronous transfers. The API documentation already described DATA_OVERRUN/UNDERRUN basically like they were babble errors, while FIFO_OVERRUN/UNDERRUN are currently described as "internal errors" at present. No driver actually checked for these. --- src/add-ons/kernel/busses/usb/ehci.cpp | 4 ++-- src/add-ons/kernel/busses/usb/ohci.cpp | 4 ++-- src/add-ons/kernel/busses/usb/uhci.cpp | 4 ++-- src/add-ons/kernel/busses/usb/xhci.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp index 934581dbcc..e294692a62 100644 --- a/src/add-ons/kernel/busses/usb/ehci.cpp +++ b/src/add-ons/kernel/busses/usb/ehci.cpp @@ -1900,7 +1900,7 @@ EHCI::FinishTransfers() int32 reasons = 0; if (status & EHCI_QTD_STATUS_BUFFER) { callbackStatus = transfer->incoming - ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; + ? B_DEV_WRITE_ERROR : B_DEV_READ_ERROR; reasons++; } if (status & EHCI_QTD_STATUS_TERROR) { @@ -1928,7 +1928,7 @@ EHCI::FinishTransfers() } else if (status & EHCI_QTD_STATUS_BABBLE) { // there is a babble condition callbackStatus = transfer->incoming - ? B_DEV_FIFO_OVERRUN : B_DEV_FIFO_UNDERRUN; + ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; } else { // if the error counter didn't count down to zero // and there was no babble, then this halt was caused diff --git a/src/add-ons/kernel/busses/usb/ohci.cpp b/src/add-ons/kernel/busses/usb/ohci.cpp index 680c081446..5c27752eb2 100644 --- a/src/add-ons/kernel/busses/usb/ohci.cpp +++ b/src/add-ons/kernel/busses/usb/ohci.cpp @@ -2594,10 +2594,10 @@ OHCI::_GetStatusOfConditionCode(uint8 conditionCode) return B_DEV_DATA_UNDERRUN; case OHCI_TD_CONDITION_BUFFER_OVERRUN: - return B_DEV_FIFO_OVERRUN; + return B_DEV_WRITE_ERROR; case OHCI_TD_CONDITION_BUFFER_UNDERRUN: - return B_DEV_FIFO_UNDERRUN; + return B_DEV_READ_ERROR; case OHCI_TD_CONDITION_NOT_ACCESSED: return B_DEV_PENDING; diff --git a/src/add-ons/kernel/busses/usb/uhci.cpp b/src/add-ons/kernel/busses/usb/uhci.cpp index 8c3ca73bbc..0581b09042 100644 --- a/src/add-ons/kernel/busses/usb/uhci.cpp +++ b/src/add-ons/kernel/busses/usb/uhci.cpp @@ -1527,7 +1527,7 @@ UHCI::FinishTransfers() // the error counter counted down to zero, report why int32 reasons = 0; if (status & TD_STATUS_ERROR_BUFFER) { - callbackStatus = transfer->incoming ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; + callbackStatus = transfer->incoming ? B_DEV_WRITE_ERROR : B_DEV_READ_ERROR; reasons++; } if (status & TD_STATUS_ERROR_TIMEOUT) { @@ -1547,7 +1547,7 @@ UHCI::FinishTransfers() callbackStatus = B_DEV_MULTIPLE_ERRORS; } else if (status & TD_STATUS_ERROR_BABBLE) { // there is a babble condition - callbackStatus = transfer->incoming ? B_DEV_FIFO_OVERRUN : B_DEV_FIFO_UNDERRUN; + callbackStatus = transfer->incoming ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; } else { // if the error counter didn't count down to zero // and there was no babble, then this halt was caused diff --git a/src/add-ons/kernel/busses/usb/xhci.cpp b/src/add-ons/kernel/busses/usb/xhci.cpp index e66448b126..2fa4c81349 100644 --- a/src/add-ons/kernel/busses/usb/xhci.cpp +++ b/src/add-ons/kernel/busses/usb/xhci.cpp @@ -270,9 +270,9 @@ xhci_error_status(uint32 error, bool directionIn) case COMP_SUCCESS: return B_OK; case COMP_DATA_BUFFER: - return directionIn ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; + return directionIn ? B_DEV_WRITE_ERROR : B_DEV_READ_ERROR; case COMP_BABBLE: - return directionIn ? B_DEV_FIFO_OVERRUN : B_DEV_FIFO_UNDERRUN; + return directionIn ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; case COMP_MISSED_SERVICE: return B_DEV_TOO_LATE; case COMP_USB_TRANSACTION: