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.
This commit is contained in:
Augustin Cavalier 2024-01-31 13:54:53 -05:00
parent 22f0158a25
commit be3ce6d7e9
4 changed files with 8 additions and 8 deletions

View File

@ -1900,7 +1900,7 @@ EHCI::FinishTransfers()
int32 reasons = 0; int32 reasons = 0;
if (status & EHCI_QTD_STATUS_BUFFER) { if (status & EHCI_QTD_STATUS_BUFFER) {
callbackStatus = transfer->incoming callbackStatus = transfer->incoming
? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN; ? B_DEV_WRITE_ERROR : B_DEV_READ_ERROR;
reasons++; reasons++;
} }
if (status & EHCI_QTD_STATUS_TERROR) { if (status & EHCI_QTD_STATUS_TERROR) {
@ -1928,7 +1928,7 @@ EHCI::FinishTransfers()
} else if (status & EHCI_QTD_STATUS_BABBLE) { } else if (status & EHCI_QTD_STATUS_BABBLE) {
// there is a babble condition // there is a babble condition
callbackStatus = transfer->incoming callbackStatus = transfer->incoming
? B_DEV_FIFO_OVERRUN : B_DEV_FIFO_UNDERRUN; ? B_DEV_DATA_OVERRUN : B_DEV_DATA_UNDERRUN;
} else { } else {
// if the error counter didn't count down to zero // if the error counter didn't count down to zero
// and there was no babble, then this halt was caused // and there was no babble, then this halt was caused

View File

@ -2594,10 +2594,10 @@ OHCI::_GetStatusOfConditionCode(uint8 conditionCode)
return B_DEV_DATA_UNDERRUN; return B_DEV_DATA_UNDERRUN;
case OHCI_TD_CONDITION_BUFFER_OVERRUN: case OHCI_TD_CONDITION_BUFFER_OVERRUN:
return B_DEV_FIFO_OVERRUN; return B_DEV_WRITE_ERROR;
case OHCI_TD_CONDITION_BUFFER_UNDERRUN: case OHCI_TD_CONDITION_BUFFER_UNDERRUN:
return B_DEV_FIFO_UNDERRUN; return B_DEV_READ_ERROR;
case OHCI_TD_CONDITION_NOT_ACCESSED: case OHCI_TD_CONDITION_NOT_ACCESSED:
return B_DEV_PENDING; return B_DEV_PENDING;

View File

@ -1527,7 +1527,7 @@ UHCI::FinishTransfers()
// the error counter counted down to zero, report why // the error counter counted down to zero, report why
int32 reasons = 0; int32 reasons = 0;
if (status & TD_STATUS_ERROR_BUFFER) { 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++; reasons++;
} }
if (status & TD_STATUS_ERROR_TIMEOUT) { if (status & TD_STATUS_ERROR_TIMEOUT) {
@ -1547,7 +1547,7 @@ UHCI::FinishTransfers()
callbackStatus = B_DEV_MULTIPLE_ERRORS; callbackStatus = B_DEV_MULTIPLE_ERRORS;
} else if (status & TD_STATUS_ERROR_BABBLE) { } else if (status & TD_STATUS_ERROR_BABBLE) {
// there is a babble condition // 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 { } else {
// if the error counter didn't count down to zero // if the error counter didn't count down to zero
// and there was no babble, then this halt was caused // and there was no babble, then this halt was caused

View File

@ -270,9 +270,9 @@ xhci_error_status(uint32 error, bool directionIn)
case COMP_SUCCESS: case COMP_SUCCESS:
return B_OK; return B_OK;
case COMP_DATA_BUFFER: 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: 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: case COMP_MISSED_SERVICE:
return B_DEV_TOO_LATE; return B_DEV_TOO_LATE;
case COMP_USB_TRANSACTION: case COMP_USB_TRANSACTION: