can: m_can: Batch acknowledge rx fifo

Instead of acknowledging every item of the fifo, only acknowledge the
last item read. This behavior is documented in the datasheet. The new
getindex will be the acknowledged item + 1.

Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
Link: https://lore.kernel.org/all/20221206115728.1056014-8-msp@baylibre.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Markus Schneider-Pargmann 2022-12-06 12:57:24 +01:00 committed by Marc Kleine-Budde
parent e3bff5256a
commit e2f1c8cb02
1 changed files with 10 additions and 5 deletions

View File

@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi)
}
stats->rx_packets++;
/* acknowledge rx fifo 0 */
m_can_write(cdev, M_CAN_RXF0A, fgi);
timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16;
m_can_receive_skb(cdev, skb, timestamp);
@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
u32 rxfs;
u32 rx_count;
u32 fgi;
int ack_fgi = -1;
int i;
int err;
int err = 0;
rxfs = m_can_read(cdev, M_CAN_RXF0S);
if (!(rxfs & RXFS_FFL_MASK)) {
@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
for (i = 0; i < rx_count && quota > 0; ++i) {
err = m_can_read_fifo(dev, fgi);
if (err)
return err;
break;
quota--;
pkts++;
ack_fgi = fgi;
fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi);
}
if (ack_fgi != -1)
m_can_write(cdev, M_CAN_RXF0A, ack_fgi);
if (err)
return err;
return pkts;
}