Netdev List
 help / color / mirror / Atom feed
From: Anurag Dutta <a-dutta@ti.com>
To: <u-kumar1@ti.com>, <vigneshr@ti.com>, <gehariprasath@ti.com>,
	<rcsekar@samsung.com>, <mkl@pengutronix.de>,
	<mailhol.vincent@wanadoo.fr>, <andrew+netdev@lunn.ch>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>
Cc: <linux-can@vger.kernel.org>, <netdev@vger.kernel.org>, <a-dutta@ti.com>
Subject: [PATCH] can: m_can: Implement workaround for errata i2278 and i2279
Date: Thu, 14 May 2026 12:25:11 +0530	[thread overview]
Message-ID: <20260514065511.3573223-1-a-dutta@ti.com> (raw)

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


             reply	other threads:[~2026-05-14  6:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14  6:55 Anurag Dutta [this message]
2026-05-14 10:05 ` [PATCH] can: m_can: Implement workaround for errata i2278 and i2279 Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514065511.3573223-1-a-dutta@ti.com \
    --to=a-dutta@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gehariprasath@ti.com \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol.vincent@wanadoo.fr \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rcsekar@samsung.com \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox