diff mbox

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

Message ID 1300715258.2010.30.camel@moestavern
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Jan Altenberg March 21, 2011, 1:47 p.m. UTC
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.

Signed-off-by: Jan Altenberg <jan@linutronix.de>
---



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Kurt Van Dijck March 21, 2011, 2:49 p.m. UTC | #1
On Mon, Mar 21, 2011 at 02:47:38PM +0100, Jan Altenberg wrote:
> 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.
> 
> The patch below fixes things for me.
Simple & good patch!
> 
> Signed-off-by: Jan Altenberg <jan@linutronix.de>
Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfgang Grandegger March 21, 2011, 4:35 p.m. UTC | #2
On 03/21/2011 02:47 PM, Jan Altenberg wrote:
> 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.
> 
> Signed-off-by: Jan Altenberg <jan@linutronix.de>

Acked-by: Wolfgang Grandegger <wg@grandegger.com>

Thanks,

Wolfgang.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller March 22, 2011, 1:19 a.m. UTC | #3
From: Wolfgang Grandegger <wg@grandegger.com>
Date: Mon, 21 Mar 2011 17:35:45 +0100

> On 03/21/2011 02:47 PM, Jan Altenberg wrote:
>> 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.
>> 
>> Signed-off-by: Jan Altenberg <jan@linutronix.de>
> 
> Acked-by: Wolfgang Grandegger <wg@grandegger.com>

Applied, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 1405078..110eda0 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -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)