v3 Moorestown clock related patches
cover v3 Moorestown clock related patches
Hi,
Please review the two patches related Moorestown/Medfield clock selection logic. tglx has suggested a much cleaner logic in
http://lkml.org/lkml/2010/5/17/406
So patch #2 is the implementation of new logic plus small tweaks based on testing results.
I also dropped x86_mask check for Penwell CPU check. It is not needed, CPU family and model should be sufficient/accurate to identify Lincroft vs Penwell.
*** BLURB HERE ***
Jacob Pan (2):
x86/mrst: add cpu type detection
x86/mrst: add more timer config options
arch/x86/include/asm/apb_timer.h | 1 - arch/x86/include/asm/mrst.h | 20 +++++++ arch/x86/kernel/apb_timer.c | 37 +++---------- arch/x86/kernel/mrst.c | 109 ++++++++++++++++++++++++++++++-------- 4 files changed, 114 insertions(+), 53 deletions(-)
PATCH 1/2 v4 x86/mrst: add cpu type detection
Medfield is the follow-up of Moorestown, it is treated under the same HW sub-architecture. However, we do need to know the CPU type in order for some of the driver to act accordingly.
We also have different optimal clock configuration for each CPU type.
--- arch/x86/include/asm/mrst.h | 19 +++++++++++++++++++ arch/x86/kernel/mrst.c | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-)
arch/x86/include/asm/mrst.h +19 -0
@@ -11,8 +11,27 @@#ifndef _ASM_X86_MRST_H#define _ASM_X86_MRST_Hextern int pci_mrst_init (void ); +extern int mrst_identify_cpu (void );int __init sfi_parse_mrtc (struct sfi_table_header *table); +/** +* Medfield is the follow-up of Moorestown, it combines two chip solution into +* one. Other than that it also added always-on and constant tsc and lapic +* timers. Medfield is the platform name, and the chip name is called Penwell +* we treat Medfield/Penwell as a variant of Moorestown. Penwell can be +* identified via MSRs. +*/ +enum mrst_cpu_type { +MRST_CPU_CHIP_LINCROFT =1 , +MRST_CPU_CHIP_PENWELL , +}; + +enum mrst_timer_options { +MRST_TIMER_DEFAULT , +MRST_TIMER_APBT_ONLY , +MRST_TIMER_LAPIC_APBT , +}; +#define SFI_MTMR_MAX_NUM 8#define SFI_MRTC_MAX 8
arch/x86/kernel/mrst.c +20 -0
@@ -216,6 +216,26 @@ static void __init mrst_setup_boot_clock(void)setup_boot_APIC_clock (); }; +int mrst_identify_cpu (void ) +{ +u32 mrst_cpu_chip; + +if (boot_cpu_data.x86 ==6 && boot_cpu_data.x86_model ==0x27 ) + mrst_cpu_chip =MRST_CPU_CHIP_PENWELL ; +else if (boot_cpu_data.x86 ==6 && boot_cpu_data.x86_model ==0x26 ) + mrst_cpu_chip =MRST_CPU_CHIP_LINCROFT ; +else { +pr_err ("Unknown Moorestown CPU (%d:%d), default to Lincroft\n" , + boot_cpu_data.x86, boot_cpu_data.x86_model); + mrst_cpu_chip =MRST_CPU_CHIP_LINCROFT ; + } +pr_debug ("Moorestown CPU %s identified\n" , + (mrst_cpu_chip ==MRST_CPU_CHIP_LINCROFT ) ? +"Lincroft" :"Penwell" ); +return mrst_cpu_chip; +} +EXPORT_SYMBOL_GPL (mrst_identify_cpu); +/* * Moorestown specific x86_init function overrides and early setup * calls.
Signature · 1 line
1.6.3.3
Re: [PATCH 1/2] v4 x86/mrst: add cpu type detection
Quoted 7 lines · Jacob Pan
arch/x86/kernel/mrst.c +6
-0+int mrst_identify_cpu (void ) +{ +u32 mrst_cpu_chip; + +if (boot_cpu_data.x86 ==6 && boot_cpu_data.x86_model ==0x27 ) + mrst_cpu_chip =MRST_CPU_CHIP_PENWELL ;
arch/x86/kernel/mrst.c static void __init mrst_setup_boot_clock(void) · line 234
Quoted 10 lines
arch/x86/kernel/mrst.c +10
-0+else if (boot_cpu_data.x86 ==6 && boot_cpu_data.x86_model ==0x26 ) + mrst_cpu_chip =MRST_CPU_CHIP_LINCROFT ; +else { +pr_err ("Unknown Moorestown CPU (%d:%d), default to Lincroft\n" , + boot_cpu_data.x86, boot_cpu_data.x86_model); + mrst_cpu_chip =MRST_CPU_CHIP_LINCROFT ; + } +pr_debug ("Moorestown CPU %s identified\n" , + (mrst_cpu_chip ==MRST_CPU_CHIP_LINCROFT ) ? +"Lincroft" :"Penwell" );
Do you really want a printk for each call ?
Aside of that wouldn't it make more sense to do the chip identification only once from mrst_init() and cache the result and change mrst_identify_cpu()
int mrst_indetify_cpu(void)
{
return mrst_cpu_chip;
}EXPORT_SYMBOL_GPL(mrst_identify_cpu);
I think one of your earlier versions did that, but was not consistent in it's behaviour.
Thanks,
tglx
Re: [PATCH 1/2] v4 x86/mrst: add cpu type detection
Quoted 5 lines
Aside of that wouldn't it make more sense to do the chip identification only once from
mrst_init()and cache the result and changemrst_identify_cpu()
the problem is again the ordering of cpuid, boot_cpu_data is not available by the time we call x86_mrst_early_setup(). I can move it to mrst_time_init() but not very ideal. Unless we go back to do cpuid directly in the v1 patch :).
Re: [PATCH 1/2] v4 x86/mrst: add cpu type detection
Quoted 7 lines · jacob pan
Quoted 5 lines
Aside of that wouldn't it make more sense to do the chip identification only once from
mrst_init()and cache the result and changemrst_identify_cpu()the problem is again the ordering of cpuid,
boot_cpu_datais not available by the time we callx86_mrst_early_setup(). I can move it tomrst_time_init()
Hmm, right.
Quoted 1 line
but not very ideal. Unless we go back to do cpuid directly in the v1 patch :).
x86_init.oem.arch_setup() is the point where you can do that, that's called after early_cpu_init() which fills boot_cpu_data. It's way before the first user of mrst_chip.
Thanks,
tglx
PATCH 2/2 v4 x86/mrst: add more timer config options
In reply to Jacob PanAlways-on local APIC timer (ARAT) has been introduced to Medfield, along with the platform APB timers we have more timer configuration options between Moorestown and Medfield.
This patch adds run-time detection of avaiable timer features so that we can treat Medfield as a variant of Moorestown and set up the optimal timer options for each platform. i.e.
Medfield: per cpu always-on local APIC timer
Moorestown: per cpu APB timer
Manual override is possible via cmdline option x86_mrst_timer.
--- arch/x86/include/asm/apb_timer.h | 1 - arch/x86/include/asm/mrst.h | 1 + arch/x86/kernel/apb_timer.c | 37 +++------------ arch/x86/kernel/mrst.c | 93 +++++++++++++++++++++++++++---------- 4 files changed, 77 insertions(+), 55 deletions(-)
arch/x86/include/asm/apb_timer.h +0 -1
@@ -55,7 +55,6 @@ extern unsigned long apbt_quick_calibrate(void);extern int arch_setup_apbt_irqs (int irq,int trigger,int mask,int cpu);extern void apbt_setup_secondary_clock (void );extern unsigned int boot_cpu_id; -extern int disable_apbt_percpu;extern struct sfi_timer_table_entry *sfi_get_mtmr (int hint);extern void sfi_free_mtmr (struct sfi_timer_table_entry *mtmr);
arch/x86/include/asm/mrst.h +1 -0
@@ -12,6 +12,7 @@#define _ASM_X86_MRST_Hextern int pci_mrst_init (void );extern int mrst_identify_cpu (void ); +extern int mrst_timer_options__cpuinitdata ;int __init sfi_parse_mrtc (struct sfi_table_header *table);/**
arch/x86/kernel/apb_timer.c +8 -29
@@ -43,10 +43,11 @@#include <asm/fixmap.h> #include <asm/apb_timer.h> +#include <asm/mrst.h> #define APBT_MASK CLOCKSOURCE_MASK(32)#define APBT_SHIFT 22 -#define APBT_CLOCKEVENT_RATING 150 +#define APBT_CLOCKEVENT_RATING 110#define APBT_CLOCKSOURCE_RATING 250#define APBT_MIN_DELTA_USEC 200
@@ -83,8 +84,6 @@ struct apbt_dev {char name[10 ]; }; -int disable_apbt_percpu__cpuinitdata ; - static DEFINE_PER_CPU(struct apbt_dev, cpu_apbt_dev);#ifdef CONFIG_SMP
@@ -195,29 +194,6 @@ static struct clock_event_device apbt_clockevent = { };/* -* if user does not want to use per CPU apb timer, just give it a lower rating -* than local apic timer and skip the late per cpu timer init. -*/ -static inline int __init setup_x86_mrst_timer (char *arg) -{ -if (!arg) -return -EINVAL ; - -if (strcmp ("apbt_only" , arg) ==0 ) - disable_apbt_percpu =0 ; -else if (strcmp ("lapic_and_apbt" , arg) ==0 ) - disable_apbt_percpu =1 ; -else { -pr_warning ("X86 MRST timer option %s not recognised" -" use x86_mrst_timer=apbt_only or lapic_and_apbt\n" , - arg); -return -EINVAL ; - } -return 0 ; -} -__setup ("x86_mrst_timer=" , setup_x86_mrst_timer); - -/* * start count down from 0xffff_ffff. this is done by toggling the enable bit * then load initial load count to ~0. */
@@ -335,7 +311,7 @@ static int __init apbt_clockevent_register(void) adev->num =smp_processor_id ();memcpy (&adev->evt, &apbt_clockevent,sizeof (struct clock_event_device )); -if (disable_apbt_percpu) { +if (mrst_timer_options ==MRST_TIMER_LAPIC_APBT ) { apbt_clockevent.rating =APBT_CLOCKEVENT_RATING -100 ; global_clock_event = &adev->evt; printk(KERN_DEBUG "%s clockevent registered as global\n",
@@ -429,7 +405,8 @@ static int apbt_cpuhp_notify(struct notifier_block *n,static __init int apbt_late_init (void ) { -if (disable_apbt_percpu || !apb_timer_block_enabled) +if (mrst_timer_options ==MRST_TIMER_LAPIC_APBT || + !apb_timer_block_enabled)return 0 ;/* This notifier should be called after workqueue is ready */ hotcpu_notifier (apbt_cpuhp_notify,-20 );
@@ -450,6 +427,8 @@ static void apbt_set_mode(enum clock_event_mode mode,int timer_num;struct apbt_dev *adev =EVT_TO_APBT_DEV (evt); +BUG_ON (!apbt_virt_address); + timer_num = adev->num;pr_debug ("%s CPU %d timer %d mode=%d\n" , __func__,first_cpu (*evt->cpumask), timer_num, mode);
@@ -676,7 +655,7 @@ void __init apbt_time_init(void) }#ifdef CONFIG_SMP /* kernel cmdline disable apb timer, so we will use lapic timers */ -if (disable_apbt_percpu) { +if (mrst_timer_options ==MRST_TIMER_LAPIC_APBT ) {printk (KERN_INFO "apbt: disabled per cpu timer\n" );return ; }
arch/x86/kernel/mrst.c +68 -25
129 lines not on this page · raw message
Signature · 1 line
1.6.3.3
Re: [PATCH 2/2] v4 x86/mrst: add more timer config options
Quoted 5 lines · Jacob Pan
Always-on local APIC timer (ARAT) has been introduced to Medfield, along with the platform APB timers we have more timer configuration options between Moorestown and Medfield.
+/**
Do not use kerneldoc /** opener from plain comments. Randy complained about that yesterday already
arch/x86/kernel/mrst.c static unsigned long __init mrst_calibrate_tsc(void) · line 211
Quoted 5 lines
void
__initmrst_time_init(void)
{arch/x86/kernel/mrst.c +3
-0+switch (mrst_timer_options) { +case MRST_TIMER_APBT_ONLY : +pr_info ("Use APB timer option on Moorestown\n" );
Do we really need all this pr_info spew ? /proc/timer_list will tell you if you're interested
arch/x86/kernel/mrst.c static unsigned long __init mrst_calibrate_tsc(void) · line 219
Quoted 8 lines
arch/x86/kernel/mrst.c +8
-0+break ; +case MRST_TIMER_LAPIC_APBT : +pr_info ("Use LAPIC and APB timer option on Moorestown\n" ); + x86_init.timers.setup_percpu_clockev = setup_boot_APIC_clock; + x86_cpuinit.setup_percpu_clockev = setup_secondary_APIC_clock; +break ; +default : +pr_info ("Use default timer option on Moorestown\n" );
And this printk is completely useless. It'd be way more interesting to see which timer gets selected as a default. but see above
arch/x86/kernel/mrst.c static unsigned long __init mrst_calibrate_tsc(void) · line 220
Quoted 1 line
arch/x86/kernel/mrst.c +1
-0+if (mrst_identify_cpu () ==MRST_CPU_CHIP_PENWELL ) {
Why do you want to pin that on PENWELL and not on ARAT ? If you check ARAT, you have coverd all next gen cpus as well.
arch/x86/kernel/mrst.c static unsigned long __init mrst_calibrate_tsc(void) · line 226
Quoted 6 lines
arch/x86/kernel/mrst.c +6
-0+ x86_init.timers.setup_percpu_clockev = + setup_boot_APIC_clock; + x86_cpuinit.setup_percpu_clockev = + setup_secondary_APIC_clock; +return ; + }
You can avoid that line splits by doing:
if (!has(ARAT)) break: x86_init.timers. ... ... return;
Way easier to read.
Thanks,
tglx
Re: [PATCH 2/2] v4 x86/mrst: add more timer config options
Quoted 7 lines
Quoted 3 lines
+/**
Do not use kerneldoc /** opener from plain comments. Randy complained about that yesterday already
I missed randy's comment at the end. sorry. I admit I did not know kernel-doc before that.
if (mrst_identify_cpu() == MRST_CPU_CHIP_PENWELL) {Quoted 3 lines
Why do you want to pin that on PENWELL and not on ARAT ? If you check ARAT, you have coverd all next gen cpus as well.
I did try ARAT first but ARAT is not available at this point. the add-on cpu features are set later.
Thanks,
Jacob
Re: [PATCH 2/2] v4 x86/mrst: add more timer config options
Quoted 10 lines · jacob pan
Quoted 7 lines
Quoted 3 lines
+/**
Do not use kerneldoc /** opener from plain comments. Randy complained about that yesterday already
I missed randy's comment at the end. sorry. I admit I did not know kernel-doc before that.
Quoted 7 lines
if (mrst_identify_cpu() == MRST_CPU_CHIP_PENWELL) {Quoted 3 lines
Why do you want to pin that on PENWELL and not on ARAT ? If you check ARAT, you have coverd all next gen cpus as well.
I did try ARAT first but ARAT is not available at this point. the add-on cpu features are set later.
Hmm, I don't see a reason why we don't to the readout of the extra features right away. I might be missing something really important though :) hpa ?????
Thanks,
tglx
This is should be the v4 cover letter instead of v3 shown in the subject line. sorry about that.
Jacob Pan Tue, 18 May 2010 05:02:44 -0700
Quoted 22 lines
Hi,
Please review the two patches related Moorestown/Medfield clock selection logic. tglx has suggested a much cleaner logic in
http://lkml.org/lkml/2010/5/17/406
So patch #2 is the implementation of new logic plus small tweaks based on testing results.
I also droppedx86_maskcheck for Penwell CPU check. It is not needed, CPU family and model should be sufficient/accurate to identify Lincroft vs Penwell.*** BLURB HERE ***
Jacob Pan (2):
x86/mrst: add cpu type detection
x86/mrst: add more timer config optionsarch/x86/include/asm/apb_timer.h | 1 - arch/x86/include/asm/mrst.h | 20 +++++++ arch/x86/kernel/apb_timer.c | 37 +++---------- arch/x86/kernel/mrst.c | 109 ++++++++++++++++++++++++++++++-------- 4 files changed, 114 insertions(+), 53 deletions(-)