]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
1a4f6884303aa7f2fc1a25a55223c20a99a3de09
[thirdparty/kernel/stable-queue.git] /
1 From 2712625200ed69c642b9abc3a403830c4643364c Mon Sep 17 00:00:00 2001
2 From: Torin Cooper-Bennun <torin@maxiluxsystems.com>
3 Date: Fri, 26 Feb 2021 16:34:41 +0000
4 Subject: can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before entering Normal Mode
5
6 From: Torin Cooper-Bennun <torin@maxiluxsystems.com>
7
8 commit 2712625200ed69c642b9abc3a403830c4643364c upstream.
9
10 This patch prevents a potentially destructive race condition. The
11 device is fully operational on the bus after entering Normal Mode, so
12 zeroing the MRAM after entering this mode may lead to loss of
13 information, e.g. new received messages.
14
15 This patch fixes the problem by first initializing the MRAM, then
16 bringing the device into Normale Mode.
17
18 Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel")
19 Link: https://lore.kernel.org/r/20210226163440.313628-1-torin@maxiluxsystems.com
20 Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
21 Signed-off-by: Torin Cooper-Bennun <torin@maxiluxsystems.com>
22 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 ---
25 drivers/net/can/m_can/tcan4x5x.c | 6 +++---
26 1 file changed, 3 insertions(+), 3 deletions(-)
27
28 --- a/drivers/net/can/m_can/tcan4x5x.c
29 +++ b/drivers/net/can/m_can/tcan4x5x.c
30 @@ -325,14 +325,14 @@ static int tcan4x5x_init(struct m_can_cl
31 if (ret)
32 return ret;
33
34 + /* Zero out the MCAN buffers */
35 + m_can_init_ram(cdev);
36 +
37 ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
38 TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL);
39 if (ret)
40 return ret;
41
42 - /* Zero out the MCAN buffers */
43 - m_can_init_ram(cdev);
44 -
45 return ret;
46 }
47