Skip to content

Conversation

@william-tang914
Copy link
Contributor

This change refactors the FlexCAN driver to use per-instance message buffer configuration instead of global Kconfig options. The driver now calculates message buffer allocation at compile time based on device tree properties for each FlexCAN instance.

Key changes:

  • Remove global CAN_MAX_MB Kconfig option and associated range constraint
  • Add max_mb, rx_mb, and tx_mb fields to mcux_flexcan_config structure
  • Move callback arrays and atomic allocation bitmaps from static global arrays to per-instance static arrays generated by macros
  • Update data structure to use pointers to per-instance arrays instead of fixed-size embedded arrays
  • Add compile-time validation to ensure sufficient message buffers are available for required RX filters

This approach allows different FlexCAN instances to have different message buffer configurations based on their hardware capabilities and device tree settings, improving memory efficiency and flexibility. The change maintains backward compatibility while enabling better resource utilization across different SoC variants.

Fixes #92798

@william-tang914 william-tang914 force-pushed the feature/move-to-per-instance-message-buffer-configuration branch from 9e4b937 to d8b2c9b Compare November 17, 2025 05:59
Fix various formatting issues in NXP device tree files including:
- Inconsistent indentation in multi-line interrupt and pll-clocks arrays
- Missing spaces around assignment operators
- Inconsistent blank line spacing between device tree nodes

Also update copyright header in nxp_k6x.dtsi.

Signed-off-by: William Tang <william.tang@nxp.com>
Add the `nxp,max-mb` and `nxp,max-mb-fd` device tree property to
all NXP FlexCAN controller nodes across various SoC families to
specify the maximum number of 8-byte and 64-byte payload message
buffers supported by each FlexCAN instance.

This change updates device tree source files for multiple NXP SoC
families including Kinetis K6x, RT10xx, RT11xx, RT118x, MCX, S32K,
S32Z series, and i.MX8MP/i.MX93. The property values are set based
on hardware specifications for each specific FlexCAN instance.

This property addition ensures proper resource allocation and
prevents buffer overflow issues in FlexCAN driver implementations.

Signed-off-by: William Tang <william.tang@nxp.com>
This change refactors the FlexCAN driver to use per-instance message
buffer configuration instead of global Kconfig options. The driver now
calculates message buffer allocation at compile time based on device
tree properties for each FlexCAN instance.

Key changes:
- Remove global CAN_MAX_MB Kconfig option and associated range constraint
- Add max_mb, rx_mb, and tx_mb fields to mcux_flexcan_config structure
- Move callback arrays and atomic allocation bitmaps from static global
  arrays to per-instance static arrays generated by macros
- Update data structure to use pointers to per-instance arrays instead
  of fixed-size embedded arrays
- Add compile-time validation to ensure sufficient message buffers are
  available for required RX filters

This approach allows different FlexCAN instances to have different
message buffer configurations based on their hardware capabilities
and device tree settings, improving memory efficiency and flexibility.
The change maintains backward compatibility while enabling better
resource utilization across different SoC variants.

Fixes zephyrproject-rtos#92798

Signed-off-by: William Tang <william.tang@nxp.com>
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can: can_mcux_flexcan.c allows a mailbox overrun resulting in an imprecise data bus fault

2 participants