Skip to contentSkip to conversation

tcan4x5x: clear MRAM before entering Normal mode

PATCH In review Torin Cooper-Bennun 2 participants 2 messages Feb 26, 2021 – Feb 28, 2021

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

PATCH 1/1 tcan4x5x: clear MRAM before entering Normal mode

This prevents a potentially destructive race condition. The device is fully operational on the bus after entering Normal mode, so zeroing the MRAM after entering this mode may lead to loss of information, e.g. new received messages.

---
 drivers/net/can/m_can/tcan4x5x-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +3 -3
index b7caec769ddb..4147cecfbbd6 100644
@@ -237,14 +237,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
 	if (ret)
 		return ret;
 
+	/* Zero out the MCAN buffers */
+	m_can_init_ram(cdev);
+
 	ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
 				 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
 	if (ret)
 		return ret;
 
-	/* Zero out the MCAN buffers */
-	m_can_init_ram(cdev);
-
 	return ret;
 }
 
Signature · 1 line
2.30.0
#1 lore raw
Quoted 6 lines · Torin Cooper-Bennun

This prevents a potentially destructive race condition. The device is fully operational on the bus after entering Normal mode, so zeroing the MRAM after entering this mode may lead to loss of information, e.g. new received messages.

I've added a Fixed: tag and applied the patch to linux-can/testing.

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