Skip to contentSkip to conversation

add mailbox support for i.MX7D

PATCH Superseded Oleksij Rempel 5 participants 21 messages Jul 31, 2018 – Aug 2, 2018

Subsystems (3)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v8 cover add mailbox support for i.MX7D

20180731 changes v7:
- imx-mailbox & DT: rework driver from 4 channel bidirectional mode to 16 channel unidirectional mode. 8 extra channels are implemented on top of General Purpose Interrupt bits provided by this MU.

20180726 changes v7:
- DT: add i.MX6SX and i.MX7S to the documentation.
- imx-mailbox: don't use devm_ functions for startup and shutdown.
- imx-mailbox: rename imx_mu_rmw to imx_mu_xcr_rmw and add locks
- imx-mailbox: pass of_property_read_bool directly to side_b

20180722 changes v6:
- include one more patch provided by Aisheng
- DT: add fall back compatible fsl,imx6sx-mu
- imx-mailbox: for now, use only fsl,imx6sx-mu

20180721 changes v5:
- DT: revert most of the changes from previous version
- imx-mailbox: remove struct imx_mu_cfg
- imx-mailbox: remove !! from imx_mu_last_tx_done()

20180718 changes v4:
- DT: change fsl,mu-side-a to fsl,mu-side-b
- DT: split the patches.
- DT: add all currently known SoCs.
- imx-mailbox: free allocated irq name on channel shutdown
- imx-mailbox: rename *_imx7 functions to *_generic

20180715 changes v3:
- DT: remove prosaic part of documentation. It describes software or firmware specific usage and not relevant for HW description.
- DT: use <soc>-mu instead of <soc>-mu-<mu side> and add fsl,mu-side-a parameter.
- DT: add most of know i.MX variants with MU
- imx-mailbox: use macros instead of precalculated bit index.
- imx-mailbox: remove warning message for clk.
- imx-mailbox: use imx_mu_chan[%idx] for devm_request_irq.
- imx-mailbox: depend on ARCH_MXC instead of SOX_IMX7

20180615 changes v2:
- DT: use mailbox@ instead of mu@
- DT: change interrupts description
- clk: use imx_clk_gate4 instead of imx_clk_gate2
- imx-mailbox: remove last_tx_done support
- imx-mailbox: fix module description

This patches are providing support for mailbox (Messaging Unit) for i.MX7D.
Functionality was tested on PHYTEC phyBOARD-Zeta i.MX7D with Linux running on all cores: ARM Cortex-A7 and ARM Cortex-M4.

Both parts of i.MX messaging Unit are visible for all CPUs available on i.MX7D. Communication worked independent of MU side in combination with CPU. For example MU-A used on ARM Cortex-A7 and MU-B used on ARM Cortex-M4 or other ways around.

Dong Aisheng (1):
dt-bindings: arm: fsl: add mu binding doc

Oleksij Rempel (3):
dt-bindings: mailbox: imx-mu: add generic MU channel support
ARM: dts: imx7s: add i.MX7 messaging unit support
mailbox: Add support for i.MX7D messaging unit

 .../devicetree/bindings/mailbox/fsl,mu.txt    |  56 +++
 arch/arm/boot/dts/imx7s.dtsi                  |  19 +
 drivers/mailbox/Kconfig                       |   6 +
 drivers/mailbox/Makefile                      |   2 +
 drivers/mailbox/imx-mailbox.c                 | 371 ++++++++++++++++++
 5 files changed, 454 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/fsl,mu.txt
 create mode 100644 drivers/mailbox/imx-mailbox.c
Signature · 1 line
2.18.0
#1 lore raw

PATCH v8 1/4 dt-bindings: arm: fsl: add mu binding doc

From: Dong Aisheng <[email protected]>

The Messaging Unit module enables two processors within the SoC to communicate and coordinate by passing messages (e.g. data, status and control) through the MU interface.

Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Mark Rutland <[email protected]>
Cc devicetree at vger.kernel.org
---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mailbox/fsl,mu.txt
Documentation/devicetree/bindings/mailbox/fsl,mu.txt new file +34 -0
new file mode 100644
index 000000000000..90e4905dfc69
@@ -0,0 +1,34 @@
+NXP i.MX Messaging Unit (MU)
+--------------------------------------------------------------------
+
+The Messaging Unit module enables two processors within the SoC to
+communicate and coordinate by passing messages (e.g. data, status
+and control) through the MU interface. The MU also provides the ability
+for one processor to signal the other processor using interrupts.
+
+Because the MU manages the messaging between processors, the MU uses
+different clocks (from each side of the different peripheral buses).
+Therefore, the MU must synchronize the accesses from one side to the
+other. The MU accomplishes synchronization using two sets of matching
+registers (Processor A-facing, Processor B-facing).
+
+Messaging Unit Device Node:
+=============================
+
+Required properties:
+-------------------
+- compatible :	should be "fsl,<chip>-mu", the supported chips include
+		imx8qxp, imx8qm.
+- reg :		Should contain the registers location and length
+- interrupts :	Interrupt number. The interrupt specifier format depends
+		on the interrupt controller parent.
+- #mbox-cells:  Must be 0. Number of cells in a mailbox
+
+Examples:
+--------
+lsio_mu0: mailbox at 5d1b0000 {
+	compatible = "fsl,imx8qxp-mu";
+	reg = <0x0 0x5d1b0000 0x0 0x10000>;
+	interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+	#mbox-cells = <0>;
+};
Signature · 1 line
2.18.0
#2 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

In reply to Oleksij Rempel

Each MU has four pairs of rx/tx data register with four rx/tx interrupts which can also be used as a separate channel.

---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 28 +++++++++++++++++--
 1 file changed, 25 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +25 -3
index 90e4905dfc69..9efd3a9ade44 100644
@@ -18,11 +18,33 @@ Messaging Unit Device Node:
 Required properties:
 -------------------
 - compatible :	should be "fsl,<chip>-mu", the supported chips include
-		imx8qxp, imx8qm.
+		imx6sx, imx7s, imx8qxp, imx8qm.
+		The "fsl,imx6sx-mu" compatible is seen as generic and should
+		be included together with SoC specific compatible.
 - reg :		Should contain the registers location and length
 - interrupts :	Interrupt number. The interrupt specifier format depends
 		on the interrupt controller parent.
-- #mbox-cells:  Must be 0. Number of cells in a mailbox
+- #mbox-cells:  Must be 2.
+			  <&phandle type channel>
+			    phandle   : Label name of controller
+			    type      : Channel type
+			    channel   : Channel number
+
+		This MU support 4 type of unidirectional channels, each type
+		has 4 channels. A total of 16 channels. Following types are
+		supported:
+		0 - TX channel with 32bit transmit register and IRQ transmit
+		acknowledgment support.
+		1 - RX channel with 32bit receive register and IRQ support
+		2 - TX doorbell channel. Without own register and no ACK support.
+		3 - RX doorbell channel.
+		The doorbell channels should be used with shared memory and protocol
+		level acknowledgment if needed.
+
+Optional properties:
+-------------------
+- clocks :	phandle to the input clock.
+- fsl,mu-side-b : Should be set for side B MU.
 
 Examples:
 --------
@@ -30,5 +52,5 @@ lsio_mu0: mailbox at 5d1b0000 {
 	compatible = "fsl,imx8qxp-mu";
 	reg = <0x0 0x5d1b0000 0x0 0x10000>;
 	interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
-	#mbox-cells = <0>;
+	#mbox-cells = <2>;
 };
Signature · 1 line
2.18.0
maintainer
#3 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 16 lines · Oleksij Rempel

Each MU has four pairs of rx/tx data register with four rx/tx interrupts which can also be used as a separate channel.

---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 28 +++++++++++++++++--
 1 file changed, 25 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +0 -0
index 90e4905dfc69..9efd3a9ade44 100644
@@ -18,11 +18,33 @@ Messaging Unit Device Node:
 Required properties:
 -------------------
 - compatible : should be "fsl,<chip>-mu", the supported chips include

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 28

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -2
-               imx8qxp, imx8qm.
+               imx6sx, imx7s, imx8qxp, imx8qm.
+               The "fsl,imx6sx-mu" compatible is seen as generic and should
+               be included together with SoC specific compatible.
 - reg :                Should contain the registers location and length
 - interrupts : Interrupt number. The interrupt specifier format depends
                on the interrupt controller parent.
-- #mbox-cells:  Must be 0. Number of cells in a mailbox
+- #mbox-cells:  Must be 2.
 

This seems like modifying the bindings. But since nothing exists yet, maybe we should merge patch 1 and 2 ?

Quoted 4 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -0
+                         <&phandle type channel>
+                           phandle   : Label name of controller
+                           type      : Channel type
+                           channel   : Channel number

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +9 -0
+
+               This MU support 4 type of unidirectional channels, each type
+               has 4 channels. A total of 16 channels. Following types are
+               supported:
+               0 - TX channel with 32bit transmit register and IRQ transmit
+               acknowledgment support.
+               1 - RX channel with 32bit receive register and IRQ support
+               2 - TX doorbell channel. Without own register and no ACK support.
+               3 - RX doorbell channel.
 

Thanks. This is great.

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 43

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +3 -0
+               The doorbell channels should be used with shared memory and protocol
+               level acknowledgment if needed.
+

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like reset) whenever the doorbell rings.

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 5 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -0
+Optional properties:
+-------------------
+- clocks :     phandle to the input clock.
+- fsl,mu-side-b : Should be set for side B MU.
 

Nit: can we call this 'fsl,no-init' ?

#4 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 21 lines · Jassi Brar
Quoted 20 lines · Oleksij Rempel

Each MU has four pairs of rx/tx data register with four rx/tx interrupts which can also be used as a separate channel.

---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 28 +++++++++++++++++--
 1 file changed, 25 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +3 -1
index 90e4905dfc69..9efd3a9ade44 100644
@@ -18,11 +18,33 @@ Messaging Unit Device Node:
 Required properties:
 -------------------
 - compatible : should be "fsl,<chip>-mu", the supported chips include
-               imx8qxp, imx8qm.
+               imx6sx, imx7s, imx8qxp, imx8qm.
+               The "fsl,imx6sx-mu" compatible is seen as generic and should
+               be included together with SoC specific compatible.
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +1 -1
 - reg :                Should contain the registers location and length
 - interrupts : Interrupt number. The interrupt specifier format depends
                on the interrupt controller parent.
-- #mbox-cells:  Must be 0. Number of cells in a mailbox
+- #mbox-cells:  Must be 2.
 

This seems like modifying the bindings. But since nothing exists yet, maybe we should merge patch 1 and 2 ?

For some weeks I already asked to squash this patches.. it was not ACKed. We can try again... @Rob, @Aisheng, should I merge this two patches?

Quoted 15 lines
Quoted 5 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -0
+                         <&phandle type channel>
+                           phandle   : Label name of controller
+                           type      : Channel type
+                           channel   : Channel number

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 10 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +9 -0
+
+               This MU support 4 type of unidirectional channels, each type
+               has 4 channels. A total of 16 channels. Following types are
+               supported:
+               0 - TX channel with 32bit transmit register and IRQ transmit
+               acknowledgment support.
+               1 - RX channel with 32bit receive register and IRQ support
+               2 - TX doorbell channel. Without own register and no ACK support.
+               3 - RX doorbell channel.
 
Quoted 8 lines

Thanks. This is great.

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 43

Quoted 3 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +3 -0
+               The doorbell channels should be used with shared memory and protocol
+               level acknowledgment if needed.
+

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like reset) whenever the doorbell rings.

Ok.

Quoted 7 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -0
+Optional properties:
+-------------------
+- clocks :     phandle to the input clock.
+- fsl,mu-side-b : Should be set for side B MU.
 

Nit: can we call this 'fsl,no-init' ?

No. It is HW description and not functionality which is present in current Linux driver.

Signature · 11 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180801/07207792/attachment.sig>
#5 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 2 lines

-----Original Message-----
From: Oleksij Rempel [mailto:o.rempel at pengutronix.de]

[...]

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +3 -1
index 90e4905dfc69..9efd3a9ade44 100644
@@ -18,11 +18,33 @@ Messaging Unit Device Node:
 Required properties:
 -------------------
 - compatible : should be "fsl,<chip>-mu", the supported chips include
-               imx8qxp, imx8qm.
+               imx6sx, imx7s, imx8qxp, imx8qm.
+               The "fsl,imx6sx-mu" compatible is seen as generic and should
+               be included together with SoC specific compatible.
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +1 -1
 - reg :                Should contain the registers location and length
 - interrupts : Interrupt number. The interrupt specifier format depends
                on the interrupt controller parent.
-- #mbox-cells:  Must be 0. Number of cells in a mailbox
+- #mbox-cells:  Must be 2.
 

This seems like modifying the bindings. But since nothing exists yet, maybe we should merge patch 1 and 2 ?

Quoted 3 lines

For some weeks I already asked to squash this patches.. it was not ACKed. We can try again... @Rob, @Aisheng, should I merge this two patches?

I guess It may depend on whether we use single channel mode for SCU.

I'm not sure we've already got the conclusion that multi channel mode is suitable for SCU. I'm trying to implement it but meet some problems. I've just explained in another reply. Hope Jassie can shine some light.

Regards
Dong Aisheng

Quoted 44 lines
Quoted 13 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node:

Quoted 13 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +12 -0
+                         <&phandle type channel>
+                           phandle   : Label name of controller
+                           type      : Channel type
+                           channel   : Channel number
+
+               This MU support 4 type of unidirectional channels, each type
+               has 4 channels. A total of 16 channels. Following types are
+               supported:
+               0 - TX channel with 32bit transmit register and IRQ transmit
+               acknowledgment support.
+               1 - RX channel with 32bit receive register and IRQ support
+               2 - TX doorbell channel. Without own register and no ACK

support.

Quoted 5 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +1 -0
+               3 - RX doorbell channel.
 

Thanks. This is great.

Quoted 1 line
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +1 -0
+               The doorbell channels should be used with shared memory and

protocol

Quoted 5 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 43

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +2 -0
+               level acknowledgment if needed.
+

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like reset) whenever the doorbell rings.

Ok.

Quoted 7 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +4 -0
+Optional properties:
+-------------------
+- clocks :     phandle to the input clock.
+- fsl,mu-side-b : Should be set for side B MU.
 

Nit: can we call this 'fsl,no-init' ?

No. It is HW description and not functionality which is present in current Linux driver.

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#6 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

In reply to Oleksij Rempel
Quoted 32 lines · Oleksij Rempel
Quoted 21 lines · Jassi Brar
Quoted 20 lines · Oleksij Rempel

Each MU has four pairs of rx/tx data register with four rx/tx interrupts which can also be used as a separate channel.

---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 28 +++++++++++++++++--
 1 file changed, 25 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +3 -1
index 90e4905dfc69..9efd3a9ade44 100644
@@ -18,11 +18,33 @@ Messaging Unit Device Node:
 Required properties:
 -------------------
 - compatible : should be "fsl,<chip>-mu", the supported chips include
-               imx8qxp, imx8qm.
+               imx6sx, imx7s, imx8qxp, imx8qm.
+               The "fsl,imx6sx-mu" compatible is seen as generic and should
+               be included together with SoC specific compatible.
Quoted 8 lines

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +1 -1
 - reg :                Should contain the registers location and length
 - interrupts : Interrupt number. The interrupt specifier format depends
                on the interrupt controller parent.
-- #mbox-cells:  Must be 0. Number of cells in a mailbox
+- #mbox-cells:  Must be 2.
 

This seems like modifying the bindings. But since nothing exists yet, maybe we should merge patch 1 and 2 ?

Quoted 3 lines

For some weeks I already asked to squash this patches.. it was not ACKed. We can try again... @Rob, @Aisheng, should I merge this two patches?

Whatever you like. I don't really care.

Rob

#7 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

In reply to Jassi Brar

Hi Jassi,

Quoted 8 lines
Quoted 1 line

+ The doorbell channels should be used with shared memory and

protocol

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 43

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +2 -0
+               level acknowledgment if needed.
+

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like reset) whenever the doorbell rings.

That's right.
i.MX8 using the general purpose interrupt for peripherals. No shmem needed. e.g. RTC, Watchdog and ON/OFF interrupt.

BTW, this means the peripheral will use mailbox doorbell channels to handle Interrupts. Is there such user case in kernel we can refer to?

Quoted 7 lines
Quoted 6 lines

+Optional properties:

+-------------------
+- clocks :     phandle to the input clock.
+- fsl,mu-side-b : Should be set for side B MU.

Nit: can we call this 'fsl,no-init' ?

Fsl,mu-side-b is more describing HW.

Regards
Dong Aisheng

maintainer
#8 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 11 lines · A.s. Dong

Hi Jassi,

Quoted 8 lines
Quoted 1 line

+ The doorbell channels should be used with shared memory and

protocol

Documentation/devicetree/bindings/mailbox/fsl,mu.txt Messaging Unit Device Node: · line 43

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +2 -0
+               level acknowledgment if needed.
+

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like reset) whenever the doorbell rings.

Quoted 7 lines

That's right.
i.MX8 using the general purpose interrupt for peripherals. No shmem needed. e.g. RTC, Watchdog and ON/OFF interrupt.

BTW, this means the peripheral will use mailbox doorbell channels to handle Interrupts. Is there such user case in kernel we can refer to?

I don't find any publicly in kernel.
It should be simple though. Acquire the RX channel, and populate the rx_callback() with the "interrupt" handler.

#9 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 32 lines

-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]
Sent: Wednesday, August 1, 2018 5:58 PM
To: A.s. Dong <[email protected]>
Cc: Oleksij Rempel <[email protected]>; Shawn Guo <[email protected]>; Fabio Estevam <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Vladimir Zapolskiy <[email protected]>; , Sascha Hauer <[email protected]>; , linux-arm-kernel at lists.infradead.org, linux- mediatek at lists.infradead.org, srv_heupstream <linux-arm- kernel at lists.infradead.org>; Devicetree List <[email protected]>; dl-linux-imx <[email protected]>
Subject: Re: [PATCH v8 2/4] dt-bindings: mailbox: imx-mu: add generic MU channel support

Quoted 7 lines · A.s. Dong

Hi Jassi,

Quoted 5 lines
Quoted 2 lines

+ The doorbell channels should be used with shared
+ memory and

protocol

Quoted 2 lines
Documentation/devicetree/bindings/mailbox/fsl,mu.txt +2 -0
+               level acknowledgment if needed.
+
Quoted 8 lines
Quoted 5 lines

I would avoid this. People might get notions that they have to use shmem with doorbell -- a trivial protocol might mean doing some fixed action (like
reset) whenever the doorbell rings.

That's right.
i.MX8 using the general purpose interrupt for peripherals. No shmem

needed.

Quoted 8 lines
Quoted 5 lines

e.g. RTC, Watchdog and ON/OFF interrupt.

BTW, this means the peripheral will use mailbox doorbell channels to handle Interrupts. Is there such user case in kernel we can refer to?

I don't find any publicly in kernel.
It should be simple though. Acquire the RX channel, and populate the rx_callback() with the "interrupt" handler.

Got it.
Thanks

Regards
Dong Aisheng

maintainer
#10 lore raw

PATCH v8 2/4 dt-bindings: mailbox: imx-mu: add generic MU channel support

In reply to Oleksij Rempel
Quoted 7 lines · Oleksij Rempel

Each MU has four pairs of rx/tx data register with four rx/tx interrupts which can also be used as a separate channel.

---
 .../devicetree/bindings/mailbox/fsl,mu.txt    | 28 +++++++++++++++++--
 1 file changed, 25 insertions(+), 3 deletions(-)
#11 lore raw

PATCH v8 3/4 ARM: dts: imx7s: add i.MX7 messaging unit support

In reply to Oleksij Rempel

Define the Messaging Unit (MU) for i.MX7 in the processor's dtsi. The respective driver is added in the next commit.

---
 arch/arm/boot/dts/imx7s.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/boot/dts/imx7s.dtsi +19 -0
index ce85b3ca1a55..3581fc2cc01d 100644
@@ -1001,6 +1001,25 @@
 				status = "disabled";
 			};
 
+			mu0a: mailbox at 30aa0000 {
+				compatible = "fsl,imx7s-mu", "fsl,imx6sx-mu";
+				reg = <0x30aa0000 0x10000>;
+				interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clks IMX7D_MU_ROOT_CLK>;
+				#mbox-cells = <2>;
+				status = "disabled";
+			};
+
+			mu0b: mailbox at 30ab0000 {
+				compatible = "fsl,imx7s-mu", "fsl,imx6sx-mu";
+				reg = <0x30ab0000 0x10000>;
+				interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clks IMX7D_MU_ROOT_CLK>;
+				#mbox-cells = <2>;
+				fsl,mu-side-b;
+				status = "disabled";
+			};
+
 			usbotg1: usb at 30b10000 {
 				compatible = "fsl,imx7d-usb", "fsl,imx27-usb";
 				reg = <0x30b10000 0x200>;
Signature · 1 line
2.18.0
#12 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

In reply to Oleksij Rempel

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

This driver was tested using the mailbox-test driver sending messages between the Cortex-A7 and the Cortex-M4.

---
 drivers/mailbox/Kconfig       |   6 +
 drivers/mailbox/Makefile      |   2 +
 drivers/mailbox/imx-mailbox.c | 371 ++++++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+)
 create mode 100644 drivers/mailbox/imx-mailbox.c
drivers/mailbox/Kconfig +6 -0
index a2bb27446dce..79060ddc380d 100644
@@ -15,6 +15,12 @@ config ARM_MHU
 	  The controller has 3 mailbox channels, the last of which can be
 	  used in Secure mode only.
 
+config IMX_MBOX
+	tristate "i.MX Mailbox"
+	depends on ARCH_MXC || COMPILE_TEST
+	help
+	  Mailbox implementation for i.MX Messaging Unit (MU).
+
 config PLATFORM_MHU
 	tristate "Platform MHU Mailbox"
 	depends on OF
drivers/mailbox/Makefile +2 -0
index cc23c3a43fcd..ba2fe1b6dd62 100644
@@ -7,6 +7,8 @@ obj-$(CONFIG_MAILBOX_TEST)	+= mailbox-test.o
 
 obj-$(CONFIG_ARM_MHU)	+= arm_mhu.o
 
+obj-$(CONFIG_IMX_MBOX)	+= imx-mailbox.o
+
 obj-$(CONFIG_PLATFORM_MHU)	+= platform_mhu.o
 
 obj-$(CONFIG_PL320_MBOX)	+= pl320-ipc.o
drivers/mailbox/imx-mailbox.c new file +371 -0

371 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer
#13 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Hi Oleksij,

A fast and fine turnaround! Mostly nits and a suggestion follows ...

Quoted 6 lines · Oleksij Rempel

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

This driver was tested using the mailbox-test driver sending messages between the Cortex-A7 and the Cortex-M4.

Do we need something MU specific here?
I mean MU doesn't really care if the endpoints are CA, CR or CM. So, maybe just the two-line ritual intro to MU?

drivers/mailbox/imx-mailbox.c line 41

Quoted 4 lines
drivers/mailbox/imx-mailbox.c new file +3 -0
+enum imx_mu_chan_type {
+       IMX_MU_TYPE_TX,         /* Tx with FIFO */
+       IMX_MU_TYPE_RX,         /* Rx with FIFO */

nit: its a register, not fifo

drivers/mailbox/imx-mailbox.c line 104

Quoted 8 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static void imx_mu_txdb_work(struct work_struct *work)
+{
+       struct imx_mu_con_priv *cp =
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0);
+}

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?
If not, at least we could use a tasklet instead of a work queue?

Quoted 10 lines
drivers/mailbox/imx-mailbox.c new file +9 -0
+static bool imx_mu_last_tx_done(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+
+       /* test if transmit register is empty */
+       return imx_mu_read(priv, IMX_MU_xSR) & IMX_MU_xSR_TEn(cp->idx);
+}
+

drivers/mailbox/imx-mailbox.c line 170

Quoted 10 lines
drivers/mailbox/imx-mailbox.c new file +10 -0
+static int imx_mu_send_data(struct mbox_chan *chan, void *data)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+       u32 *arg = data;
+
+       switch (cp->type) {
+       case IMX_MU_TYPE_TX:
+               if (!imx_mu_last_tx_done(chan))
+                       return -EBUSY;

This test should be moved to imx_mu_startup().
The api won't ever call if last tx was not done, and so it doesn't know how to recover from send_data() failure.

Quoted 8 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static int imx_mu_startup(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+       int ret;
+

drivers/mailbox/imx-mailbox.c line 201

Quoted 10 lines
drivers/mailbox/imx-mailbox.c new file +10 -0
+       if (cp->type == IMX_MU_TYPE_TXDB) {
+               /* Tx doorbell don't have ACK support */
+               INIT_WORK(&cp->work, imx_mu_txdb_work);
+               return 0;
+       }
+
+       cp->irq_desc = kasprintf(GFP_KERNEL, "imx_mu_chan[%i-%i]", cp->type,
+                                cp->idx);
+       if (!cp->irq_desc)
+               return -ENOMEM;

Probably you won't do but still .... name of irq is but one channel property. So you could set it in probe() and avoid creating another situation when startup could fail.

drivers/mailbox/imx-mailbox.c line 212

Quoted 11 lines
drivers/mailbox/imx-mailbox.c new file +10 -0
+       ret = request_irq(priv->irq, imx_mu_isr, IRQF_SHARED, cp->irq_desc,
+                         chan);
+       if (ret) {
+               dev_err(priv->dev,
+                       "Unable to acquire IRQ %d\n", priv->irq);
+               return ret;
+       }
+
+       switch (cp->type) {
+               break;

Is this intentional?

drivers/mailbox/imx-mailbox.c line 231

Quoted 8 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static void imx_mu_shutdown(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+
+       if (IMX_MU_TYPE_TXDB == cp->type)

nit: usually we do (cp->type == IMX_MU_TYPE_TXDB)

Thanks

#14 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Quoted 8 lines · Jassi Brar

Hi Oleksij,

A fast and fine turnaround! Mostly nits and a suggestion follows ...

Quoted 3 lines · Oleksij Rempel

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

Quoted 6 lines
Quoted 3 lines

This driver was tested using the mailbox-test driver sending messages between the Cortex-A7 and the Cortex-M4.

Do we need something MU specific here?
I mean MU doesn't really care if the endpoints are CA, CR or CM. So, maybe just the two-line ritual intro to MU?

Till now, every additional word about MU added more disagreement in this topic. I prefer the reduced variant.

Quoted 6 lines

drivers/mailbox/imx-mailbox.c line 41

Quoted 5 lines
drivers/mailbox/imx-mailbox.c new file +3 -0
+enum imx_mu_chan_type {
+       IMX_MU_TYPE_TX,         /* Tx with FIFO */
+       IMX_MU_TYPE_RX,         /* Rx with FIFO */

nit: its a register, not fifo

ok

Quoted 13 lines

drivers/mailbox/imx-mailbox.c line 104

Quoted 9 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static void imx_mu_txdb_work(struct work_struct *work)
+{
+       struct imx_mu_con_priv *cp =
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0);
+}

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?

I was thinking about it and decided that this pain was not worth it.

Quoted 1 line

If not, at least we could use a tasklet instead of a work queue?

ok. probably it is better to fix the mailbox framework.... may be not right now.

Quoted 16 lines
Quoted 16 lines
drivers/mailbox/imx-mailbox.c new file +15 -0
+static bool imx_mu_last_tx_done(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+
+       /* test if transmit register is empty */
+       return imx_mu_read(priv, IMX_MU_xSR) & IMX_MU_xSR_TEn(cp->idx);
+}
+
+static int imx_mu_send_data(struct mbox_chan *chan, void *data)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+       u32 *arg = data;
+
Quoted 8 lines

drivers/mailbox/imx-mailbox.c line 170

Quoted 5 lines
drivers/mailbox/imx-mailbox.c new file +4 -0
+       switch (cp->type) {
+       case IMX_MU_TYPE_TX:
+               if (!imx_mu_last_tx_done(chan))
+                       return -EBUSY;

This test should be moved to imx_mu_startup().
The api won't ever call if last tx was not done, and so it doesn't know how to recover from send_data() failure.

ok.

Quoted 14 lines
Quoted 14 lines
drivers/mailbox/imx-mailbox.c new file +13 -0
+
+static int imx_mu_startup(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+       int ret;
+
+       if (cp->type == IMX_MU_TYPE_TXDB) {
+               /* Tx doorbell don't have ACK support */
+               INIT_WORK(&cp->work, imx_mu_txdb_work);
+               return 0;
+       }
+
Quoted 8 lines

drivers/mailbox/imx-mailbox.c line 201

Quoted 5 lines
drivers/mailbox/imx-mailbox.c new file +4 -0
+       cp->irq_desc = kasprintf(GFP_KERNEL, "imx_mu_chan[%i-%i]", cp->type,
+                                cp->idx);
+       if (!cp->irq_desc)
+               return -ENOMEM;

Probably you won't do but still .... name of irq is but one channel property. So you could set it in probe() and avoid creating another situation when startup could fail.

You mean, fail on probe with no mem is better then fail on startup? Why?

Quoted 12 lines

drivers/mailbox/imx-mailbox.c line 212

Quoted 12 lines
drivers/mailbox/imx-mailbox.c new file +10 -0
+       ret = request_irq(priv->irq, imx_mu_isr, IRQF_SHARED, cp->irq_desc,
+                         chan);
+       if (ret) {
+               dev_err(priv->dev,
+                       "Unable to acquire IRQ %d\n", priv->irq);
+               return ret;
+       }
+
+       switch (cp->type) {
+               break;
Quoted 1 line

Is this intentional?

no. thx.

Quoted 10 lines

drivers/mailbox/imx-mailbox.c line 231

Quoted 9 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static void imx_mu_shutdown(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+
+       if (IMX_MU_TYPE_TXDB == cp->type)

nit: usually we do (cp->type == IMX_MU_TYPE_TXDB)

why? I do it with simple reason:
this error will be detected by compiler
if (IMX_MU_TYPE_TXDB = cp->type)

this error will silently fail
if (cp->type = IMX_MU_TYPE_TXDB)

Signature · 11 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180801/3154343e/attachment.sig>
maintainer
#15 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Quoted 8 lines · Oleksij Rempel
Quoted 6 lines · Jassi Brar
Quoted 6 lines

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

This driver was tested using the mailbox-test driver sending messages between the Cortex-A7 and the Cortex-M4.

Quoted 7 lines
Quoted 3 lines

Do we need something MU specific here?
I mean MU doesn't really care if the endpoints are CA, CR or CM. So, maybe just the two-line ritual intro to MU?

Till now, every additional word about MU added more disagreement in this topic. I prefer the reduced variant.

OK, but we don't usually specify "tested on ..." but leave details of the controller, in the new driver commit.

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
drivers/mailbox/imx-mailbox.c new file +4 -0
+
+static void imx_mu_txdb_work(struct work_struct *work)
+{
+       struct imx_mu_con_priv *cp =
Quoted 8 lines

drivers/mailbox/imx-mailbox.c line 104

Quoted 4 lines
drivers/mailbox/imx-mailbox.c new file +3 -0
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0);
+}

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?

Quoted 2 lines

I was thinking about it and decided that this pain was not worth it.

OK.

But just fyi, a common use of doorbell is to hint the master to take actions like reset, suspend or expect some periodic broadcast or some hotpath where we wouldn't want to sleep.
Another usecase is data transfer (where speed matters) via doorbell+shmem, having to sleep after each packet is going to kill performance.

Quoted 5 lines
Quoted 1 line

If not, at least we could use a tasklet instead of a work queue?

ok. probably it is better to fix the mailbox framework.... may be not right now.

No, the framework is fine. MU is the only controller that has two types of channels.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
drivers/mailbox/imx-mailbox.c new file +13 -0
+
+static int imx_mu_startup(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+       int ret;
+
+       if (cp->type == IMX_MU_TYPE_TXDB) {
+               /* Tx doorbell don't have ACK support */
+               INIT_WORK(&cp->work, imx_mu_txdb_work);
+               return 0;
+       }
+
Quoted 8 lines

drivers/mailbox/imx-mailbox.c line 201

Quoted 5 lines
drivers/mailbox/imx-mailbox.c new file +4 -0
+       cp->irq_desc = kasprintf(GFP_KERNEL, "imx_mu_chan[%i-%i]", cp->type,
+                                cp->idx);
+       if (!cp->irq_desc)
+               return -ENOMEM;

Probably you won't do but still .... name of irq is but one channel property. So you could set it in probe() and avoid creating another situation when startup could fail.

Quoted 2 lines

You mean, fail on probe with no mem is better then fail on startup? Why?

Fail early :)
But if you just have irq_name[8] in the channel struct, it won't even fail in probe. And is more consistent with other channel initialisations..... you see name of irq doesn't change across channel requests.

But OK, I am running out of energy and interest.

Quoted 10 lines
Quoted 9 lines

drivers/mailbox/imx-mailbox.c line 231

Quoted 8 lines
drivers/mailbox/imx-mailbox.c new file +7 -0
+
+static void imx_mu_shutdown(struct mbox_chan *chan)
+{
+       struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
+       struct imx_mu_con_priv *cp = chan->con_priv;
+
+       if (IMX_MU_TYPE_TXDB == cp->type)

nit: usually we do (cp->type == IMX_MU_TYPE_TXDB)

Quoted 7 lines

why? I do it with simple reason:
this error will be detected by compiler
if (IMX_MU_TYPE_TXDB = cp->type)

this error will silently fail
if (cp->type = IMX_MU_TYPE_TXDB)

Because it reads like
if (2 is equal to the variable)
instead of
if (the variable is equal to 2)

Most developers prefer latter. In fact you too, in startup() So please atleast make it consistent either way.

Cheers!

#16 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

In reply to Jassi Brar
Quoted 2 lines

-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]

[...]

Quoted 12 lines

drivers/mailbox/imx-mailbox.c

Quoted 6 lines
drivers/mailbox/imx-mailbox.c new file +5 -0
+
+static void imx_mu_txdb_work(struct work_struct *work) {
+       struct imx_mu_con_priv *cp =
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0); }

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?
If not, at least we could use a tasklet instead of a work queue?

I'm also a bit curious what the meaning of calling mbox_chan_txdone for a doorbell mailbox?

Is there any recommended way to use it?

Regards
Dong Aisheng

maintainer
#17 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Quoted 18 lines · A.s. Dong
Quoted 2 lines

-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]

[...]

Quoted 12 lines

drivers/mailbox/imx-mailbox.c

Quoted 6 lines
drivers/mailbox/imx-mailbox.c new file +5 -0
+
+static void imx_mu_txdb_work(struct work_struct *work) {
+       struct imx_mu_con_priv *cp =
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0); }

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?
If not, at least we could use a tasklet instead of a work queue?

Quoted 5 lines

I'm also a bit curious what the meaning of calling mbox_chan_txdone for a doorbell mailbox?

Is there any recommended way to use it?

The framework submits a message (a signal with or without data) for controller to transmit. Obviously, it has to know when the transfer completes (so that it can submit the next message).

Depending on the controller h/w design, there can be three ways.

a) Controller has some irq that fires when the signal is consumed by the other end. Like MU does. So upon TX-IRQ, the controller driver calls mbox_chan_txdone() to tell the framework that the last submitted transfer has completed. This is indicated by setting only txdone_irq = true

b) Controller does not have any tx-irq, but it can read some register to know the status. That is it has to be polled. The framework calls last_tx_done() periodically to check the status. This is indicated by setting only txdone_poll = true.

c) Controller has neither irq, nor any status register. This is indicated by setting only txdone_irq = false and txdone_poll =
false. In this case, the protocol/client has to tell the framework
(using some protocol level indicator like some ack packet reception) when the last submitted message was transferred, by calling mbox_client_txdone()

A 'doorbell' is (c) type channel -- just an irq raised at other end without any ack irq or status bit to check. So, the client would simply do

                mbox_send_message(chan, msg);
                mbox_client_txdone(chan, 0);
#18 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Quoted 3 lines

-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]
Sent: Wednesday, August 1, 2018 5:45 PM

[...]

Quoted 34 lines
Quoted 13 lines
Quoted 12 lines

drivers/mailbox/imx-mailbox.c

Quoted 6 lines
drivers/mailbox/imx-mailbox.c new file +5 -0
+
+static void imx_mu_txdb_work(struct work_struct *work) {
+       struct imx_mu_con_priv *cp =
+                       container_of(work, struct imx_mu_con_priv, work);
+       mbox_chan_txdone(cp->chan, 0); }

The api assumes a controller have same type of channels. So we are having to do this here.
I am not sure, but would declaring two mailbox controllers (one with doorbells and the other data channels) work?
If not, at least we could use a tasklet instead of a work queue?

Quoted 5 lines

I'm also a bit curious what the meaning of calling mbox_chan_txdone for a doorbell mailbox?

Is there any recommended way to use it?

The framework submits a message (a signal with or without data) for controller to transmit. Obviously, it has to know when the transfer completes (so that it can submit the next message).

Depending on the controller h/w design, there can be three ways.

a) Controller has some irq that fires when the signal is consumed by the other end. Like MU does. So upon TX-IRQ, the controller driver calls mbox_chan_txdone() to tell the framework that the last submitted transfer has completed. This is indicated by setting only txdone_irq = true

b) Controller does not have any tx-irq, but it can read some register to know the status. That is it has to be polled. The framework calls last_tx_done() periodically to check the status. This is indicated by setting only txdone_poll = true.

Quoted 7 lines

c) Controller has neither irq, nor any status register. This is indicated by setting only txdone_irq = false and txdone_poll =
false. In this case, the protocol/client has to tell the framework
(using some protocol level indicator like some ack packet reception) when the last submitted message was transferred, by calling mbox_client_txdone()

Thanks for a detailed and clear explanation.

Quoted 4 lines

A 'doorbell' is (c) type channel -- just an irq raised at other end without any ack irq or status bit to check. So, the client would simply do

                mbox_send_message(chan, msg);
                mbox_client_txdone(chan, 0);

Just a bit wondering whether we need client to call mbox_client_txdone() here as it actually does not know whether it's done. Not sure if it's better to handle them in mailbox controller driver or framework.
(Oleksij seems do it in the controller driver in this patch)

And see mbox_client_txdone() definition, it seems it's only used by TXDONE_BY_ACK case. Is the doorbell mailbox without IRQ or ACK support still suitable to call it to notify the framework the transfer is done?

void mbox_client_txdone(struct mbox_chan *chan, int r)

{
        if (unlikely(!(chan->txdone_method & TXDONE_BY_ACK))) {
                dev_err(chan->mbox->dev, "Client can't run the TX ticker\n");                                                                                                                                       
                return;
        }

        tx_tick(chan, r);
}

For i.MX MU case, the controller is defined as TXDONE_BY_IRQ for all channels Including TX doorbell. That's probably why we use mbox_chan_txdone to complete It in controller driver. Slightly a bit strange.
Not sure if better idea to handle it in controller driver or framework.

Regards
Dong Aisheng

#19 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

In reply to Oleksij Rempel
Quoted 13 lines

-----Original Message-----
From: Oleksij Rempel [mailto:o.rempel at pengutronix.de]
Sent: Tuesday, July 31, 2018 10:12 PM
To: Shawn Guo <[email protected]>; Fabio Estevam <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; A.s. Dong <[email protected]>; Vladimir Zapolskiy <[email protected]>; Jassi Brar <[email protected]>
Cc: Oleksij Rempel <[email protected]>; kernel at pengutronix.de; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; dl-linux- imx <[email protected]>
Subject: [PATCH v8 4/4] mailbox: Add support for i.MX7D messaging unit

Quoted 3 lines

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

I'm not sure but is this still valid after change to multi channels mode? We actually lost the HW capability to send messages up to 4 words in the multi channels mode.
And such commit message probably will confuse people.
Worth a improve?

Otherwise this patch mostly is okay to me except a few bits already pointed out by Jassi.

Regards
Dong Aisheng

#20 lore raw

PATCH v8 4/4 mailbox: Add support for i.MX7D messaging unit

Quoted 17 lines · A.s. Dong
Quoted 13 lines

-----Original Message-----
From: Oleksij Rempel [mailto:o.rempel at pengutronix.de]
Sent: Tuesday, July 31, 2018 10:12 PM
To: Shawn Guo <[email protected]>; Fabio Estevam <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; A.s. Dong <[email protected]>; Vladimir Zapolskiy <[email protected]>; Jassi Brar <[email protected]>
Cc: Oleksij Rempel <[email protected]>; kernel at pengutronix.de; linux-arm-kernel at lists.infradead.org; devicetree at vger.kernel.org; dl-linux- imx <[email protected]>
Subject: [PATCH v8 4/4] mailbox: Add support for i.MX7D messaging unit

Quoted 3 lines

The Mailbox controller is able to send messages (up to 4 32 bit words) between the endpoints.

Quoted 8 lines

I'm not sure but is this still valid after change to multi channels mode? We actually lost the HW capability to send messages up to 4 words in the multi channels mode.
And such commit message probably will confuse people.
Worth a improve?

Otherwise this patch mostly is okay to me except a few bits already pointed out by Jassi.

Ok, I schedule this task for Thursday or Friday.

Signature · 11 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180801/b9a2ebf3/attachment.sig>