direct-io.hg

changeset 4356:cc2c40950d59

bitkeeper revision 1.1236.1.144 (42484459vNunHVt3PY-Uy-M3JRd0yw)

Merge firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-2.0-testing.bk
into firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
author kaf24@firebug.cl.cam.ac.uk
date Mon Mar 28 17:52:25 2005 +0000 (2005-03-28)
parents 35abce1e2658 41b4061f42cb
children 6966b0183ab8
files xen/arch/x86/mtrr/generic.c xen/arch/x86/mtrr/main.c xen/arch/x86/smpboot.c
line diff
     1.1 --- a/xen/arch/x86/mtrr/generic.c	Sat Mar 26 02:25:05 2005 +0000
     1.2 +++ b/xen/arch/x86/mtrr/generic.c	Mon Mar 28 17:52:25 2005 +0000
     1.3 @@ -8,7 +8,6 @@
     1.4  #include <asm/msr.h>
     1.5  #include <asm/system.h>
     1.6  #include <asm/cpufeature.h>
     1.7 -//#include <asm/tlbflush.h>
     1.8  #include "mtrr.h"
     1.9  
    1.10  struct mtrr_state {
    1.11 @@ -233,6 +232,13 @@ static unsigned long cr4 = 0;
    1.12  static u32 deftype_lo, deftype_hi;
    1.13  static spinlock_t set_atomicity_lock = SPIN_LOCK_UNLOCKED;
    1.14  
    1.15 +/*
    1.16 + * Since we are disabling the cache don't allow any interrupts - they
    1.17 + * would run extremely slow and would only increase the pain.  The caller must
    1.18 + * ensure that local interrupts are disabled and are reenabled after post_set()
    1.19 + * has been called.
    1.20 + */
    1.21 +
    1.22  static void prepare_set(void)
    1.23  {
    1.24  	unsigned long cr0;
    1.25 @@ -240,11 +246,11 @@ static void prepare_set(void)
    1.26  	/*  Note that this is not ideal, since the cache is only flushed/disabled
    1.27  	   for this CPU while the MTRRs are changed, but changing this requires
    1.28  	   more invasive changes to the way the kernel boots  */
    1.29 +
    1.30  	spin_lock(&set_atomicity_lock);
    1.31  
    1.32  	/*  Enter the no-fill (CD=1, NW=0) cache mode and flush caches. */
    1.33  	cr0 = read_cr0() | 0x40000000;	/* set CD flag */
    1.34 -	wbinvd();
    1.35  	write_cr0(cr0);
    1.36  	wbinvd();
    1.37  
    1.38 @@ -266,8 +272,7 @@ static void prepare_set(void)
    1.39  
    1.40  static void post_set(void)
    1.41  {
    1.42 -	/*  Flush caches and TLBs  */
    1.43 -	wbinvd();
    1.44 +	/*  Flush TLBs (no need to flush caches - they are disabled)  */
    1.45  	__flush_tlb();
    1.46  
    1.47  	/* Intel (P6) standard MTRRs */
    1.48 @@ -285,13 +290,16 @@ static void post_set(void)
    1.49  static void generic_set_all(void)
    1.50  {
    1.51  	unsigned long mask, count;
    1.52 +	unsigned long flags;
    1.53  
    1.54 +	local_irq_save(flags);
    1.55  	prepare_set();
    1.56  
    1.57  	/* Actually set the state */
    1.58  	mask = set_mtrr_state(deftype_lo,deftype_hi);
    1.59  
    1.60  	post_set();
    1.61 +	local_irq_restore(flags);
    1.62  
    1.63  	/*  Use the atomic bitops to update the global mask  */
    1.64  	for (count = 0; count < sizeof mask * 8; ++count) {
    1.65 @@ -314,6 +322,9 @@ static void generic_set_mtrr(unsigned in
    1.66      [RETURNS] Nothing.
    1.67  */
    1.68  {
    1.69 +	unsigned long flags;
    1.70 +
    1.71 +	local_irq_save(flags);
    1.72  	prepare_set();
    1.73  
    1.74  	if (size == 0) {
    1.75 @@ -328,6 +339,7 @@ static void generic_set_mtrr(unsigned in
    1.76  	}
    1.77  
    1.78  	post_set();
    1.79 +	local_irq_restore(flags);
    1.80  }
    1.81  
    1.82  int generic_validate_add_page(unsigned long base, unsigned long size, unsigned int type)
     2.1 --- a/xen/arch/x86/mtrr/main.c	Sat Mar 26 02:25:05 2005 +0000
     2.2 +++ b/xen/arch/x86/mtrr/main.c	Mon Mar 28 17:52:25 2005 +0000
     2.3 @@ -166,10 +166,8 @@ static void ipi_handler(void *info)
     2.4  	local_irq_save(flags);
     2.5  
     2.6  	atomic_dec(&data->count);
     2.7 -	while(!atomic_read(&data->gate)) {
     2.8 +	while(!atomic_read(&data->gate))
     2.9  		cpu_relax();
    2.10 -		barrier();
    2.11 -	}
    2.12  
    2.13  	/*  The master has cleared me to execute  */
    2.14  	if (data->smp_reg != ~0U) 
    2.15 @@ -179,10 +177,9 @@ static void ipi_handler(void *info)
    2.16  		mtrr_if->set_all();
    2.17  
    2.18  	atomic_dec(&data->count);
    2.19 -	while(atomic_read(&data->gate)) {
    2.20 +	while(atomic_read(&data->gate))
    2.21  		cpu_relax();
    2.22 -		barrier();
    2.23 -	}
    2.24 +
    2.25  	atomic_dec(&data->count);
    2.26  	local_irq_restore(flags);
    2.27  }
    2.28 @@ -247,10 +244,9 @@ static void set_mtrr(unsigned int reg, u
    2.29  
    2.30  	local_irq_save(flags);
    2.31  
    2.32 -	while(atomic_read(&data.count)) {
    2.33 +	while(atomic_read(&data.count))
    2.34  		cpu_relax();
    2.35 -		barrier();
    2.36 -	}
    2.37 +
    2.38  	/* ok, reset count and toggle gate */
    2.39  	atomic_set(&data.count, num_booting_cpus() - 1);
    2.40  	atomic_set(&data.gate,1);
    2.41 @@ -267,10 +263,9 @@ static void set_mtrr(unsigned int reg, u
    2.42  		mtrr_if->set(reg,base,size,type);
    2.43  
    2.44  	/* wait for the others */
    2.45 -	while(atomic_read(&data.count)) {
    2.46 +	while(atomic_read(&data.count))
    2.47  		cpu_relax();
    2.48 -		barrier();
    2.49 -	}
    2.50 +
    2.51  	atomic_set(&data.count, num_booting_cpus() - 1);
    2.52  	atomic_set(&data.gate,0);
    2.53  
    2.54 @@ -278,10 +273,9 @@ static void set_mtrr(unsigned int reg, u
    2.55  	 * Wait here for everyone to have seen the gate change
    2.56  	 * So we're the last ones to touch 'data'
    2.57  	 */
    2.58 -	while(atomic_read(&data.count)) {
    2.59 +	while(atomic_read(&data.count))
    2.60  		cpu_relax();
    2.61 -		barrier();
    2.62 -	}
    2.63 +
    2.64  	local_irq_restore(flags);
    2.65  }
    2.66  
     3.1 --- a/xen/arch/x86/smpboot.c	Sat Mar 26 02:25:05 2005 +0000
     3.2 +++ b/xen/arch/x86/smpboot.c	Mon Mar 28 17:52:25 2005 +0000
     3.3 @@ -351,13 +351,6 @@ void __init smp_callin(void)
     3.4  
     3.5      __sti();
     3.6  
     3.7 -#ifdef CONFIG_MTRR
     3.8 -    /*
     3.9 -     * Must be done before calibration delay is computed
    3.10 -     */
    3.11 -    mtrr_init_secondary_cpu ();
    3.12 -#endif
    3.13 -
    3.14      Dprintk("Stack at about %p\n",&cpuid);
    3.15  
    3.16      /*
    3.17 @@ -784,10 +777,6 @@ void __init smp_boot_cpus(void)
    3.18  {
    3.19      int apicid, bit;
    3.20  
    3.21 -#ifdef CONFIG_MTRR
    3.22 -    /*  Must be done before other processors booted  */
    3.23 -    mtrr_init_boot_cpu ();
    3.24 -#endif
    3.25      /* Initialize the logical to physical CPU number mapping */
    3.26      init_cpu_to_apicid();
    3.27