linux/drivers/net/can
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
..
c_can can: c_can: Convert to platform remove callback returning void 2023-05-15 22:53:49 +02:00
cc770 can: cc770_platform: Convert to platform remove callback returning void 2023-05-15 22:53:49 +02:00
ctucanfd can: ctucanfd: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
dev can: length: refactor frame lengths definition to add size in bits 2023-06-22 09:43:40 +02:00
flexcan can: flexcan: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
ifi_canfd can: ifi_canfd: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
m_can can: m_can: fix coding style 2023-06-22 09:42:28 +02:00
mscan can: mscan: mpc5xxx_can: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
peak_canfd can: dev: fix skb drop check 2022-11-07 14:00:27 +01:00
rcar can: rcar: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
sja1000 can: sja1000: Prevent overrun stalls with a soft reset on Renesas SoCs 2023-06-22 09:41:32 +02:00
slcan can: slcan: fix freed work crash 2022-12-07 10:32:24 +01:00
softing can: softing: Convert to platform remove callback returning void 2023-05-15 22:53:51 +02:00
spi can: mcp251xfd: __mcp251xfd_chip_set_mode(): increase poll timeout 2023-07-17 19:54:51 +02:00
usb can: gs_usb: fix time stamp counter initialization 2023-07-17 12:16:35 +02:00
Kconfig can: kvaser_pciefd: Remove SPI flash parameter read functionality 2023-06-22 09:44:29 +02:00
Makefile can: bxcan: add support for ST bxCAN controller 2023-03-28 11:43:36 +02:00
at91_can.c can: at91_can: Convert to platform remove callback returning void 2023-05-15 22:53:49 +02:00
bxcan.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-05-18 14:39:34 -07:00
can327.c can: can327: flush TX_work on ldisc .close() 2022-12-07 10:32:36 +01:00
grcan.c can: grcan: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
janz-ican3.c can: janz-ican3: Convert to platform remove callback returning void 2023-05-15 22:53:50 +02:00
kvaser_pciefd.c can: kvaser_pciefd: Use TX FIFO size read from CAN controller 2023-06-22 09:44:30 +02:00
sun4i_can.c can: sun4i_can: Convert to platform remove callback returning void 2023-05-15 22:53:51 +02:00
ti_hecc.c can: ti_hecc: fix coding style 2023-06-22 09:42:28 +02:00
vcan.c can: dev: add CAN XL support to virtual CAN 2022-09-15 09:08:09 +02:00
vxcan.c rtnetlink: pass netlink message header and portid to rtnl_configure_link() 2022-10-31 18:10:21 -07:00
xilinx_can.c can: dev: add transceiver capabilities to xilinx_can 2023-05-22 20:21:30 +02:00