kentindell / canis-can-sdk

Canis Labs CAN SDK
MIT License
30 stars 6 forks source link

Race conditions in bus-off handling of MCP25xxFD #4

Closed kentindell closed 1 year ago

kentindell commented 1 year ago
  1. When the bus-off condition occurs, the controller resets the TXQ and an interrupt is raised for the drivers. The drivers may already be writing a new frame into the controller which occurs after the reset. When the bus-off interrupt is eventually handled it clears all the host queues, but the frame entered into the controller may eventually become transmitted and the transmit event will become spurious. To handle this race, the bus off handler must erase the TXQ (the handler must also complete before bus-off recovery completes, which is at most 128 x 11 bit times = 1.4ms at 1Mbit/sec).

  2. After bus-off occurs there may be outstanding transmit events that must be handled using the host transmit queue structure before that queue is erased. This can be done in the bus-off handling ISR before the host structures are erased, or the ISR can handle transmit events before the bus off event.

kentindell commented 1 year ago

ISR now handles edge-triggered interrupts.