Skip to contentSkip to conversation

can: m_can: reset IR_RF0L in message reception loop

PATCH In review Mariusz Madej 3 participants 4 messages Mar 1, 2021 – Mar 4, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 can: m_can: reset IR_RF0L in message reception loop

Message lost warning is reported in loop without interrupt reset. Besides redundant log messages it may lead to serious performance problem, where fifo gets full faster than next reception is scheduled by NAPI. This patch fixes it.

---
 drivers/net/can/m_can/m_can.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +3 -1
index 3752520a7..bd5539435 100644
@@ -501,8 +501,10 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	}
 
 	while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-		if (rxfs & RXFS_RFL)
+		if (rxfs & RXFS_RFL) {
 			netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
+			m_can_write(cdev, M_CAN_IR, IR_RF0L);	
+		}
 
 		m_can_read_fifo(dev, rxfs);
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 4 lines · Mariusz Madej

Message lost warning is reported in loop without interrupt reset. Besides redundant log messages it may lead to serious performance problem, where fifo gets full faster than next reception is scheduled by NAPI. This patch fixes it.

Looking at the flow in m_can_rx_handler, it looks as though m_can_handle_bus_errors -> m_can_handle_lost_msg already handles message loss properly, and issues a netdev_err. I wonder whether we can remove the warning from m_can_do_rx_poll entirely:

drivers/net/can/m_can/m_can.c +0 -3
index 3752520a7d4b..d783c46cac16 100644
@@ -501,9 +501,6 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	}
 
 	while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-		if (rxfs & RXFS_RFL)
-			netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
-
 		m_can_read_fifo(dev, rxfs);
 
 		quota--;

---
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com

#2 lore raw
Quoted 17 lines · Torin Cooper-Bennun
Quoted 4 lines · Mariusz Madej

Message lost warning is reported in loop without interrupt reset. Besides redundant log messages it may lead to serious performance problem, where fifo gets full faster than next reception is scheduled by NAPI. This patch fixes it.

Looking at the flow in m_can_rx_handler, it looks as though m_can_handle_bus_errors -> m_can_handle_lost_msg already handles message loss properly, and issues a netdev_err. I wonder whether we can remove the warning from m_can_do_rx_poll entirely:

drivers/net/can/m_can/m_can.c +0 -0
index 3752520a7d4b..d783c46cac16 100644

drivers/net/can/m_can/m_can.c static int m_can_do_rx_poll(struct net_device *dev, int quota) · line 506

Quoted 9 lines
drivers/net/can/m_can/m_can.c +0 -3
@@ -501,9 +501,6 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	}
 
 	while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-		if (rxfs & RXFS_RFL)
-			netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
-
 		m_can_read_fifo(dev, rxfs);
 
 		quota--;

Looks good to me. Can you send a proper patch?

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
#3 lore raw
Quoted 18 lines · Marc Kleine-Budde
Quoted 18 lines

Looking at the flow in m_can_rx_handler, it looks as though m_can_handle_bus_errors -> m_can_handle_lost_msg already handles message loss properly, and issues a netdev_err. I wonder whether we can remove the warning from m_can_do_rx_poll entirely:

drivers/net/can/m_can/m_can.c +0 -3
index 3752520a7d4b..d783c46cac16 100644
@@ -501,9 +501,6 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota)
 	}
 
 	while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) {
-		if (rxfs & RXFS_RFL)
-			netdev_warn(dev, "Rx FIFO 0 Message Lost\n");
-
 		m_can_read_fifo(dev, rxfs);
 
Quoted 4 lines

drivers/net/can/m_can/m_can.c static int m_can_do_rx_poll(struct net_device *dev, int quota) · line 506

Quoted 2 lines
drivers/net/can/m_can/m_can.c +0 -0
 		quota--;

Looks good to me. Can you send a proper patch?

Of course, will do shortly.

--
Regards,

Torin Cooper-Bennun
Software Engineer | maxiluxsystems.com