2023-05-23 02:48:38

by Judith Mendez

[permalink] [raw]
Subject: [PATCH v7 0/2] Enable multiple MCAN on AM62x

On AM62x there are two MCANs 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 MCAN device when there is no hardware interrupt property in
DTB MCAN node. The 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.
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.

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.

v6:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

v5:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

v4:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

v2:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

V1:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

RFC:
Link: https://lore.kernel.org/linux-can/[email protected]/T/#t

v6:
- Clean up m_can_platform.c after removing poll-interval

v6:
- Move hrtimer stop/start function calls to m_can_open and m_can_close to
support power suspend/resume

v5:
- Remove poll-interval in bindings
- Change dev_dbg to dev_info if hardware int exists and polling
is enabled

v4:
- Wrong patches sent

v3:
- Update binding poll-interval description
- Add oneOf to select either interrupts/interrupt-names or poll-interval
- Create a define for 1 ms polling interval
- Change plarform_get_irq to optional to not print error msg

v2:
- Add poll-interval property to bindings and MCAN DTB node
- Add functionality to check for 'poll-interval' property in MCAN node
- Bindings: add an example using poll-interval
- Add 'polling' flag in driver to check if device is using polling method
- Check for timer polling and hardware interrupt cases, default to
hardware interrupt method
- Change ns_to_ktime() to ms_to_ktime()

Judith Mendez (2):
dt-bindings: net: can: Remove interrupt properties for MCAN
can: m_can: Add hrtimer to generate software interrupt

.../bindings/net/can/bosch,m_can.yaml | 20 +++++++++--
drivers/net/can/m_can/m_can.c | 33 +++++++++++++++++--
drivers/net/can/m_can/m_can.h | 4 +++
drivers/net/can/m_can/m_can_platform.c | 25 ++++++++++++--
4 files changed, 75 insertions(+), 7 deletions(-)


base-commit: 9f258af06b6268be8e960f63c3f66e88bdbbbdb0
--
2.17.1



2023-05-23 03:00:09

by Judith Mendez

[permalink] [raw]
Subject: [PATCH v7 1/2] dt-bindings: net: can: Remove interrupt properties for MCAN

On AM62x SoC, MCANs on MCU domain do not have hardware interrupt
routed to A53 Linux, instead they will use software interrupt by
timer polling.

To enable timer polling method, interrupts should be
optional so remove interrupts property from required section and
add an example for MCAN node with timer polling enabled.

Signed-off-by: Judith Mendez <[email protected]>
---
Changelog:
v7:
1. No changes
v6:
1. No changes
v5:
1. Remove poll-interval
2. Remove oneOf that selects interrupts/interrupt-names or poll-interval
v3:
1. Update binding poll-interval description
2. Add oneOf to select interrupts/interrupt-names or poll-interval
v2:
1. Add poll-interval property to enable timer polling method
2. Add example using poll-interval property
---
.../bindings/net/can/bosch,m_can.yaml | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
index 67879aab623b..bb518c831f7b 100644
--- a/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
+++ b/Documentation/devicetree/bindings/net/can/bosch,m_can.yaml
@@ -122,8 +122,6 @@ required:
- compatible
- reg
- reg-names
- - interrupts
- - interrupt-names
- clocks
- clock-names
- bosch,mram-cfg
@@ -132,6 +130,7 @@ additionalProperties: false

examples:
- |
+ // Example with interrupts
#include <dt-bindings/clock/imx6sx-clock.h>
can@20e8000 {
compatible = "bosch,m_can";
@@ -149,4 +148,21 @@ examples:
};
};

+ - |
+ // Example with timer polling
+ #include <dt-bindings/clock/imx6sx-clock.h>
+ can@20e8000 {
+ compatible = "bosch,m_can";
+ reg = <0x020e8000 0x4000>, <0x02298000 0x4000>;
+ reg-names = "m_can", "message_ram";
+ clocks = <&clks IMX6SX_CLK_CANFD>,
+ <&clks IMX6SX_CLK_CANFD>;
+ clock-names = "hclk", "cclk";
+ bosch,mram-cfg = <0x0 0 0 32 0 0 0 1>;
+
+ can-transceiver {
+ max-bitrate = <5000000>;
+ };
+ };
+
...
--
2.17.1


2023-05-23 17:20:43

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v7 1/2] dt-bindings: net: can: Remove interrupt properties for MCAN

On Mon, May 22, 2023 at 09:37:48PM -0500, Judith Mendez wrote:
> On AM62x SoC, MCANs on MCU domain do not have hardware interrupt
> routed to A53 Linux, instead they will use software interrupt by
> timer polling.
>
> To enable timer polling method, interrupts should be
> optional so remove interrupts property from required section and
> add an example for MCAN node with timer polling enabled.
>
> Signed-off-by: Judith Mendez <[email protected]>

Reviewed-by: Conor Dooley <[email protected]>

Thanks,
Conor.


Attachments:
(No filename) (531.00 B)
signature.asc (235.00 B)
Download all attachments