On Mon, May 8, 2017 at 3:39 PM, Robert Richter <robert.richter@xxxxxxxxxx> wrote: > On 08.05.17 15:14:37, Linu Cherian wrote: >> On Sat May 06, 2017 at 12:18:44AM +0200, Robert Richter wrote: >> > On 05.05.17 17:38:06, Geetha sowjanya wrote: >> > > From: Linu Cherian <linu.cherian@xxxxxxxxxx> >> > > >> > > With implementations supporting only page 0 register space, >> > > resource size can be 64k as well and hence perform size checks >> > > based on SMMU option PAGE0_REGS_ONLY. >> > > >> > > 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@xxxxxxxxxx> >> > > Signed-off-by: Geetha Sowjanya <geethasowjanya.akula@xxxxxxxxxx> >> > > --- >> > > 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 107b4a6..f027676 100644 >> > > --- a/drivers/iommu/arm-smmu-v3.c >> > > +++ b/drivers/iommu/arm-smmu-v3.c >> > > @@ -2672,6 +2672,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; >> > > +} >> > > + >> > >> > I think this can be dropped. See below. >> > >> > > static int arm_smmu_device_probe(struct platform_device *pdev) >> > > { >> > > int irq, ret; >> > > @@ -2688,9 +2696,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; >> > > } >> > >> > Why not just do the follwoing here: >> > >> > /* Base address */ >> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> > if (resource_size(res) + 1 < arm_smmu_resource_size(smmu)) { >> > dev_err(dev, "MMIO region too small (%pr)\n", res); >> > return -EINVAL; >> > } >> > ioaddr = res->start; >> > >> > + /* >> > + * Override the size, for Cavium ThunderX2 implementation >> > + * which doesn't support the page 1 SMMU register space. >> > + */ >> > + if (smmu->options & ARM_SMMU_OPT_PAGE0_REGS_ONLY) >> > + res->end = res->size + SZ_64K -1; >> > + >> > smmu->base = devm_ioremap_resource(dev, res); >> > if (IS_ERR(smmu->base)) >> > return PTR_ERR(smmu->base); >> >> >> This might not work, since platform_device_add is being called from >> iort.c before the res->end gets fixed up here. > > It should. You added it with 128k and you get it back with > platform_get_resource(), but before ioremap you shrink the size to > 64k. > > -Robert Hi Robert, Linu is right. You are missing the sequence of event. If we skip the changes in iort file, smmu initialization in acpi fails. [ 3.721647] ACPI: IORT: iort_add_smmu_platform_device [ 3.726826] platform arm-smmu-v3.1.auto: failed to claim resource 0: [mem 0x402310000-0x40232ffff] [ 3.736052] arm-smmu-v3 arm-smmu-v3.0.auto: option mask 0x1 [ 3.741753] arm_smmu_device_probe Thank you, Geetha. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html