Enable multiple MCAN on AM62x
Subsystems (6)
cover Enable multiple MCAN on AM62x
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Note that in terms of power, enabling MCU MCANs with timer-polling implementation might have negative impact since we will have to wake up every 1 ms whether there are CAN packets pending in the RX FIFO or not. This might prevent the CPU from entering into deeper idle states for extended periods of time.
This patch series depends on 'Enable CAN PHY transceiver driver':
https://lore.kernel.org/lkml/[email protected]/T/
Judith Mendez (5):
arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay
arm64: defconfig: Enable MCAN driver
dt-binding: can: m_can: Remove required interrupt attributes
arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
can: m_can: Add hrtimer to generate software interrupt
.../bindings/net/can/bosch,m_can.yaml | 2 - arch/arm64/boot/dts/ti/Makefile | 2 + .../boot/dts/ti/k3-am625-sk-mcan-main.dtso | 35 +++++++++ .../boot/dts/ti/k3-am625-sk-mcan-mcu.dtso | 75 +++++++++++++++++++ arch/arm64/configs/defconfig | 2 + drivers/net/can/m_can/m_can.c | 24 +++++- drivers/net/can/m_can/m_can.h | 3 + drivers/net/can/m_can/m_can_platform.c | 9 ++- 8 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-main.dtso create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso
Signature · 1 line
2.17.1
RFC PATCH 1/5 arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay
Add an overlay for main domain MCAN on AM62x SK. The AM62x SK board does not have on-board CAN transceiver so instead of changing the dtb permanently, add an overlay to enable MAIN domain MCAN and support for 1 CAN transceiver.
--- arch/arm64/boot/dts/ti/Makefile | 2 ++ .../boot/dts/ti/k3-am625-sk-mcan-main.dtso | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-main.dtso
arch/arm64/boot/dts/ti/Makefile +2 -0
@@ -9,8 +9,10 @@ # alphabetically. # Boards with AM62x SoC +k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo dtb-$(CONFIG_ARCH_K3) += k3-am625-beagleplay.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk.dtb +dtb-$(CONFIG_ARCH_K3) += k3-am625-sk-mcan.dtb dtb-$(CONFIG_ARCH_K3) += k3-am62-lp-sk.dtb # Boards with AM62Ax SoC
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-main.dtso new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +/** + * DT overlay for MCAN transceiver in main domain on AM625 SK + * + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ + */ + +/dts-v1/; +/plugin/; + +#include <dt-bindings/pinctrl/k3.h> + +&{/} { + transceiver1: can-phy0 { + compatible = "ti,tcan1042"; + #phy-cells = <0>; + max-bitrate = <5000000>; + }; +}; + +&main_pmx0 { + main_mcan0_pins_default: main-mcan0-pins-default { + pinctrl-single,pins = < + AM62X_IOPAD(0x1dc, PIN_INPUT, 0) /* (E15) MCAN0_RX */ + AM62X_IOPAD(0x1d8, PIN_OUTPUT, 0) /* (C15) MCAN0_TX */ + >; + }; +}; + +&main_mcan0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&main_mcan0_pins_default>; + phys = <&transceiver1>; +};
Signature · 1 line
2.17.1
kernel test robot
build botRe: [RFC PATCH 1/5] arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay
kernel test robot noticed the following build warnings:
Hi Judith,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20230413]
[cannot apply to mkl-can-next/testing robh/for-next arm64/for-next/core v6.3-rc6 v6.3-rc5 v6.3-rc4 linus/master v6.3-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Judith-Mendez/arm64-dts-ti-Add-AM62x-MCAN-MAIN-domain-transceiver-overlay/20230414-063717 patch link: https://lore.kernel.org/r/20230413223051.24455-2-jm%40ti.com patch subject: [RFC PATCH 1/5] arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230414/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ec85544c219bbe3e8c693d520b5ce579c836a9e0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Judith-Mendez/arm64-dts-ti-Add-AM62x-MCAN-MAIN-domain-transceiver-overlay/20230414-063717 git checkout ec85544c219bbe3e8c693d520b5ce579c836a9e0
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from arch/arm64/boot/dts/ti/k3-am625-sk-mcan-main.dtso:11:
>> scripts/dtc/include-prefixes/dt-bindings/pinctrl/k3.h:16:2: warning: #warning "These bindings are deprecated. Instead, use the header in the DTS source directory." [-Wcpp]
16 | #warning "These bindings are deprecated. Instead, use the header in the DTS source directory."
| ^~~~~~~
vim +16 scripts/dtc/include-prefixes/dt-bindings/pinctrl/k3.h
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
RFC PATCH 2/5 arm64: defconfig: Enable MCAN driver
In reply to Judith MendezEnable CAN_M_CAN and CAN_M_CAN_PLATFORM to be built as modules by default for TI boards.
--- arch/arm64/configs/defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/configs/defconfig +2 -0
@@ -176,6 +176,8 @@ CONFIG_NET_ACT_GATE=m CONFIG_QRTR_SMD=m CONFIG_QRTR_TUN=m CONFIG_CAN=m +CONFIG_CAN_M_CAN=m +CONFIG_CAN_M_CAN_PLATFORM=m CONFIG_BT=m CONFIG_BT_HIDP=m # CONFIG_BT_LE is not set
Signature · 1 line
2.17.1
RFC PATCH 3/5 dt-binding: can: m_can: Remove required interrupt attributes
In reply to Judith MendezRemove required attributes for interrupt and interrupt names since some MCANs may not have hardware interrupt routed to A53 Linux.
--- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 2 -- 1 file changed, 2 deletions(-)
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +0 -2
@@ -122,8 +122,6 @@ required: - compatible - reg - reg-names - - interrupts - - interrupt-names - clocks - clock-names - bosch,mram-cfg
Signature · 1 line
2.17.1
Re: [RFC PATCH 3/5] dt-binding: can: m_can: Remove required interrupt attributes
Quoted 2 lines · Judith Mendez
Remove required attributes for interrupt and interrupt names since some MCANs may not have hardware interrupt routed to A53
Like which? Can you give specific model names?
Quoted 2 lines
Linux.
Use subject prefixes matching the subsystem (which you can get for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching).
It's dt-bindings:
Quoted 10 lines
Signed-off-by Judith Mendez <[email protected]>--- Documentation/devicetree/bindings/net/can/bosch,m_can.yaml | 2 -- 1 file changed, 2 deletions(-)Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +0
-0
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml required: · line 127
Quoted 8 lines
Documentation/devicetree/bindings/net/can/bosch,m_can.yaml +0
-2@@ -122,8 +122,6 @@ required: - compatible - reg - reg-names - - interrupts - - interrupt-names - clocks - clock-names - bosch,mram-cfg
Best regards,
Krzysztof
RFC PATCH 4/5 arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
In reply to Judith MendezEnable two MCAN in MCU domain. AM62x does not have on-board CAN transcievers, so instead of changing the DTB permanently, add MCU MCAN nodes and transceiver nodes to a MCU MCAN overlay.
If there are no hardware interrupts rounted to the GIC interrupt controller for MCAN IP, A53 Linux will not receive hardware interrupts. If an hrtimer is used to generate software interrupts, the two required interrupt attributes in the MCAN node do not have to be included.
--- arch/arm64/boot/dts/ti/Makefile | 2 +- .../boot/dts/ti/k3-am625-sk-mcan-mcu.dtso | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso
arch/arm64/boot/dts/ti/Makefile +1 -1
@@ -9,7 +9,7 @@ # alphabetically. # Boards with AM62x SoC -k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo +k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo k3-am625-sk-mcan-mcu.dtbo dtb-$(CONFIG_ARCH_K3) += k3-am625-beagleplay.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk-mcan.dtb
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC PATCH 4/5] arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
Quoted 84 lines · Judith Mendez
Enable two MCAN in MCU domain. AM62x does not have on-board CAN transcievers, so instead of changing the DTB permanently, add MCU MCAN nodes and transceiver nodes to a MCU MCAN overlay.
If there are no hardware interrupts rounted to the GIC interrupt controller for MCAN IP, A53 Linux will not receive hardware interrupts. If an hrtimer is used to generate software interrupts, the two required interrupt attributes in the MCAN node do not have to be included.
Signed-off-by Judith Mendez <[email protected]>--- arch/arm64/boot/dts/ti/Makefile | 2 +- .../boot/dts/ti/k3-am625-sk-mcan-mcu.dtso | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtsoarch/arm64/boot/dts/ti/Makefile +1
-1@@ -9,7 +9,7 @@ # alphabetically. # Boards with AM62x SoC -k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo +k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo k3-am625-sk-mcan-mcu.dtbo dtb-$(CONFIG_ARCH_K3) += k3-am625-beagleplay.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk-mcan.dtbarch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +48
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0 +/** + * DT overlay for MCAN in MCU domain on AM625 SK + * + * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ + */ + +/dts-v1/; +/plugin/; + +#include <dt-bindings/pinctrl/k3.h> +#include <dt-bindings/soc/ti,sci_pm_domain.h> + + +&{/} { + transceiver2: can-phy1 { + compatible = "ti,tcan1042"; + #phy-cells = <0>; + max-bitrate = <5000000>; + }; + + transceiver3: can-phy2 { + compatible = "ti,tcan1042"; + #phy-cells = <0>; + max-bitrate = <5000000>; + }; +}; + +&mcu_pmx0 { + mcu_mcan1_pins_default: mcu-mcan1-pins-default { + pinctrl-single,pins = < + AM62X_IOPAD(0x038, PIN_INPUT, 0) /* (B3) MCU_MCAN0_RX */ + AM62X_IOPAD(0x034, PIN_OUTPUT, 0) /* (D6) MCU_MCAN0_TX */ + >; + }; + + mcu_mcan2_pins_default: mcu-mcan2-pins-default { + pinctrl-single,pins = < + AM62X_IOPAD(0x040, PIN_INPUT, 0) /* (D4) MCU_MCAN1_RX */ + AM62X_IOPAD(0x03C, PIN_OUTPUT, 0) /* (E5) MCU_MCAN1_TX */ + >; + }; +}; + +&cbass_mcu { + mcu_mcan1: can@4e00000 { + compatible = "bosch,m_can"; + reg = <0x00 0x4e00000 0x00 0x8000>,
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 58
Quoted 10 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +10
-0+ <0x00 0x4e08000 0x00 0x200>; + reg-names = "message_ram", "m_can"; + power-domains = <&k3_pds 188 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 188 6>, <&k3_clks 188 1>; + clock-names = "hclk", "cclk"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + pinctrl-names = "default"; + pinctrl-0 = <&mcu_mcan1_pins_default>; + phys = <&transceiver2>; + status = "okay";
okay is by default. Why do you need it?
Best regards,
Krzysztof
Re: [RFC PATCH 4/5] arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
Quoted 41 lines · Krzysztof Kozlowski
Quoted 40 lines · Judith Mendez
Enable two MCAN in MCU domain. AM62x does not have on-board CAN transcievers, so instead of changing the DTB permanently, add MCU MCAN nodes and transceiver nodes to a MCU MCAN overlay.
If there are no hardware interrupts rounted to the GIC interrupt controller for MCAN IP, A53 Linux will not receive hardware interrupts. If an hrtimer is used to generate software interrupts, the two required interrupt attributes in the MCAN node do not have to be included.
Signed-off-by Judith Mendez <[email protected]>--- arch/arm64/boot/dts/ti/Makefile | 2 +- .../boot/dts/ti/k3-am625-sk-mcan-mcu.dtso | 75 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtsoarch/arm64/boot/dts/ti/Makefile +1
-1@@ -9,7 +9,7 @@ # alphabetically. # Boards with AM62x SoC -k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo +k3-am625-sk-mcan-dtbs := k3-am625-sk.dtb k3-am625-sk-mcan-main.dtbo k3-am625-sk-mcan-mcu.dtbo dtb-$(CONFIG_ARCH_K3) += k3-am625-beagleplay.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk.dtb dtb-$(CONFIG_ARCH_K3) += k3-am625-sk-mcan.dtbarch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +4
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0 +/** + * DT overlay for MCAN in MCU domain on AM625 SK + *
Quoted 8 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 12
Quoted 8 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +8
-0+ * Copyright (C) 2022 Texas Instruments Incorporated - https://www.ti.com/ + */ + +/dts-v1/; +/plugin/; + +#include <dt-bindings/pinctrl/k3.h> +#include <dt-bindings/soc/ti,sci_pm_domain.h>
NAK.
Quoted 40 lines
Quoted 40 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +40
-0+ + +&{/} { + transceiver2: can-phy1 { + compatible = "ti,tcan1042"; + #phy-cells = <0>; + max-bitrate = <5000000>; + }; + + transceiver3: can-phy2 { + compatible = "ti,tcan1042"; + #phy-cells = <0>; + max-bitrate = <5000000>; + }; +}; + +&mcu_pmx0 { + mcu_mcan1_pins_default: mcu-mcan1-pins-default { + pinctrl-single,pins = < + AM62X_IOPAD(0x038, PIN_INPUT, 0) /* (B3) MCU_MCAN0_RX */ + AM62X_IOPAD(0x034, PIN_OUTPUT, 0) /* (D6) MCU_MCAN0_TX */ + >; + }; + + mcu_mcan2_pins_default: mcu-mcan2-pins-default { + pinctrl-single,pins = < + AM62X_IOPAD(0x040, PIN_INPUT, 0) /* (D4) MCU_MCAN1_RX */ + AM62X_IOPAD(0x03C, PIN_OUTPUT, 0) /* (E5) MCU_MCAN1_TX */ + >; + }; +}; + +&cbass_mcu { + mcu_mcan1: can@4e00000 { + compatible = "bosch,m_can"; + reg = <0x00 0x4e00000 0x00 0x8000>, + <0x00 0x4e08000 0x00 0x200>; + reg-names = "message_ram", "m_can"; + power-domains = <&k3_pds 188 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 188 6>, <&k3_clks 188 1>;
Quoted 8 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 58
Quoted 6 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +6
-0+ clock-names = "hclk", "cclk"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + pinctrl-names = "default"; + pinctrl-0 = <&mcu_mcan1_pins_default>; + phys = <&transceiver2>; + status = "okay";okay is by default. Why do you need it?
mcan is not functional without pinmux, so it has been disabled by default in SoC. this overlay is supposed to enable it. But this is done entirely wrongly.
The mcu_mcan1 should first be added to the SoC.dtsi as disabled, then set to okay with pinctrl and transciever in the overlay.
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [RFC PATCH 4/5] arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
Quoted 18 lines · Nishanth Menon
Quoted 9 lines
Quoted 9 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +9
-0+ +&cbass_mcu { + mcu_mcan1: can@4e00000 { + compatible = "bosch,m_can"; + reg = <0x00 0x4e00000 0x00 0x8000>, + <0x00 0x4e08000 0x00 0x200>; + reg-names = "message_ram", "m_can"; + power-domains = <&k3_pds 188 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 188 6>, <&k3_clks 188 1>;Quoted 8 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 58
Quoted 6 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +6
-0+ clock-names = "hclk", "cclk"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + pinctrl-names = "default"; + pinctrl-0 = <&mcu_mcan1_pins_default>; + phys = <&transceiver2>; + status = "okay";okay is by default. Why do you need it?
Quoted 3 lines
mcan is not functional without pinmux, so it has been disabled by default in SoC. this overlay is supposed to enable it. But this is done entirely wrongly.
Ah, so this is override of existing node? Why not overriding by label/phandle?
Best regards,
Krzysztof
Nishanth Menon
maintainerRe: [RFC PATCH 4/5] arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Nishanth Menon
Quoted 17 lines
Quoted 5 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +5
-0+ +&cbass_mcu { + mcu_mcan1: can@4e00000 { + compatible = "bosch,m_can"; + reg = <0x00 0x4e00000 0x00 0x8000>,arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 58
Quoted 10 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +10
-0+ <0x00 0x4e08000 0x00 0x200>; + reg-names = "message_ram", "m_can"; + power-domains = <&k3_pds 188 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 188 6>, <&k3_clks 188 1>; + clock-names = "hclk", "cclk"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + pinctrl-names = "default"; + pinctrl-0 = <&mcu_mcan1_pins_default>; + phys = <&transceiver2>; + status = "okay";okay is by default. Why do you need it?
Quoted 6 lines
Quoted 3 lines
mcan is not functional without pinmux, so it has been disabled by default in SoC. this overlay is supposed to enable it. But this is done entirely wrongly.
Ah, so this is override of existing node? Why not overriding by label/phandle?
Yep, that is how it should be done (as every other node is done for mcan):
a) SoC.dtsi -> introduce mcu_mcan1, disabled since no transciever or pinmux, set status = "disabled";
b) overlay -> use the label and provide the missing properties, set status = "okay";
The series definitely needs a respin.
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Re: [RFC PATCH 4/5] arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
Hello, all
Quoted 27 lines · Nishanth Menon
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Nishanth Menon
Quoted 17 lines
Quoted 5 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +5
-0+ +&cbass_mcu { + mcu_mcan1: can@4e00000 { + compatible = "bosch,m_can"; + reg = <0x00 0x4e00000 0x00 0x8000>,arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso line 58
Quoted 10 lines
arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso new file +10
-0+ <0x00 0x4e08000 0x00 0x200>; + reg-names = "message_ram", "m_can"; + power-domains = <&k3_pds 188 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 188 6>, <&k3_clks 188 1>; + clock-names = "hclk", "cclk"; + bosch,mram-cfg = <0x0 128 64 64 64 64 32 32>; + pinctrl-names = "default"; + pinctrl-0 = <&mcu_mcan1_pins_default>; + phys = <&transceiver2>; + status = "okay";okay is by default. Why do you need it?
Quoted 6 lines
Quoted 3 lines
mcan is not functional without pinmux, so it has been disabled by default in SoC. this overlay is supposed to enable it. But this is done entirely wrongly.
Ah, so this is override of existing node? Why not overriding by label/phandle?
Quoted 9 lines
Yep, that is how it should be done (as every other node is done for mcan):
a)SoC.dtsi-> introducemcu_mcan1, disabled since no transciever or pinmux, set status = "disabled";
b) overlay -> use the label and provide the missing properties, set status = "okay";The series definitely needs a respin.
Thanks for your feedback, I will definitely fix and send out a v2 with this update.
Thanks,
Judith
RFC PATCH 5/5 can: m_can: Add hrtimer to generate software interrupt
In reply to Judith MendezAdd a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
The hrtimer will generate a software interrupt every 1 ms. In hrtimer callback, we check if there is a transaction pending by reading a register, then process by calling the isr if there is.
--- drivers/net/can/m_can/m_can.c | 24 ++++++++++++++++++++++-- drivers/net/can/m_can/m_can.h | 3 +++ drivers/net/can/m_can/m_can_platform.c | 9 +++++++-- 3 files changed, 32 insertions(+), 4 deletions(-)
drivers/net/can/m_can/m_can.c +22 -2
@@ -23,6 +23,7 @@#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/hrtimer.h> #include "m_can.h"
@@ -1584,6 +1585,11 @@ static int m_can_close(struct net_device *dev)if (!cdev->is_peripheral)napi_disable (&cdev->napi); +if (dev->irq <0 ) { +dev_info (cdev->dev,"Disabling the hrtimer\n" ); +hrtimer_cancel (&cdev->hrtimer); + } +m_can_stop (dev);m_can_clk_stop (cdev);free_irq (dev->irq, dev);
@@ -1792,6 +1798,19 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } +enum hrtimer_restart hrtimer_callback (struct hrtimer *timer) +{ +irqreturn_t ret; +struct m_can_classdev *cdev = + container_of(timer, struct m_can_classdev, hrtimer); + + ret =m_can_isr (0 , cdev->net); + +hrtimer_forward_now (timer,ns_to_ktime (5 *NSEC_PER_MSEC )); + +return HRTIMER_RESTART ; +} +static int m_can_open (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev);
@@ -1836,8 +1855,9 @@ static int m_can_open(struct net_device *dev) }if (err <0 ) { -netdev_err (dev,"failed to request interrupt\n" ); - goto exit_irq_fail; +dev_info (cdev->dev,"Enabling the hrtimer\n" ); + cdev->hrtimer.function = &hrtimer_callback; +hrtimer_start (&cdev->hrtimer,ns_to_ktime (0 ),HRTIMER_MODE_REL_PINNED ); }/* start the m_can controller */
drivers/net/can/m_can/m_can.h +3 -0
@@ -28,6 +28,7 @@#include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/hrtimer.h> /* m_can lec values */ enum m_can_lec_type {
@@ -93,6 +94,8 @@ struct m_can_classdev {int is_peripheral;struct mram_cfg mcfg[MRAM_CFG_NUM ]; + +struct hrtimer hrtimer; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);
drivers/net/can/m_can/m_can_platform.c +7 -2
@@ -7,6 +7,7 @@#include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/hrtimer.h> #include "m_can.h"
@@ -98,8 +99,12 @@ static int m_can_plat_probe(struct platform_device *pdev) addr =devm_platform_ioremap_resource_byname (pdev,"m_can" ); irq =platform_get_irq_byname (pdev,"int0" );if (IS_ERR (addr) || irq <0 ) { - ret = -EINVAL ; - goto probe_fail; +if (irq == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto probe_fail; + } +dev_info (mcan_class->dev,"Failed to get irq, initialize hrtimer\n" ); +hrtimer_init (&mcan_class->hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_PINNED ); }/* message ram could be shared */
Signature · 1 line
2.17.1
kernel test robot
build botRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
kernel test robot noticed the following build warnings:
Hi Judith,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on next-20230413]
[cannot apply to mkl-can-next/testing robh/for-next arm64/for-next/core v6.3-rc6 v6.3-rc5 v6.3-rc4 linus/master v6.3-rc6] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Judith-Mendez/arm64-dts-ti-Add-AM62x-MCAN-MAIN-domain-transceiver-overlay/20230414-063717 patch link: https://lore.kernel.org/r/20230413223051.24455-6-jm%40ti.com patch subject: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230414/[email protected]/config) compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/6f7bb16a77781f387f8bc623d64d3c2273cce61a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Judith-Mendez/arm64-dts-ti-Add-AM62x-MCAN-MAIN-domain-transceiver-overlay/20230414-063717 git checkout 6f7bb16a77781f387f8bc623d64d3c2273cce61a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/net/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/can/m_can/m_can.c:1802:22: warning: no previous prototype for 'hrtimer_callback' [-Wmissing-prototypes]
1802 | enum hrtimer_restart hrtimer_callback(struct hrtimer *timer)
| ^~~~~~~~~~~~~~~~
drivers/net/can/m_can/m_can.c: In function 'hrtimer_callback':
>> drivers/net/can/m_can/m_can.c:1804:21: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
1804 | irqreturn_t ret;
| ^~~vim +/hrtimer_callback +1802 drivers/net/can/m_can/m_can.c
1801
> 1802 enum hrtimer_restart hrtimer_callback(struct hrtimer *timer)
1803 {
> 1804 irqreturn_t ret; 1805 struct m_can_classdev *cdev =
1806 container_of(timer, struct m_can_classdev, hrtimer);
1807
1808 ret = m_can_isr(0, cdev->net);
1809
1810 hrtimer_forward_now(timer, ns_to_ktime(5 * NSEC_PER_MSEC));
1811
1812 return HRTIMER_RESTART;
1813 }
1814
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Marc Kleine-Budde
maintainerRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
In reply to Judith MendezQuoted 4 lines · Judith Mendez
Add a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
The hrtimer will generate a software interrupt every 1 ms. In
Are you sure about the 1ms?
Quoted 23 lines
hrtimer callback, we check if there is a transaction pending by reading a register, then process by calling the isr if there is.
Signed-off-by Judith Mendez <[email protected]>--- drivers/net/can/m_can/m_can.c | 24 ++++++++++++++++++++++-- drivers/net/can/m_can/m_can.h | 3 +++ drivers/net/can/m_can/m_can_platform.c | 9 +++++++-- 3 files changed, 32 insertions(+), 4 deletions(-)drivers/net/can/m_can/m_can.c +1
-0@@ -23,6 +23,7 @@#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/hrtimer.h> #include "m_can.h"
drivers/net/can/m_can/m_can.c static int m_can_close(struct net_device *dev) · line 1589
Quoted 5 lines
drivers/net/can/m_can/m_can.c +2
-0@@ -1584,6 +1585,11 @@ static int m_can_close(struct net_device *dev)if (!cdev->is_peripheral)napi_disable (&cdev->napi); +if (dev->irq <0 ) { +dev_info (cdev->dev,"Disabling the hrtimer\n" );
Make it a dev_dbg() or remove completely.
drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1803
Quoted 13 lines
drivers/net/can/m_can/m_can.c +6
-0+hrtimer_cancel (&cdev->hrtimer); + } +m_can_stop (dev);m_can_clk_stop (cdev);free_irq (dev->irq, dev);@@ -1792,6 +1798,19 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } +enum hrtimer_restart hrtimer_callback (struct hrtimer *timer) +{ +irqreturn_t ret;
never read value?
drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1809
Quoted 6 lines
drivers/net/can/m_can/m_can.c +6
-0+struct m_can_classdev *cdev = + container_of(timer, struct m_can_classdev, hrtimer); + + ret =m_can_isr (0 , cdev->net); + +hrtimer_forward_now (timer,ns_to_ktime (5 *NSEC_PER_MSEC ));
There's ms_to_ktime()....and the "5" doesn't match your patch description.
Quoted 8 lines
drivers/net/can/m_can/m_can.c +4
-0+ +return HRTIMER_RESTART ; +} +static int m_can_open (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev);
drivers/net/can/m_can/m_can.c static int m_can_open(struct net_device *dev) · line 1860
Quoted 8 lines
drivers/net/can/m_can/m_can.c +3
-2@@ -1836,8 +1855,9 @@ static int m_can_open(struct net_device *dev) }if (err <0 ) { -netdev_err (dev,"failed to request interrupt\n" ); - goto exit_irq_fail; +dev_info (cdev->dev,"Enabling the hrtimer\n" ); + cdev->hrtimer.function = &hrtimer_callback; +hrtimer_start (&cdev->hrtimer,ns_to_ktime (0 ),HRTIMER_MODE_REL_PINNED );
IMHO it makes no sense to request an IRQ if the device doesn't have one, and then try to fix up things in the error path. What about this?
drivers/net/can/m_can/m_can.c +3 -1
@@ -1831,9 +1831,11 @@ static int m_can_open(struct net_device *dev) err =request_threaded_irq (dev->irq,NULL , m_can_isr,IRQF_ONESHOT , dev->name, dev); - }else { + }else if (dev->irq) { err =request_irq (dev->irq, m_can_isr,IRQF_SHARED , dev->name, dev); + }else { +// polling }if (err <0 ) {
Quoted 37 lines
drivers/net/can/m_can/m_can.c +0
-0}/* start the m_can controller */ drivers/net/can/m_can/m_can.h +3
-0@@ -28,6 +28,7 @@#include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/hrtimer.h> /* m_can lec values */ enum m_can_lec_type {@@ -93,6 +94,8 @@ struct m_can_classdev {int is_peripheral;struct mram_cfg mcfg[MRAM_CFG_NUM ]; + +struct hrtimer hrtimer; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);drivers/net/can/m_can/m_can_platform.c +1
-0@@ -7,6 +7,7 @@#include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/hrtimer.h> #include "m_can.h"
drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 101
Quoted 3 lines
drivers/net/can/m_can/m_can_platform.c +0
-0@@ -98,8 +99,12 @@ static int m_can_plat_probe(struct platform_device *pdev) addr =devm_platform_ioremap_resource_byname (pdev,"m_can" ); irq =platform_get_irq_byname (pdev,"int0" );if (IS_ERR (addr) || irq <0 ) {
What about the IS_ERR(addr) case?
drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 107
Quoted 8 lines
drivers/net/can/m_can/m_can_platform.c +6
-2- ret = -EINVAL ; - goto probe_fail; +if (irq == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto probe_fail; + } +dev_info (mcan_class->dev,"Failed to get irq, initialize hrtimer\n" ); +hrtimer_init (&mcan_class->hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_PINNED );
I don't like it when polling is unconditionally set up in case of an irq error. I'm not sure if we need an explicit device tree property....
Quoted 7 lines
drivers/net/can/m_can/m_can_platform.c +0
-0}/* message ram could be shared */ Signature · 1 line
2.17.1
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 7 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
Add a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
The hrtimer will generate a software interrupt every 1 ms. In
Are you sure about the 1ms?
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
50 usecs * (FIFO queue len - 2)
if there is some FIFO involved, right?
Best regards,
Oliver
Quoted 158 lines
Quoted 23 lines
hrtimer callback, we check if there is a transaction pending by reading a register, then process by calling the isr if there is.
Signed-off-by Judith Mendez <[email protected]>--- drivers/net/can/m_can/m_can.c | 24 ++++++++++++++++++++++-- drivers/net/can/m_can/m_can.h | 3 +++ drivers/net/can/m_can/m_can_platform.c | 9 +++++++-- 3 files changed, 32 insertions(+), 4 deletions(-)drivers/net/can/m_can/m_can.c +1
-0@@ -23,6 +23,7 @@#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/hrtimer.h> #include "m_can.h" drivers/net/can/m_can/m_can.c static int m_can_close(struct net_device *dev) · line 1589
Quoted 5 lines
drivers/net/can/m_can/m_can.c +2
-0@@ -1584,6 +1585,11 @@ static int m_can_close(struct net_device *dev)if (!cdev->is_peripheral)napi_disable (&cdev->napi); +if (dev->irq <0 ) { +dev_info (cdev->dev,"Disabling the hrtimer\n" );Make it a
dev_dbg()or remove completely.drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1803
Quoted 13 lines
drivers/net/can/m_can/m_can.c +6
-0+hrtimer_cancel (&cdev->hrtimer); + } +m_can_stop (dev);m_can_clk_stop (cdev);free_irq (dev->irq, dev);@@ -1792,6 +1798,19 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; } +enum hrtimer_restart hrtimer_callback (struct hrtimer *timer) +{ +irqreturn_t ret;never read value?
drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1809
Quoted 6 lines
drivers/net/can/m_can/m_can.c +6
-0+struct m_can_classdev *cdev = + container_of(timer, struct m_can_classdev, hrtimer); + + ret =m_can_isr (0 , cdev->net); + +hrtimer_forward_now (timer,ns_to_ktime (5 *NSEC_PER_MSEC ));There's ms_to_ktime()....and the "5" doesn't match your patch description.
Quoted 8 lines
drivers/net/can/m_can/m_can.c +4
-0+ +return HRTIMER_RESTART ; +} +static int m_can_open (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev);drivers/net/can/m_can/m_can.c static int m_can_open(struct net_device *dev) · line 1860
Quoted 8 lines
drivers/net/can/m_can/m_can.c +3
-2@@ -1836,8 +1855,9 @@ static int m_can_open(struct net_device *dev) }if (err <0 ) { -netdev_err (dev,"failed to request interrupt\n" ); - goto exit_irq_fail; +dev_info (cdev->dev,"Enabling the hrtimer\n" ); + cdev->hrtimer.function = &hrtimer_callback; +hrtimer_start (&cdev->hrtimer,ns_to_ktime (0 ),HRTIMER_MODE_REL_PINNED );IMHO it makes no sense to request an IRQ if the device doesn't have one, and then try to fix up things in the error path. What about this?
drivers/net/can/m_can/m_can.c +3
-1@@ -1831,9 +1831,11 @@ static int m_can_open(struct net_device *dev) err =request_threaded_irq (dev->irq,NULL , m_can_isr,IRQF_ONESHOT , dev->name, dev); - }else { + }else if (dev->irq) { err =request_irq (dev->irq, m_can_isr,IRQF_SHARED , dev->name, dev); + }else { +// polling }if (err <0 ) {Quoted 38 lines
drivers/net/can/m_can/m_can.c +0
-0}/* start the m_can controller */ drivers/net/can/m_can/m_can.h +3
-0@@ -28,6 +28,7 @@#include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/hrtimer.h> /* m_can lec values */ enum m_can_lec_type {@@ -93,6 +94,8 @@ struct m_can_classdev {int is_peripheral;struct mram_cfg mcfg[MRAM_CFG_NUM ]; + +struct hrtimer hrtimer; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);drivers/net/can/m_can/m_can_platform.c +1
-0@@ -7,6 +7,7 @@#include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/hrtimer.h> #include "m_can.h" drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 101
Quoted 3 lines
drivers/net/can/m_can/m_can_platform.c +0
-0@@ -98,8 +99,12 @@ static int m_can_plat_probe(struct platform_device *pdev) addr =devm_platform_ioremap_resource_byname (pdev,"m_can" ); irq =platform_get_irq_byname (pdev,"int0" );if (IS_ERR (addr) || irq <0 ) {What about the
IS_ERR(addr)case?drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 107
Quoted 8 lines
drivers/net/can/m_can/m_can_platform.c +6
-2- ret = -EINVAL ; - goto probe_fail; +if (irq == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto probe_fail; + } +dev_info (mcan_class->dev,"Failed to get irq, initialize hrtimer\n" ); +hrtimer_init (&mcan_class->hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_PINNED );I don't like it when polling is unconditionally set up in case of an irq error. I'm not sure if we need an explicit device tree property....
Quoted 7 lines
drivers/net/can/m_can/m_can_platform.c +0
-0}/* message ram could be shared */ Signature · 1 line
2.17.1Marc
Marc Kleine-Budde
maintainerRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 10 lines · Oliver Hartkopp
Quoted 7 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
Add a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
The hrtimer will generate a software interrupt every 1 ms. In
Are you sure about the 1ms?
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
Quoted 7 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
Quoted 1 line
if there is some FIFO involved, right?
Yes, the mcan core has a FIFO. In the current driver the FIFO configuration is done via device tree and fixed after that. And I don't know the size of the available RAM in the mcan IP core on that TI SoC.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 8 lines · Marc Kleine-Budde
Quoted 7 lines · Oliver Hartkopp
Quoted 4 lines · Marc Kleine-Budde
Quoted 3 lines · Judith Mendez
Add a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
The hrtimer will generate a software interrupt every 1 ms. In
Are you sure about the 1ms?
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
@Judith: Can you acknowledge the value calculation?
Quoted 9 lines
Quoted 7 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
Quoted 8 lines
Quoted 1 line
if there is some FIFO involved, right?
Yes, the mcan core has a FIFO. In the current driver the FIFO configuration is done via device tree and fixed after that. And I don't know the size of the available RAM in the mcan IP core on that TI SoC.
Marc
Best regards,
Oliver
Marc Kleine-Budde
maintainerRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 11 lines · Oliver Hartkopp
Quoted 2 lines
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
@Judith: Can you acknowledge the value calculation?
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
I was assuming something like this.
I would argue that the polling time should be:
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 21 lines · Marc Kleine-Budde
Quoted 11 lines · Oliver Hartkopp
Quoted 2 lines
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
@Judith: Can you acknowledge the value calculation?
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
Quoted 7 lines
I was assuming something like this.
I would argue that the polling time should be:
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
I just tried an educated guess to prevent the FIFO to be filled up completely. How can you estimate the "IRQ overhead"? And how do you catch the CAN frames that are received while the IRQ is handled?
Best regards,
Oliver
Marc Kleine-Budde
maintainerRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 26 lines · Oliver Hartkopp
Quoted 25 lines · Marc Kleine-Budde
Quoted 11 lines · Oliver Hartkopp
Quoted 2 lines
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
@Judith: Can you acknowledge the value calculation?
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
I was assuming something like this.
I would argue that the polling time should be:
Quoted 7 lines
Quoted 3 lines
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
I just tried an educated guess to prevent the FIFO to be filled up completely. How can you estimate the "IRQ overhead"? And how do you catch the CAN frames that are received while the IRQ is handled?
We're talking about polling, better call it "overhead" or "latency from timer expiration until FIFO has at least one frame room". This value depends on your system.
It depends on many, many factors, SoC, Kernel configuration (preempt RT, powersaving, frequency scaling, system load. In your example it's 100 µs. I wanted to say there's an overhead (or latency) and we need enough space in the FIFO, to cover it.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Hello Marc,
Quoted 35 lines · Marc Kleine-Budde
Quoted 26 lines · Oliver Hartkopp
Quoted 25 lines · Marc Kleine-Budde
Quoted 11 lines · Oliver Hartkopp
Quoted 2 lines
I had the 5ms that are actually used in the code in mind. But this is a good calculation.
@Judith: Can you acknowledge the value calculation?
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
I was assuming something like this.
I would argue that the polling time should be:
Quoted 7 lines
Quoted 3 lines
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
I just tried an educated guess to prevent the FIFO to be filled up completely. How can you estimate the "IRQ overhead"? And how do you catch the CAN frames that are received while the IRQ is handled?
Quoted 9 lines
We're talking about polling, better call it "overhead" or "latency from timer expiration until FIFO has at least one frame room". This value depends on your system.
It depends on many, many factors, SoC, Kernel configuration (preempt RT, powersaving, frequency scaling, system load. In your example it's 100 µs. I wanted to say there's an overhead (or latency) and we need enough space in the FIFO, to cover it.
I am not sure how to estimate IRQ overhead, but FIFO length should be 64 elements.
50 us * 62 is about 3.1 ms and we are using 1 ms timer polling interval.
Running a few benchmarks showed that using 0.5 ms timer polling interval starts to take a toll on CPU load, that is why I chose 1 ms polling interval.
regards,
Judith
Marc Kleine-Budde
maintainerRe: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Quoted 31 lines · Judith
Quoted 31 lines
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
I was assuming something like this.
I would argue that the polling time should be:
Quoted 7 lines
Quoted 3 lines
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
I just tried an educated guess to prevent the FIFO to be filled up completely. How can you estimate the "IRQ overhead"? And how do you catch the CAN frames that are received while the IRQ is handled?
We're talking about polling, better call it "overhead" or "latency from timer expiration until FIFO has at least one frame room". This value depends on your system.
Quoted 8 lines
Quoted 5 lines
It depends on many, many factors, SoC, Kernel configuration (preempt RT, powersaving, frequency scaling, system load. In your example it's 100 µs. I wanted to say there's an overhead (or latency) and we need enough space in the FIFO, to cover it.
I am not sure how to estimate IRQ overhead, but FIFO length should be 64 elements.
Ok
Quoted 1 line
50 us * 62 is about 3.1 ms and we are using 1 ms timer polling interval.
Sounds good.
Quoted 3 lines
Running a few benchmarks showed that using 0.5 ms timer polling interval starts to take a toll on CPU load, that is why I chose 1 ms polling interval.
However in the code you use 5 ms.
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
Hello Marc,
Quoted 45 lines · Marc Kleine-Budde
Quoted 31 lines · Judith
Quoted 31 lines
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
The "shortest" 11 bit CAN ID CAN frame is a Classical CAN frame with DLC = 0 and 1 Mbit/s (arbitration) bitrate. This should be 48 bits @1Mbit => ~50 usecs
So it should be something about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
50 usecs * (FIFO queue len - 2)
Where does the "2" come from?
I thought about handling the FIFO earlier than it gets completely "full".
The fetching routine would need some time too and the hrtimer could also jitter to some extend.
I was assuming something like this.
I would argue that the polling time should be:
Quoted 7 lines
Quoted 3 lines
50 µs * FIFO length - IRQ overhead.
The max IRQ overhead depends on your SoC and kernel configuration.
I just tried an educated guess to prevent the FIFO to be filled up completely. How can you estimate the "IRQ overhead"? And how do you catch the CAN frames that are received while the IRQ is handled?
We're talking about polling, better call it "overhead" or "latency from timer expiration until FIFO has at least one frame room". This value depends on your system.
Quoted 8 lines
Quoted 5 lines
It depends on many, many factors, SoC, Kernel configuration (preempt RT, powersaving, frequency scaling, system load. In your example it's 100 µs. I wanted to say there's an overhead (or latency) and we need enough space in the FIFO, to cover it.
I am not sure how to estimate IRQ overhead, but FIFO length should be 64 elements.
Ok
Quoted 1 line
50 us * 62 is about 3.1 ms and we are using 1 ms timer polling interval.
Quoted 7 lines
Sounds good.
Quoted 3 lines
Running a few benchmarks showed that using 0.5 ms timer polling interval starts to take a toll on CPU load, that is why I chose 1 ms polling interval.
However in the code you use 5 ms.
Yes, it was a mistake, will send out a respin with the correct value, thanks.
regards,
Judith
Re: [RFC PATCH 5/5] can: m_can: Add hrtimer to generate software interrupt
In reply to Marc Kleine-BuddeHello Marc,
Quoted 30 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
Add a hrtimer to MCAN struct. Each MCAN will have its own hrtimer instantiated if there is no hardware interrupt found.
The hrtimer will generate a software interrupt every 1 ms. In
Are you sure about the 1ms?
Quoted 22 lines
hrtimer callback, we check if there is a transaction pending by reading a register, then process by calling the isr if there is.
Signed-off-by Judith Mendez <[email protected]>--- drivers/net/can/m_can/m_can.c | 24 ++++++++++++++++++++++-- drivers/net/can/m_can/m_can.h | 3 +++ drivers/net/can/m_can/m_can_platform.c | 9 +++++++-- 3 files changed, 32 insertions(+), 4 deletions(-)drivers/net/can/m_can/m_can.c +1
-0@@ -23,6 +23,7 @@#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/hrtimer.h> #include "m_can.h"
Quoted 9 lines
drivers/net/can/m_can/m_can.c static int m_can_close(struct net_device *dev) · line 1589
Quoted 6 lines
drivers/net/can/m_can/m_can.c +2
-0@@ -1584,6 +1585,11 @@ static int m_can_close(struct net_device *dev)if (!cdev->is_peripheral)napi_disable (&cdev->napi); +if (dev->irq <0 ) { +dev_info (cdev->dev,"Disabling the hrtimer\n" );Make it a
dev_dbg()or remove completely.
Will do, thanks.
Quoted 10 lines
Quoted 10 lines
drivers/net/can/m_can/m_can.c +3
-0+hrtimer_cancel (&cdev->hrtimer); + } +m_can_stop (dev);m_can_clk_stop (cdev);free_irq (dev->irq, dev);@@ -1792,6 +1798,19 @@ static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,return NETDEV_TX_OK ; }
Quoted 6 lines
drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1803
Quoted 3 lines
drivers/net/can/m_can/m_can.c +3
-0+enum hrtimer_restart hrtimer_callback (struct hrtimer *timer) +{ +irqreturn_t ret;never read value?
I have removed ret completely now.
Quoted 46 lines
drivers/net/can/m_can/m_can.c static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, · line 1809
Quoted 6 lines
drivers/net/can/m_can/m_can.c +6
-0+struct m_can_classdev *cdev = + container_of(timer, struct m_can_classdev, hrtimer); + + ret =m_can_isr (0 , cdev->net); + +hrtimer_forward_now (timer,ns_to_ktime (5 *NSEC_PER_MSEC ));There's ms_to_ktime()....and the "5" doesn't match your patch description.
Quoted 8 lines
drivers/net/can/m_can/m_can.c +4
-0+ +return HRTIMER_RESTART ; +} +static int m_can_open (struct net_device *dev) {struct m_can_classdev *cdev =netdev_priv (dev);drivers/net/can/m_can/m_can.c static int m_can_open(struct net_device *dev) · line 1860
Quoted 8 lines
drivers/net/can/m_can/m_can.c +3
-2@@ -1836,8 +1855,9 @@ static int m_can_open(struct net_device *dev) }if (err <0 ) { -netdev_err (dev,"failed to request interrupt\n" ); - goto exit_irq_fail; +dev_info (cdev->dev,"Enabling the hrtimer\n" ); + cdev->hrtimer.function = &hrtimer_callback; +hrtimer_start (&cdev->hrtimer,ns_to_ktime (0 ),HRTIMER_MODE_REL_PINNED );IMHO it makes no sense to request an IRQ if the device doesn't have one, and then try to fix up things in the error path. What about this?
drivers/net/can/m_can/m_can.c +3
-1@@ -1831,9 +1831,11 @@ static int m_can_open(struct net_device *dev) err =request_threaded_irq (dev->irq,NULL , m_can_isr,IRQF_ONESHOT , dev->name, dev); - }else { + }else if (dev->irq) { err =request_irq (dev->irq, m_can_isr,IRQF_SHARED , dev->name, dev); + }else { +// polling }if (err <0 ) {
Quoted 1 line
drivers/net/can/m_can/m_can.c static int m_can_open(struct net_device *dev) · line 1861
Quoted 1 line
drivers/net/can/m_can/m_can.c +0
-0}
Thanks for the recommendation, I will include in v2.
Quoted 33 lines
Quoted 33 lines
drivers/net/can/m_can/m_can.c +0
-0/* start the m_can controller */ drivers/net/can/m_can/m_can.h +3
-0@@ -28,6 +28,7 @@#include <linux/pm_runtime.h> #include <linux/slab.h> #include <linux/uaccess.h> +#include <linux/hrtimer.h> /* m_can lec values */ enum m_can_lec_type {@@ -93,6 +94,8 @@ struct m_can_classdev {int is_peripheral;struct mram_cfg mcfg[MRAM_CFG_NUM ]; + +struct hrtimer hrtimer; };struct m_can_classdev *m_can_class_allocate_dev (struct device *dev,int sizeof_priv);drivers/net/can/m_can/m_can_platform.c +1
-0@@ -7,6 +7,7 @@#include <linux/phy/phy.h> #include <linux/platform_device.h> +#include <linux/hrtimer.h>
Quoted 9 lines
drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 101
Quoted 6 lines
drivers/net/can/m_can/m_can_platform.c +0
-0#include "m_can.h" @@ -98,8 +99,12 @@ static int m_can_plat_probe(struct platform_device *pdev) addr =devm_platform_ioremap_resource_byname (pdev,"m_can" ); irq =platform_get_irq_byname (pdev,"int0" );if (IS_ERR (addr) || irq <0 ) {What about the
IS_ERR(addr)case?
Added, thanks.
Quoted 11 lines
drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 107
Quoted 8 lines
drivers/net/can/m_can/m_can_platform.c +6
-2- ret = -EINVAL ; - goto probe_fail; +if (irq == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto probe_fail; + } +dev_info (mcan_class->dev,"Failed to get irq, initialize hrtimer\n" ); +hrtimer_init (&mcan_class->hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_PINNED );I don't like it when polling is unconditionally set up in case of an irq error. I'm not sure if we need an explicit device tree property....
This is an interesting thought, I would definitely like to look more into this. Though I am thinking it would be part of future optimization patch. Thanks so much for your recommendation.
regards,
Judith
Vignesh Raghavendra
maintainerHi Judith,
Quoted 6 lines · Judith Mendez
Judith Mendez (5):
arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay
arm64: defconfig: Enable MCAN driver
dt-binding: can:m_can: Remove required interrupt attributes
arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
can:m_can: Add hrtimer to generate software interrupt
This is fine for RFC, but next time, please split DT and defconfig changes (1/5,2/5, and 4/5) to separate series as they have to go via arm64 tree.
Signature · 2 lines
Regards Vignesh
Hello Vignesh,
Quoted 10 lines · Vignesh Raghavendra
Hi Judith,
Quoted 6 lines · Judith Mendez
Judith Mendez (5):
arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay
arm64: defconfig: Enable MCAN driver
dt-binding: can:m_can: Remove required interrupt attributes
arm64: dts: ti: Enable multiple MCAN for AM62x in MCU MCAN overlay
can:m_can: Add hrtimer to generate software interrupt
Quoted 3 lines
This is fine for RFC, but next time, please split DT and defconfig changes (1/5,2/5, and 4/5) to separate series as they have to go via arm64 tree.
Thanks, will do in the next respin.
Marc Kleine-Budde
maintainerQuoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
Quoted 14 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Quoted 7 lines
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Quoted 8 lines
Note that in terms of power, enabling MCU MCANs with timer-polling implementation might have negative impact since we will have to wake up every 1 ms whether there are CAN packets pending in the RX FIFO or not. This might prevent the CPU from entering into deeper idle states for extended periods of time.
This patch series depends on 'Enable CAN PHY transceiver driver':
https://lore.kernel.org/lkml/[email protected]/T/
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Hello Marc,
Quoted 11 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
This is a hardware limitation that affects AM62x SoC and has been carried over to at least 1 other SoC. Using the MCU is an idea that we have juggled around for a while, we will definitely keep it in mind for future optimization. Thanks for your feedback.
Quoted 31 lines
Quoted 14 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Quoted 7 lines
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Quoted 6 lines
Note that in terms of power, enabling MCU MCANs with timer-polling implementation might have negative impact since we will have to wake up every 1 ms whether there are CAN packets pending in the RX FIFO or not. This might prevent the CPU from entering into deeper idle states for extended periods of time.
Quoted 5 lines
Quoted 2 lines
This patch series depends on 'Enable CAN PHY transceiver driver':
https://lore.kernel.org/lkml/[email protected]/T/Marc
regards,
Judith
Marc Kleine-Budde
maintainerQuoted 14 lines · Judith
Hello Marc,
Quoted 10 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
Quoted 4 lines
This is a hardware limitation that affects AM62x SoC and has been carried over to at least 1 other SoC. Using the MCU is an idea that we have juggled around for a while, we will definitely keep it in mind for future optimization. Thanks for your feedback.
Once you have a proper IRQ de-multiplexer, you can integrate it into the system with a DT change only. No need for changes in the m_can driver.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Have you seen my suggestion of the poll-interval?
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Hello Marc,
Quoted 15 lines · Marc Kleine-Budde
Quoted 14 lines · Judith
Hello Marc,
Quoted 10 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
Quoted 8 lines
Quoted 4 lines
This is a hardware limitation that affects AM62x SoC and has been carried over to at least 1 other SoC. Using the MCU is an idea that we have juggled around for a while, we will definitely keep it in mind for future optimization. Thanks for your feedback.
Once you have a proper IRQ de-multiplexer, you can integrate it into the system with a DT change only. No need for changes in the
m_candriver.
Is this a recommendation for the current patch?
The reason I am asking is because adding firmware for the M4 to forward
a mailbox with the IRQ to the A53 sounds like a good idea and we have been juggling the idea, but it is not an ideal solution if customers are using the M4 for other purposes like safety.
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Quoted 4 lines
Have you seen my suggestion of the poll-interval?
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Looking at some examples, I do think we could implement this poll-interval attribute, then read in the driver and initialize the hrtimer based on this. I like the idea to submit as a future optimization patch, thanks!
regards,
Judith
Marc Kleine-Budde
maintainerQuoted 23 lines · Judith
Hello Marc,
Quoted 20 lines · Marc Kleine-Budde
Quoted 18 lines · Judith
Hello Marc,
Quoted 10 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
This is a hardware limitation that affects AM62x SoC and has been carried over to at least 1 other SoC. Using the MCU is an idea that we have juggled around for a while, we will definitely keep it in mind for future optimization. Thanks for your feedback.
Quoted 5 lines
Quoted 3 lines
Once you have a proper IRQ de-multiplexer, you can integrate it into the system with a DT change only. No need for changes in the
m_candriver.Is this a recommendation for the current patch?
It is a recommendation on how to get around the hardware limitation, instead of falling back to polling.
Quoted 4 lines
The reason I am asking is because adding firmware for the M4 to forward a mailbox with the IRQ to the A53 sounds like a good idea and we have been juggling the idea, but it is not an ideal solution if customers are using the M4 for other purposes like safety.
Of course, the feasibility of this approach depends on your system design.
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Quoted 8 lines
Quoted 4 lines
Have you seen my suggestion of the poll-interval?
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Looking at some examples, I do think we could implement this poll-interval attribute, then read in the driver and initialize the hrtimer based on this. I like the idea to submit as a future optimization patch, thanks!
I would like to have the DT bindings in place, as handling legacy DT without poll interval adds unnecessary complexity.
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Hello Marc,
Quoted 33 lines · Marc Kleine-Budde
Quoted 23 lines · Judith
Hello Marc,
Quoted 20 lines · Marc Kleine-Budde
Quoted 18 lines · Judith
Hello Marc,
Quoted 10 lines · Marc Kleine-Budde
Quoted 4 lines · Judith Mendez
On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs.
Is this a general hardware limitation, that effects all MCU domain peripherals? Is there a mailbox mechanism between the MCU and the MAIN domain, would it be possible to pass the IRQ with a small firmware on the MCU? Anyways, that's future optimization.
This is a hardware limitation that affects AM62x SoC and has been carried over to at least 1 other SoC. Using the MCU is an idea that we have juggled around for a while, we will definitely keep it in mind for future optimization. Thanks for your feedback.
Quoted 5 lines
Quoted 3 lines
Once you have a proper IRQ de-multiplexer, you can integrate it into the system with a DT change only. No need for changes in the
m_candriver.Is this a recommendation for the current patch?
It is a recommendation on how to get around the hardware limitation, instead of falling back to polling.
Quoted 7 lines
Quoted 4 lines
The reason I am asking is because adding firmware for the M4 to forward a mailbox with the IRQ to the A53 sounds like a good idea and we have been juggling the idea, but it is not an ideal solution if customers are using the M4 for other purposes like safety.
Of course, the feasibility of this approach depends on your system design.
I understand your concern. Like mentioned, using the M4 approach may not be the best solution since some customers use the M4 for various reasons that could provide problems for this design.
I think the best way to go would be to enable polling + your suggestion of using poll-interval in device tree. If poll-interval is specified, then we can enable polling mode for MCAN.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
This solution instantiates a hrtimer with 1 ms polling interval for a MCAN when there is no hardware interrupt. This hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is.
On AM62x this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected.
Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms and lower polling periods than 1ms.
Have you seen my suggestion of the poll-interval?
Some Linux input drivers have the property poll-interval, would it make sense to ass this here too?
Quoted 6 lines
Quoted 3 lines
Looking at some examples, I do think we could implement this poll-interval attribute, then read in the driver and initialize the hrtimer based on this. I like the idea to submit as a future optimization patch, thanks!
I would like to have the DT bindings in place, as handling legacy DT without poll interval adds unnecessary complexity.
Understood, thanks so much for your feedback.
regards,
Judith