ia64/xen-unstable
changeset 18550:e1507b441be4
x86: Clean up and fix 18539:31f09a5e24cf8
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Sep 25 14:37:52 2008 +0100 (2008-09-25) |
parents | ddf62f696111 |
children | b642e39d96cf |
files | xen/arch/ia64/xen/irq.c xen/arch/x86/irq.c xen/arch/x86/physdev.c xen/common/event_channel.c xen/include/asm-x86/irq.h xen/include/xen/irq.h |
line diff
1.1 --- a/xen/arch/ia64/xen/irq.c Thu Sep 25 13:07:43 2008 +0100 1.2 +++ b/xen/arch/ia64/xen/irq.c Thu Sep 25 14:37:52 2008 +0100 1.3 @@ -459,12 +459,12 @@ int pirq_guest_bind(struct vcpu *v, int 1.4 return rc; 1.5 } 1.6 1.7 -int pirq_guest_unbind(struct domain *d, int irq) 1.8 +void pirq_guest_unbind(struct domain *d, int irq) 1.9 { 1.10 irq_desc_t *desc = &irq_desc[irq]; 1.11 irq_guest_action_t *action; 1.12 unsigned long flags; 1.13 - int i, rc = 0; 1.14 + int i; 1.15 1.16 spin_lock_irqsave(&desc->lock, flags); 1.17 1.18 @@ -472,11 +472,7 @@ int pirq_guest_unbind(struct domain *d, 1.19 1.20 for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) 1.21 continue; 1.22 - if ( i == action->nr_guests ) 1.23 - { 1.24 - rc = -EINVAL; 1.25 - goto out; 1.26 - } 1.27 + BUG_ON(i == action->nr_guests); 1.28 memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); 1.29 action->nr_guests--; 1.30 1.31 @@ -496,9 +492,7 @@ int pirq_guest_unbind(struct domain *d, 1.32 desc->handler->shutdown(irq); 1.33 } 1.34 1.35 - out: 1.36 spin_unlock_irqrestore(&desc->lock, flags); 1.37 - return rc; 1.38 } 1.39 1.40 void
2.1 --- a/xen/arch/x86/irq.c Thu Sep 25 13:07:43 2008 +0100 2.2 +++ b/xen/arch/x86/irq.c Thu Sep 25 14:37:52 2008 +0100 2.3 @@ -508,14 +508,14 @@ int pirq_guest_bind(struct vcpu *v, int 2.4 unsigned int vector; 2.5 irq_desc_t *desc; 2.6 irq_guest_action_t *action; 2.7 - unsigned long flags; 2.8 int rc = 0; 2.9 cpumask_t cpumask = CPU_MASK_NONE; 2.10 2.11 WARN_ON(!spin_is_locked(&v->domain->evtchn_lock)); 2.12 + BUG_ON(!local_irq_is_enabled()); 2.13 2.14 retry: 2.15 - desc = domain_spin_lock_irq_desc(v->domain, irq, &flags); 2.16 + desc = domain_spin_lock_irq_desc(v->domain, irq, NULL); 2.17 if ( desc == NULL ) 2.18 return -EINVAL; 2.19 2.20 @@ -575,7 +575,7 @@ int pirq_guest_bind(struct vcpu *v, int 2.21 */ 2.22 ASSERT(action->ack_type == ACKTYPE_EOI); 2.23 ASSERT(desc->status & IRQ_DISABLED); 2.24 - spin_unlock_irqrestore(&desc->lock, flags); 2.25 + spin_unlock_irq(&desc->lock); 2.26 cpu_relax(); 2.27 goto retry; 2.28 } 2.29 @@ -591,43 +591,25 @@ int pirq_guest_bind(struct vcpu *v, int 2.30 action->guest[action->nr_guests++] = v->domain; 2.31 2.32 out: 2.33 - spin_unlock_irqrestore(&desc->lock, flags); 2.34 + spin_unlock_irq(&desc->lock); 2.35 return rc; 2.36 } 2.37 2.38 -int pirq_guest_unbind(struct domain *d, int irq) 2.39 +static void __pirq_guest_unbind(struct domain *d, int irq, irq_desc_t *desc) 2.40 { 2.41 - int vector; 2.42 - irq_desc_t *desc; 2.43 + unsigned int vector; 2.44 irq_guest_action_t *action; 2.45 cpumask_t cpu_eoi_map; 2.46 - unsigned long flags; 2.47 - int i, rc = 0; 2.48 - 2.49 - WARN_ON(!spin_is_locked(&d->evtchn_lock)); 2.50 + int i; 2.51 2.52 - desc = domain_spin_lock_irq_desc(d, irq, &flags); 2.53 - if ( unlikely(desc == NULL) ) 2.54 - { 2.55 - if ( (vector = -domain_irq_to_vector(d, irq)) == 0 ) 2.56 - return -EINVAL; 2.57 - BUG_ON(vector <= 0); 2.58 - desc = &irq_desc[vector]; 2.59 - spin_lock_irqsave(&desc->lock, flags); 2.60 - d->arch.pirq_vector[irq] = d->arch.vector_pirq[vector] = 0; 2.61 - goto out; 2.62 - } 2.63 + BUG_ON(!(desc->status & IRQ_GUEST)); 2.64 2.65 action = (irq_guest_action_t *)desc->action; 2.66 vector = desc - irq_desc; 2.67 2.68 for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) 2.69 continue; 2.70 - if ( i == action->nr_guests ) 2.71 - { 2.72 - rc = -EINVAL; 2.73 - goto out; 2.74 - } 2.75 + BUG_ON(i == action->nr_guests); 2.76 memmove(&action->guest[i], &action->guest[i+1], IRQ_MAX_GUESTS-i-1); 2.77 action->nr_guests--; 2.78 2.79 @@ -645,9 +627,9 @@ int pirq_guest_unbind(struct domain *d, 2.80 (action->nr_guests != 0) ) 2.81 { 2.82 cpu_eoi_map = action->cpu_eoi_map; 2.83 - spin_unlock_irqrestore(&desc->lock, flags); 2.84 + spin_unlock_irq(&desc->lock); 2.85 on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 0); 2.86 - spin_lock_irqsave(&desc->lock, flags); 2.87 + spin_lock_irq(&desc->lock); 2.88 } 2.89 break; 2.90 } 2.91 @@ -659,7 +641,7 @@ int pirq_guest_unbind(struct domain *d, 2.92 BUG_ON(test_bit(irq, d->pirq_mask)); 2.93 2.94 if ( action->nr_guests != 0 ) 2.95 - goto out; 2.96 + return; 2.97 2.98 BUG_ON(action->in_flight != 0); 2.99 2.100 @@ -679,9 +661,9 @@ int pirq_guest_unbind(struct domain *d, 2.101 if ( !cpus_empty(cpu_eoi_map) ) 2.102 { 2.103 BUG_ON(action->ack_type != ACKTYPE_EOI); 2.104 - spin_unlock_irqrestore(&desc->lock, flags); 2.105 + spin_unlock_irq(&desc->lock); 2.106 on_selected_cpus(cpu_eoi_map, set_eoi_ready, desc, 1, 1); 2.107 - spin_lock_irqsave(&desc->lock, flags); 2.108 + spin_lock_irq(&desc->lock); 2.109 } 2.110 2.111 BUG_ON(!cpus_empty(action->cpu_eoi_map)); 2.112 @@ -692,10 +674,61 @@ int pirq_guest_unbind(struct domain *d, 2.113 desc->status &= ~IRQ_INPROGRESS; 2.114 kill_timer(&irq_guest_eoi_timer[vector]); 2.115 desc->handler->shutdown(vector); 2.116 +} 2.117 + 2.118 +void pirq_guest_unbind(struct domain *d, int irq) 2.119 +{ 2.120 + irq_desc_t *desc; 2.121 + int vector; 2.122 + 2.123 + WARN_ON(!spin_is_locked(&d->evtchn_lock)); 2.124 + 2.125 + BUG_ON(!local_irq_is_enabled()); 2.126 + desc = domain_spin_lock_irq_desc(d, irq, NULL); 2.127 + 2.128 + if ( desc == NULL ) 2.129 + { 2.130 + vector = -domain_irq_to_vector(d, irq); 2.131 + BUG_ON(vector <= 0); 2.132 + desc = &irq_desc[vector]; 2.133 + spin_lock_irq(&desc->lock); 2.134 + d->arch.pirq_vector[irq] = d->arch.vector_pirq[vector] = 0; 2.135 + } 2.136 + else 2.137 + { 2.138 + __pirq_guest_unbind(d, irq, desc); 2.139 + } 2.140 + 2.141 + spin_unlock_irq(&desc->lock); 2.142 +} 2.143 + 2.144 +int pirq_guest_force_unbind(struct domain *d, int irq) 2.145 +{ 2.146 + irq_desc_t *desc; 2.147 + irq_guest_action_t *action; 2.148 + int i, bound = 0; 2.149 + 2.150 + WARN_ON(!spin_is_locked(&d->evtchn_lock)); 2.151 + 2.152 + BUG_ON(!local_irq_is_enabled()); 2.153 + desc = domain_spin_lock_irq_desc(d, irq, NULL); 2.154 + BUG_ON(desc == NULL); 2.155 + 2.156 + if ( !(desc->status & IRQ_GUEST) ) 2.157 + goto out; 2.158 + 2.159 + action = (irq_guest_action_t *)desc->action; 2.160 + for ( i = 0; (i < action->nr_guests) && (action->guest[i] != d); i++ ) 2.161 + continue; 2.162 + if ( i == action->nr_guests ) 2.163 + goto out; 2.164 + 2.165 + bound = 1; 2.166 + __pirq_guest_unbind(d, irq, desc); 2.167 2.168 out: 2.169 - spin_unlock_irqrestore(&desc->lock, flags); 2.170 - return rc; 2.171 + spin_unlock_irq(&desc->lock); 2.172 + return bound; 2.173 } 2.174 2.175 extern void dump_ioapic_irq_info(void);
3.1 --- a/xen/arch/x86/physdev.c Thu Sep 25 13:07:43 2008 +0100 3.2 +++ b/xen/arch/x86/physdev.c Thu Sep 25 14:37:52 2008 +0100 3.3 @@ -146,7 +146,7 @@ static int unmap_domain_pirq(struct doma 3.4 goto done; 3.5 } 3.6 3.7 - forced_unbind = (pirq_guest_unbind(d, pirq) == 0); 3.8 + forced_unbind = pirq_guest_force_unbind(d, pirq); 3.9 if ( forced_unbind ) 3.10 dprintk(XENLOG_G_WARNING, "dom%d: forcing unbind of pirq %d\n", 3.11 d->domain_id, pirq);
4.1 --- a/xen/common/event_channel.c Thu Sep 25 13:07:43 2008 +0100 4.2 +++ b/xen/common/event_channel.c Thu Sep 25 14:37:52 2008 +0100 4.3 @@ -387,8 +387,7 @@ static long __evtchn_close(struct domain 4.4 break; 4.5 4.6 case ECS_PIRQ: 4.7 - if ( pirq_guest_unbind(d1, chn1->u.pirq) != 0 ) 4.8 - BUG(); 4.9 + pirq_guest_unbind(d1, chn1->u.pirq); 4.10 d1->pirq_to_evtchn[chn1->u.pirq] = 0; 4.11 break; 4.12
5.1 --- a/xen/include/asm-x86/irq.h Thu Sep 25 13:07:43 2008 +0100 5.2 +++ b/xen/include/asm-x86/irq.h Thu Sep 25 14:37:52 2008 +0100 5.3 @@ -55,4 +55,6 @@ int pirq_shared(struct domain *d , int i 5.4 #define domain_irq_to_vector(d, irq) ((d)->arch.pirq_vector[(irq)]) 5.5 #define domain_vector_to_irq(d, vec) ((d)->arch.vector_pirq[(vec)]) 5.6 5.7 +int pirq_guest_force_unbind(struct domain *d, int irq); 5.8 + 5.9 #endif /* _ASM_HW_IRQ_H */
6.1 --- a/xen/include/xen/irq.h Thu Sep 25 13:07:43 2008 +0100 6.2 +++ b/xen/include/xen/irq.h Thu Sep 25 14:37:52 2008 +0100 6.3 @@ -77,7 +77,7 @@ struct vcpu; 6.4 extern int pirq_guest_eoi(struct domain *d, int irq); 6.5 extern int pirq_guest_unmask(struct domain *d); 6.6 extern int pirq_guest_bind(struct vcpu *v, int irq, int will_share); 6.7 -extern int pirq_guest_unbind(struct domain *d, int irq); 6.8 +extern void pirq_guest_unbind(struct domain *d, int irq); 6.9 6.10 static inline void set_native_irq_info(int irq, cpumask_t mask) 6.11 {