Netdev List
 help / color / mirror / Atom feed
* [PATCH] can: m_can: Implement workaround for errata i2278 and i2279
@ 2026-05-14  6:55 Anurag Dutta
  2026-05-14 10:05 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Anurag Dutta @ 2026-05-14  6:55 UTC (permalink / raw)
  To: u-kumar1, vigneshr, gehariprasath, rcsekar, mkl, mailhol.vincent,
	andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: linux-can, netdev, a-dutta

Message transmit order is not guaranteed when dedicated TX buffers
configured with the same Message ID are submitted simultaneously via
TXBAR write. This is described in J7 errata i2278 and i2279.

As a workaround, introduce m_can_tx_peripheral_submit() to submit
buffers one at a time using ffs() to find the next pending buffer.
The TX complete interrupt(IR_TC) triggers submission of the next
buffer, ensuring strict FIFO ordering.

Link: https://www.ti.com/lit/pdf/sprz530
Signed-off-by: Anurag Dutta <a-dutta@ti.com>
---

 drivers/net/can/m_can/m_can.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index c2b1da87a9ee..1eb6397b79b9 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1225,6 +1225,17 @@ static void m_can_coalescing_update(struct m_can_classdev *cdev, u32 ir)
 			      HRTIMER_MODE_REL);
 }
 
+static void m_can_tx_peripheral_submit(struct m_can_classdev *cdev)
+{
+	int ffs_idx;
+
+	ffs_idx = ffs(cdev->tx_peripheral_submit);
+	if (ffs_idx > 0) {
+		m_can_write(cdev, M_CAN_TXBAR, ffs_idx - 1);
+		cdev->tx_peripheral_submit &= cdev->tx_peripheral_submit - 1;
+	}
+}
+
 /* This interrupt handler is called either from the interrupt thread or a
  * hrtimer. This has implications like cancelling a timer won't be possible
  * blocking.
@@ -1290,6 +1301,11 @@ static int m_can_interrupt_handler(struct m_can_classdev *cdev)
 			m_can_finish_tx(cdev, 1, frame_len);
 		}
 	} else  {
+		if (cdev->is_peripheral && (ir & IR_TC)) {
+			if (cdev->tx_peripheral_submit > 0)
+				m_can_tx_peripheral_submit(cdev);
+		}
+
 		if (ir & (IR_TEFN | IR_TEFW)) {
 			/* New TX FIFO Element arrived */
 			ret = m_can_echo_tx_event(dev);
@@ -1956,8 +1972,7 @@ static void m_can_tx_submit(struct m_can_classdev *cdev)
 	if (!cdev->is_peripheral)
 		return;
 
-	m_can_write(cdev, M_CAN_TXBAR, cdev->tx_peripheral_submit);
-	cdev->tx_peripheral_submit = 0;
+	m_can_tx_peripheral_submit(cdev);
 }
 
 static void m_can_tx_work_queue(struct work_struct *ws)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-14 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14  6:55 [PATCH] can: m_can: Implement workaround for errata i2278 and i2279 Anurag Dutta
2026-05-14 10:05 ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox