pull-request: can 2025-10-14
Subsystems (8)
Marc Kleine-Budde
maintainercover pull-request: can 2025-10-14
Hello netdev-team,
this is a pull request of 10 patches for net/main.
The first 2 paches are by Celeste Liu and target the gS_usb driver. The first patch remove the limitation to 3 CAN interface per USB device. The second patch adds the missing population of net_device->dev_port.
THe next 4 patches are by me and fix the m_can driver. They add a missing pm_runtime_disable(), fix the CAN state transition back to Error Active and fix the state after ifup and suspend/resume.
Another patch by me targets the m_can driver, too and replaces Dong Aisheng's old email address.
The next 2 patches are by Vincent Mailhol and update the CAN networking Documentation.
Tetsuo Handa contributes the last patch that add missing cleanup calls in the NETDEV_UNREGISTER notification handler.
regards,
Marc
---
The following changes since commit 2c95a756e0cfc19af6d0b32b0c6cf3bada334998:
net: pse-pd: tps23881: Fix current measurement scaling (2025-10-07 18:30:53 -0700)
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-6.18-20251014
for you to fetch changes up to 93a27b5891b8194a8c083c9a80d2141d4bf47ba8:
can: j1939: add missing calls in NETDEV_UNREGISTER notification handler (2025-10-13 21:26:31 +0200)
----------------------------------------------------------------
linux-can-fixes-for-6.18-20251014
----------------------------------------------------------------
Celeste Liu (2):
can: gs_usb: increase max interface to U8_MAX
can: gs_usb: gs_make_candev(): populate net_device->dev_port
Marc Kleine-Budde (7):
can: m_can: m_can_plat_remove(): add missing pm_runtime_disable()
can: m_can: m_can_handle_state_errors(): fix CAN state transition to Error Active
can: m_can: m_can_chip_config(): bring up interface in correct state
can: m_can: fix CAN state in system PM
Merge patch series "can: m_can: fix pm_runtime and CAN state handling"
can: m_can: replace Dong Aisheng's old email address
Merge patch series "can: add Transmitter Delay Compensation (TDC) documentation"
Tetsuo Handa (1):
can: j1939: add missing calls in NETDEV_UNREGISTER notification handler
Vincent Mailhol (2):
can: remove false statement about 1:1 mapping between DLC and length
can: add Transmitter Delay Compensation (TDC) documentation
.mailmap | 1 + Documentation/networking/can.rst | 71 ++++++++++++++++++++++++++++++++-- drivers/net/can/m_can/m_can.c | 68 ++++++++++++++++++-------------- drivers/net/can/m_can/m_can_platform.c | 6 +-- drivers/net/can/usb/gs_usb.c | 23 ++++++----- net/can/j1939/main.c | 2 + 6 files changed, 123 insertions(+), 48 deletions(-)
Marc Kleine-Budde
maintainerPATCH 1/10 can: gs_usb: increase max interface to U8_MAX
From: Celeste Liu <[email protected]>
This issue was found by Runcheng Lu when develop HSCanT USB to CAN FD converter[1]. The original developers may have only 3 interfaces device to test so they write 3 here and wait for future change.
During the HSCanT development, we actually used 4 interfaces, so the limitation of 3 is not enough now. But just increase one is not future-proofed. Since the channel index type in gs_host_frame is u8, just make canch[] become a flexible array with a u8 index, so it naturally constraint by U8_MAX and avoid statically allocate 256 pointer for every gs_usb device.
[1]: https://github.com/cherry-embedded/HSCanT-hardware
--- drivers/net/can/usb/gs_usb.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/net/can/usb/gs_usb.c +10 -12
@@ -289,11 +289,6 @@ struct gs_host_frame {#define GS_MAX_RX_URBS 30#define GS_NAPI_WEIGHT 32 -/* Maximum number of interfaces the driver supports per device. -* Current hardware only supports 3 interfaces. The future may vary. -*/ -#define GS_MAX_INTF 3 -struct gs_tx_context {struct gs_can *dev;unsigned int echo_id;
@@ -324,7 +319,6 @@ struct gs_can {/* usb interface struct */ struct gs_usb { -struct gs_can *canch[GS_MAX_INTF ];struct usb_anchor rx_submitted;struct usb_device *udev;
@@ -336,9 +330,11 @@ struct gs_usb {unsigned int hf_size_rx;u8 active_channels; +u8 channel_cnt;unsigned int pipe_in;unsigned int pipe_out; + struct gs_can *canch[] __counted_by(channel_cnt); };/* 'allocate' a tx context.
@@ -599,7 +595,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) }/* device reports out of range channel id */ -if (hf->channel >=GS_MAX_INTF ) +if (hf->channel >= parent->channel_cnt) goto device_detach; dev = parent->canch[hf->channel];
@@ -699,7 +695,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)/* USB failure take down all interfaces */ if (rc == -ENODEV ) { device_detach: -for (rc =0 ; rc <GS_MAX_INTF ; rc++) { +for (rc =0 ; rc < parent->channel_cnt; rc++) {if (parent->canch[rc])netif_device_detach (parent->canch[rc]->netdev); }
@@ -1460,17 +1456,19 @@ static int gs_usb_probe(struct usb_interface *intf, icount = dconf.icount +1 ;dev_info (&intf->dev,"Configuring for %u interfaces\n" , icount); -if (icount >GS_MAX_INTF ) { +if (icount >type_max (parent->channel_cnt)) {dev_err (&intf->dev,"Driver cannot handle more that %u CAN interfaces\n" , -GS_MAX_INTF ); +type_max (parent->channel_cnt));return -EINVAL ; } - parent =kzalloc (sizeof (*parent),GFP_KERNEL ); + parent =kzalloc (struct_size (parent, canch, icount),GFP_KERNEL );if (!parent)return -ENOMEM ; + parent->channel_cnt = icount; +init_usb_anchor (&parent->rx_submitted);usb_set_intfdata (intf, parent);
@@ -1531,7 +1529,7 @@ static void gs_usb_disconnect(struct usb_interface *intf)return ; } -for (i =0 ; i <GS_MAX_INTF ; i++) +for (i =0 ; i < parent->channel_cnt; i++)if (parent->canch[i])gs_destroy_candev (parent->canch[i]);
base-commit: 2c95a756e0cfc19af6d0b32b0c6cf3bada334998
Signature · 1 line
2.51.0
Re: [PATCH net 01/10] can: gs_usb: increase max interface to U8_MAX
This series was applied to netdev/net.git (main) by Marc Kleine-Budde <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Marc Kleine-Budde <[email protected]>:
Quoted 6 lines · On Tue, 14 Oct 2025 14:17:48 +0200 you wrote:
From: Celeste Liu <[email protected]>
This issue was found by Runcheng Lu when develop HSCanT USB to CAN FD converter[1]. The original developers may have only 3 interfaces device to test so they write 3 here and wait for future change.
Quoted 8 lines
During the HSCanT development, we actually used 4 interfaces, so the limitation of 3 is not enough now. But just increase one is not future-proofed. Since the channel index type in
gs_host_frameis u8, just make canch[] become a flexible array with a u8 index, so it naturally constraint byU8_MAXand avoid statically allocate 256 pointer for everygs_usbdevice.[...]
Here is the summary with links:
- [net,01/10] can: gs_usb: increase max interface to U8_MAX
https://git.kernel.org/netdev/net/c/2a27f6a8fb57 - [net,02/10] can: gs_usb: gs_make_candev(): populate net_device->dev_port https://git.kernel.org/netdev/net/c/a12f0bc764da - [net,03/10] can: m_can: m_can_plat_remove(): add missing pm_runtime_disable() https://git.kernel.org/netdev/net/c/ba569fb07a7e - [net,04/10] can: m_can: m_can_handle_state_errors(): fix CAN state transition to Error Active https://git.kernel.org/netdev/net/c/3d9db29b45f9 - [net,05/10] can: m_can: m_can_chip_config(): bring up interface in correct state https://git.kernel.org/netdev/net/c/4942c42fe184 - [net,06/10] can: m_can: fix CAN state in system PM https://git.kernel.org/netdev/net/c/a9e30a22d6f2 - [net,07/10] can: m_can: replace Dong Aisheng's old email address https://git.kernel.org/netdev/net/c/49836ff2f37d - [net,08/10] can: remove false statement about 1:1 mapping between DLC and length https://git.kernel.org/netdev/net/c/c282993ccd97 - [net,09/10] can: add Transmitter Delay Compensation (TDC) documentation https://git.kernel.org/netdev/net/c/b5746b3e8ea4 - [net,10/10] can: j1939: add missing calls in NETDEV_UNREGISTER notification handler https://git.kernel.org/netdev/net/c/93a27b5891b8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Marc Kleine-Budde
maintainerPATCH 2/10 can: gs_usb: gs_make_candev(): populate net_device->dev_port
In reply to Marc Kleine-BuddeFrom: Celeste Liu <[email protected]>
The gs_usb driver supports USB devices with more than 1 CAN channel. In old kernel before 3.15, it uses net_device->dev_id to distinguish different channel in userspace, which was done in commit acff76fa45b4 ("can: gs_usb: gs_make_candev(): set netdev->dev_id"). But since 3.15, the correct way is populating net_device->dev_port. And according to documentation, if network device support multiple interface, lack of net_device->dev_port SHALL be treated as a bug.
--- drivers/net/can/usb/gs_usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/usb/gs_usb.c +1 -0
@@ -1245,6 +1245,7 @@ static struct gs_can *gs_make_candev(unsigned int channel, netdev->flags |=IFF_ECHO ;/* we support full roundtrip echo */ netdev->dev_id = channel; + netdev->dev_port = channel;/* dev setup */ strcpy (dev->bt_const.name,KBUILD_MODNAME );
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 3/10 can: m_can: m_can_plat_remove(): add missing pm_runtime_disable()
In reply to Marc Kleine-BuddeCommit 227619c3ff7c ("can: m_can: move runtime PM enable/disable to m_can_platform") moved the PM runtime enable from the m_can core driver into the m_can_platform.
That patch forgot to move the pm_runtime_disable() to m_can_plat_remove(), so that unloading the m_can_platform driver causes an "Unbalanced pm_runtime_enable!" error message.
Add the missing pm_runtime_disable() to m_can_plat_remove() to fix the problem.
--- drivers/net/can/m_can/m_can_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/m_can/m_can_platform.c +1 -1
@@ -180,7 +180,7 @@ static void m_can_plat_remove(struct platform_device *pdev)struct m_can_classdev *mcan_class = &priv->cdev;m_can_class_unregister (mcan_class); - +pm_runtime_disable (mcan_class->dev);m_can_class_free_dev (mcan_class->net); }
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 4/10 can: m_can: m_can_handle_state_errors(): fix CAN state transition to Error Active
In reply to Marc Kleine-BuddeThe CAN Error State is determined by the receive and transmit error counters. The CAN error counters decrease when reception/transmission is successful, so that a status transition back to the Error Active status is possible. This transition is not handled by m_can_handle_state_errors().
Add the missing detection of the Error Active state to m_can_handle_state_errors() and extend the handling of this state in m_can_handle_state_change().
--- drivers/net/can/m_can/m_can.c | 55 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 22 deletions(-)
drivers/net/can/m_can/m_can.c +33 -22
@@ -812,6 +812,9 @@ static int m_can_handle_state_change(struct net_device *dev,u32 timestamp =0 ;switch (new_state) { +case CAN_STATE_ERROR_ACTIVE : + cdev->can.state =CAN_STATE_ERROR_ACTIVE ; +break ;case CAN_STATE_ERROR_WARNING :/* error warning state */ cdev->can.can_stats.error_warning++;
@@ -841,6 +844,12 @@ static int m_can_handle_state_change(struct net_device *dev,__m_can_get_berr_counter (dev, &bec);switch (new_state) { +case CAN_STATE_ERROR_ACTIVE : + cf->can_id |=CAN_ERR_CRTL |CAN_ERR_CNT ; + cf->data[1 ] =CAN_ERR_CRTL_ACTIVE ; + cf->data[6 ] = bec.txerr; + cf->data[7 ] = bec.rxerr; +break ;case CAN_STATE_ERROR_WARNING :/* error warning state */ cf->can_id |=CAN_ERR_CRTL |CAN_ERR_CNT ;
@@ -877,30 +886,33 @@ static int m_can_handle_state_change(struct net_device *dev,return 1 ; } -static int m_can_handle_state_errors (struct net_device *dev,u32 psr) +static enum can_state +m_can_state_get_by_psr (struct m_can_classdev *cdev) +{ +u32 reg_psr; + + reg_psr =m_can_read (cdev,M_CAN_PSR ); + +if (reg_psr &PSR_BO ) +return CAN_STATE_BUS_OFF ; +if (reg_psr &PSR_EP ) +return CAN_STATE_ERROR_PASSIVE ; +if (reg_psr &PSR_EW ) +return CAN_STATE_ERROR_WARNING ; + +return CAN_STATE_ERROR_ACTIVE ; +} + +static int m_can_handle_state_errors (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev); -int work_done =0 ; +enum can_state new_state; -if (psr &PSR_EW && cdev->can.state !=CAN_STATE_ERROR_WARNING ) { -netdev_dbg (dev,"entered error warning state\n" ); - work_done +=m_can_handle_state_change (dev, -CAN_STATE_ERROR_WARNING ); - } + new_state =m_can_state_get_by_psr (cdev); +if (new_state == cdev->can.state) +return 0 ; -if (psr &PSR_EP && cdev->can.state !=CAN_STATE_ERROR_PASSIVE ) { -netdev_dbg (dev,"entered error passive state\n" ); - work_done +=m_can_handle_state_change (dev, -CAN_STATE_ERROR_PASSIVE ); - } - -if (psr &PSR_BO && cdev->can.state !=CAN_STATE_BUS_OFF ) { -netdev_dbg (dev,"entered error bus off state\n" ); - work_done +=m_can_handle_state_change (dev, -CAN_STATE_BUS_OFF ); - } - -return work_done; +return m_can_handle_state_change (dev, new_state); }static void m_can_handle_other_err (struct net_device *dev,u32 irqstatus)
@@ -1031,8 +1043,7 @@ static int m_can_rx_handler(struct net_device *dev, int quota, u32 irqstatus) }if (irqstatus &IR_ERR_STATE ) - work_done +=m_can_handle_state_errors (dev, -m_can_read (cdev,M_CAN_PSR )); + work_done +=m_can_handle_state_errors (dev);if (irqstatus &IR_ERR_BUS_30X ) work_done += m_can_handle_bus_errors(dev, irqstatus,
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 5/10 can: m_can: m_can_chip_config(): bring up interface in correct state
In reply to Marc Kleine-BuddeIn some SoCs (observed on the STM32MP15) the M_CAN IP core keeps the CAN state and CAN error counters over an internal reset cycle. An external reset is not always possible, due to the shared reset with the other CAN core. This caused the core not always be in Error Active state when bringing up the controller.
Instead of always setting the CAN state to Error Active in m_can_chip_config(), fix this by reading and decoding the Protocol Status Regitser (PSR) and set the CAN state accordingly.
--- drivers/net/can/m_can/m_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +1 -1
@@ -1617,7 +1617,7 @@ static int m_can_start(struct net_device *dev)netdev_queue_set_dql_min_limit (netdev_get_tx_queue (cdev->net,0 ), cdev->tx_max_coalesced_frames); - cdev->can.state =CAN_STATE_ERROR_ACTIVE ; + cdev->can.state =m_can_state_get_by_psr (cdev);m_can_enable_all_interrupts (cdev);
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 6/10 can: m_can: fix CAN state in system PM
In reply to Marc Kleine-BuddeA suspend/resume cycle on a down interface results in the interface coming up in Error Active state. A suspend/resume cycle on an Up interface will always result in Error Active state, regardless of the actual CAN state.
During suspend, only set running interfaces to CAN_STATE_SLEEPING. During resume only touch the CAN state of running interfaces. For wakeup sources, set the CAN state depending on the Protocol Status Regitser (PSR), for non wakeup source interfaces m_can_start() will do the same.
--- drivers/net/can/m_can/m_can.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/can/m_can/m_can.c +3 -4
@@ -2503,12 +2503,11 @@ int m_can_class_suspend(struct device *dev) }m_can_clk_stop (cdev); + cdev->can.state =CAN_STATE_SLEEPING ; }pinctrl_pm_select_sleep_state (dev); - cdev->can.state =CAN_STATE_SLEEPING ; -return ret; }EXPORT_SYMBOL_GPL (m_can_class_suspend);
@@ -2521,8 +2520,6 @@ int m_can_class_resume(struct device *dev)pinctrl_pm_select_default_state (dev); - cdev->can.state =CAN_STATE_ERROR_ACTIVE ; -if (netif_running (ndev)) { ret =m_can_clk_start (cdev);if (ret)
@@ -2540,6 +2537,8 @@ int m_can_class_resume(struct device *dev)if (cdev->ops->init) ret = cdev->ops->init (cdev); + cdev->can.state =m_can_state_get_by_psr (cdev); +m_can_write (cdev,M_CAN_IE , cdev->active_interrupts); }else { ret =m_can_start (ndev);
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 7/10 can: m_can: replace Dong Aisheng's old email address
In reply to Marc Kleine-BuddeDong Aisheng's old Freescale email is not valid anymore and bounces, replace it by the new NXP one.
--- .mailmap | 1 + drivers/net/can/m_can/m_can.c | 4 ++-- drivers/net/can/m_can/m_can_platform.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-)
.mailmap +1 -0
@@ -227,6 +227,7 @@ Dmitry Safonov <[email protected]> <[email protected]> Dmitry Safonov <[email protected]> <[email protected]> Dmitry Safonov <[email protected]> <[email protected]> Domen Puncer <[email protected]> +Dong Aisheng <[email protected]> <[email protected]> Douglas Gilbert <[email protected]> Drew Fustini <[email protected]> <[email protected]> <[email protected]> <[email protected]>
drivers/net/can/m_can/m_can.c +2 -2
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // CAN bus driver for Bosch M_CAN controller // Copyright (C) 2014 Freescale Semiconductor, Inc. -// Dong Aisheng <[email protected]> +// Dong Aisheng <[email protected]> // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ /* Bosch M_CAN user manual can be obtained from:
@@ -2556,7 +2556,7 @@ int m_can_class_resume(struct device *dev) }EXPORT_SYMBOL_GPL (m_can_class_resume); -MODULE_AUTHOR ("Dong Aisheng <[email protected]>" ); +MODULE_AUTHOR ("Dong Aisheng <[email protected]>" );MODULE_AUTHOR ("Dan Murphy <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("CAN bus driver for Bosch M_CAN controller" );
drivers/net/can/m_can/m_can_platform.c +2 -2
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 // IOMapped CAN bus driver for Bosch M_CAN controller // Copyright (C) 2014 Freescale Semiconductor, Inc. -// Dong Aisheng <[email protected]> +// Dong Aisheng <[email protected]> // // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
@@ -236,7 +236,7 @@ static struct platform_driver m_can_plat_driver = {module_platform_driver (m_can_plat_driver); -MODULE_AUTHOR ("Dong Aisheng <[email protected]>" ); +MODULE_AUTHOR ("Dong Aisheng <[email protected]>" );MODULE_AUTHOR ("Dan Murphy <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("M_CAN driver for IO Mapped Bosch controllers" );
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 8/10 can: remove false statement about 1:1 mapping between DLC and length
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
The CAN-FD section of can.rst still states that there is a 1:1 mapping between the Classical CAN DLC and its length. This is only true for the DLC values up to 8. Beyond that point, the length remains at 8.
For reference, the mapping between the CAN DLC and the length is given in below table [1]:
DLC value CBFF and CEFF FBFF and FEFF [decimal] [byte] [byte] ---------------------------------------------- 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 8 12 10 8 16 11 8 20 12 8 24 13 8 32 14 8 48 15 8 64
Remove the erroneous statement. Instead just state that the length of a Classical CAN frame ranges from 0 to 8.
[1] ISO 11898-1:2024, Table 5 -- DLC: coding of the four LSB
--- Documentation/networking/can.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Documentation/networking/can.rst +3 -4
@@ -1398,10 +1398,9 @@ second bit timing has to be specified in order to enable the CAN FD bitrate. Additionally CAN FD capable CAN controllers support up to 64 bytes of payload. The representation of this length in can_frame.len and canfd_frame.len for userspace applications and inside the Linux network -layer is a plain value from 0 .. 64 instead of the CAN 'data length code'. -The data length code was a 1:1 mapping to the payload length in the Classical -CAN frames anyway. The payload length to the bus-relevant DLC mapping is -only performed inside the CAN drivers, preferably with the helper +layer is a plain value from 0 .. 64 instead of the Classical CAN length +which ranges from 0 to 8. The payload length to the bus-relevant DLC mapping +is only performed inside the CAN drivers, preferably with the helper functions can_fd_dlc2len() and can_fd_len2dlc(). The CAN netdevice driver capabilities can be distinguished by the network
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 9/10 can: add Transmitter Delay Compensation (TDC) documentation
In reply to Marc Kleine-BuddeFrom: Vincent Mailhol <[email protected]>
Back in 2021, support for CAN TDC was added to the kernel in series [1] and in iproute2 in series [2]. However, the documentation was never updated.
Add a new sub-section under CAN-FD driver support to document how to configure the TDC using the "ip tool".
[1] add the netlink interface for CAN-FD Transmitter Delay Compensation (TDC)
[2] iplink_can: cleaning, fixes and adding TDC support
--- Documentation/networking/can.rst | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
Documentation/networking/can.rst +64 -0
@@ -1464,6 +1464,70 @@ Example when 'fd-non-iso on' is added on this switchable CAN FD adapter:: can <FD,FD-NON-ISO> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 +Transmitter Delay Compensation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +At high bit rates, the propagation delay from the TX pin to the RX pin of +the transceiver might become greater than the actual bit time causing +measurement errors: the RX pin would still be measuring the previous bit. + +The Transmitter Delay Compensation (thereafter, TDC) resolves this problem +by introducing a Secondary Sample Point (SSP) equal to the distance, in +minimum time quantum, from the start of the bit time on the TX pin to the +actual measurement on the RX pin. The SSP is calculated as the sum of two +configurable values: the TDC Value (TDCV) and the TDC offset (TDCO). + +TDC, if supported by the device, can be configured together with CAN-FD +using the ip tool's "tdc-mode" argument as follow: + +**omitted** + When no "tdc-mode" option is provided, the kernel will automatically + decide whether TDC should be turned on, in which case it will + calculate a default TDCO and use the TDCV as measured by the + device. This is the recommended method to use TDC. + +**"tdc-mode off"** + TDC is explicitly disabled. + +**"tdc-mode auto"** + The user must provide the "tdco" argument. The TDCV will be + automatically calculated by the device. This option is only + available if the device supports the TDC-AUTO CAN controller mode. + +**"tdc-mode manual"** + The user must provide both the "tdco" and "tdcv" arguments. This + option is only available if the device supports the TDC-MANUAL CAN + controller mode. + +Note that some devices may offer an additional parameter: "tdcf" (TDC Filter +window). If supported by your device, this can be added as an optional +argument to either "tdc-mode auto" or "tdc-mode manual". + +Example configuring a 500 kbit/s arbitration bitrate, a 5 Mbit/s data +bitrate, a TDCO of 15 minimum time quantum and a TDCV automatically measured +by the device:: + + $ ip link set can0 up type can bitrate 500000 \ + fd on dbitrate 4000000 \ + tdc-mode auto tdco 15 + $ ip -details link show can0 + 5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP \ + mode DEFAULT group default qlen 10 + link/can promiscuity 0 allmulti 0 minmtu 72 maxmtu 72 + can <FD,TDC-AUTO> state ERROR-ACTIVE restart-ms 0 + bitrate 500000 sample-point 0.875 + tq 12 prop-seg 69 phase-seg1 70 phase-seg2 20 sjw 10 brp 1 + ES582.1/ES584.1: tseg1 2..256 tseg2 2..128 sjw 1..128 brp 1..512 \ + brp_inc 1 + dbitrate 4000000 dsample-point 0.750 + dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 2 dbrp 1 + tdco 15 tdcf 0 + ES582.1/ES584.1: dtseg1 2..32 dtseg2 1..16 dsjw 1..8 dbrp 1..32 \ + dbrp_inc 1 + tdco 0..127 tdcf 0..127 + clock 80000000 + + Supported CAN Hardware ----------------------
Signature · 1 line
2.51.0
Marc Kleine-Budde
maintainerPATCH 10/10 can: j1939: add missing calls in NETDEV_UNREGISTER notification handler
In reply to Marc Kleine-BuddeFrom: Tetsuo Handa <[email protected]>
Currently NETDEV_UNREGISTER event handler is not calling j1939_cancel_active_session() and j1939_sk_queue_drop_all(). This will result in these calls being skipped when j1939_sk_release() is called. And I guess that the reason syzbot is still reporting
unregister_netdevice: waiting for vcan0 to become free. Usage count = 2
is caused by lack of these calls.
Calling j1939_cancel_active_session(priv, sk) from j1939_sk_release() can be covered by calling j1939_cancel_active_session(priv, NULL) from j1939_netdev_notify().
Calling j1939_sk_queue_drop_all() from j1939_sk_release() can be covered by calling j1939_sk_netdev_event_netdown() from j1939_netdev_notify().
Therefore, we can reuse j1939_cancel_active_session(priv, NULL) and j1939_sk_netdev_event_netdown(priv) for NETDEV_UNREGISTER event handler.
--- net/can/j1939/main.c | 2 ++ 1 file changed, 2 insertions(+)
net/can/j1939/main.c +2 -0
@@ -378,6 +378,8 @@ static int j1939_netdev_notify(struct notifier_block *nb,j1939_ecu_unmap_all (priv);break ;case NETDEV_UNREGISTER : +j1939_cancel_active_session (priv,NULL ); +j1939_sk_netdev_event_netdown (priv);j1939_sk_netdev_event_unregister (priv);break ; }
Signature · 1 line
2.51.0