Skip to contentSkip to conversation

can: ctucanfd: handle bus error interrupts

PATCH In review Avi Weiss 4 participants 4 messages Jul 23 – Jul 24

Subsystems (4)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 can: ctucanfd: handle bus error interrupts

Include REG_INT_STAT_BEI in the top-level error interrupt condition.

BEI is enabled when CAN_CTRLMODE_BERR_REPORTING is requested and ctucan_err_interrupt() already handles it. Without checking and clearing BEI in the top-level handler, bus error interrupts are not handled or acknowledged.

Fixes 2dcb8e8782d8 ("can: ctucanfd: add support for CTU CAN FD open-source IP core - bus independent part.")
---
 drivers/net/can/ctucanfd/ctucanfd_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/can/ctucanfd/ctucanfd_base.c +6 -2
index 0ea1ff28dfce..0cd2d428c1f1 100644
@@ -1136,8 +1136,12 @@ static irqreturn_t ctucan_interrupt(int irq, void *dev_id)
 		/* Error interrupts */
 		if (FIELD_GET(REG_INT_STAT_EWLI, isr) ||
 		    FIELD_GET(REG_INT_STAT_FCSI, isr) ||
-		    FIELD_GET(REG_INT_STAT_ALI, isr)) {
-			icr = isr & (REG_INT_STAT_EWLI | REG_INT_STAT_FCSI | REG_INT_STAT_ALI);
+		    FIELD_GET(REG_INT_STAT_ALI, isr) ||
+		    FIELD_GET(REG_INT_STAT_BEI, isr)) {
+			icr = isr & (REG_INT_STAT_EWLI |
+				     REG_INT_STAT_FCSI |
+				     REG_INT_STAT_ALI |
+				     REG_INT_STAT_BEI);
 
 			ctucan_netdev_dbg(ndev, "some ERR interrupt: clearing 0x%08x\n", icr);
 			ctucan_write32(priv, CTUCANFD_INT_STAT, icr);
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw

Hello Avi,

thanks for correction.

Quoted 24 lines · On Thursday 23 of July 2026 09:44:03 Avi Weiss wrote:

Include REG_INT_STAT_BEI in the top-level error interrupt condition.

BEI is enabled when CAN_CTRLMODE_BERR_REPORTING is requested and ctucan_err_interrupt() already handles it. Without checking and clearing BEI in the top-level handler, bus error interrupts are not handled or acknowledged.

Fixes 2dcb8e8782d8 ("can: ctucanfd: add support for CTU CAN FD open-source

IP core - bus independent part.") Signed-off-by: Avi Weiss <[email protected]>

---
 drivers/net/can/ctucanfd/ctucanfd_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/can/ctucanfd/ctucanfd_base.c index 0ea1ff28dfce..0cd2d428c1f1 100644

drivers/net/can/ctucanfd/ctucanfd_base.c +0 -1
@@ -1136,8 +1136,12 @@ static irqreturn_t ctucan_interrupt(int irq, void
 *dev_id) /* Error interrupts */
 		if (FIELD_GET(REG_INT_STAT_EWLI, isr) ||
 		    FIELD_GET(REG_INT_STAT_FCSI, isr) ||
-		    FIELD_GET(REG_INT_STAT_ALI, isr)) {

drivers/net/can/ctucanfd/ctucanfd_base.c static irqreturn_t ctucan_interrupt(int irq, void · line 1147

Quoted 10 lines
drivers/net/can/ctucanfd/ctucanfd_base.c +6 -1
-			icr = isr & (REG_INT_STAT_EWLI | REG_INT_STAT_FCSI | REG_INT_STAT_ALI);
+		    FIELD_GET(REG_INT_STAT_ALI, isr) ||
+		    FIELD_GET(REG_INT_STAT_BEI, isr)) {
+			icr = isr & (REG_INT_STAT_EWLI |
+				     REG_INT_STAT_FCSI |
+				     REG_INT_STAT_ALI |
+				     REG_INT_STAT_BEI);
 
 			ctucan_netdev_dbg(ndev, "some ERR interrupt: clearing 0x%08x\n", icr);
 			ctucan_write32(priv, CTUCANFD_INT_STAT, icr);

Pavel Pisa
phone: +420 603531357
e-mail: [email protected]
Department of Control Engineering FEE CVUT Karlovo namesti 13, 121 35, Prague 2
university: http://control.fel.cvut.cz/
personal: http://cmp.felk.cvut.cz/~pisa
social: https://social.kernel.org/ppisa
projects: https://www.openhub.net/accounts/ppisa
CAN related:http://canbus.pages.fel.cvut.cz/ RISC-V education: https://comparch.edu.cvut.cz/
Open Technologies Research Education and Exchange Services
https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home

Acked-by on v1 1/1
#2 lore raw
In reply to Avi Weiss

Hello Avi,

thanks for correction.

Quoted 24 lines · On Thursday 23 of July 2026 09:44:03 Avi Weiss wrote:

Include REG_INT_STAT_BEI in the top-level error interrupt condition.

BEI is enabled when CAN_CTRLMODE_BERR_REPORTING is requested and ctucan_err_interrupt() already handles it. Without checking and clearing BEI in the top-level handler, bus error interrupts are not handled or acknowledged.

Fixes 2dcb8e8782d8 ("can: ctucanfd: add support for CTU CAN FD open-source

IP core - bus independent part.") Signed-off-by: Avi Weiss <[email protected]>

---
 drivers/net/can/ctucanfd/ctucanfd_base.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/can/ctucanfd/ctucanfd_base.c index 0ea1ff28dfce..0cd2d428c1f1 100644

drivers/net/can/ctucanfd/ctucanfd_base.c +0 -1
@@ -1136,8 +1136,12 @@ static irqreturn_t ctucan_interrupt(int irq, void
 *dev_id) /* Error interrupts */
 		if (FIELD_GET(REG_INT_STAT_EWLI, isr) ||
 		    FIELD_GET(REG_INT_STAT_FCSI, isr) ||
-		    FIELD_GET(REG_INT_STAT_ALI, isr)) {

drivers/net/can/ctucanfd/ctucanfd_base.c static irqreturn_t ctucan_interrupt(int irq, void · line 1147

Quoted 10 lines
drivers/net/can/ctucanfd/ctucanfd_base.c +6 -1
-			icr = isr & (REG_INT_STAT_EWLI | REG_INT_STAT_FCSI | REG_INT_STAT_ALI);
+		    FIELD_GET(REG_INT_STAT_ALI, isr) ||
+		    FIELD_GET(REG_INT_STAT_BEI, isr)) {
+			icr = isr & (REG_INT_STAT_EWLI |
+				     REG_INT_STAT_FCSI |
+				     REG_INT_STAT_ALI |
+				     REG_INT_STAT_BEI);
 
 			ctucan_netdev_dbg(ndev, "some ERR interrupt: clearing 0x%08x\n", icr);
 			ctucan_write32(priv, CTUCANFD_INT_STAT, icr);

Pavel Pisa
phone: +420 603531357
e-mail: [email protected]
Department of Control Engineering FEE CVUT Karlovo namesti 13, 121 35, Prague 2
university: http://control.fel.cvut.cz/
personal: http://cmp.felk.cvut.cz/~pisa
social: https://social.kernel.org/ppisa
projects: https://www.openhub.net/accounts/ppisa
CAN related:http://canbus.pages.fel.cvut.cz/ RISC-V education: https://comparch.edu.cvut.cz/
Open Technologies Research Education and Exchange Services
https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home

#3 lore raw
In reply to Avi Weiss
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Un-ratelimited netdev_info() on bus errors causes a printk flood. --

--- Patch [1]: [PATCH net] can: ctucanfd: handle bus error interrupts --- commit dcd94808a20ebfaa5db627f0ee1ba372c3c77c87
Author: Avi Weiss <[email protected]>

can: ctucanfd: handle bus error interrupts

Include REG_INT_STAT_BEI in the top-level error interrupt condition.

BEI is enabled when CAN_CTRLMODE_BERR_REPORTING is requested and ctucan_err_interrupt() already handles it. Without checking and clearing BEI in the top-level handler, bus error interrupts are not handled or acknowledged.

Quoted 9 lines
drivers/net/can/ctucanfd/ctucanfd_base.c +0 -1
index 0ea1ff28dfce8..0cd2d428c1f15 100644
@@ -1136,8 +1136,12 @@ static irqreturn_t ctucan_interrupt(int irq, void *dev_id)
 		/* Error interrupts */
 		if (FIELD_GET(REG_INT_STAT_EWLI, isr) ||
 		    FIELD_GET(REG_INT_STAT_FCSI, isr) ||
-		    FIELD_GET(REG_INT_STAT_ALI, isr)) {

drivers/net/can/ctucanfd/ctucanfd_base.c static irqreturn_t ctucan_interrupt(int irq, void *dev_id) · line 1147

Quoted 10 lines
drivers/net/can/ctucanfd/ctucanfd_base.c +6 -1
-			icr = isr & (REG_INT_STAT_EWLI | REG_INT_STAT_FCSI | REG_INT_STAT_ALI);
+		    FIELD_GET(REG_INT_STAT_ALI, isr) ||
+		    FIELD_GET(REG_INT_STAT_BEI, isr)) {
+			icr = isr & (REG_INT_STAT_EWLI |
+				     REG_INT_STAT_FCSI |
+				     REG_INT_STAT_ALI |
+				     REG_INT_STAT_BEI);
 
 			ctucan_netdev_dbg(ndev, "some ERR interrupt: clearing 0x%08x\n", icr);
 			ctucan_write32(priv, CTUCANFD_INT_STAT, icr);

[Severity: High]
This isn't a bug introduced by this patch, but since we are now passing REG_INT_STAT_BEI into ctucan_err_interrupt() which is called directly after this write, could this cause a printk flood?

Looking at ctucan_err_interrupt():

	/* Check for Bus Error interrupt */
	if (FIELD_GET(REG_INT_STAT_BEI, isr)) {
		netdev_info(ndev, "bus error\n");

This unconditional netdev_info() is called for every bus error interrupt, whereas other errors like ALI correctly use a dologerr ratelimit check.

Would a flurry of bus errors overwhelm the system log?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1