• Marc Kleine-Budde's avatar
    can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum · b8e0ddd3
    Marc Kleine-Budde authored
    This is a preparatory patch to work around a problem similar to
    erratum DS80000789E 6 of the mcp2518fd, the other variants of the chip
    family (mcp2517fd and mcp251863) are probably also affected.
    
    Erratum DS80000789E 6 says "reading of the FIFOCI bits in the FIFOSTA
    register for an RX FIFO may be corrupted". However observation shows
    that this problem is not limited to RX FIFOs but also effects the TEF
    FIFO.
    
    When handling the TEF interrupt, the driver reads the FIFO header
    index from the TEF FIFO STA register of the chip.
    
    In the bad case, the driver reads a too large head index. In the
    original code, the driver always trusted the read value, which caused
    old CAN transmit complete events that were already processed to be
    re-processed.
    
    Instead of reading and trusting the head index, read the head index
    and calculate the number of CAN frames that were supposedly received -
    replace mcp251xfd_tef_ring_update() with mcp251xfd_get_tef_len().
    
    The mcp251xfd_handle_tefif() function reads the CAN transmit complete
    events from the chip, iterates over them and pushes them into the
    network stack. The original driver already contains code to detect old
    CAN transmit complete events, that will be updated in the next patch.
    
    Cc: Stefan Althöfer <Stefan.Althoefer@janztec.com>
    Cc: Thomas Kopp <thomas.kopp@microchip.com>
    Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    b8e0ddd3
mcp251xfd.h 29.4 KB