Commit 7e8c182c authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge tag 'linux-can-fixes-for-5.19-20220704' of...

Merge tag 'linux-can-fixes-for-5.19-20220704' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
can 2022-07-04

The 1st patch is by Oliver Hartkopp, targets the BCM CAN protocol and
converts a costly synchronize_rcu() to call_rcu() to fix a performance
regression.

Srinivas Neeli's patch for the xilinx_can driver drops the brp limit
down to 1, as only the pre-production silicon have an issue with a brp
of 1.

The next patch is by Duy Nguyen and fixes the data transmission on
R-Car V3U SoCs in the rcar_canfd driver.

Rhett Aultman's patch fixes a DMA memory leak in the gs_usb driver.

Liang He's patch removes an extra of_node_get() in the grcan driver.

The next 2 patches are by me, target the m_can driver and fix the
timestamp handling used for peripheral devices like the tcan4x5x.

Jimmy Assarsson contributes 3 patches for the kvaser_usb driver and
fixes CAN clock and bit timing related issues.

The remaining 5 patches target the mcp251xfd driver. Thomas Kopp
contributes 2 patches to improve the workaround for broken CRC when
reading the TBC register. 3 patches by me add a missing
hrtimer_cancel() during the ndo_stop() callback, and fix the reading
of the Device ID register.

* tag 'linux-can-fixes-for-5.19-20220704' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can:
  can: mcp251xfd: mcp251xfd_register_get_dev_id(): fix endianness conversion
  can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id
  can: mcp251xfd: mcp251xfd_stop(): add missing hrtimer_cancel()
  can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register
  can: mcp251xfd: mcp251xfd_regmap_crc_read(): improve workaround handling for mcp2517fd
  can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits
  can: kvaser_usb: kvaser_usb_leaf: fix CAN clock frequency regression
  can: kvaser_usb: replace run-time checks with struct kvaser_usb_driver_info
  can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits
  can: m_can: m_can_chip_config(): actually enable internal timestamping
  can: grcan: grcan_probe(): remove extra of_node_get()
  can: gs_usb: gs_usb_open/close(): fix memory leak
  can: rcar_canfd: Fix data transmission failed on R-Car V3U
  Revert "can: xilinx_can: Limit CANFD brp to 2"
  can: bcm: use call_rcu() instead of costly synchronize_rcu()
====================

Link: https://lore.kernel.org/r/20220704122613.1551119-1-mkl@pengutronix.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 1b18f09d 1c0e78a2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1646,7 +1646,6 @@ static int grcan_probe(struct platform_device *ofdev)
	 */
	sysid_parent = of_find_node_by_path("/ambapp0");
	if (sysid_parent) {
		of_node_get(sysid_parent);
		err = of_property_read_u32(sysid_parent, "systemid", &sysid);
		if (!err && ((sysid & GRLIB_VERSION_MASK) >=
			     GRCAN_TXBUG_SAFE_GRLIB_VERSION))
+5 −3
Original line number Diff line number Diff line
@@ -529,7 +529,7 @@ static int m_can_read_fifo(struct net_device *dev, u32 rxfs)
	/* acknowledge rx fifo 0 */
	m_can_write(cdev, M_CAN_RXF0A, fgi);

	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc);
	timestamp = FIELD_GET(RX_BUF_RXTS_MASK, fifo_header.dlc) << 16;

	m_can_receive_skb(cdev, skb, timestamp);

@@ -1030,7 +1030,7 @@ static int m_can_echo_tx_event(struct net_device *dev)
		}

		msg_mark = FIELD_GET(TX_EVENT_MM_MASK, txe);
		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe);
		timestamp = FIELD_GET(TX_EVENT_TXTS_MASK, txe) << 16;

		/* ack txe element */
		m_can_write(cdev, M_CAN_TXEFA, FIELD_PREP(TXEFA_EFAI_MASK,
@@ -1351,7 +1351,9 @@ static void m_can_chip_config(struct net_device *dev)
	/* enable internal timestamp generation, with a prescalar of 16. The
	 * prescalar is applied to the nominal bit timing
	 */
	m_can_write(cdev, M_CAN_TSCC, FIELD_PREP(TSCC_TCP_MASK, 0xf));
	m_can_write(cdev, M_CAN_TSCC,
		    FIELD_PREP(TSCC_TCP_MASK, 0xf) |
		    FIELD_PREP(TSCC_TSS_MASK, TSCC_TSS_INTERNAL));

	m_can_config_endisable(cdev, false);

+4 −1
Original line number Diff line number Diff line
@@ -1332,6 +1332,9 @@ static void rcar_canfd_set_bittiming(struct net_device *dev)
		cfg = (RCANFD_DCFG_DTSEG1(gpriv, tseg1) | RCANFD_DCFG_DBRP(brp) |
		       RCANFD_DCFG_DSJW(sjw) | RCANFD_DCFG_DTSEG2(gpriv, tseg2));

		if (is_v3u(gpriv))
			rcar_canfd_write(priv->base, RCANFD_V3U_DCFG(ch), cfg);
		else
			rcar_canfd_write(priv->base, RCANFD_F_DCFG(ch), cfg);
		netdev_dbg(priv->ndev, "drate: brp %u, sjw %u, tseg1 %u, tseg2 %u\n",
			   brp, sjw, tseg1, tseg2);
+4 −2
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
// Copyright (c) 2019 Martin Sperl <kernel@martin.sperl.org>
//

#include <asm/unaligned.h>
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/device.h>
@@ -1650,6 +1651,7 @@ static int mcp251xfd_stop(struct net_device *ndev)
	netif_stop_queue(ndev);
	set_bit(MCP251XFD_FLAGS_DOWN, priv->flags);
	hrtimer_cancel(&priv->rx_irq_timer);
	hrtimer_cancel(&priv->tx_irq_timer);
	mcp251xfd_chip_interrupts_disable(priv);
	free_irq(ndev->irq, priv);
	can_rx_offload_disable(&priv->offload);
@@ -1777,7 +1779,7 @@ mcp251xfd_register_get_dev_id(const struct mcp251xfd_priv *priv, u32 *dev_id,
	xfer[0].len = sizeof(buf_tx->cmd);
	xfer[0].speed_hz = priv->spi_max_speed_hz_slow;
	xfer[1].rx_buf = buf_rx->data;
	xfer[1].len = sizeof(dev_id);
	xfer[1].len = sizeof(*dev_id);
	xfer[1].speed_hz = priv->spi_max_speed_hz_fast;

	mcp251xfd_spi_cmd_read_nocrc(&buf_tx->cmd, MCP251XFD_REG_DEVID);
@@ -1786,7 +1788,7 @@ mcp251xfd_register_get_dev_id(const struct mcp251xfd_priv *priv, u32 *dev_id,
	if (err)
		goto out_kfree_buf_tx;

	*dev_id = be32_to_cpup((__be32 *)buf_rx->data);
	*dev_id = get_unaligned_le32(buf_rx->data);
	*effective_speed_hz_slow = xfer[0].effective_speed_hz;
	*effective_speed_hz_fast = xfer[1].effective_speed_hz;

+11 −11
Original line number Diff line number Diff line
@@ -334,19 +334,21 @@ mcp251xfd_regmap_crc_read(void *context,
		 * register. It increments once per SYS clock tick,
		 * which is 20 or 40 MHz.
		 *
		 * Observation shows that if the lowest byte (which is
		 * transferred first on the SPI bus) of that register
		 * is 0x00 or 0x80 the calculated CRC doesn't always
		 * match the transferred one.
		 * Observation on the mcp2518fd shows that if the
		 * lowest byte (which is transferred first on the SPI
		 * bus) of that register is 0x00 or 0x80 the
		 * calculated CRC doesn't always match the transferred
		 * one. On the mcp2517fd this problem is not limited
		 * to the first byte being 0x00 or 0x80.
		 *
		 * If the highest bit in the lowest byte is flipped
		 * the transferred CRC matches the calculated one. We
		 * assume for now the CRC calculation in the chip
		 * works on wrong data and the transferred data is
		 * correct.
		 * assume for now the CRC operates on the correct
		 * data.
		 */
		if (reg == MCP251XFD_REG_TBC &&
		    (buf_rx->data[0] == 0x0 || buf_rx->data[0] == 0x80)) {
		    ((buf_rx->data[0] & 0xf8) == 0x0 ||
		     (buf_rx->data[0] & 0xf8) == 0x80)) {
			/* Flip highest bit in lowest byte of le32 */
			buf_rx->data[0] ^= 0x80;

@@ -356,10 +358,8 @@ mcp251xfd_regmap_crc_read(void *context,
								  val_len);
			if (!err) {
				/* If CRC is now correct, assume
				 * transferred data was OK, flip bit
				 * back to original value.
				 * flipped data is OK.
				 */
				buf_rx->data[0] ^= 0x80;
				goto out;
			}
		}
Loading