x86: ivybridge: Remove SMP from CPU_SPECIFIC_OPTIONS
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v3 2/6 x86: ivybridge: Remove SMP from CPU_SPECIFIC_OPTIONS
Ivybridge is not ready for U-Boot MP initialization yet.
---
Changes in v3:
- New patch to remove SMP from CPU_SPECIFIC_OPTIONS for ivybridge
Changes in v2: None
arch/x86/cpu/ivybridge/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/x86/cpu/ivybridge/Kconfig +0 -1
@@ -95,7 +95,6 @@ config CPU_SPECIFIC_OPTIONS select ARCH_BOOTBLOCK_X86_32 select ARCH_ROMSTAGE_X86_32 select ARCH_RAMSTAGE_X86_32 - select SMP select SSE2 select UDELAY_LAPIC select CPU_MICROCODE_IN_CBFS
Signature · 1 line
1.8.2.1
PATCH v3 2/6 x86: ivybridge: Remove SMP from CPU_SPECIFIC_OPTIONS
Quoted 6 lines · Bin Meng
Ivybridge is not ready for U-Boot MP initialization yet.
Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Changes in v3:
- New patch to remove SMP fromCPU_SPECIFIC_OPTIONSfor ivybridgeChanges in v2: None
arch/x86/cpu/ivybridge/Kconfig | 1 - 1 file changed, 1 deletion(-)
PATCH v3 3/6 x86: Move MP initialization codes into a common place
In reply to a message not in the archiveMost of the MP initialization codes in arch/x86/cpu/baytrail/cpu.c is common to all x86 processors, except detect_num_cpus() which varies from cpu to cpu. Move these to arch/x86/cpu/cpu.c and implement the new 'get_count' method for baytrail and cpu_x86 drivers. Now we call cpu_get_count() in mp_init() to get the number of CPUs.
---
Changes in v3:
- Remove num_cpus from struct mp_params
- Call cpu_get_count() in mp_init() to get the number of CPUs
- Add missing DECLARE_GLOBAL_DATA_PTR in cpu-uclass.c and cpu_x86.c
Changes in v2: None
arch/x86/cpu/baytrail/cpu.c | 99 ++++++++++++++------------------------------- arch/x86/cpu/cpu.c | 40 ++++++++++++++++++ arch/x86/cpu/cpu_x86.c | 30 ++++++++++++++ arch/x86/cpu/mp_init.c | 18 +++++++-- arch/x86/include/asm/mp.h | 1 - drivers/cpu/cpu-uclass.c | 2 + 6 files changed, 117 insertions(+), 73 deletions(-)
arch/x86/cpu/baytrail/cpu.c +30 -69
@@ -12,78 +12,9 @@#include <asm/cpu.h> #include <asm/cpu_x86.h> #include <asm/lapic.h> -#include <asm/mp.h> #include <asm/msr.h> #include <asm/turbo.h> -#ifdef CONFIG_SMP -static int enable_smis (struct udevice *cpu,void *unused) -{ -return 0 ; -} - -static struct mp_flight_record mp_steps[] = { -MP_FR_BLOCK_APS (mp_init_cpu,NULL , mp_init_cpu,NULL ), -/* Wait for APs to finish initialization before proceeding. */ -MP_FR_BLOCK_APS (NULL ,NULL , enable_smis,NULL ), -}; - -static int detect_num_cpus (void ) -{ -int ecx =0 ; - -/* -* Use the algorithm described in Intel 64 and IA-32 Architectures -* Software Developer's Manual Volume 3 (3A, 3B & 3C): System -* Programming Guide, Jan-2015. Section 8.9.2: Hierarchical Mapping -* of CPUID Extended Topology Leaf. -*/ -while (1 ) { -struct cpuid_result leaf_b; - - leaf_b =cpuid_ext (0xb , ecx); - -/* -* Bay Trail doesn't have hyperthreading so just determine the -* number of cores by from level type (ecx[15:8] == * 2) -*/ -if ((leaf_b.ecx &0xff00 ) ==0x0200 ) -return leaf_b.ebx &0xffff ; - ecx++; - } -} - -static int baytrail_init_cpus (void ) -{ -struct mp_params mp_params; - -lapic_setup (); - - mp_params.num_cpus =detect_num_cpus (); - mp_params.parallel_microcode_load =0 , - mp_params.flight_plan = &mp_steps[0 ]; - mp_params.num_records =ARRAY_SIZE (mp_steps); - mp_params.microcode_pointer =0 ; - -if (mp_init (&mp_params)) { -printf ("Warning: MP init failure\n" ); -return -EIO ; - } - -return 0 ; -} -#endif - -int x86_init_cpus (void ) -{ -#ifdef CONFIG_SMP -debug ("Init additional CPUs\n" ); -baytrail_init_cpus (); -#endif - -return 0 ; -} -static void set_max_freq (void ) {msr_t perf_ctl;
@@ -176,9 +107,39 @@ static int baytrail_get_info(struct udevice *dev, struct cpu_info *info)return 0 ; } +static int baytrail_get_count (struct udevice *dev,int *count) +{ +int ecx =0 ; + +/* +* Use the algorithm described in Intel 64 and IA-32 Architectures +* Software Developer's Manual Volume 3 (3A, 3B & 3C): System +* Programming Guide, Jan-2015. Section 8.9.2: Hierarchical Mapping +* of CPUID Extended Topology Leaf. +*/ +while (1 ) { +struct cpuid_result leaf_b; + + leaf_b =cpuid_ext (0xb , ecx); + +/* +* Bay Trail doesn't have hyperthreading so just determine the +* number of cores by from level type (ecx[15:8] == * 2) +*/ +if ((leaf_b.ecx &0xff00 ) ==0x0200 ) { + *count = leaf_b.ebx &0xffff ; +break ; + } + ecx++; + } + +return 0 ; +} +static const struct cpu_ops cpu_x86_baytrail_ops = { .get_desc = cpu_x86_get_desc, .get_info = baytrail_get_info, + .get_count = baytrail_get_count, };static const struct udevice_id cpu_x86_baytrail_ids[] = {
arch/x86/cpu/cpu.c +40 -0
@@ -21,10 +21,13 @@#include <common.h> #include <command.h> +#include <dm.h> #include <errno.h> #include <malloc.h> #include <asm/control_regs.h> #include <asm/cpu.h> +#include <asm/lapic.h> +#include <asm/mp.h> #include <asm/post.h> #include <asm/processor.h> #include <asm/processor-flags.h>
@@ -621,8 +624,45 @@ int last_stage_init(void) }#endif +#ifdef CONFIG_SMP +static int enable_smis (struct udevice *cpu,void *unused) +{ +return 0 ; +} + +static struct mp_flight_record mp_steps[] = { +MP_FR_BLOCK_APS (mp_init_cpu,NULL , mp_init_cpu,NULL ), +/* Wait for APs to finish initialization before proceeding */ +MP_FR_BLOCK_APS (NULL ,NULL , enable_smis,NULL ), +}; + +static int x86_mp_init (void ) +{ +struct mp_params mp_params; + +lapic_setup (); + + mp_params.parallel_microcode_load =0 , + mp_params.flight_plan = &mp_steps[0 ]; + mp_params.num_records =ARRAY_SIZE (mp_steps); + mp_params.microcode_pointer =0 ; + +if (mp_init (&mp_params)) { +printf ("Warning: MP init failure\n" ); +return -EIO ; + } + +return 0 ; +} +#endif +__weak int x86_init_cpus (void ) { +#ifdef CONFIG_SMP +debug ("Init additional CPUs\n" ); +x86_mp_init (); +#endif +return 0 ; }
arch/x86/cpu/cpu_x86.c +30 -0
@@ -10,6 +10,8 @@#include <errno.h> #include <asm/cpu.h> +DECLARE_GLOBAL_DATA_PTR ; +int cpu_x86_bind (struct udevice *dev) {struct cpu_platdata *plat =dev_get_parent_platdata (dev);
@@ -30,8 +32,36 @@ int cpu_x86_get_desc(struct udevice *dev, char *buf, int size)return 0 ; } +static int cpu_x86_get_count (struct udevice *dev,int *count) +{ +int node, cpu; +int num =0 ; + + node =fdt_path_offset (gd->fdt_blob,"/cpus" ); +if (node <0 ) +return -ENOENT ; + +for (cpu =fdt_first_subnode (gd->fdt_blob, node); + cpu >=0 ; + cpu =fdt_next_subnode (gd->fdt_blob, cpu)) { +const char *device_type; + + device_type =fdt_getprop (gd->fdt_blob, cpu, +"device_type" ,NULL ); +if (!device_type) +continue ; +if (strcmp (device_type,"cpu" ) ==0 ) + num++; + } + + *count = num; + +return 0 ; +} +static const struct cpu_ops cpu_x86_ops = { .get_desc = cpu_x86_get_desc, + .get_count = cpu_x86_get_count, };static const struct udevice_id cpu_x86_ids[] = {
arch/x86/cpu/mp_init.c +15 -3
@@ -22,6 +22,9 @@#include <dm/uclass-internal.h> #include <linux/linkage.h> +/* Total CPUs include BSP */ +static int num_cpus; +/* This also needs to match the sipi.S assembly code for saved MSR encoding */ struct saved_msr {uint32_t index;
@@ -383,7 +386,7 @@ static int bsp_do_flight_plan(struct udevice *cpu, struct mp_params *mp_params)int ret =0 ;const int timeout_us =100000 ;const int step_us =100 ; -int num_aps = mp_params->num_cpus -1 ; +int num_aps = num_cpus -1 ;for (i =0 ; i < mp_params->num_records; i++) {struct mp_flight_record *rec = &mp_params->flight_plan[i];
@@ -451,7 +454,16 @@ int mp_init(struct mp_params *p)return -1 ; } - ret =check_cpu_devices (p->num_cpus); + ret =cpu_get_count (cpu, &num_cpus); +if (ret <0 ) { +debug ("Cannot get number of CPUs: err=%d\n" , ret); +return ret; + } + +if (num_cpus <2 ) +debug ("Warning: Only 1 CPU is detected\n" ); + + ret =check_cpu_devices (num_cpus);if (ret)debug ("Warning: Device tree does not describe all CPUs. Extra ones will not be started correctly\n" );
@@ -471,7 +483,7 @@ int mp_init(struct mp_params *p)wbinvd ();/* Start the APs providing number of APs and the cpus_entered field */ - num_aps = p->num_cpus -1 ; + num_aps = num_cpus -1 ; ret =start_aps (num_aps, ap_count);if (ret) {mdelay (1000 );
arch/x86/include/asm/mp.h +0 -1
@@ -59,7 +59,6 @@ struct mp_flight_record {* SMM support. */ struct mp_params { -int num_cpus;/* Total cpus include BSP */ int parallel_microcode_load;const void *microcode_pointer;/* Flight plan for APs and BSP */
drivers/cpu/cpu-uclass.c +2 -0
@@ -12,6 +12,8 @@#include <dm/lists.h> #include <dm/root.h> +DECLARE_GLOBAL_DATA_PTR ; +int cpu_get_desc (struct udevice *dev,char *buf,int size) {struct cpu_ops *ops =cpu_get_ops (dev);
Signature · 1 line
1.8.2.1
PATCH v3 3/6 x86: Move MP initialization codes into a common place
Quoted 17 lines · Bin Meng
Most of the MP initialization codes in
arch/x86/cpu/baytrail/cpu.cis common to all x86 processors, exceptdetect_num_cpus()which varies from cpu to cpu. Move these toarch/x86/cpu/cpu.cand implement the new 'get_count' method for baytrail andcpu_x86drivers. Now we callcpu_get_count()inmp_init()to get the number of CPUs.Signed-off-by Bin Meng <[email protected]>---
Changes in v3:
- Removenum_cpusfrom structmp_params
- Callcpu_get_count()inmp_init()to get the number of CPUs
- Add missingDECLARE_GLOBAL_DATA_PTRincpu-uclass.candcpu_x86.cChanges in v2: None
Quoted 7 lines
arch/x86/cpu/baytrail/cpu.c | 99 ++++++++++++++------------------------------- arch/x86/cpu/cpu.c | 40 ++++++++++++++++++ arch/x86/cpu/cpu_x86.c | 30 ++++++++++++++ arch/x86/cpu/mp_init.c | 18 +++++++-- arch/x86/include/asm/mp.h | 1 - drivers/cpu/cpu-uclass.c | 2 + 6 files changed, 117 insertions(+), 73 deletions(-)
PATCH v3 4/6 x86: Move lapic_setup() call into init_bsp()
In reply to a message not in the archiveCurrently lapic_setup() is called before calling mp_init(), which then calls init_bsp() where it calls enable_lapic(), which was already enabled in lapic_setup(). Hence move lapic_setup() call into init_bsp() to avoid the duplication.
---
Changes in v3: None
Changes in v2: None
arch/x86/cpu/cpu.c | 2 -- arch/x86/cpu/mp_init.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
arch/x86/cpu/cpu.c +0 -2
@@ -640,8 +640,6 @@ static int x86_mp_init(void) {struct mp_params mp_params; -lapic_setup (); - mp_params.parallel_microcode_load =0 , mp_params.flight_plan = &mp_steps[0 ]; mp_params.num_records =ARRAY_SIZE (mp_steps);
arch/x86/cpu/mp_init.c +1 -1
@@ -418,7 +418,7 @@ static int init_bsp(struct udevice **devp)cpu_get_name (processor_name);debug ("CPU: %s.\n" , processor_name); -enable_lapic (); +lapic_setup (); apic_id =lapicid (); ret =find_cpu_by_apid_id (apic_id, devp);
Signature · 1 line
1.8.2.1
PATCH v3 5/6 x86: Clean up lapic codes
In reply to a message not in the archiveThis commit cleans up the lapic codes:
- Delete arch/x86/include/asm/lapic_def.h, and move register and bit defines into arch/x86/include/asm/lapic.h
- Use MSR defines from msr-index.h in enable_lapic() and disable_lapic()
- Remove unnecessary stuff like NEED_LAPIC, X86_GOOD_APIC and CONFIG_AP_IN_SIPI_WAIT
- Move struct x86_cpu_priv defines to asm/arch-ivybridge/bd82x6x.h, as it is not apic related and only used by ivybridge
- Fix coding convention issues
---
Changes in v3: None
Changes in v2: None
arch/x86/cpu/ivybridge/model_206ax.c | 2 +- arch/x86/cpu/lapic.c | 38 ++++---- arch/x86/include/asm/arch-ivybridge/bd82x6x.h | 14 ++- arch/x86/include/asm/lapic.h | 131 ++++++++++++++------------ arch/x86/include/asm/lapic_def.h | 101 -------------------- 5 files changed, 103 insertions(+), 183 deletions(-) delete mode 100644 arch/x86/include/asm/lapic_def.h
arch/x86/cpu/ivybridge/model_206ax.c +1 -1
@@ -13,12 +13,12 @@#include <asm/acpi.h> #include <asm/cpu.h> #include <asm/lapic.h> -#include <asm/lapic_def.h> #include <asm/msr.h> #include <asm/mtrr.h> #include <asm/processor.h> #include <asm/speedstep.h> #include <asm/turbo.h> +#include <asm/arch/bd82x6x.h> #include <asm/arch/model_206ax.h> static void enable_vmx (void )
arch/x86/cpu/lapic.c +17 -21
@@ -8,50 +8,46 @@*/ #include <common.h> -#include <asm/msr.h> -#include <asm/io.h> #include <asm/lapic.h> #include <asm/post.h> void lapic_setup (void ) { -#if NEED_LAPIC ==1 +#ifdef CONFIG_SMP /* Only Pentium Pro and later have those MSR stuff */ debug ("Setting up local apic: " );/* Enable the local apic */ enable_lapic (); -/* -* Set Task Priority to 'accept all'. -*/ +/* Set Task Priority to 'accept all' */ lapic_write_around (LAPIC_TASKPRI ,lapic_read_around (LAPIC_TASKPRI ) & ~LAPIC_TPRI_MASK );/* Put the local apic in virtual wire mode */ lapic_write_around (LAPIC_SPIV , (lapic_read_around (LAPIC_SPIV ) & - ~(LAPIC_VECTOR_MASK )) |LAPIC_SPIV_ENABLE ); + ~(LAPIC_VECTOR_MASK )) |LAPIC_SPIV_ENABLE );lapic_write_around (LAPIC_LVT0 , (lapic_read_around (LAPIC_LVT0 ) & - ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | -LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | -LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | -LAPIC_DELIVERY_MODE_MASK )) | - (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | -LAPIC_DELIVERY_MODE_EXTINT )); + ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | +LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | +LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | +LAPIC_DELIVERY_MODE_MASK )) | + (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | +LAPIC_DELIVERY_MODE_EXTINT ));lapic_write_around (LAPIC_LVT1 , (lapic_read_around (LAPIC_LVT1 ) & - ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | -LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | -LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | -LAPIC_DELIVERY_MODE_MASK )) | - (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | -LAPIC_DELIVERY_MODE_NMI )); + ~(LAPIC_LVT_MASKED |LAPIC_LVT_LEVEL_TRIGGER | +LAPIC_LVT_REMOTE_IRR |LAPIC_INPUT_POLARITY | +LAPIC_SEND_PENDING |LAPIC_LVT_RESERVED_1 | +LAPIC_DELIVERY_MODE_MASK )) | + (LAPIC_LVT_REMOTE_IRR |LAPIC_SEND_PENDING | +LAPIC_DELIVERY_MODE_NMI ));debug ("apic_id: 0x%02lx, " ,lapicid ()); -#else /* !NEED_LLAPIC */ +#else /* !CONFIG_SMP */ /* Only Pentium Pro and later have those MSR stuff */ debug ("Disabling local apic: " );disable_lapic (); -#endif /* !NEED_LAPIC */ +#endif /* CONFIG_SMP */ debug ("done.\n" );post_code (POST_LAPIC ); }
arch/x86/include/asm/arch-ivybridge/bd82x6x.h +13 -1
@@ -16,7 +16,19 @@ int gma_func0_init(pci_dev_t dev, struct pci_controller *hose, const void *blob, int node);int bd82x6x_init (void ); -struct x86_cpu_priv ; +/** +* struct x86_cpu_priv - Information about a single CPU +* +* @apic_id: Advanced Programmable Interrupt Controller Identifier, which is +* just a number representing the CPU core +* +* TODO: Move this to driver model once lifecycle is understood +*/ +struct x86_cpu_priv { +int apic_id; +int start_err; +}; +int model_206ax_init (struct x86_cpu_priv *cpu);#endif
arch/x86/include/asm/lapic.h +72 -59
199 lines not on this page · raw message
arch/x86/include/asm/lapic_def.h deleted +0 -101
101 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v3 6/6 x86: crownbay: Add MP initialization
In reply to a message not in the archiveIntel Crown Bay board has a TunnelCreek processor which supports hyper-threading. Add /cpus node in the crownbay.dts and enable the MP initialization.
---
Changes in v3: None
Changes in v2:
- Move CONFIG_MAX_CPUS after CONFIG_SMP in crownbay_defconfig to match the order in Kconfig
arch/x86/dts/crownbay.dts | 20 ++++++++++++++++++++ configs/crownbay_defconfig | 4 ++++ 2 files changed, 24 insertions(+)
arch/x86/dts/crownbay.dts +20 -0
@@ -23,6 +23,26 @@ silent_console = <0>; }; + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <0>; + intel,apic-id = <0>; + }; + + cpu at 1 { + device_type = "cpu"; + compatible = "cpu-x86"; + reg = <1>; + intel,apic-id = <1>; + }; + + }; + gpioa { compatible = "intel,ich6-gpio"; u-boot,dm-pre-reloc;
configs/crownbay_defconfig +4 -0
@@ -2,6 +2,10 @@ CONFIG_X86=y CONFIG_VENDOR_INTEL=y CONFIG_DEFAULT_DEVICE_TREE="crownbay" CONFIG_TARGET_CROWNBAY=y +CONFIG_SMP=y +CONFIG_MAX_CPUS=2 CONFIG_GENERATE_PIRQ_TABLE=y +CONFIG_CMD_CPU=y CONFIG_CMD_NET=y CONFIG_OF_CONTROL=y +CONFIG_CPU=y
Signature · 1 line
1.8.2.1