Introduce bus domains controller framework
Subsystems (3)
cover Introduce bus domains controller framework
The goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.
Bus domains controllers are typically used to control if a hardware block can perform read or write operations on bus.
Smarter domains controllers could be able to define accesses rights per hardware blocks to control where they can read or write.
Domains controller configurations are provided in device node, parsed by the framework and send to the driver to apply them. Each controller may need different number and type of inputs to configure a domain so device-tree properties size have to be define by using "#domainctrl-cells".
Domains configurations properties have to be named "domainsctrl-X" on device node.
"domainsctrl-names" keyword can also be used to give a name to a specific configuration.
An example of bus domains controller is STM32 ETZPC hardware block which got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor. Up to 94 hardware blocks of the soc could be managed by ETZPC and assigned to one of the three domains.
It is an RFC, comments are welcome to help to create this framework, thanks. Benjamin
Benjamin Gaignard (7):
devicetree: bindings: Document domains controller bindings
domainsctrl: Introduce domains controller framework
base: Add calls to domains controller
devicetree: bindings: domainsctrl: Add STM32 ETZPC bindings
bus: domainsctrl: Add driver for STM32 ETZPC controller
ARM: dts: stm32: Add domainsctrl node for stm32mp157 SoC
ARM: dts: stm32: enable domains controller node on stm32mp157c-ed1
.../bindings/bus/domains/domainsctrl.txt | 35 +++ .../bindings/bus/domains/st,stm32-etzpc.txt | 14 ++ arch/arm/boot/dts/stm32mp157c-ev1.dts | 2 + arch/arm/boot/dts/stm32mp157c.dtsi | 7 + drivers/base/dd.c | 9 + drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 2 + drivers/bus/domains/Kconfig | 14 ++ drivers/bus/domains/Makefile | 2 + drivers/bus/domains/domainsctrl.c | 234 +++++++++++++++++++++ drivers/bus/domains/stm32-etzpc.c | 140 ++++++++++++ include/dt-bindings/bus/domains/stm32-etzpc.h | 25 +++ include/linux/domainsctrl.h | 70 ++++++ 13 files changed, 556 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/domains/domainsctrl.txt create mode 100644 Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt create mode 100644 drivers/bus/domains/Kconfig create mode 100644 drivers/bus/domains/Makefile create mode 100644 drivers/bus/domains/domainsctrl.c create mode 100644 drivers/bus/domains/stm32-etzpc.c create mode 100644 include/dt-bindings/bus/domains/stm32-etzpc.h create mode 100644 include/linux/domainsctrl.h
Signature · 1 line
2.15.0
RFC 1/7 devicetree: bindings: Document domains controller bindings
Document commons domains controller bindings for controller and client devices.
--- .../bindings/bus/domains/domainsctrl.txt | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/domains/domainsctrl.txt
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt new file +35 -0
@@ -0,0 +1,35 @@ +Common Domains Controller bindings properties + +Domains Controller framework defines common bindings properties to describe +the configurations to be applied for each device. + +Domains Controller bindings: +- #domainctrl-cells : provide the number of parameters provided with the + phandle by the client device + +Client device node bindings: +- domainsctrl-names : list of strings to name the configurations. + "default" and "unbind" are reserved names used by + the framework. +- domainsctrl-X : list of configurations to be applied where X is + the index of the configuration within the node. + +Example of usage with: +- a domains controller with a 2 parameters cell +- a domains controller with a 3 parameters cell +- a client device node using the both controllers and 2 configurations + named "default" and "unbind" + +ctrl0: ctrl@0 { + #domainctrl-cells = <2>; +}; + +ctrl1: ctrl@1 { + #domainctrl-cells = <3>; +}; + +foo@0 { + domains-names = "default", "unbind"; + domainctrl-0 = <&ctrl0 1 2>, <&ctrl1 3 4 5>; + domainctrl-1 = <&ctrl0 6 7>, <&ctrl1 8 9 0>; +};
Signature · 1 line
2.15.0
Re: [RFC 1/7] devicetree: bindings: Document domains controller bindings
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt line 4
Quoted 4 lines · Benjamin Gaignard
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt new file +4
-0+Common Domains Controller bindings properties + +Domains Controller framework defines common bindings properties to describe +the configurations to be applied for each device.
I suspect this is going to need a few more words about what a Domains Controller is.
Re: [RFC 1/7] devicetree: bindings: Document domains controller bindings
Quoted 8 lines · Mark Brown
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt line 4
Quoted 4 lines · Benjamin Gaignard
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt new file +4
-0+Common Domains Controller bindings properties + +Domains Controller framework defines common bindings properties to describe +the configurations to be applied for each device.I suspect this is going to need a few more words about what a Domains Controller is.
Does the description of the framework in the cover letter looks better for you ?
I'm not comfortable to put it in bindings file but maybe I'm wrong.
Re: [RFC 1/7] devicetree: bindings: Document domains controller bindings
Quoted 7 lines · Benjamin GAIGNARD
Quoted 2 lines · Mark Brown
I suspect this is going to need a few more words about what a Domains Controller is.
Does the description of the framework in the cover letter looks better for you ?
Yes, that looks reasonable to me.
Quoted 1 line
I'm not comfortable to put it in bindings file but maybe I'm wrong.
I can't see how someone will understand the binding document as a standalone document - it's not like domains controllers are a widely understood concept in the industry.
RFC 2/7 domainsctrl: Introduce domains controller framework
In reply to Benjamin GaignardThe goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.
Bus domains controllers are typically used to control if a hardware block can perform read or write operations on bus.
Smarter domains controllers could be able to define accesses rights per hardware blocks to control where they can read or write.
Domains controller configurations are provided in device node, parsed by the framework and send to the driver to apply them. Each controller may need different number and type of inputs to configure a domain so device-tree properties size have to be define by using "#domainctrl-cells".
Domains configurations properties have to be named "domainsctrl-X" on device node.
"domainsctrl-names" keyword can also be used to give a name to a specific configuration.
Example of device-tree:
ctrl0: domainsctrl@0 {
#domainctrl-cells = <2>;
};foo: foo@0 {
domainsctrl-names = "default", "setting1";
domainsctrl-0 = <&ctrl0 1 2>;
domainsctrl-1 = <&ctrl0 3 4>;
};Configurations could be applied with functions like domainsctrl_set_config_by_index() or domainsctrl_set_config_by_name().
domainsctrl_set_default_config() function will apply the configuration named "default" (if existing) or the configuration with index 0 (i.e. domainsctrl-0).
Drivers could register/unregister themselves be calling domainsctrl_register/domainsctrl_unregister functions.
When a configuration has to be applied the driver callback, provided in the ops at registration time, set_config is called by the framework.
--- drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 2 + drivers/bus/domains/Kconfig | 7 ++ drivers/bus/domains/Makefile | 1 + drivers/bus/domains/domainsctrl.c | 234 ++++++++++++++++++++++++++++++++++++++ include/linux/domainsctrl.h | 70 ++++++++++++ 6 files changed, 316 insertions(+) create mode 100644 drivers/bus/domains/Kconfig create mode 100644 drivers/bus/domains/Makefile create mode 100644 drivers/bus/domains/domainsctrl.c create mode 100644 include/linux/domainsctrl.h
drivers/bus/Kconfig +2 -0
@@ -183,4 +183,6 @@ config DA8XX_MSTPRI source "drivers/bus/fsl-mc/Kconfig" +source "drivers/bus/domains/Kconfig" + endmenu
drivers/bus/Makefile +2 -0
@@ -32,3 +32,5 @@ obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o + +obj-$(CONFIG_DOMAINS_CONTROLLERS) += domains/
drivers/bus/domains/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +menu "Bus Domains Controllers" + +config DOMAINS_CONTROLLERS + bool "Support of bus domains controllers" + depends on OF + +endmenu
drivers/bus/domains/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_DOMAINS_CONTROLLERS) += domainsctrl.o
drivers/bus/domains/domainsctrl.c new file +234 -0
234 lines not on this page · raw message
include/linux/domainsctrl.h new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.15.0
Re: [RFC 2/7] domainsctrl: Introduce domains controller framework
Quoted 2 lines · Benjamin Gaignard
Configurations could be applied with functions like
domainsctrl_set_config_by_index()ordomainsctrl_set_config_by_name().
Do you have any clients in the works for this? It seems fairly likely that everything is fine in terms of setting the mode but it'd be good to confirm that's the case. The main thing I can think of that might be a problem here is how you'd handle a case where we were talking to another processor that owns the permissions, we'd probably want more ways to query state there but I'm thinking there'd likely be some other higher level way to talk to the other processor there so perhaps it's moot.
Otherwise this all looks pretty clean and simple, there's some handling for probe deferral in there which is the only slightly complex thing I noticed.
Re: [RFC 2/7] domainsctrl: Introduce domains controller framework
Quoted 11 lines · Mark Brown
Quoted 2 lines · Benjamin Gaignard
Configurations could be applied with functions like
domainsctrl_set_config_by_index()ordomainsctrl_set_config_by_name().Do you have any clients in the works for this? It seems fairly likely that everything is fine in terms of setting the mode but it'd be good to confirm that's the case. The main thing I can think of that might be a problem here is how you'd handle a case where we were talking to another processor that owns the permissions, we'd probably want more ways to query state there but I'm thinking there'd likely be some other higher level way to talk to the other processor there so perhaps it's moot.
Patch 3 use those functions to apply the default configuration before probing a driver (or after unbind it). I have in mind that drivers could ask to apply a configuration like it is done for pinctrl in resume/suspend functions. An example of that could be to start the hardware block on the main processor and, when going to sleep, change the configuration to grant the access to lower power processor.
I think that talking to a remote processor is another problem already addressed remoteproc or secure monitor calls. Domains controllers drivers should be created for those cases.
Quoted 4 lines
Otherwise this all looks pretty clean and simple, there's some handling for probe deferral in there which is the only slightly complex thing I noticed.
Re: [RFC 2/7] domainsctrl: Introduce domains controller framework
Quoted 9 lines · Benjamin GAIGNARD
Quoted 5 lines · Mark Brown
On Mon, Jan 14, 2019 at 03:41:57PM +0100, Benjamin Gaignard wrote:
Do you have any clients in the works for this? It seems fairly likely that everything is fine in terms of setting the mode but it'd be good to confirm that's the case. The main thing I can think of that might be a
Patch 3 use those functions to apply the default configuration before probing a driver (or after unbind it). I have in mind that drivers could ask to apply
Right, I saw that but I was more thinking of individual drivers.
Quoted 4 lines
a configuration like it is done for pinctrl in resume/suspend functions. An example of that could be to start the hardware block on the main processor and, when going to sleep, change the configuration to grant the access to lower power processor.
Yes, that sounds like a good application. I can also imagine something like handing some hardware over to an acceleration engine (or a smaller microcontroller core acting as one).
RFC 3/7 base: Add calls to domains controller
In reply to Benjamin GaignardTo avoid modifying all the drivers call domainsctrl_set_default_config before probe to apply the configuration define in device node (if any).
When unbinding the device try to apply configuration named "unbind".
--- drivers/base/dd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/base/dd.c +9 -0
@@ -20,6 +20,7 @@#include <linux/device.h> #include <linux/delay.h> #include <linux/dma-mapping.h> +#include <linux/domainsctrl.h> #include <linux/init.h> #include <linux/module.h> #include <linux/kthread.h>
@@ -478,6 +479,10 @@ static int really_probe(struct device *dev, struct device_driver *drv) re_probe: dev->driver = drv; + ret =domainsctrl_set_default_config (dev); +if (ret) + goto domainctrl_failed; +/* If using pinctrl, bind pins now before probing */ ret =pinctrl_bind_pins (dev);if (ret)
@@ -548,6 +553,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_DRIVER_NOT_BOUND , dev); pinctrl_bind_failed: +domainsctrl_set_config_by_name (dev,"unbind" ); +domainctrl_failed:device_links_no_driver (dev);devres_release_all (dev);driver_sysfs_remove (dev);
@@ -970,6 +977,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)device_links_driver_cleanup (dev);arch_teardown_dma_ops (dev); +domainsctrl_set_config_by_name (dev,"unbind" ); +devres_release_all (dev); dev->driver =NULL ;dev_set_drvdata (dev,NULL );
Signature · 1 line
2.15.0
RFC 4/7 devicetree: bindings: domainsctrl: Add STM32 ETZPC bindings
In reply to Benjamin GaignardDescribe STM32 Extended TrustZone Protection bindings.
--- .../devicetree/bindings/bus/domains/st,stm32-etzpc.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt
Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt new file +14 -0
@@ -0,0 +1,14 @@ +STMicroelectronics STM32 Extended TrustZone Protection driver + +Required properties: + - compatible : must be "st,stm32-etzpc" + - reg : physical base address of the IP registers and length of memory + mapped region. + - #domainctrl-cells : must be 2 + +Example: + etzpc@5c007000 { + compatible = "st,stm32-etzpc"; + reg = <0x5c007000 0x400>; + #domainctrl-cells = <2>; + };
Signature · 1 line
2.15.0
RFC 5/7 bus: domainsctrl: Add driver for STM32 ETZPC controller
In reply to Benjamin GaignardSTM32 Extended TrustZone Protection Controller (ETZPC) got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor.
Each hardware block status is defined by a 2 bits field and all of them are packed into 32 bits registers. ETZPC can manage up to 94 hardware blocks.
--- drivers/bus/domains/Kconfig | 7 ++ drivers/bus/domains/Makefile | 1 + drivers/bus/domains/stm32-etzpc.c | 140 ++++++++++++++++++++++++++ include/dt-bindings/bus/domains/stm32-etzpc.h | 25 +++++ 4 files changed, 173 insertions(+) create mode 100644 drivers/bus/domains/stm32-etzpc.c create mode 100644 include/dt-bindings/bus/domains/stm32-etzpc.h
drivers/bus/domains/Kconfig +7 -0
@@ -4,4 +4,11 @@ config DOMAINS_CONTROLLERS bool "Support of bus domains controllers" depends on OF +config STM32_ETZPC + bool "STM32 ETZPC Domain Controller" + depends on DOMAINS_CONTROLLERS && MACH_STM32MP157 + help + Select y to enable STM32 Extended TrustZone Protection + Controller (ETZPC) + endmenu
drivers/bus/domains/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_DOMAINS_CONTROLLERS) += domainsctrl.o +obj-$(CONFIG_STM32_ETZPC) += stm32-etzpc.o
drivers/bus/domains/stm32-etzpc.c new file +140 -0
140 lines not on this page · raw message
include/dt-bindings/bus/domains/stm32-etzpc.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) STMicroelectronics 2018 - All Rights Reserved +* Author: Benjamin Gaignard <[email protected]> for STMicroelectronics. +*/ + +#ifndef _STM32_ETZPC_H_ +#define _STM32_ETZPC_H_ + +/* ETZPC domains: secure, non-secure or coprocessor*/ +#define STM32_ETZPC_SECURE 1 +#define STM32_ETPCZ_COPRO 2 +#define STM32_ETZPC_NON_SECURE 3 + +/* ETZPC hard blaokcs index */ +#define STM32_ETZPC_USART1 3 +#define STM32_ETZPC_SPI6 4 +#define STM32_ETZPC_I2C4 5 +#define STM32_ETZPC_RNG1 7 +#define STM32_ETZPC_HASH1 8 +#define STM32_ETZPC_CRYP1 9 +#define STM32_ETZPC_I2C6 12 +#define STM32_ETZPC_CEC 38 + +#endif /* _STM32_ETZPC_H_ */
Signature · 1 line
2.15.0
RFC 6/7 ARM: dts: stm32: Add domainsctrl node for stm32mp157 SoC
In reply to Benjamin GaignardDeclare ETZPC device as a domains controller node for stm32mp157 SoC
--- arch/arm/boot/dts/stm32mp157c.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/stm32mp157c.dtsi +7 -0
@@ -1106,6 +1106,13 @@ status = "disabled"; }; + etzpc: etzpc@5c007000 { + compatible = "st,stm32-etzpc"; + reg = <0x5c007000 0x400>; + #domainctrl-cells = <2>; + status = "okay"; + }; + i2c6: i2c@5c009000 { compatible = "st,stm32f7-i2c"; reg = <0x5c009000 0x400>;
Signature · 1 line
2.15.0
RFC 7/7 ARM: dts: stm32: enable domains controller node on stm32mp157c-ed1
In reply to Benjamin GaignardEnable ETZPC and set configuration for CEC node
--- arch/arm/boot/dts/stm32mp157c-ev1.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/stm32mp157c-ev1.dts +2 -0
@@ -6,6 +6,7 @@ /dts-v1/; #include "stm32mp157c-ed1.dts" +#include <dt-bindings/bus/domains/stm32-etzpc.h> #include <dt-bindings/gpio/gpio.h> / {
@@ -32,6 +33,7 @@ &cec { pinctrl-names = "default"; pinctrl-0 = <&cec_pins_a>; + domainctrl-0 = <&etzpc STM32_ETZPC_CEC STM32_ETZPC_NON_SECURE>; status = "okay"; };
Signature · 1 line
2.15.0
Rob Herring
maintainerQuoted 6 lines · Benjamin Gaignard
The goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.
Bus domains controllers are typically used to control if a hardware block can perform read or write operations on bus.
Lots of things are domains. Power domains, clock domains, etc. But naming is hard.
We now have the inter-connect binding which ATM only deals with bandwidth. Any reason we can't add access controls to that?
Quoted 14 lines
Smarter domains controllers could be able to define accesses rights per hardware blocks to control where they can read or write.
Domains controller configurations are provided in device node, parsed by the framework and send to the driver to apply them. Each controller may need different number and type of inputs to configure a domain so device-tree properties size have to be define by using "#domainctrl-cells".
Domains configurations properties have to be named "domainsctrl-X" on device node.
"domainsctrl-names" keyword can also be used to give a name to a specific configuration.
Quoted 7 lines
An example of bus domains controller is STM32 ETZPC hardware block which got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor.
We already have a way to assign secure vs. non-secure with 'status'. Ignoring co-processors for a minute, why does that not work for you?
Co-processors are so varied in terms of capabilities and view of the system, I'm not sure we can define something generic.
Quoted 4 lines
Up to 94 hardware blocks of the soc could be managed by ETZPC and assigned to one of the three domains.
It is an RFC, comments are welcome to help to create this framework, thanks.
Finally, for a new, common binding, I'd like to see more than one platform using it (or at least an intent to use it).
Rob
Quoted 9 lines · Rob Herring
Quoted 5 lines · Benjamin Gaignard
The goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.
Bus domains controllers are typically used to control if a hardware block can perform read or write operations on bus.
Lots of things are domains. Power domains, clock domains, etc. But naming is hard.
I use 'domains' because it regroup hardware sharing the same access rights. It is maybe not the best word.
Quoted 3 lines
We now have the inter-connect binding which ATM only deals with bandwidth. Any reason we can't add access controls to that?
Because the targeted hardware block isn't the inter-connect but something that is acting as a firewall on the bus to control the accesses rights on hardware blocks.
'bus firewall' could have been a name for this framework but, for me, it sound like something related to networking and that is not the case... I could go in 'firewall' direction: driver will become 'bus firewall controller' and apply 'firewall configurations' to grant/revoke accesses rights. Does that sound better for you ?
Quoted 22 lines
Quoted 15 lines
Smarter domains controllers could be able to define accesses rights per hardware blocks to control where they can read or write.
Domains controller configurations are provided in device node, parsed by the framework and send to the driver to apply them. Each controller may need different number and type of inputs to configure a domain so device-tree properties size have to be define by using "#domainctrl-cells".
Domains configurations properties have to be named "domainsctrl-X" on device node.
"domainsctrl-names" keyword can also be used to give a name to a specific configuration.Quoted 7 lines
An example of bus domains controller is STM32 ETZPC hardware block which got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor.
Quoted 2 lines
We already have a way to assign secure vs. non-secure with 'status'. Ignoring co-processors for a minute, why does that not work for you?
I aim to be able to dynamically change the configuration (like for pinctrl) so status is not enough. It is true that stm32 etzpc is limited to control the split between main and remote processors but other controllers could have another granularity.
Quoted 3 lines
Co-processors are so varied in terms of capabilities and view of the system, I'm not sure we can define something generic.
It isn't not about define co-precessors capabilities but about define a new API for hardware blocks controlling accesses on the bus.
Quoted 7 lines
Quoted 5 lines
Up to 94 hardware blocks of the soc could be managed by ETZPC and assigned to one of the three domains.
It is an RFC, comments are welcome to help to create this framework, thanks.
Finally, for a new, common binding, I'd like to see more than one platform using it (or at least an intent to use it).
I kwon at least two other hardware block who can take benefits of this:
- ARM TCZ 400: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0504c/index.html
which is able to manage up to 8 regoins in address space.
- IMX Ressource Domain Controller (RDC): supports four domains and up to eight regions
I hope that others will show up when reading this thread.
Benjamin
Quoted 2 lines
Rob