Skip to contentSkip to conversation

can: m_can: Set device to software init mode before closing

PATCH In review Faiz Abbas 3 participants 3 messages Aug 25, 2020 – Nov 12, 2020

Subsystems (4)
lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

PATCH v2 1/1 can: m_can: Set device to software init mode before closing

There might be some requests pending in the buffer when the interface close sequence occurs. In some devices, these pending requests might lead to the module not shutting down properly when m_can_clk_stop() is called.

Therefore, move the device to init state before potentially powering it down.

---

changes since v1: Rebased to latest mainline

 drivers/net/can/m_can/m_can.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/can/m_can/m_can.c +3 -0
index 02c5795b7393..d0c458f7f6e1 100644
@@ -1414,6 +1414,9 @@ static void m_can_stop(struct net_device *dev)
 	/* disable all interrupts */
 	m_can_disable_all_interrupts(cdev);
 
+	/* Set init mode to disengage from the network */
+	m_can_config_endisable(cdev, true);
+
 	/* set the state as STOPPED */
 	cdev->can.state = CAN_STATE_STOPPED;
 }
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw

Faiz

Quoted 21 lines · Faiz Abbas

There might be some requests pending in the buffer when the interface close sequence occurs. In some devices, these pending requests might lead to the module not shutting down properly when m_can_clk_stop() is called.

Therefore, move the device to init state before potentially powering it down.

---

changes since v1: Rebased to latest mainline

  drivers/net/can/m_can/m_can.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/can/m_can/m_can.c +0 -0
index 02c5795b7393..d0c458f7f6e1 100644

drivers/net/can/m_can/m_can.c static void m_can_stop(struct net_device *dev) · line 1422

Quoted 9 lines
drivers/net/can/m_can/m_can.c +3 -0
@@ -1414,6 +1414,9 @@ static void m_can_stop(struct net_device *dev)
  	/* disable all interrupts */
  	m_can_disable_all_interrupts(cdev);
 
+	/* Set init mode to disengage from the network */
+	m_can_config_endisable(cdev, true);
+
  	/* set the state as STOPPED */
  	cdev->can.state = CAN_STATE_STOPPED;
  }
#2 lore raw
In reply to Faiz Abbas
Quoted 9 lines · Faiz Abbas

There might be some requests pending in the buffer when the interface close sequence occurs. In some devices, these pending requests might lead to the module not shutting down properly when m_can_clk_stop() is called.

Therefore, move the device to init state before potentially powering it down.

Added to linux-can/testing.

Tnx,
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 |