[PATCH 09/13] SPEAr: clk: Add Auxiliary Synthesizer clock

Arnd Bergmann arnd at arndb.de
Tue Apr 17 16:30:24 EDT 2012


On Tuesday 17 April 2012, Sascha Hauer wrote:
> > +{
> > +     struct clk_aux *aux = to_clk_aux(hw);
> > +     unsigned int num = 1, den = 1, val, eqn;
> > +     unsigned long flags = 0;
> > +
> > +     if (aux->lock)
> > +             spin_lock_irqsave(aux->lock, flags);
> > +
> > +     val = readl_relaxed(aux->reg);
> > +
> > +     if (aux->lock)
> > +             spin_unlock_irqrestore(aux->lock, flags);
> > +
> 
> A single read is atomic and needs no lock.

That depends on whether the read has any side-effects. There
is another function that does a read-modify-write on the
same register, and you might need to prevent this one from
reading the register between the other read and the following
write.

The spinlock also has the benefit of enforcing the ordering
of the read with regard to your instruction stream, otherwise
it can be delayed on out-of-order CPUs until the value
is actually used.

	Arnd



More information about the linux-arm-kernel mailing list