[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Re: APIC rework
On 11/11/09 17:00, Jeremy Fitzhardinge wrote: > On 11/11/09 16:47, Jeremy Fitzhardinge wrote: > >> For now I've applied your current patch to the branch >> xen/dom0/apic-xiantao, rooted on the last xen/master branch where it >> applies cleanly. >> >> > And xen/master-xiantao is my attempt to merge it into master. It turned > out less complex than I'd thought, but I haven't tested it yet. > And it works, at least for simple stuff (haven't tried passthrough or MSI yet). Keir, how do you feel about this change for Xen? x86: Change the interface physdev_map_pirq to support new dom0. It also keeps compatibility with old dom0. Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx> diff -r 8f81bdd57afe xen/arch/x86/irq.c --- a/xen/arch/x86/irq.c Thu Sep 03 09:51:37 2009 +0100 +++ b/xen/arch/x86/irq.c Thu Sep 24 15:36:19 2009 +0800 @@ -55,6 +55,11 @@ DEFINE_PER_CPU(vector_irq_t, vector_irq) DEFINE_PER_CPU(struct cpu_user_regs *, __irq_regs); +int check_irq_status(int irq) +{ + return irq_status[irq] != IRQ_UNUSED ? 1 : 0; +} + /* Must be called when irq disabled */ void lock_vector_lock(void) { @@ -588,6 +593,9 @@ int setup_irq(unsigned int irq, struct i desc->depth = 0; desc->status &= ~IRQ_DISABLED; desc->handler->startup(irq); + + if ( !check_irq_status(irq) ) + irq_status[irq] = IRQ_USED; spin_unlock_irqrestore(&desc->lock,flags); @@ -1277,6 +1285,8 @@ int map_domain_pirq( ASSERT(spin_is_locked(&pcidevs_lock)); ASSERT(spin_is_locked(&d->event_lock)); + + desc = irq_to_desc(irq); if ( !IS_PRIV(current->domain) ) return -EPERM; @@ -1288,6 +1298,13 @@ int map_domain_pirq( return -EINVAL; } + if ( desc->action ) + { + dprintk(XENLOG_G_WARNING, "Attempt to map in-use IRQ by Xen," + " irq:%d!\n", irq); + return 0; + } + old_irq = domain_pirq_to_irq(d, pirq); old_pirq = domain_irq_to_pirq(d, irq); @@ -1307,7 +1324,6 @@ int map_domain_pirq( return ret; } - desc = irq_to_desc(irq); if ( type == MAP_PIRQ_TYPE_MSI ) { diff -r 8f81bdd57afe xen/arch/x86/physdev.c --- a/xen/arch/x86/physdev.c Thu Sep 03 09:51:37 2009 +0100 +++ b/xen/arch/x86/physdev.c Thu Sep 24 15:45:17 2009 +0800 @@ -30,7 +30,7 @@ static int physdev_map_pirq(struct physd static int physdev_map_pirq(struct physdev_map_pirq *map) { struct domain *d; - int pirq, irq, ret = 0; + int pirq = 0, irq, ret = 0; struct msi_info _msi; void *map_data = NULL; @@ -55,23 +55,28 @@ static int physdev_map_pirq(struct physd switch ( map->type ) { case MAP_PIRQ_TYPE_GSI: - if ( map->index < 0 || map->index >= nr_irqs_gsi ) + { + int gsi, triggering, polarity; + + gsi = map->index & 0xffff; + triggering = !!(map->index & (1 << 16)); + polarity = !!(map->index & (1 << 24)); + irq = pirq = map->pirq; + + if ( gsi < 0 || gsi >= nr_irqs_gsi ) { - dprintk(XENLOG_G_ERR, "dom%d: map invalid irq %d\n", - d->domain_id, map->index); + dprintk(XENLOG_G_ERR, "dom%d: map invalid gsi %d\n", + d->domain_id, gsi); ret = -EINVAL; goto free_domain; } - irq = domain_pirq_to_irq(current->domain, map->index); - if ( !irq ) - { - dprintk(XENLOG_G_ERR, "dom%d: map pirq with incorrect irq!\n", - d->domain_id); - ret = -EINVAL; - goto free_domain; - } - break; - + if ( !check_irq_status(irq) ) { + mp_register_gsi(gsi, triggering, polarity); + printk("Register gsi:%d for dom:%d, irq:%d\n", gsi, + d->domain_id, irq); + } + break; + } case MAP_PIRQ_TYPE_MSI: irq = map->index; if ( irq == -1 ) @@ -103,7 +108,6 @@ static int physdev_map_pirq(struct physd spin_lock(&pcidevs_lock); /* Verify or get pirq. */ spin_lock(&d->event_lock); - pirq = domain_irq_to_pirq(d, irq); if ( map->pirq < 0 ) { if ( pirq ) diff -r 8f81bdd57afe xen/include/asm-x86/irq.h --- a/xen/include/asm-x86/irq.h Thu Sep 03 09:51:37 2009 +0100 +++ b/xen/include/asm-x86/irq.h Sat Sep 05 16:09:07 2009 +0800 @@ -123,6 +123,8 @@ int __assign_irq_vector(int irq, struct int bind_irq_vector(int irq, int vector, cpumask_t domain); +int check_irq_status(int irq); + #define domain_pirq_to_irq(d, pirq) ((d)->arch.pirq_irq[pirq]) #define domain_irq_to_pirq(d, irq) ((d)->arch.irq_pirq[irq]) J _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |