openwrt-misc icon indicating copy to clipboard operation
openwrt-misc copied to clipboard

mcp25xxfd pending mask off by one

Open RickMcConney opened this issue 4 years ago • 0 comments

I am suspecting that the code at line 1908 may have an error. if (pending_mask) fifo = fls(pending_mask); else fifo = priv->fifos.tx_fifo_start;

/* handle error - this should not happen... */
if (fifo >= priv->fifos.tx_fifo_start + priv->fifos.tx_fifos) {

If i set the bitrate of two can buses to be mismatched I get an expected bus error. However when I reset the rates to match the fifo value gets set to 32 by the if(pending_mask) returning true. I think this is because the fls will return 32 instead of the expected 31. So I think the code should be fifo = fls(pending_mask) - 1;

If I make this change I no longer get the error and the communication resumes.

However after such an error the pending mask always remains set. I am not sure where the pending mask should get cleared.

RickMcConney avatar Apr 08 '20 22:04 RickMcConney