82xx CPM commands
Rune Torgersen
runet at innovsys.com
Wed Jun 7 08:13:35 EST 2006
Hi.
Besause of some weird system hangs we have seen, I am wondering if the
CPM command register may need a lock around it.
In one of our drivers we can end up writing a CPM command every
millisecond on worst case during an error condition.
Sometimes during that error condition the whole CPU locks up. (or rather
it spins in an interrupt somewhere).
After looking at all the other places in the kernel the CPM command
register gets written, I am convinced that there does exists conditions
where we might accidentally write to the command register while some
other thread/irq is writing/waiting for command completion.
The code in all paces looks like:
cp->cp_cpcr = mk_cr_cmd(SOME COMMAND);
while (cp->cp_cpcr & CPM_CR_FLG);
I think we might need a lock around it.
local_irq_save() woild work, but would lock the whole CPU while the CPM
command completes (which can take 200 CPM clock cycles, avg 40 according
to maual)
Easiest way would probaby be to have a (inline) function that does the
lock/write/wait/unlock.
There is a couple of places that does a udelay between the write and the
wait.
More information about the Linuxppc-embedded
mailing list