Message ID | 1491921765-29475-3-git-send-email-linucherian@gmail.com (mailing list archive) |
---|---|
State | RFC, archived |
Headers | show |
On 11/04/17 15:42, linucherian@gmail.com wrote: > From: Linu Cherian <linu.cherian@cavium.com> > > With implementations supporting only page 0 of register space, > resource size can be 64k as well and hence perform size checks > based on smmu option PAGE0_REGS_ONLY. What harm comes of mapping page 1 if we don't access it? Robin. > For this, arm_smmu_device_dt_probe/acpi_probe has been moved before > platform_get_resource call, so that smmu options are set beforehand. > > Signed-off-by: Linu Cherian <linu.cherian@cavium.com> > --- > drivers/iommu/arm-smmu-v3.c | 26 +++++++++++++++++--------- > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c > index df9f27b..b326195 100644 > --- a/drivers/iommu/arm-smmu-v3.c > +++ b/drivers/iommu/arm-smmu-v3.c > @@ -2669,6 +2669,14 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, > return ret; > } > > +static unsigned long arm_smmu_resource_size(struct arm_smmu_device *smmu) > +{ > + if (ARM_SMMU_PAGE0_REGS_ONLY(smmu)) > + return SZ_64K; > + else > + return SZ_128K; > +} > + > static int arm_smmu_device_probe(struct platform_device *pdev) > { > int irq, ret; > @@ -2685,9 +2693,17 @@ static int arm_smmu_device_probe(struct platform_device *pdev) > } > smmu->dev = dev; > > + if (dev->of_node) { > + ret = arm_smmu_device_dt_probe(pdev, smmu); > + } else { > + ret = arm_smmu_device_acpi_probe(pdev, smmu); > + if (ret == -ENODEV) > + return ret; > + } > + > /* Base address */ > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - if (resource_size(res) + 1 < SZ_128K) { > + if (resource_size(res) + 1 < arm_smmu_resource_size(smmu)) { > dev_err(dev, "MMIO region too small (%pr)\n", res); > return -EINVAL; > } > @@ -2714,14 +2730,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) > if (irq > 0) > smmu->gerr_irq = irq; > > - if (dev->of_node) { > - ret = arm_smmu_device_dt_probe(pdev, smmu); > - } else { > - ret = arm_smmu_device_acpi_probe(pdev, smmu); > - if (ret == -ENODEV) > - return ret; > - } > - > /* Set bypass mode according to firmware probing result */ > bypass = !!ret; > > -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Apr 11, 2017 at 9:13 PM, Robin Murphy <robin.murphy@arm.com> wrote: > On 11/04/17 15:42, linucherian@gmail.com wrote: >> From: Linu Cherian <linu.cherian@cavium.com> >> >> With implementations supporting only page 0 of register space, >> resource size can be 64k as well and hence perform size checks >> based on smmu option PAGE0_REGS_ONLY. > > What harm comes of mapping page 1 if we don't access it? > > Robin. > There are multiple SMMUs on the silicon and CSRs of each SMMU are 64K apart. Hence can't map page-1 even though it's not accessed. Thanks, Sunil. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index df9f27b..b326195 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -2669,6 +2669,14 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, return ret; } +static unsigned long arm_smmu_resource_size(struct arm_smmu_device *smmu) +{ + if (ARM_SMMU_PAGE0_REGS_ONLY(smmu)) + return SZ_64K; + else + return SZ_128K; +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -2685,9 +2693,17 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } smmu->dev = dev; + if (dev->of_node) { + ret = arm_smmu_device_dt_probe(pdev, smmu); + } else { + ret = arm_smmu_device_acpi_probe(pdev, smmu); + if (ret == -ENODEV) + return ret; + } + /* Base address */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (resource_size(res) + 1 < SZ_128K) { + if (resource_size(res) + 1 < arm_smmu_resource_size(smmu)) { dev_err(dev, "MMIO region too small (%pr)\n", res); return -EINVAL; } @@ -2714,14 +2730,6 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (irq > 0) smmu->gerr_irq = irq; - if (dev->of_node) { - ret = arm_smmu_device_dt_probe(pdev, smmu); - } else { - ret = arm_smmu_device_acpi_probe(pdev, smmu); - if (ret == -ENODEV) - return ret; - } - /* Set bypass mode according to firmware probing result */ bypass = !!ret;