soc: imx: add scu firmware api support
Subsystems (4)
v5 cover soc: imx: add scu firmware api support
Unlike the former i.MX Architectures, the new generation i.MX8 SoCs (e.g. MX8QXP and MX8QM) contain a system controller which runs on a dedicated Cortex-M core to provide power, clock, Pad, and resource management. Communication between the host processor running an OS and the system controller happens through a SCU protocol. This patchset adds the SCU APIs which is implemented based on MU and will be used by different system components.
It mainly consists of below parts:
1) SCU IPC
Basic IPC mechanism implemention based on mailbox which is used for communication between AP and SCU firmware.
2) SCU IPC Service API
Dong Aisheng (5):
dt-bindings: arm: fsl: add scu binding doc
soc: imx: add SC firmware IPC and APIs
soc: imx: sc: add pm svc support
soc: imx: sc: add pad svc support
soc: imx: sc: add misc svc support
.../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 ++++++ drivers/soc/imx/Kconfig | 4 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/sc/Makefile | 5 + drivers/soc/imx/sc/main/ipc.c | 258 +++++++++ drivers/soc/imx/sc/main/rpc.h | 51 ++ drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 106 ++++ drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 82 +++ drivers/soc/imx/sc/svc/pm/rpc_clnt.c | 275 +++++++++ include/soc/imx/sc/ipc.h | 46 ++ include/soc/imx/sc/sci.h | 20 + include/soc/imx/sc/svc/misc/api.h | 60 ++ include/soc/imx/sc/svc/pad/api.h | 60 ++ include/soc/imx/sc/svc/pm/api.h | 229 ++++++++ include/soc/imx/sc/types.h | 636 +++++++++++++++++++++ 15 files changed, 2012 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt create mode 100644 drivers/soc/imx/sc/Makefile create mode 100644 drivers/soc/imx/sc/main/ipc.c create mode 100644 drivers/soc/imx/sc/main/rpc.h create mode 100644 drivers/soc/imx/sc/svc/misc/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pad/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pm/rpc_clnt.c create mode 100644 include/soc/imx/sc/ipc.h create mode 100644 include/soc/imx/sc/sci.h create mode 100644 include/soc/imx/sc/svc/misc/api.h create mode 100644 include/soc/imx/sc/svc/pad/api.h create mode 100644 include/soc/imx/sc/svc/pm/api.h create mode 100644 include/soc/imx/sc/types.h
Signature · 1 line
2.7.4
PATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
---v4->v5:
* scu node should be under firmware node
* add pd/clk/pinctrl binding as well according to Rob's suggestion
* switch to new generic MU binding
Use 8 separate mu channels in one MU instance for SCU communicationv3->v4:
* fully change to mailbox binding
* add child node descriptionv2->v3:
* update a bit to mailbox bindingv1->v2:
* remove status
* changed to mu1
--- .../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +179 -0
@@ -0,0 +1,179 @@ +NXP i.MX System Controller Firmware (SCFW) -------------------------------------------------------------------- + +The System Controller Firmware (SCFW) is a low-level system function +which runs on a dedicated Cortex-M core to provide power, clock, and +resource management. It exists on some i.MX8 processors. e.g. i.MX8QM +(QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module found +in the LSIO subsystem. The current definition of this MU module provides +5 remote AP connections to the SC to support up to 5 execution environments +(TZ, HV, standard Linux, etc.). The SC side of this MU module interfaces +with the LSIO DSC IP bus. The SC firmware will communicate with this MU +using the MSI bus. + +System Controller Device Node: +============================================================ + +The scu node with the following properties shall be under the /firmware/ node. + +Required properties: +------------------- +- compatible: should be "fsl,imx-scu". +- mbox-names: should include "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3". +- mboxes: List of phandle of 4 MU channels for tx and 4 MU channels + for rx. All 8 MU channels must be in the same MU instance. + Cross instances are not allowed. The MU instance can only + be one of LSIO MU0~M4 for imx8qxp and imx8qm. Users need + to make sure use the one which is not conflict with other + execution environments. e.g. ATF. + Note: + Channel 0 must be "tx0" or "rx0". + Channel 1 must be "tx1" or "rx1". + Channel 2 must be "tx2" or "rx2". + Channel 3 must be "tx3" or "rx3". + e.g. + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + See Documentation/devicetree/bindings/mailbox/fsl,mu.txt + for detailed mailbox binding. + +i.MX SCU Client Device Node: +============================================================ + +Client nodes are maintained as children of the relevant IMX-SCU device node. + +Power domain bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding for the SCU power domain providers uses the generic power +domain binding[2]. + +Required properties: +- compatible: Should be "fsl,scu-pd". +- #address-cells: Should be 1. +- #size-cells: Should be 0. + +Required properties for power domain sub nodes: +- #power-domain-cells: Must be 0. + +Optional Properties: +- reg: Resource ID of this power domain. + No exist means uncontrollable by user. + See detailed Resource ID list from: + include/dt-bindings/power/imx-rsrc.h +- power-domains: phandle pointing to the parent power domain. + +Clock bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the common clock binding[1]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-clock". +- #clock-cells: Should be 1. Contains the Clock ID value. + +The clock consumer should specify the desired clock by having the clock +ID in its "clocks" phandle cell. + +See the full list of clock IDs from: +include/dt-bindings/clock/imx8qxp-clock.h + +Pinctrl bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the i.MX common pinctrl binding[3]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-iomuxc". + +Required properties for Pinctrl sub nodes: +- fsl,pins: Each entry consists of 3 integers which represents + the mux and config setting for one pin. The first 2 + integers <pin_id mux_mode> are specified using a + PIN_FUNC_ID macro, which can be found in + <dt-bindings/pinctrl/pads-imx8qxp.h>. + The last integer CONFIG is the pad setting value like + pull-up on this pin. + + Please refer to i.MX8QXP Reference Manual for detailed + CONFIG settings. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/power/power_domain.txt +[3] Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt + +Example (imx8qxp): +------------- +lsio_mu1: mailbox at 5d1c0000 { + ... + #mbox-cells = <2>; +}; + +firmware { + scu { + compatible = "fsl,imx-scu"; + mbox-names = "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3"; + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + + clk: clk { + compatible = "fsl,imx8qxp-clk"; + #clock-cells = <1>; + }; + + iomuxc { + compatible = "fsl,imx8qxp-iomuxc"; + + pinctrl_lpuart0: lpuart0grp { + fsl,pins = < + SC_P_UART0_RX_ADMA_UART0_RX 0x06000020 + SC_P_UART0_TX_ADMA_UART0_TX 0x06000020 + >; + }; + ... + }; + + imx8qx-pm { + compatible = "fsl,scu-pd"; + #address-cells = <1>; + #size-cells = <0>; + + pd_dma: dma-power-domain { + #power-domain-cells = <0>; + + pd_dma_lpuart0: dma-lpuart0 at 57 { + reg = <SC_R_UART_0>; + #power-domain-cells = <0>; + power-domains = <&pd_dma>; + }; + ... + }; + ... + }; + }; +}; + +serial at 5a060000 { + ... + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_lpuart0>; + clocks = <&clk IMX8QXP_UART0_CLK>, + <&clk IMX8QXP_UART0_IPG_CLK>; + clock-names = "per", "ipg"; + power-domains = <&pd_dma_lpuart0>; +};
Signature · 1 line
2.7.4
Rob Herring
maintainerPATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
Quoted 45 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Sascha Hauer <[email protected]>Cc Jassi Brar <[email protected]>Cc Linus Walleij <[email protected]>Cc Stephen Boyd <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Ulf Hansson <[email protected]>Cc Shawn Guo <[email protected]>Cc Fabio Estevam <[email protected]>Cc devicetree at vger.kernel.orgCc linux-clk at vger.kernel.orgCc linux-gpio at vger.kernel.orgCc linux-pm at vger.kernel.orgSigned-off-by Dong Aisheng <[email protected]>---
v4->v5:
* scu node should be under firmware node
* add pd/clk/pinctrl binding as well according to Rob's suggestion
* switch to new generic MU binding
Use 8 separate mu channels in one MU instance for SCU communicationv3->v4:
* fully change to mailbox binding
* add child node descriptionv2->v3:
* update a bit to mailbox bindingv1->v2:
* remove status
* changed to mu1--- .../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txtDocumentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +0
-0
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +1
-0@@ -0,0 +1,179 @@ +NXP i.MX System Controller Firmware (SCFW) --------------------------------------------------------------------
Think you wanted a newline here ^?
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 13
Quoted 12 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +12
-0+ +The System Controller Firmware (SCFW) is a low-level system function +which runs on a dedicated Cortex-M core to provide power, clock, and +resource management. It exists on some i.MX8 processors. e.g. i.MX8QM +(QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module found +in the LSIO subsystem. The current definition of this MU module provides +5 remote AP connections to the SC to support up to 5 execution environments +(TZ, HV, standard Linux, etc.). The SC side of this MU module interfaces +with the LSIO DSC IP bus. The SC firmware will communicate with this MU +using the MSI bus.
How are 5 users supported with only 4 channels defined below?
Quoted 7 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +7
-0+ +System Controller Device Node: +============================================================ + +The scu node with the following properties shall be under the /firmware/ node. + +Required properties:
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 30
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+------------------- +- compatible: should be "fsl,imx-scu". +- mbox-names: should include "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3". +- mboxes: List of phandle of 4 MU channels for tx and 4 MU channels + for rx. All 8 MU channels must be in the same MU instance. + Cross instances are not allowed. The MU instance can only + be one of LSIO MU0~M4 for imx8qxp and imx8qm. Users need + to make sure use the one which is not conflict with other + execution environments. e.g. ATF.
How is one supposed to know what channels are in use already?
IMO, ATF should remove the channel it uses before passing the DT to the next stage. That doesn't help if later stages get a different DT though.
Quoted 41 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +41
-0+ Note: + Channel 0 must be "tx0" or "rx0". + Channel 1 must be "tx1" or "rx1". + Channel 2 must be "tx2" or "rx2". + Channel 3 must be "tx3" or "rx3". + e.g. + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + See Documentation/devicetree/bindings/mailbox/fsl,mu.txt + for detailed mailbox binding. + +i.MX SCU Client Device Node: +============================================================ + +Client nodes are maintained as children of the relevant IMX-SCU device node. + +Power domain bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding for the SCU power domain providers uses the generic power +domain binding[2]. + +Required properties: +- compatible: Should be "fsl,scu-pd". +- #address-cells: Should be 1. +- #size-cells: Should be 0. + +Required properties for power domain sub nodes: +- #power-domain-cells: Must be 0. + +Optional Properties: +- reg: Resource ID of this power domain. + No exist means uncontrollable by user. + See detailed Resource ID list from: + include/dt-bindings/power/imx-rsrc.h
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 81
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+- power-domains: phandle pointing to the parent power domain. + +Clock bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the common clock binding[1]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-clock". +- #clock-cells: Should be 1. Contains the Clock ID value.
There was a recent patch adding input clocks to other i.MX CCM bindings. Is that needed here?
Quoted 101 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +98
-0+ +The clock consumer should specify the desired clock by having the clock +ID in its "clocks" phandle cell. + +See the full list of clock IDs from: +include/dt-bindings/clock/imx8qxp-clock.h + +Pinctrl bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the i.MX common pinctrl binding[3]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-iomuxc". + +Required properties for Pinctrl sub nodes: +- fsl,pins: Each entry consists of 3 integers which represents + the mux and config setting for one pin. The first 2 + integers <pin_id mux_mode> are specified using a + PIN_FUNC_ID macro, which can be found in + <dt-bindings/pinctrl/pads-imx8qxp.h>. + The last integer CONFIG is the pad setting value like + pull-up on this pin. + + Please refer to i.MX8QXP Reference Manual for detailed + CONFIG settings. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/power/power_domain.txt +[3] Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt + +Example (imx8qxp): +------------- +lsio_mu1: mailbox at 5d1c0000 { + ... + #mbox-cells = <2>; +}; + +firmware { + scu { + compatible = "fsl,imx-scu"; + mbox-names = "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3"; + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + + clk: clk { + compatible = "fsl,imx8qxp-clk"; + #clock-cells = <1>; + }; + + iomuxc { + compatible = "fsl,imx8qxp-iomuxc"; + + pinctrl_lpuart0: lpuart0grp { + fsl,pins = < + SC_P_UART0_RX_ADMA_UART0_RX 0x06000020 + SC_P_UART0_TX_ADMA_UART0_TX 0x06000020 + >; + }; + ... + }; + + imx8qx-pm { + compatible = "fsl,scu-pd"; + #address-cells = <1>; + #size-cells = <0>; + + pd_dma: dma-power-domain { + #power-domain-cells = <0>; + + pd_dma_lpuart0: dma-lpuart0 at 57 { + reg = <SC_R_UART_0>; + #power-domain-cells = <0>; + power-domains = <&pd_dma>; + }; + ... + }; + ... + }; + }; +}; + +serial at 5a060000 { + ... + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_lpuart0>; + clocks = <&clk IMX8QXP_UART0_CLK>, + <&clk IMX8QXP_UART0_IPG_CLK>; + clock-names = "per", "ipg"; + power-domains = <&pd_dma_lpuart0>; +};Signature · 1 line
2.7.4
PATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
Hi Rob,
Quoted 56 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Tuesday, August 21, 2018 2:12 AM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; Mark Rutland <[email protected]>; Jassi Brar <[email protected]>; Linus Walleij <[email protected]>; Stephen Boyd <[email protected]>; Rafael J. Wysocki <[email protected]>; Ulf Hansson <[email protected]>; devicetree at vger.kernel.org; linux-
clk at vger.kernel.org; linux-gpio at vger.kernel.org; linux-pm at vger.kernel.org
Subject: Re: [PATCH V5 1/5] dt-bindings: arm: fsl: add scu binding docQuoted 41 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Sascha Hauer <[email protected]>Cc Jassi Brar <[email protected]>Cc Linus Walleij <[email protected]>Cc Stephen Boyd <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Ulf Hansson <[email protected]>Cc Shawn Guo <[email protected]>Cc Fabio Estevam <[email protected]>Cc devicetree at vger.kernel.orgCc linux-clk at vger.kernel.orgCc linux-gpio at vger.kernel.orgCc linux-pm at vger.kernel.orgSigned-off-by Dong Aisheng <[email protected]>---
v4->v5:
* scu node should be under firmware node
* add pd/clk/pinctrl binding as well according to Rob's suggestion
* switch to new generic MU binding
Use 8 separate mu channels in one MU instance for SCU communicationv3->v4:
* fully change to mailbox binding
* add child node descriptionv2->v3:
* update a bit to mailbox bindingv1->v2:
* remove status
* changed to mu1--- .../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 +++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 12 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 2
Quoted 10 lines
diff --git
a/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txtb/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txtnew file mode 100644
index 0000000..2cd7e4aDocumentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +2
-0@@ -0,0 +1,179 @@ +NXP i.MX System Controller Firmware (SCFW) +--------------------------------------------------------------------Think you wanted a newline here ^?
Yes, of course.
It seems to be introduced by mistake.
Thanks for reminder.
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +3
-0+ +The System Controller Firmware (SCFW) is a low-level system function +which runs on a dedicated Cortex-M core to provide power, clock, andDocumentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+resource management. It exists on some i.MX8 processors. e.g. i.MX8QM +(QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module found +in the LSIO subsystem. The current definition of this MU module +provides +5 remote AP connections to the SC to support up to 5 execution +environments (TZ, HV, standard Linux, etc.). The SC side of this MU +module interfaces with the LSIO DSC IP bus. The SC firmware will +communicate with this MU using the MSI bus.How are 5 users supported with only 4 channels defined below?
There're 5 MU instances designed to be specifically communicate with SCU Firmware on MX8 hardware.
With the new generic mu binding [1], each MU instance is abstracted Into 16 virtual MU channels. (4 Tx, 4 Rx, 4 Tx doorbell, 4 Rx doorbell). (MU has 4 pair of Tx/Rx data register which can be used to send/receive multi words. With new binding, each data register is abstracted into one MU channel, totally 8 channels for data transfer).
SCU protocol is already designed to uses all data registers to send/receive multi words according to MU hardware reference manual. So it must use all channels in one MU instances with new binding.
On MX8, it can be one of LSIO MU0~M4.
[1] https://patchwork.kernel.org/patch/10554565/
Quoted 20 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 17
Quoted 4 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +2
-0+ +System Controller Device Node:+=========================================================
===Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 19
Quoted 2 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +2
-0+ +The scu node with the following properties shall be under the /firmware/node.
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+ +Required properties: +------------------- +- compatible: should be "fsl,imx-scu". +- mbox-names: should include "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3". +- mboxes: List of phandle of 4 MU channels for tx and 4 MU channels + for rx. All 8 MU channels must be in the same MU instance. + Cross instances are not allowed. The MU instance can only + be one of LSIO MU0~M4 for imx8qxp and imx8qm. Usersneed
Quoted 5 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 30
Quoted 2 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +2
-0+ to make sure use the one which is not conflict with other + execution environments. e.g. ATF.How is one supposed to know what channels are in use already?
Currently it's simply predefined.
E.g. ATF uses MU0 and u-Boot & Kernel uses MU1.
Quoted 2 lines
IMO, ATF should remove the channel it uses before passing the DT to the next stage.
Sounds like a good idea.
To be more specific, you mean simply marking the MU node status used in ATF to be "disabled" before passing to the next stage, am I understand correct?
Quoted 1 line
That doesn't help if later stages get a different DT though.
Doesn't help? Sorry a bit confusing...
Quoted 50 lines
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +8
-0+ Note: + Channel 0 must be "tx0" or "rx0". + Channel 1 must be "tx1" or "rx1". + Channel 2 must be "tx2" or "rx2". + Channel 3 must be "tx3" or "rx3". + e.g. + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 48
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+ &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + See Documentation/devicetree/bindings/mailbox/fsl,mu.txt + for detailed mailbox binding. + +i.MX SCU Client Device Node:+=========================================================
===Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 51
Quoted 2 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +2
-0+ +Client nodes are maintained as children of the relevant IMX-SCU devicenode.
Quoted 25 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +25
-0+ +Power domain bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding for the SCU power domain providers uses the generic +power domain binding[2]. + +Required properties: +- compatible: Should be "fsl,scu-pd". +- #address-cells: Should be 1. +- #size-cells: Should be 0. + +Required properties for power domain sub nodes: +- #power-domain-cells: Must be 0. + +Optional Properties: +- reg: Resource ID of this power domain. + No exist means uncontrollable by user. + See detailed Resource ID list from: + include/dt-bindings/power/imx-rsrc.h +- power-domains: phandle pointing to the parent power domain. + +Clock bindings based on SCU Message Protocol +------------------------------------------------------------ +
Quoted 9 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 81
Quoted 5 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +5
-0+This binding uses the common clock binding[1]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-clock". +- #clock-cells: Should be 1. Contains the Clock ID value.There was a recent patch adding input clocks to other i.MX CCM bindings. Is that needed here?
Will double check it, thanks for reminder.
Regards
Dong Aisheng
Quoted 104 lines
Quoted 15 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +15
-0+ +The clock consumer should specify the desired clock by having the +clock ID in its "clocks" phandle cell. + +See the full list of clock IDs from: +include/dt-bindings/clock/imx8qxp-clock.h + +Pinctrl bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the i.MX common pinctrl binding[3]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-iomuxc". +Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+Required properties for Pinctrl sub nodes: +- fsl,pins: Each entry consists of 3 integers which represents + the mux and config setting for one pin. The first 2 + integers <pin_id mux_mode> are specified using a + PIN_FUNC_ID macro, which can be found in + <dt-bindings/pinctrl/pads-imx8qxp.h>. + The last integer CONFIG is the pad setting value like + pull-up on this pin. + + Please refer to i.MX8QXP Reference Manual fordetailed
Quoted 28 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +28
-0+ CONFIG settings. + +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/power/power_domain.txt +[3] Documentation/devicetree/bindings/pinctrl/fsl,imx-pinctrl.txt + +Example (imx8qxp): +------------- +lsio_mu1: mailbox at 5d1c0000 { + ... + #mbox-cells = <2>; +}; + +firmware { + scu { + compatible = "fsl,imx-scu"; + mbox-names = "tx0", "tx1", "tx2", "tx3", + "rx0", "rx1", "rx2", "rx3"; + mboxes = <&lsio_mu1 0 0 + &lsio_mu1 0 1 + &lsio_mu1 0 2 + &lsio_mu1 0 3 + &lsio_mu1 1 0 + &lsio_mu1 1 1 + &lsio_mu1 1 2 + &lsio_mu1 1 3>; + + clk: clk {Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+ compatible = "fsl,imx8qxp-clk"; + #clock-cells = <1>; + }; + + iomuxc { + compatible = "fsl,imx8qxp-iomuxc"; + + pinctrl_lpuart0: lpuart0grp { + fsl,pins = < + SC_P_UART0_RX_ADMA_UART0_RX0x06000020Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 145
Quoted 1 line
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +1
-0+ SC_P_UART0_TX_ADMA_UART0_TX0x06000020Quoted 37 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +34
-1+ >; + }; + ... + }; + + imx8qx-pm { + compatible = "fsl,scu-pd"; + #address-cells = <1>; + #size-cells = <0>; + + pd_dma: dma-power-domain { + #power-domain-cells = <0>; + + pd_dma_lpuart0: dma-lpuart0 at 57 { + reg = <SC_R_UART_0>; + #power-domain-cells = <0>; + power-domains = <&pd_dma>; + }; + ... + }; + ... + }; + }; +}; + +serial at 5a060000 { + ... + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_lpuart0>; + clocks = <&clk IMX8QXP_UART0_CLK>, + <&clk IMX8QXP_UART0_IPG_CLK>; + clock-names = "per", "ipg"; + power-domains = <&pd_dma_lpuart0>; +}; --2.7.4
PATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
Hi Rob,
Quoted 13 lines
Quoted 12 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt line 81
Quoted 8 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +8
-0+Clock bindings based on SCU Message Protocol +------------------------------------------------------------ + +This binding uses the common clock binding[1]. + +Required properties: +- compatible: Should be "fsl,imx8qxp-clock". +- #clock-cells: Should be 1. Contains the Clock ID value.There was a recent patch adding input clocks to other i.MX CCM bindings. Is that needed here?
Quoted 1 line
Will double check it, thanks for reminder.
It should work for mx8 as well.
I will add them like below:
+- clocks: List of clock specifiers, must contain an entry for + each required entry in clock-names +- clock-names: Should include entries "xtal_32KHz", "xtal_24MHz"
Thanks for the suggestion.
Regards
Dong Aisheng
PATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
In reply to A.s. DongQuoted 17 lines · A.s. Dong
Quoted 16 lines
Quoted 4 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +3
-0+ +The System Controller Firmware (SCFW) is a low-level system function +which runs on a dedicated Cortex-M core to provide power, clock, andDocumentation/devicetree/bindings/arm/freescale/fsl,scu.txt
Quoted 10 lines
Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt new file +10
-0+resource management. It exists on some i.MX8 processors. e.g. i.MX8QM +(QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module found +in the LSIO subsystem. The current definition of this MU module +provides +5 remote AP connections to the SC to support up to 5 execution +environments (TZ, HV, standard Linux, etc.). The SC side of this MU +module interfaces with the LSIO DSC IP bus. The SC firmware will +communicate with this MU using the MSI bus.How are 5 users supported with only 4 channels defined below?
Quoted 3 lines
There're 5 MU instances designed to be specifically communicate with SCU Firmware on MX8 hardware.
This is correct.
Quoted 10 lines
With the new generic mu binding [1], each MU instance is abstracted Into 16 virtual MU channels. (4 Tx, 4 Rx, 4 Tx doorbell, 4 Rx doorbell). (MU has 4 pair of Tx/Rx data register which can be used to send/receive multi words. With new binding, each data register is abstracted into one MU channel, totally 8 channels for data transfer).
SCU protocol is already designed to uses all data registers to send/receive multi words according to MU hardware reference manual. So it must use all channels in one MU instances with new binding.
FYI, this is incorrect.
The 16 channels are physical and not virtual. In fact, all this is to avoid virtual channels.
The physical resources required by new bindings are exactly the same as by old bindings. Now you use 8 physical channels instead of 1 virtual.
PATCH v5 1/5 dt-bindings: arm: fsl: add scu binding doc
Quoted 35 lines
-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]Quoted 17 lines · A.s. Dong
Quoted 16 lines
Quoted 4 lines
(quoted diff) +3
-0+ +The System Controller Firmware (SCFW) is a low-level system +function which runs on a dedicated Cortex-M core to provideReview
Quoted 10 lines
(quoted diff) +10
-0+power, clock, and resource management. It exists on some i.MX8 +processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX). + +The AP communicates with the SC using a multi-ported MU module +found in the LSIO subsystem. The current definition of this MU +module provides +5 remote AP connections to the SC to support up to 5 execution +environments (TZ, HV, standard Linux, etc.). The SC side of this +MU module interfaces with the LSIO DSC IP bus. The SC firmware +will communicate with this MU using the MSI bus.How are 5 users supported with only 4 channels defined below?
Quoted 3 lines
There're 5 MU instances designed to be specifically communicate with SCU Firmware on MX8 hardware.
This is correct.
Quoted 10 lines
With the new generic mu binding [1], each MU instance is abstracted Into 16 virtual MU channels. (4 Tx, 4 Rx, 4 Tx doorbell, 4 Rx doorbell). (MU has 4 pair of Tx/Rx data register which can be used to send/receive multi words. With new binding, each data register is abstracted into one MU channel, totally 8 channels for data transfer).
SCU protocol is already designed to uses all data registers to send/receive multi words according to MU hardware reference manual. So it must use all channels in one MU instances with new binding.
Quoted 5 lines
FYI, this is incorrect.
The 16 channels are physical and not virtual. In fact, all this is to avoid virtual channels.
The physical resources required by new bindings are exactly the same as by old bindings. Now you use 8 physical channels instead of 1 virtual.
Okay, got it.
I'm fine to refer to them all as physical channels. Thanks
Regards
Dong Aisheng
PATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
In reply to Dong AishengThe System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC calls
---v4->v5:
* switch to new generic MU binding.
Use 8 separate mu channels in one MU instance for SCU communication
* create struct sc_rpc_msg to separate the msg header and service, accordingly the old sc_rpc_msg_s with raw data union is removed. This can gain better readability.
* remove defines like RPC_XXX(MSG)
* remove unused types
* headfiles cleanup
* NOTE:
With the new approach that uses 8 separate irq driven changes, i still did not find a clean way to better support receiving msg over 4 words. So the current driver does not support it.
As in current SCU protocol, there's only a minor of commands need receiving msg over 4 words which is still not used by Linux, so it does not affect the normal function.
* Know issue:
The performance drops a lot after using 8 separate interrupt driven MUs to send/receive msgs.
e.g. Sending a scu message with tx size 2 words and rx size 2 words:
Former (polling) : < 10us to handle a SCU msg
Now (irq) : 20~30 us to handle a SCU msg (Caused by interrupt latency)v3->v4:
* change to use mailbox
* separate the IPC part and RPC API for easy review
* headfiles cleanupv2->v3:
* add the ipc read/write error checkv1->v2:
* change the type of sc_ipc_t from uint32_t to unsigned long. This can make it be capable of storing 64 bit pointer in ARMv8 system.
* Update to use the new MU library implemenation (handle iomem privately)
* remove unused delcarations e.g. sc_rpc_dispatch and sc_rpc_xlate.
* remove unneeded pad ctl functions
--- drivers/soc/imx/Kconfig | 4 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/sc/Makefile | 2 + drivers/soc/imx/sc/main/ipc.c | 258 +++++++++++++++++ drivers/soc/imx/sc/main/rpc.h | 51 ++++ include/soc/imx/sc/ipc.h | 46 +++ include/soc/imx/sc/sci.h | 16 ++ include/soc/imx/sc/types.h | 636 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 1014 insertions(+) create mode 100644 drivers/soc/imx/sc/Makefile create mode 100644 drivers/soc/imx/sc/main/ipc.c create mode 100644 drivers/soc/imx/sc/main/rpc.h create mode 100644 include/soc/imx/sc/ipc.h create mode 100644 include/soc/imx/sc/sci.h create mode 100644 include/soc/imx/sc/types.h
drivers/soc/imx/Kconfig +4 -0
@@ -7,4 +7,8 @@ config IMX7_PM_DOMAINS select PM_GENERIC_DOMAINS default y if SOC_IMX7D +config HAVE_IMX_SCU + bool + depends on IMX_MBOX + endmenu
drivers/soc/imx/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX7_PM_DOMAINS) += gpcv2.o +obj-$(CONFIG_HAVE_IMX_SCU) += sc/
drivers/soc/imx/sc/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-y += main/ipc.o
drivers/soc/imx/sc/main/ipc.c new file +258 -0
258 lines not on this page · raw message
drivers/soc/imx/sc/main/rpc.h new file +51 -0
51 lines not on this page · raw message
include/soc/imx/sc/ipc.h new file +46 -0
46 lines not on this page · raw message
include/soc/imx/sc/sci.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2016 Freescale Semiconductor, Inc. +* Copyright 2017~2018 NXP +* +* Header file containing the public System Controller Interface (SCI) +* definitions. +*/ + +#ifndef _SC_SCI_H +#define _SC_SCI_H + +#include <soc/imx/sc/ipc.h> +#include <soc/imx/sc/types.h> + +#endif /* _SC_SCI_H */
include/soc/imx/sc/types.h new file +636 -0
636 lines not on this page · raw message
Signature · 1 line
2.7.4
Sascha Hauer
maintainerPATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Quoted 60 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +44
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) +{ +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl; + cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch =mbox_request_channel_byname (cl, chan_name); +if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + }
drivers/soc/imx/sc/main/ipc.c line 206
Quoted 10 lines
drivers/soc/imx/sc/main/ipc.c new file +10
-0+ + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done); + + *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);
You export a sc_ipc_open() but it's only ever used once, in your internal code. Every other user uses sc_ipc_get_handle() which returns the same global handle for every user. In fact, I think sc_ipc_open() *can* only be used once, because every other user would get -EBUSY when requesting the same mailboxes again.
Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
I had a look at the FSL Kernel to see where this code comes from and what the initial intention might be and I almost fell from my chair laughing.
Every scu consumer does a:
Quoted 1 line
sc_ipc_getMuID(&mu_id);
which returs a global mu id
Quoted 1 line
sc_ipc_open(&ipcHndl, mu_id);
mu_id is not used in this function (or correctly, used to calculate a value which is then unused). ipcHndl is filled with the current task pid. Hell what, how is the current task pid used as an identifier? Ok, read on.
Quoted 1 line
sc_misc_set_control(ipcHndl, ...);
Following the code we end up in sc_ipc_write() / sc_ipc_read() where this handle, filled with some random value is not even used. So everything around sc_ipc_getMuID() and sc_ipc_open() is just dead code. It's just a complicated way to generate an arbitrary number which then ends up being unused. Even some init code calls sc_ipc_open() and assigns the result to some global variable mu_ipcHandle. This variable is only used to pass it to sc_irq_enable(), but looking at sc_irq_enable() you see that this parameter is again unused.
If you want to get this upstream I strongly suggest that you free yourself from the FSL codebase.
include/soc/imx/sc/ipc.h line 19
Quoted 5 lines
include/soc/imx/sc/ipc.h new file +5
-0+/* +* This type is used to declare a handle for an IPC communication +* channel. Its meaning is specific to the IPC implementation. +*/ +typedef unsigned long sc_ipc_t ;
sc_ipc_t is a typedef to unsigned long. Let's see how it's used:
void sc_ipc_close(sc_ipc_t ipc)
{
struct sc_ipc *sc_ipc = (struct sc_ipc *)ipc;
...
}So sc_ipc_t really is a struct sc_ipc *. Why don't you simply use it as such? Forget about typdefs. Do not use them. Call this thingy "struct sc_ipc" and that's it. No need for casting or typedefing.
Sascha
Signature · 4 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 |
PATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Quoted 87 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 4:41 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 59 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +43
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) { +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl; + cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch =mbox_request_channel_byname (cl, chan_name); +if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + }drivers/soc/imx/sc/main/ipc.c line 206
Quoted 10 lines
drivers/soc/imx/sc/main/ipc.c new file +10
-0+ + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done); + + *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);You export a
sc_ipc_open()but it's only ever used once, in your internal code. Every other user usessc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()
*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.
Quoted 4 lines
Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So sc_ipc_open() may not be used only once.
e.g.
SCU MU1 sc_ipc_open()
CLK MU1 sc_ipc_get_handle()
Power Domain MU2 sc_ipc_open()
Pinctrl MU3 sc_ipc_open()
and etc...
Quoted 1 line
From TI SCI code, it seems it also support multiple SCI phandle although the kernel currently
Only users one. But the idea behind is the same.
Quoted 3 lines
I had a look at the FSL Kernel to see where this code comes from and what the initial intention might be and I almost fell from my chair laughing.
I'm really sorry you got a bad impression on the internal code. We do know those issues and I've already reported them to internal team a few months ago and I would like to help clean up them later. For upstream, I actually have already totally rewritten the code, none of them are used except keep a few function name definition from an abstract view.
Quoted 23 lines
Every scu consumer does a:
Quoted 1 line
sc_ipc_getMuID(&mu_id);which returs a global mu id
Quoted 1 line
sc_ipc_open(&ipcHndl, mu_id);
mu_idis not used in this function (or correctly, used to calculate a value which is then unused). ipcHndl is filled with the current task pid. Hell what, how is the current task pid used as an identifier? Ok, read on.Quoted 1 line
sc_misc_set_control(ipcHndl, ...);Following the code we end up in
sc_ipc_write()/sc_ipc_read()where this handle, filled with some random value is not even used. So everything aroundsc_ipc_getMuID()andsc_ipc_open()is just dead code.
It's just a complicated way to generate an arbitrary number which then ends up being unused. Even some init code callssc_ipc_open()and assigns the result to some global variablemu_ipcHandle. This variable is only used to pass it tosc_irq_enable(), but looking atsc_irq_enable()you see that this parameter is again unused.
Quoted 2 lines
If you want to get this upstream I strongly suggest that you free yourself from the FSL codebase.
Yes, I've already totally rewritten them before upstream. The above code you pointed out are not in my patches.
Quoted 10 lines
include/soc/imx/sc/ipc.h line 19
Quoted 6 lines
include/soc/imx/sc/ipc.h new file +5
-0+/* +* This type is used to declare a handle for an IPC communication +* channel. Its meaning is specific to the IPC implementation. +*/ +typedef unsigned long sc_ipc_t ;
sc_ipc_tis a typedef to unsigned long. Let's see how it's used:void
sc_ipc_close(sc_ipc_t ipc)
Quoted 9 lines
{ struct sc_ipc *sc_ipc = (struct sc_ipc *)ipc; ... }So
sc_ipc_treally is a structsc_ipc*. Why don't you simply use it as such? Forget about typdefs. Do not use them. Call this thingy "structsc_ipc" and that's it. No need for casting or typedefing.
Our SCU firmware is OS independent. From SC point of view definition, sc_ipc_t implementation is OS dependant. OS can interpret them into the structure they needed. That's the orginal purpose and where the APIs are prototyped.
But I'm also ok if you think no need to keep it as it's already determined for Linux OS. Just let me know and I will do it.
Thanks for the review.
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C3d 7053028342490dd3e008d616f91982%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636721656469432903&sdata=MKpRwuI7HlZNmDcvrV OxpkUHqtv1It%2FHKiSK031ITuM%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
Sascha Hauer
maintainerPATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Quoted 92 lines · A.s. Dong
Quoted 87 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 4:41 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 59 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +43
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) { +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl; + cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch =mbox_request_channel_byname (cl, chan_name); +if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + }drivers/soc/imx/sc/main/ipc.c line 206
Quoted 10 lines
drivers/soc/imx/sc/main/ipc.c new file +10
-0+ + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done); + + *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);You export a
sc_ipc_open()but it's only ever used once, in your internal code. Every other user usessc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()
*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.Quoted 4 lines
Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
Quoted 9 lines
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So
sc_ipc_open()may not be used only once.
e.g.
SCU MU1sc_ipc_open()
CLK MU1sc_ipc_get_handle()
Power Domain MU2sc_ipc_open()
Pinctrl MU3sc_ipc_open()
and etc...
Your code started by busy polling the MU units until it would send an answer. The communication is completely synchronous and on the SCU side we have a single core cortex M4 processor. Why should we use another SCU channel? I bet the SCU side services the MUs round robin, so changing the MU won't change much.
Quoted 4 lines
Our SCU firmware is OS independent. From SC point of view definition,
sc_ipc_timplementation is OS dependant. OS can interpret them into the structure they needed. That's the orginal purpose and where the APIs are prototyped.
Nobody is interested in the SCU side here. I'd really like to have a peek, but it's totally irrelevant for the Kernel code.
Sascha
Signature · 4 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 |
PATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Hi Sascha,
Quoted 114 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 8:12 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 74 lines · A.s. Dong
Quoted 74 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 4:41 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 63 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +47
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) { +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl; + cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch =mbox_request_channel_byname (cl, chan_name); +if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + } + + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done);Quoted 8 lines
Quoted 8 lines
drivers/soc/imx/sc/main/ipc.c line 206
Quoted 6 lines
drivers/soc/imx/sc/main/ipc.c new file +6
-0+ + *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);You export a
sc_ipc_open()but it's only ever used once, in your internalcode.
Quoted 10 lines
Quoted 9 lines
Every other user uses
sc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
Quoted 9 lines
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So
sc_ipc_open()may not be used only once. e.g.
SCU MU1sc_ipc_open()
CLK MU1sc_ipc_get_handle()
Power Domain MU2sc_ipc_open()
Pinctrl MU3sc_ipc_open()
and etc...
Quoted 5 lines
Your code started by busy polling the MU units until it would send an answer. The communication is completely synchronous and on the SCU side we have a single core cortex M4 processor. Why should we use another SCU channel? I bet the SCU side services the MUs round robin, so changing the MU won't change much.
I carefully went through our SCU side code, SCU messages are completely handled asynchronously by interrupt driven and it does not have to wait for one SCU Message to be completed handled before being able to handle the next one.
The pseudo-code is like:Handle_mu_irq()
{
For (mu = 0; mu < NUM_MU; mu++) {
If (mu_pending()) {
Read(mu); // if available
Handle(mu); //if rx done
Write(mu);
}
}
...
}That means Read and Write process for all MUs channels can be processed sequentially within one IRQ, Don't have to wait one of them to be fully completed first.
For example, the follow could be:
MU IRQ #0 -> Read MU0 word 0-1 -> Read MU1 word 0-2 -> Read MU2 word 0 -> Exit. MU IRQ #1 -> Read MU0 word 2 -> Read MU1 word 3 -> Handle MU1 -> Write MU1
-> Read MU2 word 1 -> Exit. MU IRQ #2 -> Read MU0 word 3 -> Handle MU0 -> Write MU0 -> Read MU2 word 2 -> Handle MU2 -> Write MU2 -> Exit.
(Assume MU0 msg size 4, MU1 msg size 4, MU2 msg size 3)
But if we only support one SCU MU in kernel, then all SCU messages must be handled one by one. So it seems like using multiple SCU MUs in kernel are still better than using a single one. Am I understand correct?
Furthermore, If I understand correct, even SCU msg are processed one by one in SCU side. Using multiple channels in kernel side still can improve the performance a bit in theory Because it saves the MU lock contention time. Just like the Async request feature supported By MMC subsystem(saving MMC command prepare time asynchronously). And multiple MU channels actually are better because they're individual instances than mmc controller.
Quoted 9 lines
Quoted 5 lines
Our SCU firmware is OS independent. From SC point of view definition,
sc_ipc_timplementation is OS dependant. OS can interpret them into the structure they needed. That's the orginal purpose and where the APIs are prototyped.Nobody is interested in the SCU side here. I'd really like to have a peek, but it's totally irrelevant for the Kernel code.
Okay, got your point. I would remove it.
I'd also wish it opensource some day in the future...
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C07 e353ec055a48ca0eee08d61716992d%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636721783169922469&sdata=o2rN%2FE3UtksWsVRC 37wgre5bwqlWu51ZQVgDOUDkG2U%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
PATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Hi Sascha,
Quoted 2 lines
-----Original Message-----
From: A.s. Dong
[...]
Quoted 66 lines
Quoted 23 lines
Quoted 2 lines
Quoted 2 lines
You export a
sc_ipc_open()but it's only ever used once, in your internalcode.
Quoted 10 lines
Quoted 9 lines
Every other user uses
sc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
Quoted 9 lines
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So
sc_ipc_open()may not be used only once. e.g.
SCU MU1sc_ipc_open()
CLK MU1sc_ipc_get_handle()
Power Domain MU2sc_ipc_open()
Pinctrl MU3sc_ipc_open()
and etc...Quoted 5 lines
Your code started by busy polling the MU units until it would send an answer. The communication is completely synchronous and on the SCU side we have a single core cortex M4 processor. Why should we use another SCU channel? I bet the SCU side services the MUs round robin, so changing the MU won't change much.
I carefully went through our SCU side code, SCU messages are completely handled asynchronously by interrupt driven and it does not have to wait for one SCU Message to be completed handled before being able to handle the next one.
The pseudo-code is like:
Handle_mu_irq(){ For (mu = 0; mu < NUM_MU; mu++) { If (mu_pending()) { Read(mu); // if available Handle(mu); //if rx done Write(mu); } } ... }That means Read and Write process for all MUs channels can be processed sequentially within one IRQ, Don't have to wait one of them to be fully completed first.
For example, the follow could be:
MU IRQ #0 -> Read MU0 word 0-1 -> Read MU1 word 0-2 -> Read MU2 word 0 -> Exit.
MU IRQ #1 -> Read MU0 word 2 -> Read MU1 word 3 -> Handle MU1 -> Write MU1-> Read MU2 word 1 -> Exit. MU IRQ #2 -> Read MU0 word 3 -> Handle MU0 -> Write MU0 -> Read MU2 word 2 -> Handle MU2 -> Write MU2 -> Exit.(Assume MU0 msg size 4, MU1 msg size 4, MU2 msg size 3)
But if we only support one SCU MU in kernel, then all SCU messages must be handled one by one. So it seems like using multiple SCU MUs in kernel are still better than using a single one. Am I understand correct?
Quoted 8 lines
Furthermore, If I understand correct, even SCU msg are processed one by one in SCU side.
Using multiple channels in kernel side still can improve the performance a bit in theory Because it saves the MU lock contention time. Just like the Async request feature supported By MMC subsystem(saving MMC command prepare time asynchronously). And multiple MU channels actually are better because they're individual instances than mmc controller.
Would you mind give some hints about this?
Can you help clarify a bit if you still think we don't need support multi channels In kernels regardless of the performance issue?
Then I can just drop it and go ahead.
Regards
Dong Aisheng
Sascha Hauer
maintainerPATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
In reply to A.s. DongQuoted 145 lines · A.s. Dong
Hi Sascha,
Quoted 114 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 8:12 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 74 lines · A.s. Dong
Quoted 74 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 4:41 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 63 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +47
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) { +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl; + cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch =mbox_request_channel_byname (cl, chan_name); +if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + } + + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done);Quoted 8 lines
Quoted 8 lines
drivers/soc/imx/sc/main/ipc.c line 206
Quoted 6 lines
drivers/soc/imx/sc/main/ipc.c new file +6
-0+ + *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);You export a
sc_ipc_open()but it's only ever used once, in your internalcode.
Quoted 10 lines
Quoted 9 lines
Every other user uses
sc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
Quoted 9 lines
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So
sc_ipc_open()may not be used only once. e.g.
SCU MU1sc_ipc_open()
CLK MU1sc_ipc_get_handle()
Power Domain MU2sc_ipc_open()
Pinctrl MU3sc_ipc_open()
and etc...Quoted 5 lines
Your code started by busy polling the MU units until it would send an answer. The communication is completely synchronous and on the SCU side we have a single core cortex M4 processor. Why should we use another SCU channel? I bet the SCU side services the MUs round robin, so changing the MU won't change much.
I carefully went through our SCU side code, SCU messages are completely handled asynchronously by interrupt driven and it does not have to wait for one SCU Message to be completed handled before being able to handle the next one.
The pseudo-code is like:
Handle_mu_irq(){ For (mu = 0; mu < NUM_MU; mu++) { If (mu_pending()) { Read(mu); // if available Handle(mu); //if rx done Write(mu); } } ... }That means Read and Write process for all MUs channels can be processed sequentially within one IRQ, Don't have to wait one of them to be fully completed first.
For example, the follow could be:
MU IRQ #0 -> Read MU0 word 0-1 -> Read MU1 word 0-2 -> Read MU2 word 0 -> Exit. MU IRQ #1 -> Read MU0 word 2 -> Read MU1 word 3 -> Handle MU1 -> Write MU1
Quoted 8 lines
-> Read MU2 word 1 -> Exit. MU IRQ #2 -> Read MU0 word 3 -> Handle MU0 -> Write MU0 -> Read MU2 word 2 -> Handle MU2 -> Write MU2 -> Exit.(Assume MU0 msg size 4, MU1 msg size 4, MU2 msg size 3)
But if we only support one SCU MU in kernel, then all SCU messages must be handled one by one. So it seems like using multiple SCU MUs in kernel are still better than using a single one. Am I understand correct?
There's still only one CPU core in the SCU. Why should it be faster when it does two things at the same time?
Honestly, start simple. Drop the stuff you don't need currently and add it when you actually can argument *why* you need it and that it improves something. And when we are there we can discuss how we want to do this and how proper resource management can be done.
Sascha
Signature · 4 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 |
PATCH v5 2/5 soc: imx: add SC firmware IPC and APIs
Quoted 170 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Tuesday, September 18, 2018 2:23 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 64 lines · A.s. Dong
Hi Sascha,
Quoted 62 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 8:12 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 51 lines · A.s. Dong
Quoted 51 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 4:41 PM
To: A.s. Dong <[email protected]>
Cc: linux-arm-kernel at lists.infradead.org; dongas86 at gmail.com; Jassi Brar <[email protected]>; dl-linux-imx <[email protected]>; kernel at pengutronix.de; Fabio Estevam <[email protected]>; shawnguo at kernel.org
Subject: Re: [PATCH V5 2/5] soc: imx: add SC firmware IPC and APIsQuoted 39 lines · Dong Aisheng
The System Controller Firmware (SCFW) is a low-level system function which runs on a dedicated Cortex-M core to provide power, clock, and resource management. It exists on some i.MX8 processors. e.g. i.MX8QM (QM, QP), and i.MX8QX (QXP, DX).
This patch adds the SC firmware service APIs used by the system. It mainly consists of two parts:
1) Implementation of the IPC functions using MUs (client side).
2) SCU firmware services APIs implemented based on RPC callsCc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Fabio Estevam <[email protected]>Cc Jassi Brar <[email protected]>Signed-off-by Dong Aisheng <[email protected]>---
drivers/soc/imx/sc/main/ipc.c new file +23
-0+int sc_ipc_open (sc_ipc_t *ipc,struct device *dev) { +struct sc_ipc *sc_ipc; +struct sc_chan *sc_chan; +struct mbox_client *cl; +char *chan_name; +int ret; +int i; + + sc_ipc =devm_kzalloc (dev,sizeof (*sc_ipc),GFP_KERNEL ); +if (!sc_ipc) +return -ENOMEM ; + +for (i =0 ; i <SCU_MU_CHAN_NUM ; i++) { +if (i <4 ) + chan_name =kasprintf (GFP_KERNEL ,"tx%d" , i); +else + chan_name =kasprintf (GFP_KERNEL ,"rx%d" , i -4 ); + +if (!chan_name) +return -ENOMEM ; + + sc_chan = &sc_ipc->chans[i]; + cl = &sc_chan->cl;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/soc/imx/sc/main/ipc.c
Quoted 8 lines
drivers/soc/imx/sc/main/ipc.c new file +8
-0+ cl->dev = dev; + cl->tx_block = false; + cl->knows_txdone = true; + cl->rx_callback = sc_rx_callback; + + sc_chan->sc_ipc = sc_ipc; + sc_chan->idx = i %4 ; + sc_chan->ch = mbox_request_channel_byname(cl,
chan_name);Quoted 46 lines
Quoted 46 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
drivers/soc/imx/sc/main/ipc.c new file +17
-0+if (IS_ERR (sc_chan->ch)) { + ret =PTR_ERR (sc_chan->ch); +if (ret != -EPROBE_DEFER ) +dev_err (dev,"Failed to get mbox %d\n" , ret); + +return ret; + } + +dev_dbg (dev,"mbox request chan %s\n" , chan_name); +/* chan_name is not used anymore by framework */ +kfree (chan_name); + } + + sc_ipc->dev = dev; +mutex_init (&sc_ipc->lock); +init_completion (&sc_ipc->done); +Quoted 8 lines
Quoted 8 lines
drivers/soc/imx/sc/main/ipc.c line 206
Quoted 5 lines
drivers/soc/imx/sc/main/ipc.c new file +5
-0+ *ipc = (sc_ipc_t )sc_ipc; + +return 0 ; +} +EXPORT_SYMBOL (sc_ipc_open);You export a
sc_ipc_open()but it's only ever used once, in your internalcode.
Quoted 19 lines
Quoted 9 lines
Every other user uses
sc_ipc_get_handle()which returns the same global handle for every user. In fact, I thinksc_ipc_open()*can* only be used once, because every other user would get-EBUSYwhen requesting the same mailboxes again.Please drop all this pseudo resource management nonsense. You simply do no resource management. Face it, there is only one global handle that is used, don't try to hide it.
The original purpose of this code is that there're 5 MUs can be used by the system, that means other users can choose to not use the default SCU MU. So
sc_ipc_open()may not be used only once. e.g.
SCU MU1sc_ipc_open()
CLK MU1sc_ipc_get_handle()
Power Domain MU2sc_ipc_open()
Pinctrl MU3sc_ipc_open()
and etc...Quoted 1 line
Quoted 1 line
Your code started by busy polling the MU units until it would send an
answer.
Quoted 8 lines
Quoted 4 lines
The communication is completely synchronous and on the SCU side we have a single core cortex M4 processor. Why should we use another SCU channel? I bet the SCU side services the MUs round robin, so changing the MU won't change much.
I carefully went through our SCU side code, SCU messages are completely handled asynchronously by interrupt driven and it does not have to wait for one SCU Message to be completed handled before being
able to handle the next one.
Quoted 14 lines
The pseudo-code is like:
Handle_mu_irq(){ For (mu = 0; mu < NUM_MU; mu++) { If (mu_pending()) { Read(mu); // if available Handle(mu); //if rx done Write(mu); } } ... }Quoted 2 lines
That means Read and Write process for all MUs channels can be processed sequentially within one IRQ, Don't have to wait one of them to be
fully completed first.
Quoted 3 lines
For example, the follow could be:
MU IRQ #0 -> Read MU0 word 0-1 -> Read MU1 word 0-2 -> Read MU2 word0 -> Exit.
Quoted 1 line
MU IRQ #1 -> Read MU0 word 2 -> Read MU1 word 3 -> Handle MU1 -> Write
MU1
Quoted 2 lines
-> Read MU2 word 1 -> Exit.MU IRQ #2 -> Read MU0 word 3 -> Handle MU0 -> Write MU0 -> Read MU2
word 2
Quoted 3 lines
-> Handle MU2 -> Write MU2 -> Exit.(Assume MU0 msg size 4, MU1 msg size 4, MU2 msg size 3)
Quoted 7 lines
Quoted 3 lines
But if we only support one SCU MU in kernel, then all SCU messages must be handled one by one. So it seems like using multiple SCU MUs in kernel are still better than using a single one. Am I understand correct?
There's still only one CPU core in the SCU. Why should it be faster when it does two things at the same time?
Not at the same time, but got a chance to handle another thing while waiting for the former thing to be ready. I already described in above process.
When SCU read MU0, MU0 messages may not be fully ready assume it's a four word message (depends on A core send speed, actually it may be worse than the initial polling mode after using 8 separate interrupt driven channels)
Quoted 5 lines
Honestly, start simple. Drop the stuff you don't need currently and add it when you actually can argument *why* you need it and that it improves something. And when we are there we can discuss how we want to do this and how proper resource management can be done.
Okay, it's fine with that. Thanks for the suggestion.
I can then provide some tuning data at that point to help the understanding.
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C0f 743e829180493bc76d08d61d2f2473%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636728485665858207&sdata=VPLDzUInryAFCok%2Bw ZOJ%2BQK6ezqRx4U2DPiaUwz3%2Bl0%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
PATCH v5 3/5 soc: imx: sc: add pm svc support
In reply to Dong AishengAdd SCU PM SVC support which provides clock gate, rate, parent set support as well as resource power management.
--- drivers/soc/imx/sc/Makefile | 1 + drivers/soc/imx/sc/svc/pm/rpc_clnt.c | 275 +++++++++++++++++++++++++++++++++++ include/soc/imx/sc/sci.h | 2 + include/soc/imx/sc/svc/pm/api.h | 229 +++++++++++++++++++++++++++++ 4 files changed, 507 insertions(+) create mode 100644 drivers/soc/imx/sc/svc/pm/rpc_clnt.c create mode 100644 include/soc/imx/sc/svc/pm/api.h
drivers/soc/imx/sc/Makefile +1 -0
@@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += main/ipc.o +obj-y += svc/pm/rpc_clnt.o
drivers/soc/imx/sc/svc/pm/rpc_clnt.c new file +275 -0
275 lines not on this page · raw message
include/soc/imx/sc/sci.h +2 -0
@@ -13,4 +13,6 @@#include <soc/imx/sc/ipc.h> #include <soc/imx/sc/types.h> +#include <soc/imx/sc/svc/pm/api.h> +#endif /* _SC_SCI_H */
include/soc/imx/sc/svc/pm/api.h new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 4/5 soc: imx: sc: add pad svc support
In reply to Dong AishengAdd SCU PAD SVC support which provides pad get/set functions.
--- drivers/soc/imx/sc/Makefile | 1 + drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 82 +++++++++++++++++++++++++++++++++++ include/soc/imx/sc/sci.h | 1 + include/soc/imx/sc/svc/pad/api.h | 60 +++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 drivers/soc/imx/sc/svc/pad/rpc_clnt.c create mode 100644 include/soc/imx/sc/svc/pad/api.h
drivers/soc/imx/sc/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += main/ipc.o +obj-y += svc/pad/rpc_clnt.o obj-y += svc/pm/rpc_clnt.o
drivers/soc/imx/sc/svc/pad/rpc_clnt.c new file +82 -0
82 lines not on this page · raw message
include/soc/imx/sc/sci.h +1 -0
@@ -13,6 +13,7 @@#include <soc/imx/sc/ipc.h> #include <soc/imx/sc/types.h> +#include <soc/imx/sc/svc/pad/api.h> #include <soc/imx/sc/svc/pm/api.h> #endif /* _SC_SCI_H */
include/soc/imx/sc/svc/pad/api.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 5/5 soc: imx: sc: add misc svc support
In reply to Dong AishengAdd SCU MISC SVC support which provides misc control get/set functions.
--- drivers/soc/imx/sc/Makefile | 1 + drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 106 +++++++++++++++++++++++++++++++++ include/soc/imx/sc/sci.h | 1 + include/soc/imx/sc/svc/misc/api.h | 60 +++++++++++++++++++ 4 files changed, 168 insertions(+) create mode 100644 drivers/soc/imx/sc/svc/misc/rpc_clnt.c create mode 100644 include/soc/imx/sc/svc/misc/api.h
drivers/soc/imx/sc/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += main/ipc.o +obj-y += svc/misc/rpc_clnt.o obj-y += svc/pad/rpc_clnt.o obj-y += svc/pm/rpc_clnt.o
drivers/soc/imx/sc/svc/misc/rpc_clnt.c new file +106 -0
106 lines not on this page · raw message
include/soc/imx/sc/sci.h +1 -0
@@ -13,6 +13,7 @@#include <soc/imx/sc/ipc.h> #include <soc/imx/sc/types.h> +#include <soc/imx/sc/svc/misc/api.h> #include <soc/imx/sc/svc/pad/api.h> #include <soc/imx/sc/svc/pm/api.h>
include/soc/imx/sc/svc/misc/api.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
v5 cover soc: imx: add scu firmware api support
In reply to Dong AishengHi Jassi & Sascha,
Would you help review this new version patch series?
It's changed to generic MU driver using 8 separately MU channels according to Jassi's suggestion.
Please help check if this is okay to you.
Regards
Dong Aisheng
Quoted 63 lines
-----Original Message-----
From: A.s. Dong
Sent: Tuesday, August 21, 2018 12:08 AM
To: linux-arm-kernel at lists.infradead.org
Cc: dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <linux-
imx at nxp.com>; A.s. Dong <[email protected]>
Subject: [PATCH V5 0/5] soc: imx: add scu firmware api supportUnlike the former i.MX Architectures, the new generation i.MX8 SoCs (e.g. MX8QXP and MX8QM) contain a system controller which runs on a dedicated Cortex-M core to provide power, clock, Pad, and resource management. Communication between the host processor running an OS and the system controller happens through a SCU protocol.
This patchset adds the SCU APIs which is implemented based on MU and will be used by different system components.It mainly consists of below parts:
1) SCU IPC
Basic IPC mechanism implemention based on mailbox which is used for communication between AP and SCU firmware.
2) SCU IPC Service APIDong Aisheng (5):
dt-bindings: arm: fsl: add scu binding doc
soc: imx: add SC firmware IPC and APIs
soc: imx: sc: add pm svc support
soc: imx: sc: add pad svc support
soc: imx: sc: add misc svc support.../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 ++++++ drivers/soc/imx/Kconfig | 4 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/sc/Makefile | 5 + drivers/soc/imx/sc/main/ipc.c | 258 +++++++++ drivers/soc/imx/sc/main/rpc.h | 51 ++ drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 106 ++++ drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 82 +++ drivers/soc/imx/sc/svc/pm/rpc_clnt.c | 275 +++++++++ include/soc/imx/sc/ipc.h | 46 ++ include/soc/imx/sc/sci.h | 20 + include/soc/imx/sc/svc/misc/api.h | 60 ++ include/soc/imx/sc/svc/pad/api.h | 60 ++ include/soc/imx/sc/svc/pm/api.h | 229 ++++++++ include/soc/imx/sc/types.h | 636 +++++++++++++++++++++ 15 files changed, 2012 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt create mode 100644 drivers/soc/imx/sc/Makefile create mode 100644 drivers/soc/imx/sc/main/ipc.c create mode 100644 drivers/soc/imx/sc/main/rpc.h create mode 100644 drivers/soc/imx/sc/svc/misc/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pad/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pm/rpc_clnt.c create mode 100644 include/soc/imx/sc/ipc.h create mode 100644
include/soc/imx/sc/sci.hcreate mode 100644include/soc/imx/sc/svc/misc/api.hcreate mode 100644include/soc/imx/sc/svc/pad/api.hcreate mode 100644include/soc/imx/sc/svc/pm/api.hcreate mode 100644include/soc/imx/sc/types.h--
2.7.4
v5 cover soc: imx: add scu firmware api support
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
Regards
Dong Aisheng
Quoted 86 lines
-----Original Message-----
From: A.s. Dong
Sent: Tuesday, August 21, 2018 12:32 AM
To: Jassi Brar <[email protected]>; Sascha Hauer <[email protected]>
Cc: dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: RE: [PATCH V5 0/5] soc: imx: add scu firmware api supportHi Jassi & Sascha,
Would you help review this new version patch series?
It's changed to generic MU driver using 8 separately MU channels according to Jassi's suggestion.
Please help check if this is okay to you.Regards
Dong AishengQuoted 9 lines
-----Original Message-----
From: A.s. Dong
Sent: Tuesday, August 21, 2018 12:08 AM
To: linux-arm-kernel at lists.infradead.org
Cc: dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <linux-
imx at nxp.com>; A.s. Dong <[email protected]>
Subject: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 3 lines
Unlike the former i.MX Architectures, the new generation i.MX8 SoCs (e.g. MX8QXP and MX8QM) contain a system controller which runs on a dedicated Cortex-M core to provide power, clock, Pad, and resource
management.
Quoted 18 lines
Communication between the host processor running an OS and the system controller happens through a SCU protocol.
This patchset adds the SCU APIs which is implemented based on MU and will be used by different system components.It mainly consists of below parts:
1) SCU IPC
Basic IPC mechanism implemention based on mailbox which is used for communication between AP and SCU firmware.
2) SCU IPC Service APIDong Aisheng (5):
dt-bindings: arm: fsl: add scu binding doc
soc: imx: add SC firmware IPC and APIs
soc: imx: sc: add pm svc support
soc: imx: sc: add pad svc support
soc: imx: sc: add misc svc supportQuoted 15 lines
.../devicetree/bindings/arm/freescale/fsl,scu.txt | 179 ++++++ drivers/soc/imx/Kconfig | 4 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/sc/Makefile | 5 + drivers/soc/imx/sc/main/ipc.c | 258 +++++++++ drivers/soc/imx/sc/main/rpc.h | 51 ++ drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 106 ++++ drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 82 +++ drivers/soc/imx/sc/svc/pm/rpc_clnt.c | 275 +++++++++ include/soc/imx/sc/ipc.h | 46 ++ include/soc/imx/sc/sci.h | 20 + include/soc/imx/sc/svc/misc/api.h | 60 ++ include/soc/imx/sc/svc/pad/api.h | 60 ++ include/soc/imx/sc/svc/pm/api.h | 229 ++++++++ include/soc/imx/sc/types.h | 636+++++++++++++++++++++
Quoted 18 lines
15 files changed, 2012 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt create mode 100644 drivers/soc/imx/sc/Makefile create mode 100644 drivers/soc/imx/sc/main/ipc.c create mode 100644 drivers/soc/imx/sc/main/rpc.h create mode 100644 drivers/soc/imx/sc/svc/misc/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pad/rpc_clnt.c create mode 100644 drivers/soc/imx/sc/svc/pm/rpc_clnt.c create mode 100644 include/soc/imx/sc/ipc.h create mode 100644
include/soc/imx/sc/sci.hcreate mode 100644include/soc/imx/sc/svc/misc/api.hcreate mode 100644include/soc/imx/sc/svc/pad/api.hcreate mode 100644include/soc/imx/sc/svc/pm/api.hcreate mode 100644include/soc/imx/sc/types.h--
2.7.4
v5 cover soc: imx: add scu firmware api support
Quoted 5 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
The client uses the mailbox api as expected. And I leave the implementation upto you. So, I am fine.
v5 cover soc: imx: add scu firmware api support
Quoted 10 lines
-----Original Message-----
From: Jassi Brar [mailto:jassisinghbrar at gmail.com]Quoted 5 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
The client uses the mailbox api as expected. And I leave the implementation upto you. So, I am fine.
Thanks
Sascha,
What's your suggestion?
Regards
Dong Aisheng
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
In reply to A.s. DongQuoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call sc_call_rpc(), no need for this shim at all.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Quoted 10 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, August 27, 2018 4:33 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api support
Quoted 8 lines
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.
Sorry, I'm a bit confuse.
What specific shim do you mean not needed?
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_t sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource,
sc_pm_clk_t clk, sc_pm_clock_rate_t *rate)
Change to:drivers/clk/imx/scu/scu_clock.c ?sc_err_t sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource,
sc_pm_clk_t clk, sc_pm_clock_rate_t *rate)
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C39 eeb76a11134dbbf23d08d60bf7b9d1%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636709555948361895&sdata=qFfNaPeDvy3IN5O4Ou UUYg3I6360%2FDX6Bg8YAJB11pg%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
v5 cover soc: imx: add scu firmware api support
Quoted 14 lines
From: A.s. Dong
Quoted 9 lines
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?
Quoted 12 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
I thought even make client driver to directly to sc_call_rpc(), it may still better to Make them into a serrate function call like sc_pm_get_clock_rate() but just put In client driver instead of in the central SCU SVC place.
Not sure the point to do that.
Would you please help clarify a bit more?
Regards
Dong Aisheng
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
Quoted 27 lines · A.s. Dong
Quoted 14 lines
From: A.s. Dong
Quoted 9 lines
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?Quoted 12 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
Quoted 5 lines
I thought even make client driver to directly to
sc_call_rpc(), it may still better to Make them into a serrate function call likesc_pm_get_clock_rate()but just put In client driver instead of in the central SCU SVC place.
Not sure the point to do that.
Would you please help clarify a bit more?
I think translating the sc message setup into a function only adds additional overhead that the reader has to follow. I do not see the point for doing this.
Also when we do the message sending directly in the clients we do not end up with a huge bag of all possible message sending function of which only a fraction is ever going to be used.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Quoted 42 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Tuesday, August 28, 2018 2:21 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 28 lines · A.s. Dong
Quoted 14 lines
From: A.s. Dong
Quoted 9 lines
From: Sascha Hauer [mailto:s.hauer at pengutronix.de] On Fri, Aug 24,
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?Quoted 13 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate) Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate)Quoted 3 lines
I thought even make client driver to directly to
sc_call_rpc(), it may still better to Make them into a serrate function call likesc_pm_get_clock_rate()but just put In client driver instead of in the central
Quoted 7 lines
SCU SVC place.
Quoted 2 lines
Not sure the point to do that.
Would you please help clarify a bit more?I think translating the sc message setup into a function only adds additional overhead that the reader has to follow. I do not see the point for doing this.
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be maintained independently.
And this way seems like to be commonly used in current kernel:
See:drivers/firmware/ti_sci.c drivers/firmware/arm_scpi.c drivers/firmware/arm_scmi/clock.c
Should we be the exception?
Quoted 4 lines
Also when we do the message sending directly in the clients we do not end up with a huge bag of all possible message sending function of which only a fraction is ever going to be used.
Currently I only add the APIs actually used by client driver. All unused APIs are not added until we have real requirements.
So changing a place seems like would not affect much.
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C79 cabf129d764c8d2dec08d60cae7563%7C686ea1d3bc2b4c6fa92cd99c5c30163 5%7C0%7C0%7C636710340764331803&sdata=vWXc5oHn6fZN0zBYbMI mgsVMzPQMU08wvSt3HNvbGgM%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
Quoted 46 lines · A.s. Dong
Quoted 46 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Tuesday, August 28, 2018 2:21 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 28 lines · A.s. Dong
Quoted 14 lines
From: A.s. Dong
Quoted 9 lines
From: Sascha Hauer [mailto:s.hauer at pengutronix.de] On Fri, Aug 24,
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?Quoted 13 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate) Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate)Quoted 3 lines
I thought even make client driver to directly to
sc_call_rpc(), it may still better to Make them into a serrate function call likesc_pm_get_clock_rate()but just put In client driver instead of in the centralSCU SVC place.
Quoted 2 lines
Not sure the point to do that.
Would you please help clarify a bit more?
Quoted 8 lines
Quoted 3 lines
I think translating the sc message setup into a function only adds additional overhead that the reader has to follow. I do not see the point for doing this.
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a message struct. With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Quoted 70 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Wednesday, August 29, 2018 2:54 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 46 lines · A.s. Dong
Quoted 46 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Tuesday, August 28, 2018 2:21 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 35 lines · A.s. Dong
Quoted 15 lines
From: A.s. Dong
Quoted 10 lines
From: Sascha Hauer [mailto:s.hauer at pengutronix.de] On Fri, Aug 24,
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?Quoted 15 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver? For example:
drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate) Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate)I thought even make client driver to directly to
sc_call_rpc(), it may still better to Make them into a serrate function call likesc_pm_get_clock_rate()but just put In client driver instead of in the centralQuoted 6 lines
Quoted 6 lines
SCU SVC place.
Quoted 2 lines
Not sure the point to do that.
Would you please help clarify a bit more?I think translating the sc message setup into a function only adds additional overhead that the reader has to follow. I do not see the point for
doing this.
Quoted 6 lines
Quoted 1 line
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
Quoted 7 lines
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a message struct. With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype. The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmware updates. e.g. protocol params layout and size and etc.
This way give us a clear separation between API internals and client users which are more like to be maintained independently.
And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
So aren't those more valuable comparing to move SCU APIs into client drivers? And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C97 6c8b12abfc4be67f0708d60d7c2c1e%7C686ea1d3bc2b4c6fa92cd99c5c30163 5%7C0%7C0%7C636711224308904255&sdata=i2OfGviDpZrpEQVVv51gd gu2Cq20aBtRRtzR2wLzr0U%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
v5 cover soc: imx: add scu firmware api support
Hi Sascha,
Quoted 4 lines
-----Original Message-----
From: A.s. Dong
Sent: Wednesday, August 29, 2018 4:35 PM
To: Sascha Hauer <[email protected]>
[...]
Quoted 27 lines
Quoted 9 lines
Quoted 5 lines
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a
message struct.
Quoted 3 lines
With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype.
The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmware updates. e.g. protocol params layout and size and etc.This way give us a clear separation between API internals and client users which are more like to be maintained independently.
And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
Quoted 6 lines
So aren't those more valuable comparing to move SCU APIs into client drivers? And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..
Please let me know if you still believe moving SCU API implementation into each client driver is a more reasonable way to go, then i will do it as I trust your professionality.
.
This patch series has been pending for a long time. We need a way out to speed up the work.
Regards
Dong Aisheng
Quoted 23 lines
Regards
Dong AishengQuoted 7 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
Quoted 1 line
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C97
Quoted 1 line
6c8b12abfc4be67f0708d60d7c2c1e%7C686ea1d3bc2b4c6fa92cd99c5c30163
Quoted 1 line
5%7C0%7C0%7C636711224308904255&sdata=i2OfGviDpZrpEQVVv51gd
Quoted 5 lines
gu2Cq20aBtRRtzR2wLzr0U%3D&reserved=0 | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
|
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
Quoted 35 lines · A.s. Dong
Hi Sascha,
Quoted 4 lines
-----Original Message-----
From: A.s. Dong
Sent: Wednesday, August 29, 2018 4:35 PM
To: Sascha Hauer <[email protected]>[...]
Quoted 26 lines
Quoted 9 lines
Quoted 5 lines
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a
message struct.
Quoted 3 lines
With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype.
The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmware updates. e.g. protocol params layout and size and etc.This way give us a clear separation between API internals and client users which are more like to be maintained independently.
And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
Examples?
Quoted 11 lines
Quoted 7 lines
So aren't those more valuable comparing to move SCU APIs into client drivers? And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..Please let me know if you still believe moving SCU API implementation into each client driver is a more reasonable way to go, then i will do it as I trust your professionality.
Yes, I still think that. I still think the 1:1 mapping between messages and function calls is an unnecessary overhead.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Hi Sasha,
Quoted 44 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 3, 2018 7:45 PMQuoted 28 lines · A.s. Dong
Hi Sascha,
Quoted 4 lines
-----Original Message-----
From: A.s. Dong
Sent: Wednesday, August 29, 2018 4:35 PM
To: Sascha Hauer <[email protected]>[...]
Quoted 19 lines
Quoted 10 lines
Quoted 5 lines
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a
message struct.
Quoted 3 lines
With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype.
The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmwareupdates.
Quoted 9 lines
Quoted 9 lines
e.g. protocol params layout and size and etc.
This way give us a clear separation between API internals and client users which are more like to be maintained independently. And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
Quoted 2 lines
Examples?
Take sc_misc_set_control as example which is widely used by various client drivers. Encoding message in driver may cause many duplicated code.
Cscope tag: sc_misc_set_control
# line filename / context / line
1 206 drivers/clk/imx/clk-divider-scu.c <<clk_divider3_scu_set_rate>>
sci_err = sc_misc_set_control(ccm_ipc_handle, clk->rsrc_id,
2 372 drivers/clk/imx/clk-gate-scu.c <<clk_gate3_scu_prepare>>
return sc_misc_set_control(ccm_ipc_handle,
4 319 drivers/clk/imx/clk-mux-scu.c <<clk_mux_gpr_scu_set_parent>>
sc_misc_set_control(ccm_ipc_handle,
5 128 drivers/gpu/drm/imx/hdp/imx-hdp.c <<imx8qm_pixel_link_validate>>
sciErr = sc_misc_set_control(hdp->ipcHndl, SC_R_DC_0,
10 432 drivers/gpu/drm/imx/hdp/imx-hdp.c <<imx8qm_dp_pixel_clock_set_rate>>
sc_misc_set_control(ipc_handle, SC_R_HDMI, SC_C_MODE, 1);
11 339 drivers/gpu/drm/imx/imx-ldb.c <<dpu_pixel_link_validate>>
sciErr = sc_misc_set_control(ipcHndl, SC_R_DC_0,
30 271 drivers/gpu/drm/imx/nwl_dsi-imx.c <<imx8q_dsi_poweron>>
sci_err = sc_misc_set_control(ipc_handle,
41 1544 drivers/gpu/imx/dpu/dpu-common.c <<dpu_pixel_link_init>>
sciErr = sc_misc_set_control(ipcHndl, SC_R_DC_0, SC_C_KACHUNK_CNT, 32);
58 1612 drivers/gpu/imx/dpu/dpu-common.c <<dpu_pixel_link_init>>
sciErr = sc_misc_set_control(ipcHndl, SC_R_DC_1, SC_C_SYNC_CTRL1, 0);
59 147 drivers/gpu/imx/dpu/dpu-framegen.c <<dpu_pixel_link_enable>>
sciErr = sc_misc_set_control(ipcHndl, SC_R_DC_0,
65 312 drivers/gpu/imx/imx8_dprc.c <<dprc_dpu_gpr_configure>>
sciErr = sc_misc_set_control(ipcHndl, dprc->sc_resource,
67 573 drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c <<imx8qm_hdmi_phy_reset>>
sciErr = sc_misc_set_control(hdmi_rx->ipcHndl, SC_R_HDMI_RX, SC_C_PHY_RESET, reset);
68 139 drivers/media/platform/imx8/mxc-mipi-csi2.c <<mipi_sc_fw_init>>
sciErr = sc_misc_set_control(ipcHndl, rsrc_id, SC_C_MIPI_RESET, enable);
69 1261 drivers/mxc/gpu-viv/hal/os/linux/kernel/platform/freescale/gc_hal_kernel_platform_imx.c <<set_power>>
sc_err_t sciErr = sc_misc_set_control(gpu_ipcHandle, priv->sc_gpu_pid[gpu], SC_C_ID, gpu);
72 230 drivers/net/ethernet/freescale/fec_fixup.c <<imx8qm_ipg_stop_enable>>
sc_err = sc_misc_set_control(ipc_handle, rsrc_id, SC_C_IPG_STOP, val);
73 187 drivers/phy/phy-mixel-mipi-dsi.c <<mixel_mipi_phy_enable>>
sci_err = sc_misc_set_control(ipc_handle,
74 794 sound/soc/fsl/fsl_dsp.c <<fsl_dsp_probe>>
sciErr = sc_misc_set_control(dsp_priv->dsp_ipcHandle, SC_R_DSP,...
Quoted 9 lines
Quoted 2 lines
Quoted 2 lines
So aren't those more valuable comparing to move SCU APIs into client
drivers?
Quoted 6 lines
Quoted 5 lines
And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..
Quoted 7 lines
Quoted 3 lines
Please let me know if you still believe moving SCU API implementation into each client driver is a more reasonable way to go, then i will do it as I trust your professionality.
Yes, I still think that. I still think the 1:1 mapping between messages and function calls is an unnecessary overhead.
Okay, let's do that way first if you still think it's proper. BTW, do you have any comment about the MU usage in Patch 2/5 ? [V5,2/5] soc: imx: add SC firmware IPC and APIs
https://patchwork.kernel.org/patch/10570551/
As this patch may not change much even changing to new approach, except moving drivers/soc/imx/sc/main/rpc.h under include/soc/imx to allow drivers to touch the internal details of SCU API implementation. So I guess this version does not affect review process.
Regards
Dong Aisheng
Quoted 16 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7Ca0 3cf22e3f194f921f2d08d61192a293%7C686ea1d3bc2b4c6fa92cd99c5c30163 5%7C0%7C0%7C636715718821871337&sdata=usMYj5iYuKFhqBU2HMHI gGL8w0FTMQ632a6HiTotNoc%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
Quoted 49 lines · A.s. Dong
Hi Sasha,
Quoted 44 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 3, 2018 7:45 PMQuoted 28 lines · A.s. Dong
Hi Sascha,
Quoted 4 lines
-----Original Message-----
From: A.s. Dong
Sent: Wednesday, August 29, 2018 4:35 PM
To: Sascha Hauer <[email protected]>[...]
Quoted 19 lines
Quoted 10 lines
Quoted 5 lines
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a
message struct.
Quoted 3 lines
With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype.
The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmwareupdates.
Quoted 9 lines
Quoted 9 lines
e.g. protocol params layout and size and etc.
This way give us a clear separation between API internals and client users which are more like to be maintained independently. And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
Quoted 2 lines
Examples?
Quoted 6 lines
Take
sc_misc_set_controlas example which is widely used by various client drivers. Encoding message in driver may cause many duplicated code.
Cscope tag:sc_misc_set_control
# line filename / context / line
1 206drivers/clk/imx/clk-divider-scu.c<<clk_divider3_scu_set_rate>>sci_err = sc_misc_set_control(ccm_ipc_handle, clk->rsrc_id,
You can still create a helper function for these calls. I was mainly aiming for the oneshot usages of several other functions.
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
So aren't those more valuable comparing to move SCU APIs into client
drivers?
Quoted 9 lines
Quoted 5 lines
And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..Please let me know if you still believe moving SCU API implementation into each client driver is a more reasonable way to go, then i will do it as I trust your professionality.
Quoted 8 lines
Quoted 3 lines
Yes, I still think that. I still think the 1:1 mapping between messages and function calls is an unnecessary overhead.
Okay, let's do that way first if you still think it's proper. BTW, do you have any comment about the MU usage in Patch 2/5 ? [V5,2/5] soc: imx: add SC firmware IPC and APIs
https://patchwork.kernel.org/patch/10570551/
The MU usage looks fine from a first glance.
The way you share a global scu handle with your clients still looks ridiculous though.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Quoted 67 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 10, 2018 3:04 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 47 lines · A.s. Dong
Hi Sasha,
Quoted 45 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, September 3, 2018 7:45 PMQuoted 29 lines · A.s. Dong
Hi Sascha,
Quoted 4 lines
-----Original Message-----
From: A.s. Dong
Sent: Wednesday, August 29, 2018 4:35 PM
To: Sascha Hauer <[email protected]>[...]
Quoted 20 lines
Quoted 10 lines
Quoted 5 lines
The original point is to separate the SCU service API implementation from the client drivers. Client drivers don't have to know the internal details of the API implementation, they just use the service API provided by SCU firmware. API implementation and client users will be
maintained independently.
I would buy this argument if the 'API implementation' was more than a shim layer that directly translates between function arguments and a
message struct.
Quoted 3 lines
With this you effectively can't change the API implementation without changing the API you provide to the client drivers.
In reality, the API implementation could change without changing the API prototype.
The API is defined in a more generic way and less possible to change. But the internal implementation is allowed to change if the firmwareupdates.
Quoted 9 lines
Quoted 9 lines
e.g. protocol params layout and size and etc.
This way give us a clear separation between API internals and client users which are more like to be maintained independently. And it may also help if we want to support old firmware due to API internal implementation changes. (And note that SCU firmware supports many functions, distribute them into various drivers may cause a bit mess. Some of them may get troubles on finding a proper place to put.)
Quoted 4 lines
Quoted 2 lines
Examples?
Take
sc_misc_set_controlas example which is widely used by various clientdrivers.
Quoted 4 lines
Encoding message in driver may cause many duplicated code. Cscope tag:
sc_misc_set_control
# line filename / context / line
1 206drivers/clk/imx/clk-divider-scu.c
Quoted 7 lines
<<
clk_divider3_scu_set_rate>>Quoted 2 lines
sci_err= sc_misc_set_control(ccm_ipc_handle,clk->rsrc_id,You can still create a helper function for these calls. I was mainly aiming for the oneshot usages of several other functions.
Okay. That seems good to me.
So you mean we can still put the generic SVC APIs (e.g. sc_misc_set/get_control) in a generic place. e.g. under drivers/soc/imx/sc/svc/
But put those oneshot usages APIs into individuals drivers. Right?
We can do that way.
Quoted 29 lines
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
So aren't those more valuable comparing to move SCU APIs into client
drivers?
Quoted 9 lines
Quoted 5 lines
And current kernel users (arm scpi/scmi, ti sci) already do like this... why not i.MX?
Sorry if I still not get your point.
Please help clarify a bit more if I missed something..Please let me know if you still believe moving SCU API implementation into each client driver is a more reasonable way to go, then i will do it as I trust your professionality.
Quoted 9 lines
Quoted 3 lines
Yes, I still think that. I still think the 1:1 mapping between messages and function calls is an unnecessary overhead.
Okay, let's do that way first if you still think it's proper. BTW, do you have any comment about the MU usage in Patch 2/5 ? [V5,2/5] soc: imx: add SC firmware IPC and APIs
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F10570551%2F&data=02%7C01%7Caishe ng.don
Quoted 1 line
g%40nxp.com%7C195b82e11bc04a2a342a08d616eb906e%7C686ea1d3bc2b
4c6fa92cdQuoted 1 line
Quoted 8 lines
99c5c301635%7C0%7C0%7C636721598339072295&sdata=dYWNSEOoll 1%2BCq2i1
Quoted 1 line
5uBxwelooUbAkNE6S9fnMOzf2I%3D&reserved=0
The MU usage looks fine from a first glance.
The way you share a global scu handle with your clients still looks ridiculous though.
What's your suggestion?
I checked other references:
ARM SCPI, it also shares a global scpi_ops, no much difference than handler. struct scpi_ops *get_scpi_ops(void)
{
return scpi_info ? scpi_info->scpi_ops : NULL;
} EXPORT_SYMBOL_GPL(get_scpi_ops);
TI also indirectly shares a global handler, they put it in a global ti_sci_list. And allocate it dynamically (there's actually only one SCI instance in current kernel) const struct ti_sci_handle *ti_sci_get_handle(struct device *dev)
{
}
It looks like they have no too much difference from i.MX.
And we have 5 MU instances, the scu handle used by client can be different later.
Regards
Dong Aisheng
Quoted 16 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C19 5b82e11bc04a2a342a08d616eb906e%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636721598339072295&sdata=dZKI%2FX4zoUTDTchK8 7DEpRzXIFUI1IR8kwUlA3t3HlY%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |
Sascha Hauer
maintainerv5 cover soc: imx: add scu firmware api support
In reply to A.s. DongQuoted 22 lines · A.s. Dong
Quoted 10 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, August 27, 2018 4:33 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 8 lines
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?
Quoted 11 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t*rate)
That particular function would go into drivers/clk/imx/scu/clk-divider-scu.c and probably would be no separate function at all but go into clk_divider_scu_recalc_rate(), but yes, that's the idea.
Sascha
Signature · 4 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 |
v5 cover soc: imx: add scu firmware api support
Quoted 46 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Tuesday, August 28, 2018 2:15 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 22 lines · A.s. Dong
Quoted 10 lines
-----Original Message-----
From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
Sent: Monday, August 27, 2018 4:33 PM
To: A.s. Dong <[email protected]>
Cc: Jassi Brar <[email protected]>; dongas86 at gmail.com; kernel at pengutronix.de; shawnguo at kernel.org; Fabio Estevam <[email protected]>; dl-linux-imx <[email protected]>; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH V5 0/5] soc: imx: add scu firmware api supportQuoted 8 lines
Quoted 3 lines · A.s. Dong
Hi Jassi & Sasha,
Do you have some suggestions about this patch series?
I still think that the users like clk and pinctrl should directly call
sc_call_rpc(), no need for this shim at all.Sorry, I'm a bit confuse.
What specific shim do you mean not needed?Quoted 12 lines
Do you mean we don't need all the SCU SVC APIs (clk/pm/pinctrl/misc and etc) Implemented in this patch series and instead directly implement them in client driver?
For example:drivers/soc/imx/sc/svc/pm/rpc_clnt.csc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate) Change to:drivers/clk/imx/scu/scu_clock.c?sc_err_tsc_pm_get_clock_rate(sc_ipc_t ipc,sc_rsrc_tresource,
sc_pm_clk_tclk,sc_pm_clock_rate_t
*rate)
Quoted 4 lines
That particular function would go into
drivers/clk/imx/scu/clk-divider-scu.cand probably would be no separate function at all but go intoclk_divider_scu_recalc_rate(), but yes, that's the idea.
I understanding your point. Just a bit wondering whether it's so worth to do that... As in my last reply, this is a common way in current kernel and separate well between the SCU API implementation details and the client users which somehow can ease our maintain.
Do you think it makes sense?
Regards
Dong Aisheng
Quoted 15 lines
Sascha
--
Pengutronix e.K. |
|
Industrial Linux Solutions |
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.
pengutronix.de%2F&data=02%7C01%7Caisheng.dong%40nxp.com%7C64 6e546c196147b1e76a08d60cad9e8b%7C686ea1d3bc2b4c6fa92cd99c5c3016 35%7C0%7C0%7C636710337160102101&sdata=idEapYpZEVA%2FHP3i% 2FfYTBKpPJxaGeZ3jY5RzZgfhdLc%3D&reserved=0 |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax:
+49-5121-206917-5555 |