[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] fold struct irq_cfg into struct irq_desc
fold struct irq_cfg into struct irq_desc struct irq_cfg really has become an architecture extension to struct irq_desc, and hence it should be treated as such (rather than as IRQ chip specific data, which it was meant to be originally). For a first step, only convert a subset of the uses; subsequent patches (partly to be sent later) will aim at fully eliminating the use of the old structure type. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/arch/ia64/xen/irq.c +++ b/xen/arch/ia64/xen/irq.c @@ -79,16 +79,13 @@ irq_desc_t irq_desc[NR_IRQS] = { .status = IRQ_DISABLED, .handler = &no_irq_type, .lock = SPIN_LOCK_UNLOCKED + .arch = { + .vector = -1, + .cpu_mask = CPU_MASK_ALL, + } } }; -struct irq_cfg irq_cfg[NR_IRQS] = { - [0 ... NR_IRQS-1] ={ - .vector = -1, - .cpu_mask = CPU_MASK_ALL, -} -}; - void __do_IRQ_guest(int irq); /* @@ -238,7 +235,6 @@ int setup_vector(unsigned int vector, st unsigned long flags; struct irqaction *old, **p; irq_desc_t *desc = irq_descp(vector); - struct irq_cfg *cfg = irq_cfg(vector); /* * The following block of code has to be executed atomically @@ -256,8 +252,7 @@ int setup_vector(unsigned int vector, st desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_GUEST); desc->handler->startup(vector); desc->handler->enable(vector); - desc->chip_data = cfg; - cfg->vector = vector; + desc->arch.vector = vector; spin_unlock_irqrestore(&desc->lock,flags); return 0; @@ -283,13 +278,11 @@ void __init release_irq_vector(unsigned { unsigned long flags; irq_desc_t *desc; - struct irq_cfg *cfg; if ( vec == IA64_INVALID_VECTOR ) return; desc = irq_descp(vec); - cfg = irq_cfg(vec); spin_lock_irqsave(&desc->lock, flags); clear_bit(vec, ia64_xen_vector); @@ -297,8 +290,7 @@ void __init release_irq_vector(unsigned desc->depth = 1; desc->status |= IRQ_DISABLED; desc->handler->shutdown(vec); - desc->chip_data = NULL; - cfg->vector = -1; + desc->arch.vector = -1; spin_unlock_irqrestore(&desc->lock, flags); while (desc->status & IRQ_INPROGRESS) --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -281,7 +281,6 @@ static void hpet_msi_set_affinity(struct { struct msi_msg msg; unsigned int dest; - struct irq_cfg *cfg= desc->chip_data; dest = set_desc_affinity(desc, mask); if (dest == BAD_APICID) @@ -289,7 +288,7 @@ static void hpet_msi_set_affinity(struct hpet_msi_read(desc->action->dev_id, &msg); msg.data &= ~MSI_DATA_VECTOR_MASK; - msg.data |= MSI_DATA_VECTOR(cfg->vector); + msg.data |= MSI_DATA_VECTOR(desc->arch.vector); msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; msg.address_lo |= MSI_ADDR_DEST_ID(dest); hpet_msi_write(desc->action->dev_id, &msg); --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -395,12 +395,11 @@ void __init init_IRQ(void) for (irq = 0; platform_legacy_irq(irq); irq++) { struct irq_desc *desc = irq_to_desc(irq); - struct irq_cfg *cfg = desc->chip_data; desc->handler = &i8259A_irq_type; per_cpu(vector_irq, cpu)[FIRST_LEGACY_VECTOR + irq] = irq; - cfg->cpu_mask= cpumask_of_cpu(cpu); - cfg->vector = FIRST_LEGACY_VECTOR + irq; + cpumask_copy(&desc->arch.cpu_mask, cpumask_of(cpu)); + desc->arch.vector = FIRST_LEGACY_VECTOR + irq; } per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR] = 0; --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -552,7 +552,7 @@ fastcall void smp_irq_move_cleanup_inter if (!desc) continue; - cfg = desc->chip_data; + cfg = &desc->arch; spin_lock(&desc->lock); if (!cfg->move_cleanup_count) goto unlock; @@ -613,7 +613,7 @@ static void send_cleanup_vector(struct i void irq_complete_move(struct irq_desc *desc) { - struct irq_cfg *cfg = desc->chip_data; + struct irq_cfg *cfg = &desc->arch; unsigned vector, me; if (likely(!cfg->move_in_progress)) @@ -638,7 +638,7 @@ unsigned int set_desc_affinity(struct ir return BAD_APICID; irq = desc->irq; - cfg = desc->chip_data; + cfg = &desc->arch; local_irq_save(flags); lock_vector_lock(); @@ -661,11 +661,9 @@ set_ioapic_affinity_irq(struct irq_desc unsigned long flags; unsigned int dest; int pin, irq; - struct irq_cfg *cfg; struct irq_pin_list *entry; irq = desc->irq; - cfg = desc->chip_data; spin_lock_irqsave(&ioapic_lock, flags); dest = set_desc_affinity(desc, mask); @@ -682,7 +680,7 @@ set_ioapic_affinity_irq(struct irq_desc io_apic_write(entry->apic, 0x10 + 1 + pin*2, dest); data = io_apic_read(entry->apic, 0x10 + pin*2); data &= ~IO_APIC_REDIR_VECTOR_MASK; - data |= cfg->vector & 0xFF; + data |= desc->arch.vector & 0xFF; io_apic_modify(entry->apic, 0x10 + pin*2, data); if (!entry->next) @@ -2448,7 +2446,7 @@ int ioapic_guest_write(unsigned long phy return irq; desc = irq_to_desc(irq); - cfg = desc->chip_data; + cfg = &desc->arch; /* * Since PHYSDEVOP_alloc_irq_vector is dummy, rte.vector is the pirq --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -45,8 +45,6 @@ struct irq_desc __read_mostly *irq_desc static DECLARE_BITMAP(used_vectors, NR_VECTORS); -struct irq_cfg __read_mostly *irq_cfg = NULL; - static DEFINE_SPINLOCK(vector_lock); DEFINE_PER_CPU(vector_irq_t, vector_irq); @@ -156,7 +154,7 @@ static inline int find_unassigned_irq(vo int irq; for (irq = nr_irqs_gsi; irq < nr_irqs; irq++) - if (irq_cfg[irq].used == IRQ_UNUSED) + if (irq_to_desc(irq)->arch.used == IRQ_UNUSED) return irq; return -ENOSPC; } @@ -198,7 +196,7 @@ static void dynamic_irq_cleanup(unsigned desc->action = NULL; desc->msi_desc = NULL; desc->handler = &no_irq_type; - desc->chip_data->used_vectors=NULL; + desc->arch.used_vectors = NULL; cpus_setall(desc->affinity); spin_unlock_irqrestore(&desc->lock, flags); @@ -322,26 +320,22 @@ static void __init init_one_irq_cfg(stru int __init init_irq_data(void) { struct irq_desc *desc; - struct irq_cfg *cfg; int irq, vector; for (vector = 0; vector < NR_VECTORS; ++vector) this_cpu(vector_irq)[vector] = -1; irq_desc = xzalloc_array(struct irq_desc, nr_irqs); - irq_cfg = xzalloc_array(struct irq_cfg, nr_irqs); irq_vector = xzalloc_array(u8, nr_irqs_gsi); - if ( !irq_desc || !irq_cfg ||! irq_vector ) + if ( !irq_desc || !irq_vector ) return -ENOMEM; for (irq = 0; irq < nr_irqs; irq++) { desc = irq_to_desc(irq); - cfg = irq_cfg(irq); desc->irq = irq; - desc->chip_data = cfg; init_one_irq_desc(desc); - init_one_irq_cfg(cfg); + init_one_irq_cfg(&desc->arch); } /* Never allocate the hypercall vector or Linux/BSD fast-trap vector. */ @@ -384,7 +378,7 @@ static vmask_t *irq_get_used_vector_mask ret = &global_used_vector_map; - if ( desc->chip_data->used_vectors ) + if ( desc->arch.used_vectors ) { printk(XENLOG_INFO "%s: Strange, unassigned irq %d already has used_vectors!\n", __func__, irq); @@ -526,7 +520,7 @@ int assign_irq_vector(int irq) { int ret; unsigned long flags; - struct irq_cfg *cfg = &irq_cfg[irq]; + struct irq_cfg *cfg = irq_cfg(irq); struct irq_desc *desc = irq_to_desc(irq); BUG_ON(irq >= nr_irqs || irq <0); @@ -1736,15 +1730,15 @@ int map_domain_pirq( setup_msi_handler(desc, msi_desc); if ( opt_irq_vector_map == OPT_IRQ_VECTOR_MAP_PERDEV - && !desc->chip_data->used_vectors ) + && !desc->arch.used_vectors ) { - desc->chip_data->used_vectors = &pdev->info.used_vectors; - if ( desc->chip_data->vector != IRQ_VECTOR_UNASSIGNED ) + desc->arch.used_vectors = &pdev->info.used_vectors; + if ( desc->arch.vector != IRQ_VECTOR_UNASSIGNED ) { - int vector = desc->chip_data->vector; - ASSERT(!test_bit(vector, desc->chip_data->used_vectors)); + int vector = desc->arch.vector; + ASSERT(!test_bit(vector, desc->arch.used_vectors)); - set_bit(vector, desc->chip_data->used_vectors); + set_bit(vector, desc->arch.used_vectors); } } @@ -1858,7 +1852,6 @@ static void dump_irqs(unsigned char key) { int i, irq, pirq; struct irq_desc *desc; - struct irq_cfg *cfg; irq_guest_action_t *action; struct domain *d; const struct pirq *info; @@ -1870,7 +1863,6 @@ static void dump_irqs(unsigned char key) { desc = irq_to_desc(irq); - cfg = desc->chip_data; if ( !desc->handler || desc->handler == &no_irq_type ) continue; @@ -1881,7 +1873,7 @@ static void dump_irqs(unsigned char key) desc->affinity); printk(" IRQ:%4d affinity:%s vec:%02x type=%-15s" " status=%08x ", - irq, keyhandler_scratch, cfg->vector, + irq, keyhandler_scratch, desc->arch.vector, desc->handler->typename, desc->status); if ( !(desc->status & IRQ_GUEST) ) --- a/xen/arch/x86/msi.c +++ b/xen/arch/x86/msi.c @@ -123,16 +123,15 @@ static void msix_put_fixmap(struct pci_d void msi_compose_msg(struct irq_desc *desc, struct msi_msg *msg) { unsigned dest; - struct irq_cfg *cfg = desc->chip_data; - int vector = cfg->vector; + int vector = desc->arch.vector; - if ( cpus_empty(cfg->cpu_mask) ) { + if ( cpumask_empty(&desc->arch.cpu_mask) ) { dprintk(XENLOG_ERR,"%s, compose msi message error!!\n", __func__); return; } if ( vector ) { - dest = cpu_mask_to_apicid(&cfg->cpu_mask); + dest = cpu_mask_to_apicid(&desc->arch.cpu_mask); msg->address_hi = MSI_ADDR_BASE_HI; msg->address_lo = @@ -259,7 +258,6 @@ static void set_msi_affinity(struct irq_ struct msi_msg msg; unsigned int dest; struct msi_desc *msi_desc = desc->msi_desc; - struct irq_cfg *cfg = desc->chip_data; dest = set_desc_affinity(desc, mask); if (dest == BAD_APICID || !msi_desc) @@ -271,7 +269,7 @@ static void set_msi_affinity(struct irq_ read_msi_msg(msi_desc, &msg); msg.data &= ~MSI_DATA_VECTOR_MASK; - msg.data |= MSI_DATA_VECTOR(cfg->vector); + msg.data |= MSI_DATA_VECTOR(desc->arch.vector); msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK; msg.address_lo |= MSI_ADDR_DEST_ID(dest); msg.dest32 = dest; --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1010,8 +1010,8 @@ void __init smp_intr_init(void) continue; irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1; per_cpu(vector_irq, cpu)[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq; - irq_cfg[irq].vector = FIRST_HIPRIORITY_VECTOR + seridx + 1; - irq_cfg[irq].cpu_mask = cpu_online_map; + irq_to_desc(irq)->arch.vector = FIRST_HIPRIORITY_VECTOR + seridx + 1; + cpumask_copy(&irq_to_desc(irq)->arch.cpu_mask, &cpu_online_map); } /* IPI for cleanuping vectors after irq move */ --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -348,7 +348,6 @@ static void iommu_msi_set_affinity(struc struct msi_msg msg; unsigned int dest; struct amd_iommu *iommu = desc->action->dev_id; - struct irq_cfg *cfg = desc->chip_data; u16 seg = iommu->seg; u8 bus = (iommu->bdf >> 8) & 0xff; u8 dev = PCI_SLOT(iommu->bdf & 0xff); @@ -363,7 +362,7 @@ static void iommu_msi_set_affinity(struc } memset(&msg, 0, sizeof(msg)); - msg.data = MSI_DATA_VECTOR(cfg->vector) & 0xff; + msg.data = MSI_DATA_VECTOR(desc->arch.vector) & 0xff; msg.data |= 1 << 14; msg.data |= (INT_DELIVERY_MODE != dest_LowestPrio) ? MSI_DATA_DELIVERY_FIXED: --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1001,7 +1001,6 @@ static void dma_msi_set_affinity(struct unsigned int dest; unsigned long flags; struct iommu *iommu = desc->action->dev_id; - struct irq_cfg *cfg = desc->chip_data; #ifdef CONFIG_X86 dest = set_desc_affinity(desc, mask); @@ -1011,7 +1010,7 @@ static void dma_msi_set_affinity(struct } memset(&msg, 0, sizeof(msg)); - msg.data = MSI_DATA_VECTOR(cfg->vector) & 0xff; + msg.data = MSI_DATA_VECTOR(desc->arch.vector) & 0xff; msg.data |= 1 << 14; msg.data |= (INT_DELIVERY_MODE != dest_LowestPrio) ? MSI_DATA_DELIVERY_FIXED: @@ -1029,7 +1028,7 @@ static void dma_msi_set_affinity(struct msg.address_lo |= MSI_ADDR_DEST_ID(dest & 0xff); #else memset(&msg, 0, sizeof(msg)); - msg.data = cfg->vector & 0xff; + msg.data = desc->arch.vector & 0xff; msg.data |= 1 << 14; msg.address_lo = (MSI_ADDRESS_HEADER << (MSI_ADDRESS_HEADER_SHIFT + 8)); msg.address_lo |= MSI_PHYSICAL_MODE << 2; --- a/xen/include/asm-ia64/linux-xen/asm/README.origin +++ b/xen/include/asm-ia64/linux-xen/asm/README.origin @@ -10,6 +10,7 @@ cache.h -> linux/include/asm-ia64/cach gcc_intrin.h -> linux/include/asm-ia64/gcc_intrin.h ia64regs.h -> linux/include/asm-ia64/ia64regs.h io.h -> linux/include/asm-ia64/io.h +irq.h -> linux/include/asm-ia64/irq.h hw_irq.h -> linux/include/asm-ia64/hw_irq.h kregs.h -> linux/include/asm-ia64/kregs.h mca_asm.h -> linux/include/asm-ia64/mca_asm.h --- /dev/null +++ b/xen/include/asm-ia64/linux-xen/asm/irq.h @@ -0,0 +1,73 @@ +#ifndef _ASM_IA64_IRQ_H +#define _ASM_IA64_IRQ_H + +/* + * Copyright (C) 1999-2000, 2002 Hewlett-Packard Co + * David Mosberger-Tang <davidm@xxxxxxxxxx> + * Stephane Eranian <eranian@xxxxxxxxxx> + * + * 11/24/98 S.Eranian updated TIMER_IRQ and irq_canonicalize + * 01/20/99 S.Eranian added keyboard interrupt + * 02/29/00 D.Mosberger moved most things into hw_irq.h + */ + +#define NR_VECTORS 256 +#define NR_IRQS 256 + +#ifdef XEN +struct irq_cfg { +#define arch_irq_desc irq_cfg + int vector; + cpumask_t cpu_mask; +}; +#endif + +static __inline__ int +irq_canonicalize (int irq) +{ + /* + * We do the legacy thing here of pretending that irqs < 16 + * are 8259 irqs. This really shouldn't be necessary at all, + * but we keep it here as serial.c still uses it... + */ + return ((irq == 2) ? 9 : irq); +} + +extern void disable_irq (unsigned int); +extern void disable_irq_nosync (unsigned int); +extern void enable_irq (unsigned int); +extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); + +#ifdef CONFIG_SMP +extern void move_irq(int irq); +#else +#define move_irq(irq) +#endif + +struct irqaction; +struct pt_regs; +int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); + +extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); + +#ifdef XEN +static inline unsigned int irq_to_vector(int); +extern int setup_irq_vector(unsigned int, struct irqaction *); +extern void release_irq_vector(unsigned int); +extern int request_irq_vector(unsigned int vector, + void (*handler)(int, void *, struct cpu_user_regs *), + unsigned long irqflags, const char * devname, void *dev_id); + +#define create_irq(x) assign_irq_vector(AUTO_ASSIGN_IRQ) +#define destroy_irq(x) free_irq_vector(x) + +#define irq_cfg(x) (&irq_desc[x].arch) +#define irq_to_desc(x) (&irq_desc[x] + +#define irq_complete_move(x) do {} \ + while(!x) + +#define domain_pirq_to_irq(d, irq) domain_irq_to_vector(d, irq) +#endif + +#endif /* _ASM_IA64_IRQ_H */ --- a/xen/include/asm-ia64/linux/asm/README.origin +++ b/xen/include/asm-ia64/linux/asm/README.origin @@ -19,7 +19,6 @@ fpu.h -> linux/include/asm-ia64/fpu.h hdreg.h -> linux/include/asm-ia64/hdreg.h intrinsics.h -> linux/include/asm-ia64/intrinsics.h ioctl.h -> linux/include/asm-ia64/ioctl.h -irq.h -> linux/include/asm-ia64/irq.h linkage.h -> linux/include/asm-ia64/linkage.h machvec_hpsim.h -> linux/include/asm-ia64/machvec_hpsim.h mca.h -> linux/include/asm-ia64/mca.h --- a/xen/include/asm-ia64/linux/asm/irq.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _ASM_IA64_IRQ_H -#define _ASM_IA64_IRQ_H - -/* - * Copyright (C) 1999-2000, 2002 Hewlett-Packard Co - * David Mosberger-Tang <davidm@xxxxxxxxxx> - * Stephane Eranian <eranian@xxxxxxxxxx> - * - * 11/24/98 S.Eranian updated TIMER_IRQ and irq_canonicalize - * 01/20/99 S.Eranian added keyboard interrupt - * 02/29/00 D.Mosberger moved most things into hw_irq.h - */ - -#define NR_VECTORS 256 -#define NR_IRQS 256 - -static __inline__ int -irq_canonicalize (int irq) -{ - /* - * We do the legacy thing here of pretending that irqs < 16 - * are 8259 irqs. This really shouldn't be necessary at all, - * but we keep it here as serial.c still uses it... - */ - return ((irq == 2) ? 9 : irq); -} - -extern void disable_irq (unsigned int); -extern void disable_irq_nosync (unsigned int); -extern void enable_irq (unsigned int); -extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); - -#ifdef CONFIG_SMP -extern void move_irq(int irq); -#else -#define move_irq(irq) -#endif - -struct irqaction; -struct pt_regs; -int handle_IRQ_event(unsigned int, struct pt_regs *, struct irqaction *); - -extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); - -#endif /* _ASM_IA64_IRQ_H */ --- a/xen/include/asm-x86/irq.h +++ b/xen/include/asm-x86/irq.h @@ -21,7 +21,7 @@ #define LEGACY_VECTOR(irq) ((irq) + FIRST_LEGACY_VECTOR) #define irq_to_desc(irq) (&irq_desc[irq]) -#define irq_cfg(irq) (&irq_cfg[irq]) +#define irq_cfg(irq) (&irq_desc[irq].arch) typedef struct { DECLARE_BITMAP(_bits,NR_VECTORS); @@ -30,6 +30,7 @@ typedef struct { struct irq_desc; struct irq_cfg { +#define arch_irq_desc irq_cfg s16 vector; /* vector itself is only 8 bits, */ s16 old_vector; /* but we use -1 for unassigned */ cpumask_t cpu_mask; @@ -46,8 +47,6 @@ struct irq_cfg { #define IRQ_VECTOR_UNASSIGNED (-1) -extern struct irq_cfg *irq_cfg; - typedef int vector_irq_t[NR_VECTORS]; DECLARE_PER_CPU(vector_irq_t, vector_irq); --- a/xen/include/xen/irq.h +++ b/xen/include/xen/irq.h @@ -63,7 +63,6 @@ extern unsigned int nr_irqs; #endif struct msi_desc; -struct irq_cfg; /* * This is the "IRQ descriptor", which contains various information * about the irq, including what kind of hardware handling it has, @@ -74,9 +73,9 @@ typedef struct irq_desc { hw_irq_controller *handler; struct msi_desc *msi_desc; struct irqaction *action; /* IRQ action list */ - struct irq_cfg *chip_data; int irq; spinlock_t lock; + struct arch_irq_desc arch; cpumask_t affinity; cpumask_t pending_mask; /* IRQ migration pending mask */ @@ -97,32 +96,6 @@ extern irq_desc_t irq_desc[NR_VECTORS]; #define request_irq(irq, handler, irqflags, devname, devid) \ request_irq_vector(irq_to_vector(irq), handler, irqflags, devname, devid) - -static inline unsigned int irq_to_vector(int); -extern int setup_irq_vector(unsigned int, struct irqaction *); -extern void release_irq_vector(unsigned int); -extern int request_irq_vector(unsigned int vector, - void (*handler)(int, void *, struct cpu_user_regs *), - unsigned long irqflags, const char * devname, void *dev_id); - -#define create_irq(x) assign_irq_vector(AUTO_ASSIGN_IRQ) -#define destroy_irq(x) free_irq_vector(x) - -#define irq_cfg(x) &irq_cfg[(x)] -#define irq_to_desc(x) &irq_desc[(x)] - -#define irq_complete_move(x) do {} \ - while(!x) - -#define domain_pirq_to_irq(d, irq) domain_irq_to_vector(d, irq) - -struct irq_cfg { - int vector; - cpumask_t cpu_mask; -}; - -extern struct irq_cfg irq_cfg[]; - #else extern int setup_irq(unsigned int irq, struct irqaction *); extern void release_irq(unsigned int irq); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |