iommu/arm-smmu: Add support for adding masters/clocks using generic bindings
Subsystems (4)
cover iommu/arm-smmu: Add support for adding masters/clocks using generic bindings
This series adds support for xlate callback to add master devices configs using generic bindings and clocks/regulators required to access smmu.
OF_IOMMU_DECLARE is used to register and probe the smmu controller devices before the masters are added in of_platform_populate. Here, we are registering only the smmu driver and iommu_ops. The smmu device registration is not done in OF_IOMMU_DECLARE to avoid early smmu probe, because the clocks if any required for the controller are not yet ready.
So the idea here is to get the right direction in adding this support.
Mitchel Humpherys (2):
iommu/arm-smmu: add support for specifying clocks iommu/arm-smmu: Add support for specifying regulators
Sricharan R (2):
iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE iommu/arm-smmu: Add xlate callback for initializing master devices
from dt
.../devicetree/bindings/iommu/arm,smmu.txt | 14 ++ drivers/iommu/arm-smmu.c | 210 +++++++++++++++++++-- 2 files changed, 208 insertions(+), 16 deletions(-)
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
RFC PATCH 1/4 iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE
This patch uses IOMMU_OF_DECLARE to register the driver and the iommu_ops. So when master devices of the iommu are registered, of_xlate callback can be used to add the master configurations to the smmu driver.
--- drivers/iommu/arm-smmu.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
drivers/iommu/arm-smmu.c +23 -13
@@ -41,6 +41,8 @@#include <linux/platform_device.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/of_iommu.h> +#include <linux/of_platform.h> #include <linux/amba/bus.h>
@@ -254,6 +256,8 @@#define FSYNR0_WNR (1 << 4)static int force_stage; +static bool init_done; +module_param_named (force_stage, force_stage, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (force_stage,"Force SMMU mappings to be installed@a particular stage of translation. A value of '1' or '2' forces the corresponding stage. All other values are ignored (i.e. no stage is forced). Note that selecting a specific stage will disable support for nested translation." );
@@ -1848,20 +1852,8 @@ static struct platform_driver arm_smmu_driver = {static int __init arm_smmu_init (void ) { -struct device_node *np;int ret; -/* -* Play nice with systems that don't have an ARM SMMU by checking that -* an ARM SMMU exists in the system before proceeding with the driver -* and IOMMU bus operation registration. -*/ - np =of_find_matching_node (NULL , arm_smmu_of_match); -if (!np) -return 0 ; - -of_node_put (np); - ret =platform_driver_register (&arm_smmu_driver);if (ret)return ret;
@@ -1880,15 +1872,33 @@ static int __init arm_smmu_init(void)bus_set_iommu (&pci_bus_type, &arm_smmu_ops);#endif + init_done = true; +return 0 ; } +static int __init arm_smmu_of_setup (struct device_node *np) +{ + +if (!init_done) +arm_smmu_init (); + +of_iommu_set_ops (np, &arm_smmu_ops); + +return 0 ; +} + +IOMMU_OF_DECLARE (arm_smmu_v1,"arm,smmu-v1" , arm_smmu_of_setup); +IOMMU_OF_DECLARE (arm_smmu_v2,"arm,smmu-v2" , arm_smmu_of_setup); +IOMMU_OF_DECLARE (arm_smmu_400,"arm,mmu-400" , arm_smmu_of_setup); +IOMMU_OF_DECLARE (arm_smmu_401,"arm,mmu-401" , arm_smmu_of_setup); +IOMMU_OF_DECLARE (arm_smmu_500,"arm,mmu-500" , arm_smmu_of_setup); + static void __exit arm_smmu_exit(void) {return platform_driver_unregister (&arm_smmu_driver); } -subsys_initcall (arm_smmu_init);module_exit (arm_smmu_exit);MODULE_DESCRIPTION ("IOMMU API for ARM architected SMMU implementations" );
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
RFC PATCH 1/4 iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE
[adding Robin]
Quoted 4 lines · Sricharan R
This patch uses
IOMMU_OF_DECLAREto register the driver and theiommu_ops. So when master devices of the iommu are registered,of_xlatecallback can be used to add the master configurations to the smmu driver.
I'd really prefer to do this on top of Laurent's series reworking some of the of_xlate code and I think Robin [CC'd] is working on that. That will also pave the way for specifying per-master SMR configuration in the device-tree.
Will
RFC PATCH 1/4 iommu/arm-smmu: Init driver using IOMMU_OF_DECLARE
Hi Will,
Quoted 5 lines
-----Original Message-----
From: Will Deacon [mailto:will.deacon at arm.com]
Sent: Tuesday, July 21, 2015 8:33 PM
To: Sricharan R
Cc: linux-arm-kernel at lists.infradead.org;
iommu at lists.linux-foundation.org;
Quoted 7 lines
devicetree at vger.kernel.org; linux-arm-msm at vger.kernel.org; mitchelh at codeaurora.org; robin.murphy at arm.com
Subject: Re: [RFC PATCH 1/4] iommu/arm-smmu: Init driver usingIOMMU_OF_DECLARE[adding Robin]
Quoted 7 lines
Quoted 4 lines · Sricharan R
This patch uses
IOMMU_OF_DECLAREto register the driver and theiommu_ops. So when master devices of the iommu are registered,of_xlatecallback can be used to add the master configurations to the smmu driver.I'd really prefer to do this on top of Laurent's series reworking some of
the
Quoted 1 line
of_xlatecode and I think Robin [CC'd] is working on that. That will also
pave
Quoted 1 line
the way for specifying per-master SMR configuration in the device-tree.
Ok, understand it. By Rebasing on Laurent's series this patch should
not
be needed at all, dependencies with clock devices should also be
solved.
I will rebase this series over there.
Regards,
Sricharan
RFC PATCH 2/4 iommu/arm-smmu: Add xlate callback for initializing master devices from dt
In reply to Sricharan RThis adds of_xlate callback to arm-smmu driver. xlate callback is called during device registration from DT for those master devices attached to iommus using generic iommu bindings.
--- drivers/iommu/arm-smmu.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/iommu/arm-smmu.c +36 -0
@@ -321,6 +321,7 @@ struct arm_smmu_device {unsigned int *irqs;struct list_head list; +struct device_node *node;struct rb_root masters; };
@@ -1434,6 +1435,38 @@ out_unlock:return ret; } +static int arm_smmu_of_xlate (struct device *dev, +struct of_phandle_args *spec) +{ +struct arm_smmu_device *smmu; +struct arm_smmu_master *master; +int streamid; + +spin_lock (&arm_smmu_devices_lock); +list_for_each_entry (smmu, &arm_smmu_devices, list) { +if (smmu->node == spec->np) +break ; + } +spin_unlock (&arm_smmu_devices_lock); + +if (!smmu || (smmu->node != spec->np)) +return -ENODEV ; + + spec->np = dev->of_node; + + master =find_smmu_master (smmu, spec->np); +if (!master) { +if (register_smmu_master (smmu, smmu->dev, spec)) +return -ENODEV ; + }else { + streamid = master->cfg.num_streamids; + master->cfg.streamids[streamid] = spec->args[0 ]; + master->cfg.num_streamids++; + } + +return 0 ; +} +static struct iommu_ops arm_smmu_ops = { .capable = arm_smmu_capable, .domain_init = arm_smmu_domain_init,
@@ -1449,6 +1482,7 @@ static struct iommu_ops arm_smmu_ops = { .domain_get_attr = arm_smmu_domain_get_attr, .domain_set_attr = arm_smmu_domain_set_attr, .pgsize_bitmap = -1UL, /* Restricted during device attach */ + .of_xlate = arm_smmu_of_xlate, };static void arm_smmu_device_reset (struct arm_smmu_device *smmu)
@@ -1782,6 +1816,8 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) } } + smmu->node = dev->of_node; +INIT_LIST_HEAD (&smmu->list);spin_lock (&arm_smmu_devices_lock);list_add (&smmu->list, &arm_smmu_devices);
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
RFC PATCH 3/4 iommu/arm-smmu: Add support for specifying clocks
In reply to Sricharan RFrom: Mitchel Humpherys <[email protected]>
On some platforms with tight power constraints it is polite to only leave your clocks on for as long as you absolutely need them. Currently we assume that all clocks necessary for SMMU register access are always on.
Add some optional device tree properties to specify any clocks that are necessary for SMMU register access and turn them on and off as needed.
If no clocks are specified in the device tree things continue to work the way they always have: we assume all necessary clocks are always turned on. The clocks are turned 'on' during the SMMU device probe and remains 'on' till the device exists.
--- .../devicetree/bindings/iommu/arm,smmu.txt | 11 +++ drivers/iommu/arm-smmu.c | 86 +++++++++++++++++++++- 2 files changed, 94 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/iommu/arm,smmu.txt +11 -0
@@ -49,6 +49,17 @@ conditions. aliases of secure registers have to be used during SMMU configuration. +- clocks : List of clocks to be used during SMMU register access. See + Documentation/devicetree/bindings/clock/clock-bindings.txt + for information about the format. For each clock specified + here, there must be a corresponding entery in clock-names + (see below). + +- clock-names : List of clock names corresponding to the clocks specified in + the "clocks" property (above). See + Documentation/devicetree/bindings/clock/clock-bindings.txt + for more info. + Example: smmu {
drivers/iommu/arm-smmu.c +83 -3
136 lines not on this page · raw message
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
RFC PATCH 3/4 iommu/arm-smmu: Add support for specifying clocks
Quoted 6 lines · Sricharan R
From: Mitchel Humpherys <[email protected]>
On some platforms with tight power constraints it is polite to only leave your clocks on for as long as you absolutely need them. Currently we assume that all clocks necessary for SMMU register access are always on.
You've borrowed this commit message from Mitch's previous version of this patch, but now you leave the clocks enabled most of the time so it doesn't make much sense anymore.
Anyway, I'm OK with this kind of clock management in the driver, but I think that anything more fine-grained needs to be designed into the IOMMU core.
Will
RFC PATCH 3/4 iommu/arm-smmu: Add support for specifying clocks
Hi Will,
Quoted 6 lines
-----Original Message-----
From: linux-arm-msm-owner at vger.kernel.org [mailto:linux-arm-msm- owner at vger.kernel.org] On Behalf Of Will Deacon
Sent: Tuesday, July 21, 2015 8:31 PM
To: Sricharan R
Cc: linux-arm-kernel at lists.infradead.org;
iommu at lists.linux-foundation.org;
Quoted 8 lines
devicetree at vger.kernel.org; linux-arm-msm at vger.kernel.org; mitchelh at codeaurora.org
Subject: Re: [RFC PATCH 3/4] iommu/arm-smmu: Add support for specifying clocksQuoted 2 lines · Sricharan R
From: Mitchel Humpherys <[email protected]>
Quoted 9 lines
Quoted 4 lines
On some platforms with tight power constraints it is polite to only leave your clocks on for as long as you absolutely need them. Currently we assume that all clocks necessary for SMMU register access are always on.
You've borrowed this commit message from Mitch's previous version of this patch, but now you leave the clocks enabled most of the time so it doesn't make much sense anymore.
Sorry, I should have changed that to make it clear.
Quoted 1 line
Anyway, I'm OK with this kind of clock management in the driver, but I
think
Quoted 2 lines
that anything more fine-grained needs to be designed into the IOMMU core.
Ok. Tried this to get the right direction.
I will check for the power savings and if there are not much then I would
use
the above approach.
Regards,
Sricharan
RFC PATCH 4/4 iommu/arm-smmu: Add support for specifying regulators
In reply to Sricharan RFrom: Mitchel Humpherys <[email protected]>
This adds the support to turn on the regulators required for SMMUs. It is turned on during the SMMU probe and remains 'on' till the device exists.
--- .../devicetree/bindings/iommu/arm,smmu.txt | 3 ++ drivers/iommu/arm-smmu.c | 48 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/iommu/arm,smmu.txt +3 -0
@@ -60,6 +60,9 @@ conditions. Documentation/devicetree/bindings/clock/clock-bindings.txt for more info. +- vdd-supply : Phandle of the regulator that should be powered on during + SMMU register access. + Example: smmu {
drivers/iommu/arm-smmu.c +47 -1
88 lines not on this page · raw message
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
RFC PATCH 4/4 iommu/arm-smmu: Add support for specifying regulators
Quoted 5 lines · Sricharan R
From: Mitchel Humpherys <[email protected]>
This adds the support to turn on the regulators required for SMMUs. It is turned on during the SMMU probe and remains 'on' till the device exists.
The device always exists. Until the driver is removed perhaps?
Quoted 2 lines
Signed-off-by Sricharan R <[email protected]>
We won't be using regulators. We'll be using power domains instead so please rewrite this patch accordingly.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
RFC PATCH 4/4 iommu/arm-smmu: Add support for specifying regulators
Hi Stephen,
Quoted 11 lines
-----Original Message-----
From: linux-arm-kernel [mailto:linux-arm-kernel-
bounces at lists.infradead.org] On Behalf Of Stephen Boyd
Sent: Tuesday, July 21, 2015 11:48 PM
To: Sricharan R
Cc: devicetree at vger.kernel.org; linux-arm-msm at vger.kernel.org; will.deacon at arm.com; iommu at lists.linux-foundation.org; mitchelh at codeaurora.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [RFC PATCH 4/4] iommu/arm-smmu: Add support for specifying regulators
Quoted 9 lines
Quoted 5 lines · Sricharan R
From: Mitchel Humpherys <[email protected]>
This adds the support to turn on the regulators required for SMMUs. It is turned on during the SMMU probe and remains 'on' till the device exists.
The device always exists. Until the driver is removed perhaps?
Till the device exists.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Sricharan R <[email protected]>We won't be using regulators. We'll be using power domains instead so please rewrite this patch accordingly.
Ok. Thanks for the direction.
Regards,
Sricharan