ia64/linux-2.6.18-xen.hg

changeset 670:0ba49e9e74f9

evtchn: Clean up pirq/dynirq handling.

* Remove dynirq/pirq_to/from_irq() macros. It's clearer to use *_BASE
and NR_* macros directly.
* Avoid and fix confusion between a Linux 'pirq' and a Xen
'pirq'. This is basically done by avoiding the notion of a Linux
'pirq' at all.
* Fix IA64 build.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Sep 16 10:39:05 2008 +0100 (2008-09-16)
parents de4d39818577
children 8ca4d2b16eb3
files drivers/xen/core/evtchn.c include/asm-i386/mach-xen/irq_vectors.h include/asm-ia64/irq.h include/asm-powerpc/xen/asm/hypervisor.h include/asm-x86_64/mach-xen/irq_vectors.h
line diff
     1.1 --- a/drivers/xen/core/evtchn.c	Fri Sep 12 10:37:32 2008 +0100
     1.2 +++ b/drivers/xen/core/evtchn.c	Tue Sep 16 10:39:05 2008 +0100
     1.3 @@ -319,13 +319,11 @@ asmlinkage void evtchn_do_upcall(struct 
     1.4  static int find_unbound_irq(void)
     1.5  {
     1.6  	static int warned;
     1.7 -	int dynirq, irq;
     1.8 +	int irq;
     1.9  
    1.10 -	for (dynirq = 0; dynirq < NR_DYNIRQS; dynirq++) {
    1.11 -		irq = dynirq_to_irq(dynirq);
    1.12 +	for (irq = DYNIRQ_BASE; irq < (DYNIRQ_BASE + NR_DYNIRQS); irq++)
    1.13  		if (irq_bindcount[irq] == 0)
    1.14  			return irq;
    1.15 -	}
    1.16  
    1.17  	if (!warned) {
    1.18  		warned = 1;
    1.19 @@ -761,9 +759,12 @@ void evtchn_register_pirq(int irq)
    1.20  	irq_info[irq] = mk_irq_info(IRQT_PIRQ, irq, 0);
    1.21  }
    1.22  
    1.23 -#ifndef CONFIG_X86_IO_APIC
    1.24 -#undef IO_APIC_IRQ
    1.25 -#define IO_APIC_IRQ(irq) ((irq) >= pirq_to_irq(16))
    1.26 +#if defined(CONFIG_X86_IO_APIC)
    1.27 +#define identity_mapped_irq(irq) (!IO_APIC_IRQ((irq) - PIRQ_BASE))
    1.28 +#elif defined(CONFIG_X86)
    1.29 +#define identity_mapped_irq(irq) (((irq) - PIRQ_BASE) < 16)
    1.30 +#else
    1.31 +#define identity_mapped_irq(irq) (0)
    1.32  #endif
    1.33  
    1.34  int evtchn_map_pirq(int irq, int xen_pirq)
    1.35 @@ -771,10 +772,10 @@ int evtchn_map_pirq(int irq, int xen_pir
    1.36  	if (irq < 0) {
    1.37  		static DEFINE_SPINLOCK(irq_alloc_lock);
    1.38  
    1.39 -		irq = pirq_to_irq(NR_PIRQS - 1);
    1.40 +		irq = PIRQ_BASE + NR_PIRQS - 1;
    1.41  		spin_lock(&irq_alloc_lock);
    1.42  		do {
    1.43 -			if (!IO_APIC_IRQ(irq))
    1.44 +			if (identity_mapped_irq(irq))
    1.45  				continue;
    1.46  			if (!index_from_irq(irq)) {
    1.47  				BUG_ON(type_from_irq(irq) != IRQT_UNBOUND);
    1.48 @@ -782,9 +783,9 @@ int evtchn_map_pirq(int irq, int xen_pir
    1.49  							    xen_pirq, 0);
    1.50  				break;
    1.51  			}
    1.52 -		} while (--irq);
    1.53 +		} while (--irq >= PIRQ_BASE);
    1.54  		spin_unlock(&irq_alloc_lock);
    1.55 -		if (irq < pirq_to_irq(16))
    1.56 +		if (irq < PIRQ_BASE)
    1.57  			return -ENOSPC;
    1.58  	} else if (!xen_pirq) {
    1.59  		if (unlikely(type_from_irq(irq) != IRQT_PIRQ))
    1.60 @@ -803,29 +804,28 @@ int evtchn_map_pirq(int irq, int xen_pir
    1.61  
    1.62  int evtchn_get_xen_pirq(int irq)
    1.63  {
    1.64 -	if (!IO_APIC_IRQ(irq))
    1.65 +	if (identity_mapped_irq(irq))
    1.66  		return irq;
    1.67 -	if (unlikely(type_from_irq(irq) != IRQT_PIRQ))
    1.68 -		return 0;
    1.69 +	BUG_ON(type_from_irq(irq) != IRQT_PIRQ);
    1.70  	return index_from_irq(irq);
    1.71  }
    1.72  
    1.73 -static inline void pirq_unmask_notify(int pirq)
    1.74 +static inline void pirq_unmask_notify(int irq)
    1.75  {
    1.76 -	struct physdev_eoi eoi = { .irq = pirq };
    1.77 -	if (unlikely(test_bit(pirq, pirq_needs_eoi)))
    1.78 +	struct physdev_eoi eoi = { .irq = evtchn_get_xen_pirq(irq) };
    1.79 +	if (unlikely(test_bit(irq - PIRQ_BASE, pirq_needs_eoi)))
    1.80  		VOID(HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi));
    1.81  }
    1.82  
    1.83 -static inline void pirq_query_unmask(int pirq)
    1.84 +static inline void pirq_query_unmask(int irq)
    1.85  {
    1.86  	struct physdev_irq_status_query irq_status;
    1.87 -	irq_status.irq = pirq;
    1.88 +	irq_status.irq = evtchn_get_xen_pirq(irq);
    1.89  	if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status))
    1.90  		irq_status.flags = 0;
    1.91 -	clear_bit(pirq, pirq_needs_eoi);
    1.92 +	clear_bit(irq - PIRQ_BASE, pirq_needs_eoi);
    1.93  	if (irq_status.flags & XENIRQSTAT_needs_eoi)
    1.94 -		set_bit(pirq, pirq_needs_eoi);
    1.95 +		set_bit(irq - PIRQ_BASE, pirq_needs_eoi);
    1.96  }
    1.97  
    1.98  /*
    1.99 @@ -853,7 +853,7 @@ static unsigned int startup_pirq(unsigne
   1.100  	}
   1.101  	evtchn = bind_pirq.port;
   1.102  
   1.103 -	pirq_query_unmask(irq_to_pirq(irq));
   1.104 +	pirq_query_unmask(irq);
   1.105  
   1.106  	evtchn_to_irq[evtchn] = irq;
   1.107  	bind_evtchn_to_cpu(evtchn, 0);
   1.108 @@ -861,7 +861,7 @@ static unsigned int startup_pirq(unsigne
   1.109  
   1.110   out:
   1.111  	unmask_evtchn(evtchn);
   1.112 -	pirq_unmask_notify(irq_to_pirq(irq));
   1.113 +	pirq_unmask_notify(irq);
   1.114  
   1.115  	return 0;
   1.116  }
   1.117 @@ -915,7 +915,7 @@ static void end_pirq(unsigned int irq)
   1.118  		shutdown_pirq(irq);
   1.119  	} else if (VALID_EVTCHN(evtchn)) {
   1.120  		unmask_evtchn(evtchn);
   1.121 -		pirq_unmask_notify(irq_to_pirq(irq));
   1.122 +		pirq_unmask_notify(irq);
   1.123  	}
   1.124  }
   1.125  
   1.126 @@ -1062,7 +1062,7 @@ static void restore_cpu_ipis(unsigned in
   1.127  
   1.128  void irq_resume(void)
   1.129  {
   1.130 -	unsigned int cpu, pirq, irq, evtchn;
   1.131 +	unsigned int cpu, irq, evtchn;
   1.132  
   1.133  	init_evtchn_cpu_bindings();
   1.134  
   1.135 @@ -1071,8 +1071,8 @@ void irq_resume(void)
   1.136  		mask_evtchn(evtchn);
   1.137  
   1.138  	/* Check that no PIRQs are still bound. */
   1.139 -	for (pirq = 0; pirq < NR_PIRQS; pirq++)
   1.140 -		BUG_ON(irq_info[pirq_to_irq(pirq)] != IRQ_UNBOUND);
   1.141 +	for (irq = PIRQ_BASE; irq < (PIRQ_BASE + NR_PIRQS); irq++)
   1.142 +		BUG_ON(irq_info[irq] != IRQ_UNBOUND);
   1.143  
   1.144  	/* No IRQ <-> event-channel mappings. */
   1.145  	for (irq = 0; irq < NR_IRQS; irq++)
   1.146 @@ -1102,28 +1102,29 @@ void __init xen_init_IRQ(void)
   1.147  		irq_info[i] = IRQ_UNBOUND;
   1.148  
   1.149  	/* Dynamic IRQ space is currently unbound. Zero the refcnts. */
   1.150 -	for (i = 0; i < NR_DYNIRQS; i++) {
   1.151 -		irq_bindcount[dynirq_to_irq(i)] = 0;
   1.152 +	for (i = DYNIRQ_BASE; i < (DYNIRQ_BASE + NR_DYNIRQS); i++) {
   1.153 +		irq_bindcount[i] = 0;
   1.154  
   1.155 -		irq_desc[dynirq_to_irq(i)].status = IRQ_DISABLED;
   1.156 -		irq_desc[dynirq_to_irq(i)].action = NULL;
   1.157 -		irq_desc[dynirq_to_irq(i)].depth = 1;
   1.158 -		irq_desc[dynirq_to_irq(i)].chip = &dynirq_type;
   1.159 +		irq_desc[i].status = IRQ_DISABLED;
   1.160 +		irq_desc[i].action = NULL;
   1.161 +		irq_desc[i].depth = 1;
   1.162 +		irq_desc[i].chip = &dynirq_type;
   1.163  	}
   1.164  
   1.165  	/* Phys IRQ space is statically bound (1:1 mapping). Nail refcnts. */
   1.166 -	for (i = 0; i < NR_PIRQS; i++) {
   1.167 -		irq_bindcount[pirq_to_irq(i)] = 1;
   1.168 +	for (i = PIRQ_BASE; i < (PIRQ_BASE + NR_PIRQS); i++) {
   1.169 +		irq_bindcount[i] = 1;
   1.170  
   1.171  #ifdef RTC_IRQ
   1.172  		/* If not domain 0, force our RTC driver to fail its probe. */
   1.173 -		if ((i == RTC_IRQ) && !is_initial_xendomain())
   1.174 +		if (identity_mapped_irq(i) && ((i - PIRQ_BASE) == RTC_IRQ)
   1.175 +		    && !is_initial_xendomain())
   1.176  			continue;
   1.177  #endif
   1.178  
   1.179 -		irq_desc[pirq_to_irq(i)].status = IRQ_DISABLED;
   1.180 -		irq_desc[pirq_to_irq(i)].action = NULL;
   1.181 -		irq_desc[pirq_to_irq(i)].depth = 1;
   1.182 -		irq_desc[pirq_to_irq(i)].chip = &pirq_type;
   1.183 +		irq_desc[i].status = IRQ_DISABLED;
   1.184 +		irq_desc[i].action = NULL;
   1.185 +		irq_desc[i].depth = 1;
   1.186 +		irq_desc[i].chip = &pirq_type;
   1.187  	}
   1.188  }
     2.1 --- a/include/asm-i386/mach-xen/irq_vectors.h	Fri Sep 12 10:37:32 2008 +0100
     2.2 +++ b/include/asm-i386/mach-xen/irq_vectors.h	Tue Sep 16 10:39:05 2008 +0100
     2.3 @@ -122,10 +122,4 @@
     2.4  #define NR_IRQS			(NR_PIRQS + NR_DYNIRQS)
     2.5  #define NR_IRQ_VECTORS		NR_IRQS
     2.6  
     2.7 -#define pirq_to_irq(_x)		((_x) + PIRQ_BASE)
     2.8 -#define irq_to_pirq(_x)		((_x) - PIRQ_BASE)
     2.9 -
    2.10 -#define dynirq_to_irq(_x)	((_x) + DYNIRQ_BASE)
    2.11 -#define irq_to_dynirq(_x)	((_x) - DYNIRQ_BASE)
    2.12 -
    2.13  #endif /* _ASM_IRQ_VECTORS_H */
     3.1 --- a/include/asm-ia64/irq.h	Fri Sep 12 10:37:32 2008 +0100
     3.2 +++ b/include/asm-ia64/irq.h	Tue Sep 16 10:39:05 2008 +0100
     3.3 @@ -34,12 +34,6 @@
     3.4  #define NR_IRQS			(NR_PIRQS + NR_DYNIRQS)
     3.5  #define NR_IRQ_VECTORS		NR_IRQS
     3.6  
     3.7 -#define pirq_to_irq(_x)		((_x) + PIRQ_BASE)
     3.8 -#define irq_to_pirq(_x)		((_x) - PIRQ_BASE)
     3.9 -
    3.10 -#define dynirq_to_irq(_x)	((_x) + DYNIRQ_BASE)
    3.11 -#define irq_to_dynirq(_x)	((_x) - DYNIRQ_BASE)
    3.12 -
    3.13  #define RESCHEDULE_VECTOR	0
    3.14  #define IPI_VECTOR		1
    3.15  #define CMCP_VECTOR		2
     4.1 --- a/include/asm-powerpc/xen/asm/hypervisor.h	Fri Sep 12 10:37:32 2008 +0100
     4.2 +++ b/include/asm-powerpc/xen/asm/hypervisor.h	Tue Sep 16 10:39:05 2008 +0100
     4.3 @@ -154,13 +154,6 @@ int direct_remap_pfn_range(struct vm_are
     4.4  
     4.5  #define NR_IRQ_VECTORS		NR_IRQS
     4.6  
     4.7 -#define pirq_to_irq(_x)		((_x) + PIRQ_BASE)
     4.8 -#define irq_to_pirq(_x)		((_x) - PIRQ_BASE)
     4.9 -
    4.10 -#define dynirq_to_irq(_x)	((_x) + DYNIRQ_BASE)
    4.11 -#define irq_to_dynirq(_x)	((_x) - DYNIRQ_BASE)
    4.12 -
    4.13 -
    4.14  /* END:  all of these need a new home */
    4.15  
    4.16  #if defined(CONFIG_X86_64)
     5.1 --- a/include/asm-x86_64/mach-xen/irq_vectors.h	Fri Sep 12 10:37:32 2008 +0100
     5.2 +++ b/include/asm-x86_64/mach-xen/irq_vectors.h	Tue Sep 16 10:39:05 2008 +0100
     5.3 @@ -114,10 +114,4 @@
     5.4  #define NR_IRQS			(NR_PIRQS + NR_DYNIRQS)
     5.5  #define NR_IRQ_VECTORS		NR_IRQS
     5.6  
     5.7 -#define pirq_to_irq(_x)		((_x) + PIRQ_BASE)
     5.8 -#define irq_to_pirq(_x)		((_x) - PIRQ_BASE)
     5.9 -
    5.10 -#define dynirq_to_irq(_x)	((_x) + DYNIRQ_BASE)
    5.11 -#define irq_to_dynirq(_x)	((_x) - DYNIRQ_BASE)
    5.12 -
    5.13  #endif /* _ASM_IRQ_VECTORS_H */