Commit 16164b9f authored by Martin Jeřábek's avatar Martin Jeřábek

driver: ctucan_tx_interrupt fix potential race condition

parent 4f60c183
...@@ -628,13 +628,11 @@ static void ctucan_tx_interrupt(struct net_device *ndev) ...@@ -628,13 +628,11 @@ static void ctucan_tx_interrupt(struct net_device *ndev)
/* do not clear nor wake */ /* do not clear nor wake */
return; return;
} }
/* some_buffers_processed is still false */
goto clear; goto clear;
} }
priv->txb_tail++; priv->txb_tail++;
first = false; first = false;
some_buffers_processed = true; some_buffers_processed = true;
/* Adjust priorities *before* marking the buffer /* Adjust priorities *before* marking the buffer
* as empty. * as empty.
*/ */
...@@ -642,11 +640,16 @@ static void ctucan_tx_interrupt(struct net_device *ndev) ...@@ -642,11 +640,16 @@ static void ctucan_tx_interrupt(struct net_device *ndev)
ctu_can_fd_txt_set_empty(&priv->p, txb_idx); ctu_can_fd_txt_set_empty(&priv->p, txb_idx);
} }
clear: clear:
/* Clear the interrupt again as not to receive it again for /* If no buffers were processed this time, wa cannot
* a buffer we already handled (possibly causing the bug log) * clear - that would introduce a race condition. */
*/ if (some_buffers_processed) {
ctu_can_fd_int_clr(&priv->p, icr); /* Clear the interrupt again as not to receive it again
* for a buffer we already handled (possibly causing
* the bug log) */
ctu_can_fd_int_clr(&priv->p, icr);
}
} while (some_buffers_processed); } while (some_buffers_processed);
can_led_event(ndev, CAN_LED_EVENT_TX); can_led_event(ndev, CAN_LED_EVENT_TX);
netif_wake_queue(ndev); netif_wake_queue(ndev);
} }
...@@ -696,9 +699,7 @@ static irqreturn_t ctucan_interrupt(int irq, void *dev_id) ...@@ -696,9 +699,7 @@ static irqreturn_t ctucan_interrupt(int irq, void *dev_id)
/* TX Buffer HW Command Interrupt */ /* TX Buffer HW Command Interrupt */
if (isr.s.txbhci) { if (isr.s.txbhci) {
netdev_dbg(ndev, "TXBHCI"); netdev_dbg(ndev, "TXBHCI");
icr.u32 = 0; /* Cleared inside */
icr.s.txbhci = 1;
ctu_can_fd_int_clr(&priv->p, icr);
ctucan_tx_interrupt(ndev); ctucan_tx_interrupt(ndev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment