• Thomas Gleixner's avatar
    can: c_can: Fix buffer ordering · 64f08f2f
    Thomas Gleixner authored
    The buffer handling of c_can has been broken forever. That leads to
    message reordering:
    
    ksoftirqd/0-3     [000] ..s.    79.123776: c_can_poll: rx_poll: val: 00007fff
    ksoftirqd/0-3     [000] ..s.    79.124101: c_can_poll: rx_poll: val: 00008001
    
    What happens is:
    
    CPU				HW
    				queue new packet into obj 16 (0-15 are busy)
    read obj 1-15
    return because pending is 0
    				set pending obj 16 -> pending reg 8000
    				queue new packet into obj 1
    				set pending obj 1 -> pending reg 8001
    
    So the current algorithmus reads the newest message first, which
    violates the ordering rules of CAN.
    
    Add proper handling of that situation by analyzing the contents of the
    pending register for gaps.
    
    This does NOT fix the message object corruption which can lead to
    interrupt storms. Thats addressed in the next patches.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    [mkl: adjusted subject]
    Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    64f08f2f
c_can.c 36.3 KB