Subject: [PATCH v2 2/2] iommu/arm-smmu: Do not access non-existing SMR registers

From: [email-masked] (Will Deacon)
Date: Wed, 6 Aug 2014 11:19:48 +0100

Hi Olav,

On Mon, Aug 04, 2014 at 07:01:03PM +0100, Olav Haugan wrote:
> The SMR registers do not exist when stream matching is not
> supported by the hardware. Avoid writing to this register if not needed.
> 
> Signed-off-by: Olav Haugan <[email-masked]>
> ---
>  drivers/iommu/arm-smmu.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index c16431f..1f3a5b3 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -1731,7 +1731,10 @@ static void arm_smmu_device_reset(struct arm_smmu_device *smmu)
>  
>  	/* Mark all SMRn as invalid and all S2CRn as bypass */
>  	for (i = 0; i < smmu->num_mapping_groups; ++i) {
> -		writel_relaxed(~SMR_VALID, gr0_base + ARM_SMMU_GR0_SMR(i));
> +		if (smmu->features & ARM_SMMU_FEAT_STREAM_MATCH) {
> +			writel_relaxed(~SMR_VALID,
> +					gr0_base + ARM_SMMU_GR0_SMR(i));
> +		}
>  		writel_relaxed(S2CR_TYPE_BYPASS,
>  			gr0_base + ARM_SMMU_GR0_S2CR(i));

smmu->num_mapping_groups should be zero for an SMMU that doesn't include
the SMR registers, so I don't think this change is needed. Are you seeing
problems with real hardware?

Will