shared config registers and locking
Benjamin Herrenschmidt
benh at kernel.crashing.org
Thu Dec 7 09:57:45 EST 2006
On Wed, 2006-12-06 at 22:57 +0100, Roger Larsson wrote:
> On Wednesday 06 December 2006 06:10, Benjamin Herrenschmidt wrote:
> >
> > On UP configuration, there is no real problem: local_irq_disable/enable
> > around the code tweaking those bits (read/modify/write) is enough and
> > everybody is happy. That's what the current emac code does.
> >
> > However, on SMP, we need spinlocking (or a semaphore, but for simple
> > register accesses like that, spinlocks are probably better).
> >
> It is actually simple.
>
> You should use
> spin_lock_irq_save()
Thanks you very much for telling me about spinlocks ... I wonder how I
did all these years ... :-)
Now, more seriously, of course the thing will boil down to a spinlock.
My point was what do you guys think about having one shared spinlock
exposed by the powerpc platform code for use by all those little bits
here or there that whack global configuration registers like clock
control things, etc... that we have all over the place on embedded
processors.
Since I don't like exposing a naked data structure though, rather than
exposing the spinlock itself, I was proposing to expose an API of two
functions (just in case we want to do something fancy) though they could
well end up being inline and thus boil down to the same...
Ben.
More information about the Linuxppc-embedded
mailing list