• Alexander Stein's avatar
    can: flexcan: Always use last mailbox for TX · cbffaf7a
    Alexander Stein authored
    Essentially this patch moves the TX mailbox to position 63, regardless
    of timestamp based offloading or RX FIFO. So mainly the iflag register
    usage regarding TX has changed. The rest is consolidating RX FIFO and
    timestamp offloading as they now use both the same TX mailbox.
    
    The reason is a very annoying behavior regarding sending RTR frames when
    _not_ using RX FIFO:
    
    If a TX mailbox sent a RTR frame it becomes a RX mailbox. For that
    reason flexcan_irq disables the TX mailbox again. But if during the time
    the RTR was sent and the TX mailbox is disabled a new CAN frames is
    received, it is lost without notice. The reason is that so-called
    "Move-in" process starts from the lowest mailbox which happen to be a TX
    mailbox set to EMPTY.
    
    Steps to reproduce (I used an imx7d):
    1. generate regular bursts of messages
    2. send a RTR from flexcan with higher priority than burst messages every
       1ms, e.g. cangen -I 0x100 -L 0 -g 1 -R can0
    3. notice a lost message without notification after some seconds
    
    When running an iperf in parallel this problem is occurring even more
    frequently. Using filters is not possible as at least one single CAN-ID
    is allowed. Handling the TX MB during RX is also not possible as there
    is no race-free disable of RX MB.
    
    There is still a slight window when the described problem can occur. But
    for that all RX MB must be in use which is essentially next to an
    overrun. Still there will be no indication if it ever occurs.
    Signed-off-by: default avatarAlexander Stein <alexander.stein@systec-electronic.com>
    Cc: linux-stable <stable@vger.kernel.org>
    Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
    cbffaf7a
flexcan.c 41.2 KB