I was (well, still am) hunting down some memory corruptions inside our kernel, and figured removing as many of possible culprits would be a good idea. Given the different PL310 cache controller errata I figured I might as well disable this guy and see if that helps stability somewhat. Doing that is as easy as disabling
CONFIG_CACHE_L2X0. Even though I obviously wasn't going to play with disabling L1 (after all, if that's where your problems are, you have bigger issues...), once I saw the
CONFIG_CPU_ICACHE_DISABLE/
CONFIG_CPU_DCACHE_DISABLE options I knew I had to try them out. Even if just to see our ARM target crawl.
Of course, after building with that I booted to a hard hang. I tried with just
CONFIG_CPU_ICACHE_DISABLE, which worked (glacially), so it was disabling the d-cache that was hosing me. I wasn't going to let a measly kernel config option defeat me, so there went my Friday night :-)... It took me a while to figure out it was actually hanging inside
printk(). On a
spin_lock. Locking and atomic operations are implemented on Linux with the
LDREX/
STREX instructions on ARMv6 and above. If you look at the description of these instructions, they involve an exclusive monitor, which is part of the
Data Cache Unit (
DCU) for L1, and my L2 is off (not that it would do me any good - PL310 doesn't contain an exclusive monitor). So the
STREX always fails, and the lock appears taken. Of course, spinlocks are only used with SMP, and SMP is only supported in Linux on ARMv6 and above (which added support for
STREX and
LDREX), so since I didn't feel like implementing
raw_spin_lock with the SWP instruction (deprecated on >= ARMv6), disabling SMP was pretty much the obvious choice at 1 AM. After that I needed to enable pre-ARMv6 variants for mutexes, locks, atomic operations, bit operations and
__xchg/
cmpxchg. And now it boots.... Of course my user space, being compiled for ARMv7, expects functional
LDREX/STREX, and so it hangs there...in the
init process.