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

Drivers: QURT I2C do not use a static mutex for all I2C drivers #23523

Closed

Conversation

hendjoshsr71
Copy link
Member

Solved Problem

This makes the QURT I2C driver use a mutex per I2C bus.

Previously, if one I2C bus crashes or is hung it crashes all the other buses. For example the baro bus can get stalled if another bus gets stalled.

Note: The timeout to recognize an I2C bus is being held for too long is still on the order of 6 seconds at times. Far too long for safety of others devices on the same bus.

Changelog Entry

For release notes: QURT I2C do not use a static mutex for all I2C drivers

Test coverage

Tested by forcefully hanging the I2C bus before and after the change. Before this change the baro and voxl-pm busses on my system would crash when i forcefully hang a different bus.

@dagar dagar requested a review from katzfey August 9, 2024 14:14
@dagar
Copy link
Member

dagar commented Aug 9, 2024

This isn't necessarily per bus though right? Each driver has an instance of this I2C, so it sounds like you need an actual per bus mutex somewhere. We don't deal with this on NuttX because per bus locking is handled lower level by the OS driver.

@katzfey
Copy link
Contributor

katzfey commented Aug 9, 2024

Yes, @dagar you are absolutely correct. Needs to be per bus, not per driver instance.

@dagar
Copy link
Member

dagar commented Aug 9, 2024

FYI if everything I2C is a typical PX4 driver (I2CSPIDriverConfig) then you should already be fine as those are all going to run in a work queue (thread per bus).

@dagar dagar marked this pull request as draft August 9, 2024 16:58
@katzfey
Copy link
Contributor

katzfey commented Aug 9, 2024

Yes, it's currently all standard I2C driver stuff so good to know that it's only ever a single thread per bus. So don't really need a mutex at all then but I think I'll be paranoid and just change it to a per bus mutex in case some custom code comes along that needs it.

@katzfey
Copy link
Contributor

katzfey commented Aug 9, 2024

Made a new PR. #23531

@hendjoshsr71 hendjoshsr71 deleted the pr/main_qurt_i2c_mutex_per_bus branch August 9, 2024 22:17
@hendjoshsr71
Copy link
Member Author

Thanks Eric!

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