ta_set_timeout can fail to set an alarm#2127
Conversation
If alarm_pool_irq_handler takes <1us between handling an alarm and calling ta_set_timeout then no alarms will be set as it will appear as if an earlier alarm is already armedi before the target time. Make sure ta_set_timeout always leaves with an alarm set by checking the armed status. Fixes raspberrypi#2118
|
From #2118: why does this not loop? |
earliest_target is correct and > the current time so the loop will exit. We've just called ta_set_timeout with earliest_target, but that's no guarantee that the alarm was set to this time IF it thinks there's an earlier alarm. It will wrongly think there's an earlier alarm set if the current alarm time == current time. |
|
ok, this is really difficult to follow; please annotate the callee and caller code (the two fragments above) with all the values at each place |
|
|
OK, i agree this makes sense.... Also while looking, i think we should clear the arming in can you please add that to this PR |
Good spot. I've added that change. |
38c9d03 to
2282b2b
Compare
|
nice! |
If alarm_pool_irq_handler takes <1us between handling an alarm and calling ta_set_timeout then no alarms will be set as it will appear as if an earlier alarm is already armedi before the target time.
Make sure ta_set_timeout always leaves with an alarm set by checking the armed status.
Fixes #2118