Commit 6c6b4af
can: mcp251xfd: fix infinite loop when xmit fails
commit d8fb63e upstream.
When the mcp251xfd_start_xmit() function fails, the driver stops
processing messages, and the interrupt routine does not return,
running indefinitely even after killing the running application.
Error messages:
[ 441.298819] mcp251xfd spi2.0 can0: ERROR in mcp251xfd_start_xmit: -16
[ 441.306498] mcp251xfd spi2.0 can0: Transmit Event FIFO buffer not empty. (seq=0x000017c7, tef_tail=0x000017cf, tef_head=0x000017d0, tx_head=0x000017d3).
... and repeat forever.
The issue can be triggered when multiple devices share the same SPI
interface. And there is concurrent access to the bus.
The problem occurs because tx_ring->head increments even if
mcp251xfd_start_xmit() fails. Consequently, the driver skips one TX
package while still expecting a response in
mcp251xfd_handle_tefif_one().
Resolve the issue by starting a workqueue to write the tx obj
synchronously if err = -EBUSY. In case of another error, decrement
tx_ring->head, remove skb from the echo stack, and drop the message.
Fixes: 55e5b97 ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Cc: stable@vger.kernel.org
Signed-off-by: Vitor Soares <vitor.soares@toradex.com>
Link: https://lore.kernel.org/all/20240517134355.770777-1-ivitro@gmail.com
[mkl: use more imperative wording in patch description]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 9d42bcb commit 6c6b4af
File tree
3 files changed
+65
-9
lines changed- drivers/net/can/spi/mcp251xfd
3 files changed
+65
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1618 | 1618 | | |
1619 | 1619 | | |
1620 | 1620 | | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1621 | 1630 | | |
1622 | 1631 | | |
1623 | 1632 | | |
1624 | 1633 | | |
1625 | | - | |
| 1634 | + | |
1626 | 1635 | | |
1627 | 1636 | | |
1628 | 1637 | | |
| |||
1634 | 1643 | | |
1635 | 1644 | | |
1636 | 1645 | | |
| 1646 | + | |
| 1647 | + | |
1637 | 1648 | | |
1638 | 1649 | | |
1639 | 1650 | | |
| |||
1661 | 1672 | | |
1662 | 1673 | | |
1663 | 1674 | | |
| 1675 | + | |
1664 | 1676 | | |
1665 | 1677 | | |
1666 | 1678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
134 | 167 | | |
135 | 168 | | |
136 | 169 | | |
| |||
162 | 195 | | |
163 | 196 | | |
164 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
165 | 203 | | |
166 | 204 | | |
167 | 205 | | |
| |||
175 | 213 | | |
176 | 214 | | |
177 | 215 | | |
178 | | - | |
| 216 | + | |
| 217 | + | |
179 | 218 | | |
180 | 219 | | |
181 | 220 | | |
| |||
193 | 232 | | |
194 | 233 | | |
195 | 234 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
203 | 242 | | |
204 | 243 | | |
205 | 244 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
636 | 640 | | |
637 | 641 | | |
638 | 642 | | |
| |||
952 | 956 | | |
953 | 957 | | |
954 | 958 | | |
| 959 | + | |
955 | 960 | | |
956 | 961 | | |
957 | 962 | | |
| |||
0 commit comments