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

Avoid overwriting HCI buffer until sent #398

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

bjoernQ
Copy link
Contributor

@bjoernQ bjoernQ commented Jan 2, 2024

When implementing an BLE HID device it turned out that for BTDM based drivers we shouldn't touch the packet passed to API_vhci_host_send_packet until it's sent

API_vhci_host_check_send_available doesn't seem to be suitable for that - for an easy fix this uses the notify_host_send_available callback to toggle a flag which seems to fix the issue

NPL based drivers seem to copy the packet in their send function and are not affected

If this ever turns out to become a performance problem, we can implement something more advanced but for now it seems to be good enough

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@MabezDev MabezDev merged commit 90589fd into main Jan 2, 2024
8 checks passed
@bugadani
Copy link
Contributor

bugadani commented Jan 2, 2024

I guess it's too late but I'd have preferred waiting right before PACKET_SENT.store(false, Ordering::Relaxed);, so that the code doesn't unnecessarily burn CPU time.

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Jan 2, 2024

I guess it's too late but I'd have preferred waiting right before PACKET_SENT.store(false, Ordering::Relaxed);, so that the code doesn't unnecessarily burn CPU time.

I thought about it but then it's possible that code will overwrite the in-flight packet before it's completely processed

@bugadani
Copy link
Contributor

bugadani commented Jan 2, 2024

ah okay, makes sense I guess

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.

3 participants