Skip to content

Commit 80c5bac

Browse files
scosumarckleinebudde
authored andcommitted
can: m_can: Cache tx putidx
m_can_tx_handler is the only place where data is written to the tx fifo. We can calculate the putidx in the driver code here to avoid the dependency on the txfqs register. Signed-off-by: Markus Schneider-Pargmann <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 14f0a0a commit 80c5bac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,10 @@ static int m_can_start(struct net_device *dev)
15041504

15051505
m_can_enable_all_interrupts(cdev);
15061506

1507+
if (cdev->version > 30)
1508+
cdev->tx_fifo_putidx = FIELD_GET(TXFQS_TFQPI_MASK,
1509+
m_can_read(cdev, M_CAN_TXFQS));
1510+
15071511
return 0;
15081512
}
15091513

@@ -1793,7 +1797,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
17931797
}
17941798

17951799
/* get put index for frame */
1796-
putidx = FIELD_GET(TXFQS_TFQPI_MASK, txfqs);
1800+
putidx = cdev->tx_fifo_putidx;
17971801

17981802
/* Construct DLC Field, with CAN-FD configuration.
17991803
* Use the put index of the fifo as the message marker,
@@ -1827,6 +1831,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
18271831

18281832
/* Enable TX FIFO element to start transfer */
18291833
m_can_write(cdev, M_CAN_TXBAR, (1 << putidx));
1834+
cdev->tx_fifo_putidx = (++cdev->tx_fifo_putidx >= cdev->can.echo_skb_max ?
1835+
0 : cdev->tx_fifo_putidx);
18301836

18311837
/* stop network queue if fifo full */
18321838
if (m_can_tx_fifo_full(cdev) ||

drivers/net/can/m_can/m_can.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ struct m_can_classdev {
101101
u32 tx_max_coalesced_frames_irq;
102102
u32 tx_coalesce_usecs_irq;
103103

104+
// Store this internally to avoid fetch delays on peripheral chips
105+
int tx_fifo_putidx;
106+
104107
struct mram_cfg mcfg[MRAM_CFG_NUM];
105108

106109
struct hrtimer hrtimer;

0 commit comments

Comments
 (0)