pull-request: can 2021-01-07
Subsystems (6)
Marc Kleine-Budde
maintainerHello Jakub, hello David,
this is a pull request of 6 patches for net/master.
The first patch is by me for the m_can driver and removes an erroneous m_can_clk_stop() from the driver's unregister function.
The second patch targets the tcan4x5x driver, is by me, and fixes the bit timing constant parameters.
The next two patches are by me, target the mcp251xfd driver, and fix a race condition in the optimized TEF path (which was added in net-next for v5.11). The similar code in the RX path is changed to look the same, although it doesn't suffer from the race condition.
A patch by Lad Prabhakar updates the description and help text for the rcar CAN driver to reflect all supported SoCs.
In the last patch Sriram Dash transfers the maintainership of the m_can driver to Pankaj Sharma.
regards,
Marc
---
The following changes since commit 1f685e6adbbe3c7b1bd9053be771b898d9efa655:
ptp: ptp_ines: prevent build when HAS_IOMEM is not set (2021-01-06 16:17:23 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-5.11-20210107
for you to fetch changes up to 6ee49118f87cf02b36f68812bc49855b7b627a2b:
MAINTAINERS: Update MCAN MMIO device driver maintainer (2021-01-07 11:02:10 +0100)
----------------------------------------------------------------
linux-can-fixes-for-5.11-20210107
----------------------------------------------------------------
Lad Prabhakar (1):
can: rcar: Kconfig: update help description for CAN_RCAR config
Marc Kleine-Budde (4):
can: m_can: m_can_class_unregister(): remove erroneous m_can_clk_stop()
can: tcan4x5x: fix bittiming const, use common bittiming from m_can driver
can: mcp251xfd: mcp251xfd_handle_tefif(): fix TEF vs. TX race condition
can: mcp251xfd: mcp251xfd_handle_rxif_ring(): first increment RX tail pointer in HW, then in driver
Sriram Dash (1):
MAINTAINERS: Update MCAN MMIO device driver maintainer
MAINTAINERS | 2 +- drivers/net/can/m_can/m_can.c | 2 -- drivers/net/can/m_can/tcan4x5x.c | 26 -------------------------- drivers/net/can/rcar/Kconfig | 4 ++-- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 17 ++++++++--------- 5 files changed, 11 insertions(+), 40 deletions(-)
Marc Kleine-Budde
maintainerPATCH 1/6 can: m_can: m_can_class_unregister(): remove erroneous m_can_clk_stop()
In m_can_class_register() the clock is started, but stopped on exit. When calling m_can_class_unregister(), the clock is stopped a second time.
This patch removes the erroneous m_can_clk_stop() in m_can_class_unregister().
--- drivers/net/can/m_can/m_can.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/can/m_can/m_can.c +0 -2
@@ -1852,8 +1852,6 @@ EXPORT_SYMBOL_GPL(m_can_class_register);void m_can_class_unregister (struct m_can_classdev *cdev) {unregister_candev (cdev->net); - -m_can_clk_stop (cdev); }EXPORT_SYMBOL_GPL (m_can_class_unregister);
base-commit: 1f685e6adbbe3c7b1bd9053be771b898d9efa655
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerPATCH 2/6 can: tcan4x5x: fix bittiming const, use common bittiming from m_can driver
In reply to Marc Kleine-BuddeAccording to the TCAN4550 datasheet "SLLSF91 - DECEMBER 2018" the tcan4x5x has the same bittiming constants as a m_can revision 3.2.x/3.3.0.
The tcan4x5x chip I'm using identifies itself as m_can revision 3.2.1, so remove the tcan4x5x specific bittiming values and rely on the values in the m_can driver, which are selected according to core revision.
--- drivers/net/can/m_can/tcan4x5x.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/net/can/m_can/tcan4x5x.c +0 -26
@@ -131,30 +131,6 @@ static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev) } -static struct can_bittiming_const tcan4x5x_bittiming_const = { - .name =DEVICE_NAME , - .tseg1_min =2 , - .tseg1_max =31 , - .tseg2_min =2 , - .tseg2_max =16 , - .sjw_max =16 , - .brp_min =1 , - .brp_max =32 , - .brp_inc =1 , -}; - -static struct can_bittiming_const tcan4x5x_data_bittiming_const = { - .name =DEVICE_NAME , - .tseg1_min =1 , - .tseg1_max =32 , - .tseg2_min =1 , - .tseg2_max =16 , - .sjw_max =16 , - .brp_min =1 , - .brp_max =32 , - .brp_inc =1 , -}; -static void tcan4x5x_check_wake (struct tcan4x5x_priv *priv) {int wake_state =0 ;
@@ -469,8 +445,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi) mcan_class->dev = &spi->dev; mcan_class->ops = &tcan4x5x_ops; mcan_class->is_peripheral = true; - mcan_class->bit_timing = &tcan4x5x_bittiming_const; - mcan_class->data_timing = &tcan4x5x_data_bittiming_const; mcan_class->net->irq = spi->irq;spi_set_drvdata (spi, priv);
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerPATCH 3/6 can: mcp251xfd: mcp251xfd_handle_tefif(): fix TEF vs. TX race condition
In reply to Marc Kleine-BuddeThe mcp251xfd driver uses a TX FIFO for sending CAN frames and a TX Event FIFO (TEF) for completed TX-requests.
The TEF event handling in the mcp251xfd_handle_tefif() function has a race condition. It first increments the tx-ring's tail counter to signal that there's room in the TX and TEF FIFO, then it increments the TEF FIFO in hardware.
A running mcp251xfd_start_xmit() on a different CPU might not stop the txqueue (as the tx-ring still shows free space). The next mcp251xfd_start_xmit() will push a message into the chip and the TX complete event might overflow the TEF FIFO.
This patch changes the order to fix the problem.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +4 -5
@@ -1368,13 +1368,10 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)struct mcp251xfd_tx_ring *tx_ring = priv->tx;struct spi_transfer *last_xfer; - tx_ring->tail += len; -/* Increment the TEF FIFO tail pointer 'len' times in * a single SPI message. -*/ - -/* Note: +* +* Note: * * "cs_change == 1" on the last transfer results in an * active chip select after the complete SPI
@@ -1391,6 +1388,8 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv)if (err)return err; + tx_ring->tail += len; + err =mcp251xfd_check_tef_tail (priv);if (err)return err;
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerPATCH 4/6 can: mcp251xfd: mcp251xfd_handle_rxif_ring(): first increment RX tail pointer in HW, then in driver
In reply to Marc Kleine-BuddeThe previous patch fixes a TEF vs. TX race condition, by first updating the TEF tail pointer in hardware, and then updating the driver internal pointer.
The same pattern exists in the RX-path, too. This should be no problem, as the driver accesses the RX-FIFO from the interrupt handler only, thus the access is properly serialized. Fix the order here, too, so that the TEF- and RX-path look similar.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +4 -4
@@ -1552,10 +1552,8 @@ mcp251xfd_handle_rxif_ring(struct mcp251xfd_priv *priv,/* Increment the RX FIFO tail pointer 'len' times in a * single SPI message. -*/ - ring->tail += len; - -/* Note: +* +* Note: * * "cs_change == 1" on the last transfer results in an * active chip select after the complete SPI
@@ -1571,6 +1569,8 @@ mcp251xfd_handle_rxif_ring(struct mcp251xfd_priv *priv, last_xfer->cs_change =1 ;if (err)return err; + + ring->tail += len; }return 0 ;
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerPATCH 5/6 can: rcar: Kconfig: update help description for CAN_RCAR config
In reply to Marc Kleine-BuddeFrom: Lad Prabhakar <[email protected]>
The rcar_can driver also supports RZ/G SoC's, update the description to reflect this.
--- drivers/net/can/rcar/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/rcar/Kconfig +2 -2
@@ -1,10 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 config CAN_RCAR - tristate "Renesas R-Car CAN controller" + tristate "Renesas R-Car and RZ/G CAN controller" depends on ARCH_RENESAS || ARM help Say Y here if you want to use CAN controller found on Renesas R-Car - SoCs. + or RZ/G SoCs. To compile this driver as a module, choose M here: the module will be called rcar_can.
Signature · 1 line
2.29.2
Marc Kleine-Budde
maintainerPATCH 6/6 MAINTAINERS: Update MCAN MMIO device driver maintainer
In reply to Marc Kleine-BuddeFrom: Sriram Dash <[email protected]>
Update Pankaj Sharma as maintainer for mcan mmio device driver as I will be moving to a different role.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -10847,7 +10847,7 @@ F: drivers/media/radio/radio-maxiradio* MCAN MMIO DEVICE DRIVER M: Dan Murphy <[email protected]> -M: Sriram Dash <[email protected]> +M: Pankaj Sharma <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
Signature · 1 line
2.29.2
Jakub Kicinski
maintainerQuoted 15 lines · On Thu, 7 Jan 2021 11:34:45 +0100 Marc Kleine-Budde wrote:
Hello Jakub, hello David,
this is a pull request of 6 patches for net/master.
The first patch is by me for the
m_candriver and removes an erroneousm_can_clk_stop()from the driver's unregister function.The second patch targets the tcan4x5x driver, is by me, and fixes the bit timing constant parameters.
The next two patches are by me, target the mcp251xfd driver, and fix a race condition in the optimized TEF path (which was added in net-next for v5.11). The similar code in the RX path is changed to look the same, although it doesn't suffer from the race condition.
Quoted 5 lines
A patch by Lad Prabhakar updates the description and help text for the rcar CAN driver to reflect all supported SoCs.
In the last patch Sriram Dash transfers the maintainership of the
m_candriver to Pankaj Sharma.
Pulled, thanks!