Stephen Warren <[email protected]> wrote @ Mon, 4 Feb 2013 21:35:45 +0100:

> >> This loop is purely for checking offset to be valid. And this loop is
> >> repeated in the smmu_write() function. I queued a patch on-top to make
> >> this more clear. Please double-check:
> > 
> > Actually I did the similar thing in the first version of this patch(*1)
> > 
> > +static inline void smmu_check_reg_range(size_t offs)
> > +{
> > +   int i;
> > +
> > +   for (i = 0; i < smmu->nregs; i++) {
> > +       BUG_ON(offs < smmu->regs[i] - smmu->regbase);
> > +                   if (offs <= smmu->rege[i] - smmu->regbase)
> > +                            break;
> > +    }
> > +}
> > 
> > *1:
> > http://lists.linuxfoundation.org/pipermail/iommu/2013-January/005072.html
> > 
> > Then, Stehpen pointed out about this check function(*2).
> > 
> > "... here, you'd be doing the loop every access anyway, so you may as
> > well not calculate regbase at all, move the body of
> > smmu_check_reg_range() into smmu_read()/smmu_write(), and do the access
> > inside the if statement inside the loop, with the per-range mapping."
> 
> Upon reflection, that comment probably isn't correct, since the only way
> to know where each register range begins, relative to the register
> numbers that the driver uses, is to calculate reg_base. So, I think you
> do need reg_base, and Joerg's latest patch seems reasonable.

Ok, now it's clear. Joerg, please get yours merged on the top of this.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to