[PATCH] powerpc/fsl-booke: Work around erratum A-006958
David Laight
David.Laight at ACULAB.COM
Mon Jul 15 18:45:36 EST 2013
> +#define MFTB(dest, scratch1, scratch2) \
> +90: mftbu scratch1; \
> + mftbl dest; \
> + mftbu scratch2; \
> + cmpw scratch1,scratch2; \
> + bne 90b; \
> + rldimi dest,scratch1,32,0;
Are the three mftbu/l instructions guaranteed to be executed
in order?
Also, if the high word changes, there is no need to loop.
Just return the second value with a low word of zero
(the returned count happened while the function was active).
If the mftbx instructions are synchronizing ones (or need
sequencing), then it might be possible to only have 2 of them
by reading the 64bit value and the high 32bits.
(The correct order depends on the exact definition of the errata!)
Another option is that the 64bit value returned by mftb is
(presumably) only likely to be wrong when the low 32bits is
very near zero (either side).
A second mftb could be done in this case only with some logic
to work out a valid result (I think):
High changed - 2nd high, low zero.
First low -ve - first value.
First low +ve - second value.
David
More information about the Linuxppc-dev
mailing list