On 09/16/2014 05:18 PM, David Jander wrote: > On Tue, 16 Sep 2014 16:20:33 +0200 > Marc Kleine-Budde wrote: > >> After sending a RTR frame the TX mailbox becomes a RX_EMPTY mailbox. To avoid >> side effects when the RX-FIFO is full, this patch puts the TX mailbox into >> TX_INACTIVE mode after the transmission has been completed. >> >> Signed-off-by: Marc Kleine-Budde >> --- >> >> Changes since v3: >> - new >> >> drivers/net/can/flexcan.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c >> index 54061c4..c17ae9e 100644 >> --- a/drivers/net/can/flexcan.c >> +++ b/drivers/net/can/flexcan.c >> @@ -765,6 +765,9 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id) >> stats->tx_bytes += can_get_echo_skb(dev, 0); >> stats->tx_packets++; >> can_led_event(dev, CAN_LED_EVENT_TX); >> + /* after sending a RTR frame mailbox is in RX mode */ >> + flexcan_write(FLEXCAN_MB_CODE_TX_INACTIVE, >> + ®s->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl); >> flexcan_write((1 << FLEXCAN_TX_BUF_ID), ®s->iflag1); >> netif_wake_queue(dev); >> } > > Good one. I hadn't notice that case yet. Just stumbled over it, the reference manual is a bit vague, it this mailbox will receive any CAN frame or just a CAN frame with the same ID. > Since you do this in the IRQ, I assume the expected race-condition window is > minimal, but AFAICS there is stil a (very) small chance of a race if an Yes, there's a race window. > overflow message arrives before this code in the IRQ handler is reached. > Both chance of occurring and impact is so small that it will not likely be a > problem ever... besides the fact that it cannot be avoided. Should this be > mentioned? Good point, I'll add a comment to the code. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |