Thread (13 messages) 13 messages, 4 authors, 2015-03-16

read_cpuid_id() in arch/arm/kernel/setup.c

From: Russell King - ARM Linux <hidden>
Date: 2015-03-13 16:45:46

On Fri, Mar 13, 2015 at 05:39:23PM +0100, Mason wrote:
Good point. I hadn't thought of that.

Do you know the latency of an mrc instruction? (compared to a mov)
Not offhand.  It'll be different for different CPUs, but it's probably
not far off mov.
quoted
It seems that GCC 4.7.4 optimises better than Linaro's 4.9.3.  In fact,
it looks like Linaro's 4.9.3 is rather buggy as far as optimisation
goes.

Later compilers aren't always better.
I did NOT expect that. Compiler optimizations passes are so fragile.
You're learning :)
quoted hunk ↗ jump to hunk
Anyway, here's another proposed nano-improvement ;-)
(This one is code factorization)
--- setup.c	2015-03-03 18:04:59.000000000 +0100
+++ setup.bar.c	2015-03-13 17:29:23.800668429 +0100
@@ -246,12 +246,9 @@
 		if (cpu_arch)
 			cpu_arch += CPU_ARCH_ARMv3;
 	} else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
-		unsigned int mmfr0;
-
 		/* Revised CPUID format. Read the Memory Model Feature
 		 * Register 0 and check for VMSAv7 or PMSAv7 */
-		asm("mrc	p15, 0, %0, c0, c1, 4"
-		    : "=r" (mmfr0));
+		unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0);
 		if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
 		    (mmfr0 & 0x000000f0) >= 0x00000030)
 			cpu_arch = CPU_ARCH_ARMv7;

This one looks good, doesn't it? :-)
Yes, this one I like - and it probably fixes a potential latent bug
where the compiler was free to re-order that mrc outside of the if()
statement.

Please wrap it up as a normal submission, thanks.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help