can: flexcan: handle tx-complete CAN frames via rx-offload infrastructure
authorOleksij Rempel <o.rempel@pengutronix.de>
Tue, 18 Sep 2018 09:40:39 +0000 (11:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:37:29 +0000 (09:37 +0100)
commit ed72bc8bcb9277061e753faf300b20f97323761c upstream.

Current flexcan driver will put TX-ECHO in regular unsorted way, in
this case TX-ECHO can come after the response to the same TXed message.
In some cases, for example for J1939 stack, things will break.
This patch is using new rx-offload API to put the messages just in the
right place.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/can/flexcan.c

index 08bb6f8..b1239b5 100644 (file)
@@ -794,8 +794,11 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
 
        /* transmission complete interrupt */
        if (reg_iflag1 & FLEXCAN_IFLAG_MB(priv->tx_mb_idx)) {
+               u32 reg_ctrl = priv->read(&regs->mb[FLEXCAN_TX_MB].can_ctrl);
+
                handled = IRQ_HANDLED;
-               stats->tx_bytes += can_get_echo_skb(dev, 0);
+               stats->tx_bytes += can_rx_offload_get_echo_skb(&priv->offload,
+                                                              0, reg_ctrl << 16);
                stats->tx_packets++;
                can_led_event(dev, CAN_LED_EVENT_TX);