System resource management
Subsystems (3)
v2 cover System resource management
This RFC follows discussions in OpenAMP meeting around a resource manager for the remote processor.
Here is a patchset that implements a system resource management. By 'system resource' we speak about resource that is requested to operate a peripheral, used by a remote processor.
Note: 'shared resource' may be a more appropriate term than 'system resource'. These 'system resources' can introduce potential contention if they are not controlled by a master core.
The system resource manager configures and enables the following identified 'system resources':
- Clocks
- GPIOs
- Regulators
- Interrupts
Theses 'system resources' are declared in devicetree sub-nodes of the resource manager. A subnode corresponds to one peripheral used by the remote processor. For each peripheral a generic driver can be probed to handle the 'system resource'. Developers can also define their own driver for more complexe use cases.
In this second patchset the configuration of the 'system resources' is not only static : it can be updated during runtime ('dynamic' resource management). The implementation of this part relies on an an RPMSG service and offers the remote processor the ability to get and set the following configurations:
- Clock enable / disable
- Clock rate
- Regulator enable / disable
- Regulator voltage (min/max, current)
- Pin state configuration
The proposed implementation allows to extend the list of 'system resources' and configurations.
Notes:
1- This patchset depends on the "remoteproc: updates for new events" patchset
submitted by Alex Elder [https://lkml.org/lkml/2018/6/25/1081]
2- This proposed implementation deals with 'system resources', not with
peripheral: hence it does not propose to assign a peripheral from one core to another core during runtime.
3- See also TI proposed solution:
[http://git.omapzoom.org/?p=repo/sysbios-rpmsg.git;a=summary]
v2 changes :
- Add interrupts as a 'system resource'
- Add RPMSG-based 'dynamic' resource management
Fabien Dessenne (5):
dt-bindings: remoteproc: add system resource manager (SRM)
remoteproc: add system resource manager core
remoteproc: add system resource manager device
remoteproc: probe the system resource manager
remoteproc: srm: introduce dynamic resource manager
.../devicetree/bindings/remoteproc/rproc-srm.txt | 54 ++ Documentation/remoteproc.txt | 23 + drivers/remoteproc/Kconfig | 18 + drivers/remoteproc/Makefile | 2 + drivers/remoteproc/remoteproc_core.c | 8 + drivers/remoteproc/rproc_srm_core.c | 295 +++++++ drivers/remoteproc/rproc_srm_core.h | 113 +++ drivers/remoteproc/rproc_srm_dev.c | 890 +++++++++++++++++++++ 8 files changed, 1403 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/rproc-srm.txt create mode 100644 drivers/remoteproc/rproc_srm_core.c create mode 100644 drivers/remoteproc/rproc_srm_core.h create mode 100644 drivers/remoteproc/rproc_srm_dev.c
Signature · 1 line
2.7.4
RFC v2 1/5 dt-bindings: remoteproc: add system resource manager (SRM)
Add Documentation of devicetree bindings to support the remote processor system resource manager.
--- .../devicetree/bindings/remoteproc/rproc-srm.txt | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/rproc-srm.txt
Documentation/devicetree/bindings/remoteproc/rproc-srm.txt new file +54 -0
@@ -0,0 +1,54 @@ +Remoteproc System Resource Manager +---------------------------------- + +The remoteproc SRM (System Resource Manager) handles resources allocated +to remote processors. +This makes it possible for remote proc to reserve and initialize system +resources for a peripheral assigned to a coprocessor. + +The devices are grouped in a core node + +Core +==== +Required properties: +- compatible: should be "rproc-srm-core" + +Dev +=== +Required properties: +- compatible: should be "rproc-srm-dev" + +Optional properties: +- clocks: clocks required by the coprocessor +- clock-names: see clock-bindings.txt +- assigned-clocks: see clock-bindings.txt +- assigned-clock-parents: see clock-bindings.txt +- assigned-clock-rates: see clock-bindings.txt +- pinctrl-x: pins configurations required by the coprocessor +- pinctrl-names: see pinctrl-bindings.txt +- x-supply: power supplies required by the coprocessor +- interrupts: see interrupts.txt +- interrupt-parent: see interrupts.txt +- interrupt-names: see interrupts.txt + +Example: + system_resources { + compatible = "rproc-srm-core"; + + mmc0: sdhci@09060000 { + compatible = "rproc-srm-dev"; + pinctrl-names = "default", "idle"; + pinctrl-0 = <&pinctrl_mmc0>; + pinctrl-1 = <&pinctrl_mmc1>; + clock-names = "mmc", "icn"; + clocks = <&clk_s_c0_flexgen CLK_MMC_0>, + <&clk_s_c0_flexgen CLK_RX_ICN_HVA>; + vdda-supply = <&vdda>; + }; + button { + compatible = "rproc-srm-dev"; + interrupt-parent = <&gpioa>; + interrupts = <5 1>; + interrupt-names = "gpio_key"; + }; + };
Signature · 1 line
2.7.4
RFC v2 2/5 remoteproc: add system resource manager core
In reply to Fabien DessenneThe remoteproc SRM (System Resource Manager) handles resources allocated to remote processors.
This makes it possible for remote proc to reserve and initialize system resources for a peripheral assigned to a coprocessor.
This is the core part which is in charge of controlling the device children.
--- Documentation/remoteproc.txt | 23 ++++ drivers/remoteproc/Kconfig | 8 ++ drivers/remoteproc/Makefile | 1 + drivers/remoteproc/rproc_srm_core.c | 205 ++++++++++++++++++++++++++++++++++++ 4 files changed, 237 insertions(+) create mode 100644 drivers/remoteproc/rproc_srm_core.c
Documentation/remoteproc.txt +23 -0
@@ -353,3 +353,26 @@ Of course, RSC_VDEV resource entries are only good enough for static allocation of virtio devices. Dynamic allocations will also be made possible using the rpmsg bus (similar to how we already do dynamic allocations of rpmsg channels; read more about it in rpmsg.txt). + +8. System Resource Manager (SRM) + +Since some resources are shared (directly or not) between the processors, a +processor cannot manage such resources without potentially impacting the other +processors : as an example, if a processor changes the frequency of a clock, the +frequency of another clock managed by another processor may be updated too. + +The System Resource Manager prevents such resource conflicts between the +processors : it reserves and initializes the system resources of the peripherals +assigned to a remote processor. + +As of today the following resources are controlled by the SRM: +- clocks +- gpios (pinctrl) +- regulators (power supplies) + +The SRM is implemented as an 'rproc_subdev' and registered to remoteproc_core. +Unlike the virtio device (vdev), the SRM subdev is probed *before* the rproc +boots, ensuring the availability of the resources before the remoteproc starts. + +The resources handled by the SRM are defined in the DeviceTree: please read +Documentation/devicetree/bindings/remoteproc/rproc-srm.txt for details.
drivers/remoteproc/Kconfig +8 -0
@@ -13,6 +13,14 @@ config REMOTEPROC if REMOTEPROC +config REMOTEPROC_SRM_CORE + tristate "Remoteproc System Resource Manager core" + help + Say y here to enable the core driver of the remoteproc System Resource + Manager (SRM). + The SRM handles resources allocated to remote processors. + The core part is in charge of controlling the device children. + config IMX_REMOTEPROC tristate "IMX6/7 remoteproc support" depends on SOC_IMX6SX || SOC_IMX7D
drivers/remoteproc/Makefile +1 -0
@@ -9,6 +9,7 @@ remoteproc-y += remoteproc_debugfs.o remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o +obj-$(CONFIG_REMOTEPROC_SRM_CORE) += rproc_srm_core.o obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o
drivers/remoteproc/rproc_srm_core.c new file +205 -0
205 lines not on this page · raw message
Signature · 1 line
2.7.4
RFC v2 3/5 remoteproc: add system resource manager device
In reply to Fabien DessenneThe SRM device reserves and enables the resources needed by a remote processor.
In this initial commit the only managed resources are:
- clocks which are prepared and enabled
- pins which are configured
- regulators which are enabled
- interrupts which are prepared
--- drivers/remoteproc/Kconfig | 10 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/rproc_srm_dev.c | 570 +++++++++++++++++++++++++++++++++++++ 3 files changed, 581 insertions(+) create mode 100644 drivers/remoteproc/rproc_srm_dev.c
drivers/remoteproc/Kconfig +10 -0
@@ -21,6 +21,16 @@ config REMOTEPROC_SRM_CORE The SRM handles resources allocated to remote processors. The core part is in charge of controlling the device children. +config REMOTEPROC_SRM_DEV + tristate "Remoteproc System Resource Manager device" + depends on REMOTEPROC_SRM_CORE + help + Say y here to enable the device driver of the remoteproc System + Resource Manager (SRM). + The SRM handles resources allocated to remote processors. + The device part is in charge of reserving and initializing resources + for a peripheral assigned to a coprocessor. + config IMX_REMOTEPROC tristate "IMX6/7 remoteproc support" depends on SOC_IMX6SX || SOC_IMX7D
drivers/remoteproc/Makefile +1 -0
@@ -10,6 +10,7 @@ remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o obj-$(CONFIG_REMOTEPROC_SRM_CORE) += rproc_srm_core.o +obj-$(CONFIG_REMOTEPROC_SRM_DEV) += rproc_srm_dev.o obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o
drivers/remoteproc/rproc_srm_dev.c new file +570 -0
570 lines not on this page · raw message
Signature · 1 line
2.7.4
RFC v2 4/5 remoteproc: probe the system resource manager
In reply to Fabien DessenneWhen a remote processor registers, populate the device tree to probe the SRM core driver
--- drivers/remoteproc/remoteproc_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/remoteproc/remoteproc_core.c +8 -0
@@ -41,6 +41,7 @@#include <linux/crc32.h> #include <linux/virtio_ids.h> #include <linux/virtio_ring.h> +#include <linux/of_platform.h> #include <asm/byteorder.h> #include "remoteproc_internal.h"
@@ -1485,6 +1486,11 @@ int rproc_add(struct rproc *rproc)return ret; } +/* add resource manager device */ + ret =devm_of_platform_populate (dev->parent); +if (ret <0 ) +return ret; +/* expose to rproc_get_by_phandle users */ mutex_lock (&rproc_list_mutex);list_add (&rproc->node, &rproc_list);
@@ -1705,6 +1711,8 @@ int rproc_del(struct rproc *rproc)list_del (&rproc->node);mutex_unlock (&rproc_list_mutex); +of_platform_depopulate (rproc->dev.parent); +device_del (&rproc->dev);return 0 ;
Signature · 1 line
2.7.4
RFC v2 5/5 remoteproc: srm: introduce dynamic resource manager
In reply to Fabien DessenneThe dynamic resource manager allows the remote processor to configure the system resources that were statically allocated and setup before the processor was started.
It relies on an rpmsg link and offers the remote processor the ability to get and set the following configurations:
- Clock enable / disable
- Clock rate
- Regulator enable / disable
- Regulator voltage (min/max, current)
- Pin state configuration
The proposed implementation allows to extend the list of resources and configurations.
--- drivers/remoteproc/rproc_srm_core.c | 124 +++++++-- drivers/remoteproc/rproc_srm_core.h | 113 ++++++++ drivers/remoteproc/rproc_srm_dev.c | 518 +++++++++++++++++++++++++++++------- 3 files changed, 639 insertions(+), 116 deletions(-) create mode 100644 drivers/remoteproc/rproc_srm_core.h
drivers/remoteproc/rproc_srm_core.c +107 -17
@@ -1,20 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* -* Copyright (C) 2017, STMicroelectronics - All Rights Reserved -* Author: Fabien Dessenne <[email protected]>. -* -* License type: GPLv2 -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License version 2 as published by -* the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -* or FITNESS FOR A PARTICULAR PURPOSE. -* See the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License along with -* this program. If not, see <http://www.gnu.org/licenses/>. +* Copyright (C) STMicroelectronics 2018 - All Rights Reserved +* Author: Fabien Dessenne <[email protected]> for STMicroelectronics. */ #include <linux/component.h>
@@ -22,6 +9,9 @@#include <linux/module.h> #include <linux/of_platform.h> #include <linux/remoteproc.h> +#include <linux/rpmsg.h> + +#include "rproc_srm_core.h" #define BIND_TIMEOUT 10000
@@ -31,10 +21,98 @@ struct rproc_srm_core {int bind_status;atomic_t prepared;struct rproc_subdev subdev; +struct rpmsg_driver rpdrv; +struct blocking_notifier_head notifier; };#define to_rproc_srm_core (s) container_of(s, struct rproc_srm_core, subdev) +static struct rproc_srm_core *rpmsg_srm_to_core (struct rpmsg_device *rpdev) +{ +struct rpmsg_driver *rpdrv; +struct rproc_srm_core *core; + + rpdrv = container_of(rpdev->dev.driver, struct rpmsg_driver, drv); + core = container_of(rpdrv, struct rproc_srm_core, rpdrv); + +return core; +} + +int rpmsg_srm_send (struct rpmsg_endpoint *ept,struct rpmsg_srm_msg *msg) +{ +int ret; + + ret =rpmsg_send (ept, (void *)msg,sizeof (*msg)); +if (ret) +dev_err (&ept->rpdev->dev,"rpmsg_send failed: %d\n" , ret); + +return ret; +} +EXPORT_SYMBOL (rpmsg_srm_send); + +static int rpmsg_srm_cb (struct rpmsg_device *rpdev,void *data,int len, +void *priv,u32 src) +{ +struct rproc_srm_core *core =rpmsg_srm_to_core (rpdev); +struct rpmsg_srm_msg_desc desc; +int ret; + + desc.ept = rpdev->ept; + desc.msg = data; + + ret =blocking_notifier_call_chain (&core->notifier,0 , &desc); + +if (!(ret &NOTIFY_STOP_MASK )) { +dev_warn (&rpdev->dev,"unknown device\n" ); + desc.msg->message_type =RPROC_SRM_MSG_ERROR ; +rpmsg_srm_send (desc.ept, desc.msg); + } + +return 0 ; +} + +static int rpmsg_srm_probe (struct rpmsg_device *rpdev) +{ +/* Note : the probe ops is mandatory */ +dev_dbg (&rpdev->dev,"%s\n" , __func__); + +return 0 ; +} + +static void rpmsg_srm_remove (struct rpmsg_device *rpdev) +{ +/* Note : the remove ops is mandatory */ +dev_dbg (&rpdev->dev,"%s\n" , __func__); +} + +static struct rpmsg_device_id rpmsg_srm_id_table[] = { + { .name ="rproc-srm" }, + { }, +}; +MODULE_DEVICE_TABLE (rpmsg, rpmsg_srm_id_table); + +static struct rpmsg_driver rpmsg_srm_drv = { + .drv.name ="rpmsg_srm" , + .id_table = rpmsg_srm_id_table, + .probe = rpmsg_srm_probe, + .callback = rpmsg_srm_cb, + .remove = rpmsg_srm_remove, +}; + +int rproc_srm_core_register_notifier (struct rproc_srm_core *core, +struct notifier_block *nb) +{ +return blocking_notifier_chain_register (&core->notifier, nb); +} +EXPORT_SYMBOL (rproc_srm_core_register_notifier); + +int rproc_srm_core_unregister_notifier (struct rproc_srm_core *core, +struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister (&core->notifier, nb); +} +EXPORT_SYMBOL (rproc_srm_core_unregister_notifier); +static int compare_of (struct device *dev,void *data) {return dev->of_node == data;
@@ -115,6 +193,15 @@ static int rproc_srm_core_prepare(struct rproc_subdev *subdev)dev_err (dev,"failed to bind\n" ); goto master; } + +/* Register rpmsg driver for dynamic management */ + rproc_srm_core->rpdrv = rpmsg_srm_drv; + ret =register_rpmsg_driver (&rproc_srm_core->rpdrv); +if (ret) { +dev_err (dev,"failed to register rpmsg drv\n" ); + goto master; + } + done:atomic_inc (&rproc_srm_core->prepared);
@@ -127,7 +214,7 @@ static int rproc_srm_core_prepare(struct rproc_subdev *subdev)return ret; } -static void rproc_srm_core_do_unprepare (struct rproc_subdev *subdev) +static void rproc_srm_core_unprepare (struct rproc_subdev *subdev) {struct rproc_srm_core *rproc_srm_core =to_rproc_srm_core (subdev);struct device *dev = rproc_srm_core->dev;
@@ -136,6 +223,8 @@ static void rproc_srm_core_do_unprepare(struct rproc_subdev *subdev)atomic_dec (&rproc_srm_core->prepared); +unregister_rpmsg_driver (&rproc_srm_core->rpdrv); +component_master_del (dev, &srm_comp_ops);devm_of_platform_depopulate (dev); }
@@ -154,6 +243,7 @@ static int rproc_srm_core_probe(struct platform_device *pdev)return -ENOMEM ; rproc_srm_core->dev = dev; +BLOCKING_INIT_NOTIFIER_HEAD (&rproc_srm_core->notifier);/* Register rproc subdevice with (un)prepare ops */ rproc_srm_core->subdev.prepare = rproc_srm_core_prepare;
drivers/remoteproc/rproc_srm_core.h new file +113 -0
113 lines not on this page · raw message
drivers/remoteproc/rproc_srm_dev.c +419 -99
808 lines not on this page · raw message
Signature · 1 line
2.7.4