Skip to contentSkip to conversation

can: c_can: Do basic c_can configuration _before_ enabling the interrupts

PATCH Applied Jan Altenberg 4 participants 4 messages Mar 21, 2011 – Mar 22, 2011

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

PATCH 1/1 can: c_can: Do basic c_can configuration _before_ enabling the interrupts

Hi all,

I ran into some trouble while testing the SocketCAN driver for the BOSCH C_CAN controller. The interface is not correctly initialized, if I put some CAN traffic on the line, _while_ the interface is being started (which means: the interface doesn't come up correcty, if there's some RX traffic while doing 'ifconfig can0 up').

The current implementation enables the controller interrupts _before_ doing the basic c_can configuration. I think, this should be done the other way round.

The patch below fixes things for me.

---

drivers/net/can/c_can/c_can.c +3 -3
index 1405078..110eda0 100644
@@ -633,9 +633,6 @@ static void c_can_start(struct net_device *dev)
 {
 	struct c_can_priv *priv = netdev_priv(dev);
 
-	/* enable status change, error and module interrupts */
-	c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
-
 	/* basic c_can configuration */
 	c_can_chip_config(dev);
 
@@ -643,6 +640,9 @@ static void c_can_start(struct net_device *dev)
 
 	/* reset tx helper pointers */
 	priv->tx_next = priv->tx_echo = 0;
+
+	/* enable status change, error and module interrupts */
+	c_can_enable_all_interrupts(priv, ENABLE_ALL_INTERRUPTS);
 }
 
 static void c_can_stop(struct net_device *dev)
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jan Altenberg

Hi all,

I ran into some trouble while testing the SocketCAN driver for the BOSCH C_CAN controller. The interface is not correctly initialized, if I put some CAN traffic on the line, _while_ the interface is being started (which means: the interface doesn't come up correcty, if there's some RX traffic while doing 'ifconfig can0 up').

The current implementation enables the controller interrupts _before_ doing the basic c_can configuration. I think, this should be done the other way round.

The existing code indeed is susceptible for the decribed scenario.

Quoted 2 lines

The patch below fixes things for me.

Simple & good patch!

Quoted 2 lines
Acked-by on v1 1/1
#2 lore raw
In reply to Jan Altenberg
Quoted 8 lines · Jan Altenberg

Hi all,

I ran into some trouble while testing the SocketCAN driver for the BOSCH C_CAN controller. The interface is not correctly initialized, if I put some CAN traffic on the line, _while_ the interface is being started (which means: the interface doesn't come up correcty, if there's some RX traffic while doing 'ifconfig can0 up').

Quoted 7 lines

The current implementation enables the controller interrupts _before_ doing the basic c_can configuration. I think, this should be done the other way round.

The patch below fixes things for me.

Thanks,

Wolfgang.

maintainer Applied
#3 lore raw

From: Wolfgang Grandegger <[email protected]>
Date: Mon, 21 Mar 2011 17:35:45 +0100

Quoted 13 lines · Jan Altenberg
Quoted 12 lines

Hi all,

I ran into some trouble while testing the SocketCAN driver for the BOSCH C_CAN controller. The interface is not correctly initialized, if I put some CAN traffic on the line, _while_ the interface is being started (which means: the interface doesn't come up correcty, if there's some RX traffic while doing 'ifconfig can0 up').

The current implementation enables the controller interrupts _before_ doing the basic c_can configuration. I think, this should be done the other way round.

Quoted 5 lines
Quoted 3 lines

The patch below fixes things for me.

Applied, thanks everyone.