]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
379a7de5a44dd309a825aadc068edaa8c0374d21
[thirdparty/kernel/stable-queue.git] /
1 From 403a89e2f717c3540f88ffb933a9ad942331ffe9 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 13 Oct 2020 17:39:47 +0200
4 Subject: can: peak_canfd: pucan_handle_can_rx(): fix echo management when
5 loopback is on
6
7 From: Stephane Grosjean <s.grosjean@peak-system.com>
8
9 [ Upstream commit 93ef65e5a6357cc7381f85fcec9283fe29970045 ]
10
11 Echo management is driven by PUCAN_MSG_LOOPED_BACK bit, while loopback
12 frames are identified with PUCAN_MSG_SELF_RECEIVE bit. Those bits are set
13 for each outgoing frame written to the IP core so that a copy of each one
14 will be placed into the rx path. Thus,
15
16 - when PUCAN_MSG_LOOPED_BACK is set then the rx frame is an echo of a
17 previously sent frame,
18 - when PUCAN_MSG_LOOPED_BACK+PUCAN_MSG_SELF_RECEIVE are set, then the rx
19 frame is an echo AND a loopback frame. Therefore, this frame must be
20 put into the socket rx path too.
21
22 This patch fixes how CAN frames are handled when these are sent while the
23 can interface is configured in "loopback on" mode.
24
25 Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
26 Link: https://lore.kernel.org/r/20201013153947.28012-1-s.grosjean@peak-system.com
27 Fixes: 8ac8321e4a79 ("can: peak: add support for PEAK PCAN-PCIe FD CAN-FD boards")
28 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
30 ---
31 drivers/net/can/peak_canfd/peak_canfd.c | 11 ++++++++---
32 1 file changed, 8 insertions(+), 3 deletions(-)
33
34 diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c
35 index 10aa3e457c33d..40c33b8a5fda3 100644
36 --- a/drivers/net/can/peak_canfd/peak_canfd.c
37 +++ b/drivers/net/can/peak_canfd/peak_canfd.c
38 @@ -262,8 +262,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
39 cf_len = get_can_dlc(pucan_msg_get_dlc(msg));
40
41 /* if this frame is an echo, */
42 - if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
43 - !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
44 + if (rx_msg_flags & PUCAN_MSG_LOOPED_BACK) {
45 unsigned long flags;
46
47 spin_lock_irqsave(&priv->echo_lock, flags);
48 @@ -277,7 +276,13 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
49 netif_wake_queue(priv->ndev);
50
51 spin_unlock_irqrestore(&priv->echo_lock, flags);
52 - return 0;
53 +
54 + /* if this frame is only an echo, stop here. Otherwise,
55 + * continue to push this application self-received frame into
56 + * its own rx queue.
57 + */
58 + if (!(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE))
59 + return 0;
60 }
61
62 /* otherwise, it should be pushed into rx fifo */
63 --
64 2.27.0
65