Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for locking when USB sends fail (e.g. on BLE only) #96

Conversation

petejohanson
Copy link
Contributor

@petejohanson petejohanson commented Aug 18, 2020

No description provided.

@petejohanson petejohanson changed the title core/usb-hid-error-release-semaphore Fix for locking when USB sends fail (e.g. on BLE only) Aug 18, 2020
@petejohanson petejohanson force-pushed the core/usb-hid-error-release-semaphore branch from f55b514 to e99ebbb Compare Aug 18, 2020
k_sem_take(&hid_sem, K_FOREVER);
return hid_int_ep_write(hid_dev, report, len, NULL);
int err = hid_int_ep_write(hid_dev, report, len, NULL);

if (err) {
k_sem_give(&hid_sem);
}

return err;
Copy link
Contributor

@careyk007 careyk007 Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a bad feeling about this shortly after the PR was merged. I think changing K_FOREVER to a sensible value would help prevent any future issues. I'm not too familiar with the USB protocol, so I have no idea what a sensible value would be though, but I would guess ~30ms would be a good starting point.

Copy link
Contributor Author

@petejohanson petejohanson Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@careyk007 No worries. It happens.

I took your suggestion and removed the use of K_FOREVER, and additionally, added code to first check the usb status we're already tracking before even trying to send the value to the EP.

@petejohanson petejohanson force-pushed the core/usb-hid-error-release-semaphore branch from e99ebbb to 6d6dd09 Compare Aug 18, 2020
@petejohanson petejohanson force-pushed the core/usb-hid-error-release-semaphore branch from 6d6dd09 to 66c4b7e Compare Aug 18, 2020
@petejohanson petejohanson merged commit 1ae9e9d into zmkfirmware:main Aug 18, 2020
1 check passed
MangoIV referenced this pull request in MangoIV/zmk Dec 18, 2020
…emaphore

Fix for locking when USB sends fail (e.g. on BLE only)
tyalie pushed a commit to tyalie/zmk that referenced this pull request Nov 15, 2022
…r-release-semaphore

Fix for locking when USB sends fail (e.g. on BLE only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants