Skip to content

Commit 1f442d7

Browse files
Yinghai LuIngo Molnar
authored andcommitted
x86: remove smp_apply_quirks()/smp_checks()
Impact: cleanup and code size reduction on 64-bit This code is only applied to Intel Pentium and AMD K7 32-bit cpus. Move those checks to intel_init()/amd_init() for 32-bit so 64-bit will not build this code. Also change to use cpu_index check to see if we need to emit warning. Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <49B377D2.8030108@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 31bbed5 commit 1f442d7

3 files changed

Lines changed: 77 additions & 78 deletions

File tree

‎arch/x86/kernel/cpu/amd.c‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <asm/io.h>
66
#include <asm/processor.h>
77
#include <asm/apic.h>
8+
#include <asm/cpu.h>
89

910
#ifdef CONFIG_X86_64
1011
# include <asm/numa_64.h>
@@ -141,6 +142,55 @@ static void __cpuinit init_amd_k6(struct cpuinfo_x86 *c)
141142
}
142143
}
143144

145+
static void __cpuinit amd_k7_smp_check(struct cpuinfo_x86 *c)
146+
{
147+
#ifdef CONFIG_SMP
148+
/* calling is from identify_secondary_cpu() ? */
149+
if (c->cpu_index == boot_cpu_id)
150+
return;
151+
152+
/*
153+
* Certain Athlons might work (for various values of 'work') in SMP
154+
* but they are not certified as MP capable.
155+
*/
156+
/* Athlon 660/661 is valid. */
157+
if ((c->x86_model == 6) && ((c->x86_mask == 0) ||
158+
(c->x86_mask == 1)))
159+
goto valid_k7;
160+
161+
/* Duron 670 is valid */
162+
if ((c->x86_model == 7) && (c->x86_mask == 0))
163+
goto valid_k7;
164+
165+
/*
166+
* Athlon 662, Duron 671, and Athlon >model 7 have capability
167+
* bit. It's worth noting that the A5 stepping (662) of some
168+
* Athlon XP's have the MP bit set.
169+
* See http://www.heise.de/newsticker/data/jow-18.10.01-000 for
170+
* more.
171+
*/
172+
if (((c->x86_model == 6) && (c->x86_mask >= 2)) ||
173+
((c->x86_model == 7) && (c->x86_mask >= 1)) ||
174+
(c->x86_model > 7))
175+
if (cpu_has_mp)
176+
goto valid_k7;
177+
178+
/* If we get here, not a certified SMP capable AMD system. */
179+
180+
/*
181+
* Don't taint if we are running SMP kernel on a single non-MP
182+
* approved Athlon
183+
*/
184+
WARN_ONCE(1, "WARNING: This combination of AMD"
185+
"processors is not suitable for SMP.\n");
186+
if (!test_taint(TAINT_UNSAFE_SMP))
187+
add_taint(TAINT_UNSAFE_SMP);
188+
189+
valid_k7:
190+
;
191+
#endif
192+
}
193+
144194
static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
145195
{
146196
u32 l, h;
@@ -175,6 +225,8 @@ static void __cpuinit init_amd_k7(struct cpuinfo_x86 *c)
175225
}
176226

177227
set_cpu_cap(c, X86_FEATURE_K7);
228+
229+
amd_k7_smp_check(c);
178230
}
179231
#endif
180232

‎arch/x86/kernel/cpu/intel.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/uaccess.h>
1414
#include <asm/ds.h>
1515
#include <asm/bugs.h>
16+
#include <asm/cpu.h>
1617

1718
#ifdef CONFIG_X86_64
1819
#include <asm/topology.h>
@@ -110,6 +111,28 @@ static void __cpuinit trap_init_f00f_bug(void)
110111
}
111112
#endif
112113

114+
static void __cpuinit intel_smp_check(struct cpuinfo_x86 *c)
115+
{
116+
#ifdef CONFIG_SMP
117+
/* calling is from identify_secondary_cpu() ? */
118+
if (c->cpu_index == boot_cpu_id)
119+
return;
120+
121+
/*
122+
* Mask B, Pentium, but not Pentium MMX
123+
*/
124+
if (c->x86 == 5 &&
125+
c->x86_mask >= 1 && c->x86_mask <= 4 &&
126+
c->x86_model <= 3) {
127+
/*
128+
* Remember we have B step Pentia with bugs
129+
*/
130+
WARN_ONCE(1, "WARNING: SMP operation may be unreliable"
131+
"with B stepping processors.\n");
132+
}
133+
#endif
134+
}
135+
113136
static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
114137
{
115138
unsigned long lo, hi;
@@ -186,6 +209,8 @@ static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)
186209
#ifdef CONFIG_X86_NUMAQ
187210
numaq_tsc_disable();
188211
#endif
212+
213+
intel_smp_check(c);
189214
}
190215
#else
191216
static void __cpuinit intel_workarounds(struct cpuinfo_x86 *c)

‎arch/x86/kernel/smpboot.c‎

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
114114

115115
atomic_t init_deasserted;
116116

117-
118-
/* Set if we find a B stepping CPU */
119-
static int __cpuinitdata smp_b_stepping;
120-
121117
#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
122118

123119
/* which logical CPUs are on which nodes */
@@ -271,8 +267,6 @@ static void __cpuinit smp_callin(void)
271267
cpumask_set_cpu(cpuid, cpu_callin_mask);
272268
}
273269

274-
static int __cpuinitdata unsafe_smp;
275-
276270
/*
277271
* Activate a secondary processor.
278272
*/
@@ -340,76 +334,6 @@ notrace static void __cpuinit start_secondary(void *unused)
340334
cpu_idle();
341335
}
342336

343-
static void __cpuinit smp_apply_quirks(struct cpuinfo_x86 *c)
344-
{
345-
/*
346-
* Mask B, Pentium, but not Pentium MMX
347-
*/
348-
if (c->x86_vendor == X86_VENDOR_INTEL &&
349-
c->x86 == 5 &&
350-
c->x86_mask >= 1 && c->x86_mask <= 4 &&
351-
c->x86_model <= 3)
352-
/*
353-
* Remember we have B step Pentia with bugs
354-
*/
355-
smp_b_stepping = 1;
356-
357-
/*
358-
* Certain Athlons might work (for various values of 'work') in SMP
359-
* but they are not certified as MP capable.
360-
*/
361-
if ((c->x86_vendor == X86_VENDOR_AMD) && (c->x86 == 6)) {
362-
363-
if (num_possible_cpus() == 1)
364-
goto valid_k7;
365-
366-
/* Athlon 660/661 is valid. */
367-
if ((c->x86_model == 6) && ((c->x86_mask == 0) ||
368-
(c->x86_mask == 1)))
369-
goto valid_k7;
370-
371-
/* Duron 670 is valid */
372-
if ((c->x86_model == 7) && (c->x86_mask == 0))
373-
goto valid_k7;
374-
375-
/*
376-
* Athlon 662, Duron 671, and Athlon >model 7 have capability
377-
* bit. It's worth noting that the A5 stepping (662) of some
378-
* Athlon XP's have the MP bit set.
379-
* See http://www.heise.de/newsticker/data/jow-18.10.01-000 for
380-
* more.
381-
*/
382-
if (((c->x86_model == 6) && (c->x86_mask >= 2)) ||
383-
((c->x86_model == 7) && (c->x86_mask >= 1)) ||
384-
(c->x86_model > 7))
385-
if (cpu_has_mp)
386-
goto valid_k7;
387-
388-
/* If we get here, not a certified SMP capable AMD system. */
389-
unsafe_smp = 1;
390-
}
391-
392-
valid_k7:
393-
;
394-
}
395-
396-
static void __cpuinit smp_checks(void)
397-
{
398-
if (smp_b_stepping)
399-
printk(KERN_WARNING "WARNING: SMP operation may be unreliable"
400-
"with B stepping processors.\n");
401-
402-
/*
403-
* Don't taint if we are running SMP kernel on a single non-MP
404-
* approved Athlon
405-
*/
406-
if (unsafe_smp && num_online_cpus() > 1) {
407-
printk(KERN_INFO "WARNING: This combination of AMD"
408-
"processors is not suitable for SMP.\n");
409-
add_taint(TAINT_UNSAFE_SMP);
410-
}
411-
}
412-
413337
/*
414338
* The bootstrap kernel entry code has set these up. Save them for
415339
* a given CPU
@@ -423,7 +347,6 @@ void __cpuinit smp_store_cpu_info(int id)
423347
c->cpu_index = id;
424348
if (id != 0)
425349
identify_secondary_cpu(c);
426-
smp_apply_quirks(c);
427350
}
428351

429352

@@ -1193,7 +1116,6 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
11931116
pr_debug("Boot done.\n");
11941117

11951118
impress_friends();
1196-
smp_checks();
11971119
#ifdef CONFIG_X86_IO_APIC
11981120
setup_ioapic_dest();
11991121
#endif

0 commit comments

Comments
 (0)