Skip to content

Commit e2f1c8c

Browse files
scosumarckleinebudde
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent e3bff52 commit e2f1c8c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,6 @@ static int m_can_read_fifo(struct net_device *dev, u32 fgi)
530530
}
531531
stats->rx_packets++;
532532

533-
/* acknowledge rx fifo 0 */
534-
m_can_write(cdev, M_CAN_RXF0A, fgi);
535-
536533
timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16;
537534

538535
m_can_receive_skb(cdev, skb, timestamp);
@@ -553,8 +550,9 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
553550
u32 rxfs;
554551
u32 rx_count;
555552
u32 fgi;
553+
int ack_fgi = -1;
556554
int i;
557-
int err;
555+
int err = 0;
558556

559557
rxfs = m_can_read(cdev, M_CAN_RXF0S);
560558
if (!(rxfs & RXFS_FFL_MASK)) {
@@ -568,13 +566,20 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
568566
for (i = 0; i < rx_count && quota > 0; ++i) {
569567
err = m_can_read_fifo(dev, fgi);
570568
if (err)
571-
return err;
569+
break;
572570

573571
quota--;
574572
pkts++;
573+
ack_fgi = fgi;
575574
fgi = (++fgi >= cdev->mcfg[MRAM_RXF0].num ? 0 : fgi);
576575
}
577576

577+
if (ack_fgi != -1)
578+
m_can_write(cdev, M_CAN_RXF0A, ack_fgi);
579+
580+
if (err)
581+
return err;
582+
578583
return pkts;
579584
}
580585

0 commit comments

Comments
 (0)