* [RFC -tip] x86,apic: set cpu_has_apic manually for discrete apic
@ 2009-08-16 19:57 Cyrill Gorcunov
2009-08-19 16:15 ` Cyrill Gorcunov
0 siblings, 1 reply; 2+ messages in thread
From: Cyrill Gorcunov @ 2009-08-16 19:57 UTC (permalink / raw)
To: Ingo Molnar; +Cc: H. Peter Anvin, Thomas Gleixner, Maciej W. Rozycki, LKML
In case of discrete apic (due to hardware or firmware reason)
cpuid may not retrieve cpu_has_apic bit. But we rely on this
bit in SMP compiled kernels. So instead of long condition checking
we set cpu_has_apic bit manually and check it only in further
code flow.
Note that the case is applied to x86-32 pretty old machines only.
Also verify_local_APIC is the only place where such a trick
could be done. We can't do it earlier since there could be
a BIOS bug and other checks which we are to pass to ensure
that APIC is functional.
The patch also make lapic_shutdown, disable_IO_APIC callable
which should take place even on discrete apics.
As a side effect it makes lapic sysfs device available
for such machines so lets check for apic being integrated
since we don't support suspend/resume for disrete apics.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
Please review carefully. I've tested it with manually disabled
cpu_has_apic and apic was set to "discrete" state as well
under qemu.
Actually this "two-line" patch could be more dangerous
then it looks like and need more wide range _long_ testing.
Or, perhaps, we could just fix lapic_shutdown and disable_IO_APIC
instead since old machines already that rare to find out.
Anyway if someone has 486DX machine please give the patch a try.
arch/x86/kernel/apic/apic.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
Index: linux-2.6.git/arch/x86/kernel/apic/apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/apic.c
@@ -1004,6 +1004,25 @@ int __init verify_local_APIC(void)
unsigned int reg0, reg1;
/*
+ * For discrete APIC cpu_has_apic bit may not
+ * be retrieved via cpuid instruction. Same time
+ * we rely on this bit (mostly for SMP compiled
+ * kernel) and instead of checking the long condition
+ * (as shown below) all the time we may check for
+ * plain cpu_has_apic further in code.
+ *
+ * At this moment all the checks are passed and we've
+ * already complained if there was a BIOS bug.
+ * This place is safe for such a trick. --cvg
+ */
+#ifdef CONFIG_X86_32
+ if (smp_found_config && !cpu_has_apic && !disable_apic) {
+ set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
+ pr_info("APIC: cpu_has_apic being set manually\n");
+ }
+#endif
+
+ /*
* The version register is read-only in a real APIC.
*/
reg0 = apic_read(APIC_LVR);
@@ -2145,7 +2164,7 @@ static int __init init_lapic_sysfs(void)
{
int error;
- if (!cpu_has_apic)
+ if (!cpu_has_apic || !lapic_is_integrated())
return 0;
/* XXX: remove suspend/resume procs if !apic_pm_state.active? */
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC -tip] x86,apic: set cpu_has_apic manually for discrete apic
2009-08-16 19:57 [RFC -tip] x86,apic: set cpu_has_apic manually for discrete apic Cyrill Gorcunov
@ 2009-08-19 16:15 ` Cyrill Gorcunov
0 siblings, 0 replies; 2+ messages in thread
From: Cyrill Gorcunov @ 2009-08-19 16:15 UTC (permalink / raw)
To: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Maciej W. Rozycki,
LKML
[Cyrill Gorcunov - Sun, Aug 16, 2009 at 11:57:36PM +0400]
|
| In case of discrete apic (due to hardware or firmware reason)
| cpuid may not retrieve cpu_has_apic bit. But we rely on this
| bit in SMP compiled kernels. So instead of long condition checking
| we set cpu_has_apic bit manually and check it only in further
| code flow.
|
| Note that the case is applied to x86-32 pretty old machines only.
| Also verify_local_APIC is the only place where such a trick
| could be done. We can't do it earlier since there could be
| a BIOS bug and other checks which we are to pass to ensure
| that APIC is functional.
|
| The patch also make lapic_shutdown, disable_IO_APIC callable
| which should take place even on discrete apics.
|
| As a side effect it makes lapic sysfs device available
| for such machines so lets check for apic being integrated
| since we don't support suspend/resume for disrete apics.
|
| Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
| ---
Please drop this RFC now as to eliminate side effects
a number of quirks (MCE,MSI) would be needed. I didn't trigger
problems because not all interrupt types were covered
with qemu. The simpliest (and more safe) approach will
be just to fix lapic_shutdown and disable_IO_APIC for
discrete apic case. Will cook a patch.
-- Cyrill
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-19 16:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-16 19:57 [RFC -tip] x86,apic: set cpu_has_apic manually for discrete apic Cyrill Gorcunov
2009-08-19 16:15 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox