Skip to content

driver_vive: clear_halt before submit_transfer in AttachInterface#356

Open
rocketmark wants to merge 1 commit intocollabora:masterfrom
rocketmark:upstream-pr/clear-halt
Open

driver_vive: clear_halt before submit_transfer in AttachInterface#356
rocketmark wants to merge 1 commit intocollabora:masterfrom
rocketmark:upstream-pr/clear-halt

Conversation

@rocketmark
Copy link
Contributor

Summary

AttachInterface calls libusb_submit_transfer() without first clearing any halt condition on the endpoint. If the endpoint is stalled — from a previous session, a failed transfer, or a device re-enumeration — the submit returns LIBUSB_ERROR_PIPE (-9) and the interface attachment fails silently.

Demonstration

BEFOREAttachInterface in src/driver_vive.c:

iface->last_submit_time = OGGetAbsoluteTimeUS();
int rc = libusb_submit_transfer(tx);
if (rc) {
    SV_ERROR(SURVIVE_ERROR_HARWARE_FAULT, "Error: Could not submit transfer …");
    return 6;
}

AFTER:

iface->last_submit_time = OGGetAbsoluteTimeUS();

libusb_clear_halt(devh, endpoint_num);

int rc = libusb_submit_transfer(tx);

Impact

Without this, any stalled endpoint causes AttachInterface to fail with LIBUSB_ERROR_PIPE. The device appears to open successfully but receives no data. The fix matches standard libusb practice: always clear halt before the first submit.

Change

One call to libusb_clear_halt(devh, endpoint_num) before libusb_submit_transfer() in the libusb path of AttachInterface.

Found via

Observed on hardware after device re-enumeration left an endpoint halted; libusb_submit_transfer returned -9 and tracking never started.

A stalled USB endpoint must be cleared before resubmitting a transfer.
Without libusb_clear_halt(), libusb_submit_transfer() will return
LIBUSB_ERROR_PIPE (-9) on any endpoint left halted from a previous
session or failed transfer, causing the interface attachment to fail.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rocketmark rocketmark force-pushed the upstream-pr/clear-halt branch from 610a6a8 to 9f86cc6 Compare March 22, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant