direct-io.hg

changeset 10503:30a5eb240a20

[XEN] Various cleanups to bitops usage.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Tue Jun 27 14:34:52 2006 +0100 (2006-06-27)
parents 02b0ed160e8e
children 1a52829fd60e
files xen/arch/x86/hvm/vioapic.c xen/arch/x86/hvm/vlapic.c xen/arch/x86/smp.c xen/include/asm-x86/bitops.h xen/include/asm-x86/hvm/vlapic.h xen/include/public/hvm/ioreq.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vioapic.c	Tue Jun 27 12:17:45 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vioapic.c	Tue Jun 27 14:34:52 2006 +0100
     1.3 @@ -450,15 +450,10 @@ static void ioapic_deliver(hvm_vioapic_t
     1.4  
     1.5  static int ioapic_get_highest_irq(hvm_vioapic_t *s)
     1.6  {
     1.7 -    uint32_t irqs;
     1.8 -
     1.9 -    ASSERT(s);
    1.10 -
    1.11 -    irqs = s->irr & ~s->isr & ~s->imr;
    1.12 -    return __fls(irqs);
    1.13 +    uint32_t irqs = s->irr & ~s->isr & ~s->imr;
    1.14 +    return fls(irqs) - 1;
    1.15  }
    1.16  
    1.17 -
    1.18  static void service_ioapic(hvm_vioapic_t *s)
    1.19  {
    1.20      int irqno;
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Jun 27 12:17:45 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Jun 27 14:34:52 2006 +0100
     2.3 @@ -50,7 +50,7 @@ int vlapic_find_highest_irr(struct vlapi
     2.4  {
     2.5      int result;
     2.6  
     2.7 -    result = find_highest_bit((uint32_t *)&vlapic->irr[0], INTR_LEN_32);
     2.8 +    result = find_highest_bit(vlapic->irr, MAX_VECTOR);
     2.9  
    2.10      if ( result != -1 && result < 16 )
    2.11      {
    2.12 @@ -79,14 +79,14 @@ int vlapic_find_highest_isr(struct vlapi
    2.13  {
    2.14      int result;
    2.15  
    2.16 -    result = find_highest_bit((uint32_t *)&vlapic->isr[0], INTR_LEN_32);
    2.17 +    result = find_highest_bit(vlapic->isr, MAX_VECTOR);
    2.18  
    2.19      if ( result != -1 && result < 16 )
    2.20      {
    2.21          int i = 0;
    2.22          printk("VLAPIC: isr on reserved bits %d, isr is\n ", result);
    2.23 -        for ( i = 0; i < INTR_LEN_32; i += 2 )
    2.24 -            printk("%d: 0x%08x%08x\n", i, vlapic->isr[i], vlapic->isr[i+1]);
    2.25 +        for ( i = 0; i < ARRAY_SIZE(vlapic->isr); i++ )
    2.26 +            printk("%d: %p\n", i, (void *)vlapic->isr[i]);
    2.27          return -1;
    2.28      }
    2.29  
    2.30 @@ -896,7 +896,7 @@ vlapic_check_direct_intr(struct vcpu *v,
    2.31      struct vlapic *vlapic = VLAPIC(v);
    2.32      int type;
    2.33  
    2.34 -    type = __fls(vlapic->direct_intr.deliver_mode);
    2.35 +    type = fls(vlapic->direct_intr.deliver_mode) - 1;
    2.36      if ( type == -1 )
    2.37          return -1;
    2.38  
     3.1 --- a/xen/arch/x86/smp.c	Tue Jun 27 12:17:45 2006 +0100
     3.2 +++ b/xen/arch/x86/smp.c	Tue Jun 27 14:34:52 2006 +0100
     3.3 @@ -302,8 +302,9 @@ int on_selected_cpus(
     3.4  
     3.5  static void stop_this_cpu (void *dummy)
     3.6  {
     3.7 -    clear_bit(smp_processor_id(), &cpu_online_map);
     3.8 +    cpu_clear(smp_processor_id(), cpu_online_map);
     3.9  
    3.10 +    local_irq_disable();
    3.11      disable_local_APIC();
    3.12  
    3.13      for ( ; ; )
     4.1 --- a/xen/include/asm-x86/bitops.h	Tue Jun 27 12:17:45 2006 +0100
     4.2 +++ b/xen/include/asm-x86/bitops.h	Tue Jun 27 14:34:52 2006 +0100
     4.3 @@ -335,8 +335,6 @@ static inline unsigned long ffz(unsigned
     4.4  	return word;
     4.5  }
     4.6  
     4.7 -#define fls64(x)   generic_fls64(x)
     4.8 -
     4.9  /**
    4.10   * ffs - find first bit set
    4.11   * @x: the word to search
    4.12 @@ -345,15 +343,15 @@ static inline unsigned long ffz(unsigned
    4.13   * the libc and compiler builtin ffs routines, therefore
    4.14   * differs in spirit from the above ffz (man ffs).
    4.15   */
    4.16 -static inline int ffs(int x)
    4.17 +static inline int ffs(unsigned long x)
    4.18  {
    4.19 -	int r;
    4.20 +	long r;
    4.21  
    4.22 -	__asm__("bsfl %1,%0\n\t"
    4.23 +	__asm__("bsf %1,%0\n\t"
    4.24  		"jnz 1f\n\t"
    4.25 -		"movl $-1,%0\n"
    4.26 +		"mov $-1,%0\n"
    4.27  		"1:" : "=r" (r) : "rm" (x));
    4.28 -	return r+1;
    4.29 +	return (int)r+1;
    4.30  }
    4.31  
    4.32  /**
    4.33 @@ -362,15 +360,15 @@ static inline int ffs(int x)
    4.34   *
    4.35   * This is defined the same way as ffs.
    4.36   */
    4.37 -static inline int fls(int x)
    4.38 +static inline int fls(unsigned long x)
    4.39  {
    4.40 -	int r;
    4.41 +	long r;
    4.42  
    4.43 -	__asm__("bsrl %1,%0\n\t"
    4.44 +	__asm__("bsr %1,%0\n\t"
    4.45  		"jnz 1f\n\t"
    4.46 -		"movl $-1,%0\n"
    4.47 +		"mov $-1,%0\n"
    4.48  		"1:" : "=r" (r) : "rm" (x));
    4.49 -	return r+1;
    4.50 +	return (int)r+1;
    4.51  }
    4.52  
    4.53  /**
     5.1 --- a/xen/include/asm-x86/hvm/vlapic.h	Tue Jun 27 12:17:45 2006 +0100
     5.2 +++ b/xen/include/asm-x86/hvm/vlapic.h	Tue Jun 27 14:34:52 2006 +0100
     5.3 @@ -23,52 +23,12 @@
     5.4  #include <asm/msr.h>
     5.5  #include <public/hvm/ioreq.h>
     5.6  
     5.7 -#if defined(__i386__) || defined(__x86_64__)
     5.8 -static inline int __fls(uint32_t word)
     5.9 -{
    5.10 -    int bit;
    5.11 -
    5.12 -    __asm__("bsrl %1,%0"
    5.13 -      :"=r" (bit)
    5.14 -      :"rm" (word));
    5.15 -    return word ? bit : -1;
    5.16 -}
    5.17 -#else
    5.18 -#define __fls(x)    generic_fls(x)
    5.19 -static __inline__ int generic_fls(uint32_t x)
    5.20 +static __inline__ int find_highest_bit(unsigned long *data, int nr_bits)
    5.21  {
    5.22 -    int r = 31;
    5.23 -
    5.24 -    if (!x)
    5.25 -        return -1;
    5.26 -    if (!(x & 0xffff0000u)) {
    5.27 -        x <<= 16;
    5.28 -        r -= 16;
    5.29 -    }
    5.30 -    if (!(x & 0xff000000u)) {
    5.31 -        x <<= 8;
    5.32 -        r -= 8;
    5.33 -    }
    5.34 -    if (!(x & 0xf0000000u)) {
    5.35 -        x <<= 4;
    5.36 -        r -= 4;
    5.37 -    }
    5.38 -    if (!(x & 0xc0000000u)) {
    5.39 -        x <<= 2;
    5.40 -        r -= 2;
    5.41 -    }
    5.42 -    if (!(x & 0x80000000u)) {
    5.43 -        x <<= 1;
    5.44 -        r -= 1;
    5.45 -    }
    5.46 -    return r;
    5.47 -}
    5.48 -#endif
    5.49 -
    5.50 -static __inline__ int find_highest_bit(uint32_t *data, int length)
    5.51 -{
    5.52 -    while(length && !data[--length]);
    5.53 -    return __fls(data[length]) +  32 * length;
    5.54 +    int length = BITS_TO_LONGS(nr_bits);
    5.55 +    while ( length && !data[--length] )
    5.56 +        continue;
    5.57 +    return (fls(data[length]) - 1) + (length * BITS_PER_LONG);
    5.58  }
    5.59  
    5.60  #define VLAPIC(v)                       (v->arch.hvm_vcpu.vlapic)
    5.61 @@ -146,17 +106,17 @@ typedef struct direct_intr_info {
    5.62      int source[6];
    5.63  } direct_intr_info_t;
    5.64  
    5.65 -struct vlapic
    5.66 -{
    5.67 -    //FIXME check what would be 64 bit on EM64T
    5.68 +#define MAX_VECTOR      256
    5.69 +
    5.70 +struct vlapic {
    5.71      uint32_t           version;
    5.72      uint32_t           status;
    5.73      uint32_t           id;
    5.74      uint32_t           vcpu_id;
    5.75      unsigned long      base_address;
    5.76 -    uint32_t           isr[8];
    5.77 -    uint32_t           irr[INTR_LEN_32];
    5.78 -    uint32_t           tmr[INTR_LEN_32];
    5.79 +    unsigned long      isr[BITS_TO_LONGS(MAX_VECTOR)];
    5.80 +    unsigned long      irr[BITS_TO_LONGS(MAX_VECTOR)];
    5.81 +    unsigned long      tmr[BITS_TO_LONGS(MAX_VECTOR)];
    5.82      uint32_t           task_priority;
    5.83      uint32_t           processor_priority;
    5.84      uint32_t           logical_dest;
     6.1 --- a/xen/include/public/hvm/ioreq.h	Tue Jun 27 12:17:45 2006 +0100
     6.2 +++ b/xen/include/public/hvm/ioreq.h	Tue Jun 27 14:34:52 2006 +0100
     6.3 @@ -58,11 +58,6 @@ struct ioreq {
     6.4  };
     6.5  typedef struct ioreq ioreq_t;
     6.6  
     6.7 -#define MAX_VECTOR      256
     6.8 -#define BITS_PER_BYTE   8
     6.9 -#define INTR_LEN        (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint64_t)))
    6.10 -#define INTR_LEN_32     (MAX_VECTOR/(BITS_PER_BYTE * sizeof(uint32_t)))
    6.11 -
    6.12  struct global_iodata {
    6.13      uint16_t    pic_elcr;
    6.14      uint16_t    pic_irr;