aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu/arm-smmu.c
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2016-04-04 11:49:22 -0400
committerRob Herring <robh@kernel.org>2016-04-19 18:25:15 -0400
commitcb6c27bb09122ceb0effda0b15885123870a6af7 (patch)
treebb993a2b468374aeab3950c747ec7c195aa2c0e1 /drivers/iommu/arm-smmu.c
parentabdaa77b18480361f3565d958a2acffad268c39c (diff)
iommu/arm-smmu: Make use of phandle iterators in device-tree parsing
Remove the usage of of_parse_phandle_with_args() and replace it by the phandle-iterator implementation so that we can parse out all of the potentially present 128 stream-ids. Signed-off-by: Joerg Roedel <jroedel@suse.de> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/iommu/arm-smmu.c')
-rw-r--r--drivers/iommu/arm-smmu.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 2409e3bd3df2..a1c965cdcfad 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -49,7 +49,7 @@
49#include "io-pgtable.h" 49#include "io-pgtable.h"
50 50
51/* Maximum number of stream IDs assigned to a single device */ 51/* Maximum number of stream IDs assigned to a single device */
52#define MAX_MASTER_STREAMIDS MAX_PHANDLE_ARGS 52#define MAX_MASTER_STREAMIDS 128
53 53
54/* Maximum number of context banks per SMMU */ 54/* Maximum number of context banks per SMMU */
55#define ARM_SMMU_MAX_CBS 128 55#define ARM_SMMU_MAX_CBS 128
@@ -357,6 +357,12 @@ struct arm_smmu_domain {
357 struct iommu_domain domain; 357 struct iommu_domain domain;
358}; 358};
359 359
360struct arm_smmu_phandle_args {
361 struct device_node *np;
362 int args_count;
363 uint32_t args[MAX_MASTER_STREAMIDS];
364};
365
360static struct iommu_ops arm_smmu_ops; 366static struct iommu_ops arm_smmu_ops;
361 367
362static DEFINE_SPINLOCK(arm_smmu_devices_lock); 368static DEFINE_SPINLOCK(arm_smmu_devices_lock);
@@ -466,7 +472,7 @@ static int insert_smmu_master(struct arm_smmu_device *smmu,
466 472
467static int register_smmu_master(struct arm_smmu_device *smmu, 473static int register_smmu_master(struct arm_smmu_device *smmu,
468 struct device *dev, 474 struct device *dev,
469 struct of_phandle_args *masterspec) 475 struct arm_smmu_phandle_args *masterspec)
470{ 476{
471 int i; 477 int i;
472 struct arm_smmu_master *master; 478 struct arm_smmu_master *master;
@@ -1737,7 +1743,8 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
1737 struct arm_smmu_device *smmu; 1743 struct arm_smmu_device *smmu;
1738 struct device *dev = &pdev->dev; 1744 struct device *dev = &pdev->dev;
1739 struct rb_node *node; 1745 struct rb_node *node;
1740 struct of_phandle_args masterspec; 1746 struct of_phandle_iterator it;
1747 struct arm_smmu_phandle_args *masterspec;
1741 int num_irqs, i, err; 1748 int num_irqs, i, err;
1742 1749
1743 smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL); 1750 smmu = devm_kzalloc(dev, sizeof(*smmu), GFP_KERNEL);
@@ -1798,20 +1805,35 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
1798 1805
1799 i = 0; 1806 i = 0;
1800 smmu->masters = RB_ROOT; 1807 smmu->masters = RB_ROOT;
1801 while (!of_parse_phandle_with_args(dev->of_node, "mmu-masters", 1808
1802 "#stream-id-cells", i, 1809 err = -ENOMEM;
1803 &masterspec)) { 1810 /* No need to zero the memory for masterspec */
1804 err = register_smmu_master(smmu, dev, &masterspec); 1811 masterspec = kmalloc(sizeof(*masterspec), GFP_KERNEL);
1812 if (!masterspec)
1813 goto out_put_masters;
1814
1815 of_for_each_phandle(&it, err, dev->of_node,
1816 "mmu-masters", "#stream-id-cells", 0) {
1817 int count = of_phandle_iterator_args(&it, masterspec->args,
1818 MAX_MASTER_STREAMIDS);
1819 masterspec->np = of_node_get(it.node);
1820 masterspec->args_count = count;
1821
1822 err = register_smmu_master(smmu, dev, masterspec);
1805 if (err) { 1823 if (err) {
1806 dev_err(dev, "failed to add master %s\n", 1824 dev_err(dev, "failed to add master %s\n",
1807 masterspec.np->name); 1825 masterspec->np->name);
1826 kfree(masterspec);
1808 goto out_put_masters; 1827 goto out_put_masters;
1809 } 1828 }
1810 1829
1811 i++; 1830 i++;
1812 } 1831 }
1832
1813 dev_notice(dev, "registered %d master devices\n", i); 1833 dev_notice(dev, "registered %d master devices\n", i);
1814 1834
1835 kfree(masterspec);
1836
1815 parse_driver_options(smmu); 1837 parse_driver_options(smmu);
1816 1838
1817 if (smmu->version > ARM_SMMU_V1 && 1839 if (smmu->version > ARM_SMMU_V1 &&