--- - branch: MAIN date: Sat May 14 19:44:26 UTC 2022 files: - new: '1.165' old: '1.164' path: src/sys/dev/usb/xhci.c pathrev: src/sys/dev/usb/xhci.c@1.165 type: modified id: 20220514T194426Z.558d434993a167dd6c955f19cfdd7db40ea63ba0 log: "xhci(4): Fix edge case in simultaneous xfer abort and failure.\n\nOn successful usbd_xfer_trycomplete, caller must set ux_status and\ncall usb_transfer_complete before releasing the pipe (bus) lock.\nFailing to call usb_transfer_complete is a mistake. Presumably this\nwas intended to claim the xfer to complete it only on the last\npacket.\n\nI previously introduced the violation of this rule when the code\nlooked like\n\n\txfer->ux_status = err;\n\tif (trb stuff)\n\t\tusb_transfer_complete(xfer);\n\nI mostly mechanically changed all the assignments of xfer->ux_status\nto do usbd_xfer_trycomplete first and then usb_transfer_complete.\n\nIn the original, the extra assignment of xfer->ux_status in the event\nwe _don't_ immediately call usb_transfer_complete was likely\nredundant and (except insofar as the abort protocol was broken)\nharmless. \ But now it is a problem because of the contract between\nusbd_xfer_trycomplete and usb_transfer_complete under the pipe (bus)\nlock. In retrospect, the original probably should have been\n\n\tif (trb stuff) {\n\t\txfer->ux_status = err;\n\t\tusb_transfer_complete(xfer);\n\t}\n\nand my mechanical transformation should have worked, but also in\nretrospect I should have put more thought into the change and done it\na little less mechanically.\n" module: src subject: 'CVS commit: src/sys/dev/usb' unixtime: '1652557466' user: riastradh