linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linu Cherian <linu.cherian@cavium.com>
To: Robert Richter <robert.richter@cavium.com>
Cc: Geetha sowjanya <gakula@caviumnetworks.com>,
	will.deacon@arm.com, robin.murphy@arm.com,
	lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org,
	sudeep.holla@arm.com, iommu@lists.linux-foundation.org,
	jcm@redhat.com, linux-kernel@vger.kernel.org,
	catalin.marinas@arm.com, sgoutham@cavium.com,
	linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
	geethasowjanya.akula@gmail.com, Charles.Garcia-Tobin@arm.com,
	Geetha Sowjanya <geethasowjanya.akula@cavium.com>
Subject: Re: [PATCH v3 2/7] iommu/arm-smmu-v3: Do resource size checks based on SMMU
Date: Mon, 8 May 2017 15:14:37 +0530	[thread overview]
Message-ID: <20170508094437.GA26538@virtx40> (raw)
In-Reply-To: <20170505221844.GW16981@rric.localdomain>

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@cavium.com>
> > 
> > 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@cavium.com>
> > Signed-off-by:  Geetha Sowjanya <geethasowjanya.akula@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 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. 


-- 
Linu cherian

  reply	other threads:[~2017-05-08  9:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05 12:08 [PATCH v3 0/7] Cavium ThunderX2 SMMUv3 errata workarounds Geetha sowjanya
2017-05-05 12:08 ` [PATCH v3 1/7] iommu/arm-smmu-v3: Introduce SMMU option PAGE0_REGS_ONLY for ThunderX2 errata #74 Geetha sowjanya
2017-05-05 22:26   ` Robert Richter
2017-05-05 23:03   ` Robert Richter
2017-05-08  9:17     ` Linu Cherian
2017-05-08  9:29       ` Robert Richter
2017-05-08  9:59       ` Robin Murphy
2017-05-08 10:04         ` Robert Richter
2017-05-05 12:08 ` [PATCH v3 2/7] iommu/arm-smmu-v3: Do resource size checks based on SMMU Geetha sowjanya
2017-05-05 22:18   ` Robert Richter
2017-05-08  9:44     ` Linu Cherian [this message]
2017-05-08 10:09       ` Robert Richter
2017-05-08 10:50         ` Linu Cherian
2017-05-08 12:21           ` Robert Richter
2017-05-08 11:03         ` Geetha Akula
2017-05-05 12:08 ` [PATCH v3 3/7] ACPICA: IORT: Add Cavium ThunderX2 SMMUv3 model definition Geetha sowjanya
2017-05-05 13:53   ` Hanjun Guo
2017-05-05 14:56     ` David Daney
2017-05-05 14:58       ` Will Deacon
2017-05-05 15:33         ` Jon Masters
2017-05-05 12:08 ` [PATCH v3 4/7] iommu/arm-smmu-v3: For ACPI based device probing, set PAGE0_REGS_ONLY option for ThunderX2 SMMUv3 implementation Geetha sowjanya
2017-05-05 12:08 ` [PATCH v3 5/7] ACPI/IORT: Fixup SMMUv3 resource size for Cavium ThunderX2 SMMUv3 model Geetha sowjanya
2017-05-05 22:19   ` Robert Richter
2017-05-05 12:08 ` [PATCH v3 6/7] iommu/arm-smmu-v3: Add workaround for Cavium ThunderX2 erratum #126 Geetha sowjanya
2017-05-08 11:21   ` Robin Murphy
2017-05-08 12:02     ` Geetha Akula
2017-05-05 12:08 ` [PATCH v3 7/7] arm64: Documentation: Add Cavium ThunderX2 SMMUv3 erratas Geetha sowjanya
2017-05-05 22:22 ` [PATCH v3 0/7] Cavium ThunderX2 SMMUv3 errata workarounds Robert Richter
2017-05-08 15:15   ` Linu Cherian
2017-05-09 16:07     ` Robert Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170508094437.GA26538@virtx40 \
    --to=linu.cherian@cavium.com \
    --cc=Charles.Garcia-Tobin@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=gakula@caviumnetworks.com \
    --cc=geethasowjanya.akula@cavium.com \
    --cc=geethasowjanya.akula@gmail.com \
    --cc=hanjun.guo@linaro.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jcm@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=robert.richter@cavium.com \
    --cc=robin.murphy@arm.com \
    --cc=sgoutham@cavium.com \
    --cc=sudeep.holla@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).