1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/can/spi/mcp251xfd
Fedor Ross 9efa1a5407 can: mcp251xfd: __mcp251xfd_chip_set_mode(): increase poll timeout
The mcp251xfd controller needs an idle bus to enter 'Normal CAN 2.0
mode' or . The maximum length of a CAN frame is 736 bits (64 data
bytes, CAN-FD, EFF mode, worst case bit stuffing and interframe
spacing). For low bit rates like 10 kbit/s the arbitrarily chosen
MCP251XFD_POLL_TIMEOUT_US of 1 ms is too small.

Otherwise during polling for the CAN controller to enter 'Normal CAN
2.0 mode' the timeout limit is exceeded and the configuration fails
with:

| $ ip link set dev can1 up type can bitrate 10000
| [  731.911072] mcp251xfd spi2.1 can1: Controller failed to enter mode CAN 2.0 Mode (6) and stays in Configuration Mode (4) (con=0x068b0760, osc=0x00000468).
| [  731.927192] mcp251xfd spi2.1 can1: CRC read error at address 0x0e0c (length=4, data=00 00 00 00, CRC=0x0000) retrying.
| [  731.938101] A link change request failed with some changes committed already. Interface can1 may have been left with an inconsistent configuration, please check.
| RTNETLINK answers: Connection timed out

Make MCP251XFD_POLL_TIMEOUT_US timeout calculation dynamic. Use
maximum of 1ms and bit time of 1 full 64 data bytes CAN-FD frame in
EFF mode, worst case bit stuffing and interframe spacing at the
current bit rate.

For easier backporting define the macro MCP251XFD_FRAME_LEN_MAX_BITS
that holds the max frame length in bits, which is 736. This can be
replaced by can_frame_bits(true, true, true, true, CANFD_MAX_DLEN) in
a cleanup patch later.

Fixes: 55e5b97f00 ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Signed-off-by: Fedor Ross <fedor.ross@ifm.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20230717-mcp251xfd-fix-increase-poll-timeout-v5-1-06600f34c684@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2023-07-17 19:54:51 +02:00
..
Kconfig can: Kconfig: add CONFIG_CAN_RX_OFFLOAD 2022-06-11 17:11:02 +02:00
Makefile can: mcp251xfd: ethtool: add support 2022-03-13 09:45:35 +01:00
mcp251xfd-chip-fifo.c can: mcp251xfd: introduce struct mcp251xfd_tx_ring::nr and ::fifo_nr and make use of it 2022-02-24 08:46:59 +01:00
mcp251xfd-core.c can: mcp251xfd: __mcp251xfd_chip_set_mode(): increase poll timeout 2023-07-17 19:54:51 +02:00
mcp251xfd-crc16.c can: mcp251xfd: rename all remaining occurrence to mcp251xfd 2020-09-30 21:55:28 +02:00
mcp251xfd-dump.c can: mcp251xfd: mcp251xfd_dump(): fix comment 2022-07-26 10:43:37 +02:00
mcp251xfd-dump.h can: mcp251xfd: add dev coredump support 2021-03-30 11:14:49 +02:00
mcp251xfd-ethtool.c can: mcp251xfd: mcp251xfd_ring_set_ringparam(): assign missing tx_obj_num_coalesce_irq 2023-02-02 10:33:27 +01:00
mcp251xfd-ram.c can: mcp251xfd: ram: coalescing support 2022-03-13 09:45:35 +01:00
mcp251xfd-ram.h can: mcp251xfd: ram: coalescing support 2022-03-13 09:45:35 +01:00
mcp251xfd-regmap.c can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register 2022-07-04 12:46:45 +02:00
mcp251xfd-ring.c can: mcp251xfd: regmap: optimizing transfer size for CRC transfers size 1 2023-02-02 15:42:10 +01:00
mcp251xfd-rx.c can: rx-offload: rename can_rx_offload_queue_sorted() -> can_rx_offload_queue_timestamp() 2022-04-19 16:58:04 +02:00
mcp251xfd-tef.c can: mcp251xfd: add TX IRQ coalescing support 2022-03-13 09:45:36 +01:00
mcp251xfd-timestamp.c can: mcp251xfd: mark some instances of struct mcp251xfd_priv as const 2021-08-19 15:07:03 +02:00
mcp251xfd-tx.c can: dev: fix skb drop check 2022-11-07 14:00:27 +01:00
mcp251xfd.h can: mcp251xfd: __mcp251xfd_chip_set_mode(): increase poll timeout 2023-07-17 19:54:51 +02:00