dyn_array/nr_irqs/sparse_irq support v10 - fix
Subsystems (3)
cover dyn_array/nr_irqs/sparse_irq support v10 - fix
fix the 32bit with bigsmp
fix 64 bit with irq migration
ordering functions in io_apic_xx.c
to do:
merge io_apic_xx.c
Thanks
Yinghai Lu
PATCH 1/7 x86: some debug info for 32bit sparse_irq
so could figure out who get interrupt, but vector_irq is not initialized.
--- arch/x86/kernel/io_apic_32.c | 8 ++++++-- arch/x86/kernel/io_apic_64.c | 2 ++ arch/x86/kernel/irq_32.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-)
arch/x86/kernel/io_apic_32.c +6 -2
@@ -1120,8 +1120,12 @@ next: cfg->move_in_progress =1 ; cfg->old_domain = cfg->domain; } -for_each_cpu_mask_nr (new_cpu, new_mask) -per_cpu (vector_irq, new_cpu)[vector] = irq; +printk (KERN_DEBUG "assign_irq_vector: irq %d vector %#x cpu " , irq, vector); +for_each_cpu_mask_nr (new_cpu, new_mask) { +per_cpu (vector_irq, new_cpu)[vector] = irq; +printk (KERN_CONT " %d " , new_cpu); + } +printk (KERN_CONT "\n" ); cfg->vector = vector; cfg->domain = domain;return 0 ;
arch/x86/kernel/io_apic_64.c +2 -0
@@ -1392,6 +1392,8 @@ __apicdebuginit(void) print_IO_APIC(void)printk (KERN_DEBUG "IO APIC #%d......\n" , mp_ioapics[apic].mp_apicid);printk (KERN_DEBUG ".... register #00: %08X\n" , reg_00.raw);printk (KERN_DEBUG "....... : physical APIC id: %02X\n" , reg_00.bits.ID); +printk (KERN_DEBUG "....... : Delivery Type: %X\n" , reg_00.bits.delivery_type); +printk (KERN_DEBUG "....... : LTS : %X\n" , reg_00.bits.LTS);printk (KERN_DEBUG ".... register #01: %08X\n" , *(int *)®_01);printk (KERN_DEBUG "....... : max redirection entries: %04X\n" , reg_01.bits.entries);
arch/x86/kernel/irq_32.c +2 -2
@@ -237,8 +237,8 @@ unsigned int do_IRQ(struct pt_regs *regs) desc =irq_desc (irq);if (unlikely (!desc)) { -printk (KERN_EMERG "%s: cannot handle IRQ %d vector %#x\n" , - __func__, irq, vector); +printk (KERN_EMERG "%s: cannot handle IRQ %d vector %#x cpu %d\n" , + __func__, irq, vector,smp_processor_id ());BUG (); }
Signature · 1 line
1.5.4.5
PATCH 2/7 x86: remove union about dest for log/phy
let user decide the bits.
--- arch/x86/kernel/io_apic_32.c | 18 +++++++----------- include/asm-x86/io_apic.h | 16 ---------------- 2 files changed, 7 insertions(+), 27 deletions(-)
arch/x86/kernel/io_apic_32.c +7 -11
@@ -1230,7 +1230,7 @@ static int setup_ioapic_entry(int apic, int irq, entry->delivery_mode =INT_DELIVERY_MODE ; entry->dest_mode =INT_DEST_MODE ; - entry->dest.logical.logical_dest = destination; + entry->dest = destination; entry->mask =0 ;/* enable IRQ */ entry->trigger = trigger;
@@ -1342,7 +1342,7 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,*/ entry.dest_mode =INT_DEST_MODE ; entry.mask =1 ;/* mask IRQ now */ - entry.dest.logical.logical_dest =cpu_mask_to_apicid (TARGET_CPUS ); + entry.dest =cpu_mask_to_apicid (TARGET_CPUS ); entry.delivery_mode =INT_DELIVERY_MODE ; entry.polarity =0 ; entry.trigger =0 ;
@@ -1431,19 +1431,15 @@ __apicdebuginit(void) print_IO_APIC(void)printk (KERN_DEBUG ".... IRQ redirection table:\n" ); -printk (KERN_DEBUG " NR Log Phy Mask Trig IRR Pol" -" Stat Dest Deli Vect: \n" ); +printk (KERN_DEBUG " NR Dst Mask Trig IRR Pol" +" Stat Dmod Deli Vect: \n" );for (i =0 ; i <= reg_01.bits.entries; i++) {struct IO_APIC_route_entry entry; entry =ioapic_read_entry (apic, i); -printk (KERN_DEBUG " %02x %03X %02X " , - i, - entry.dest.logical.logical_dest, - entry.dest.physical.physical_dest - ); +printk (KERN_DEBUG " %02x %02X " , i, entry.dest); printk("%1d %1d %1d %1d %1d %1d %1d %02X\n", entry.mask,
@@ -1723,7 +1719,7 @@ void disable_IO_APIC(void) entry.dest_mode =0 ;/* Physical */ entry.delivery_mode = dest_ExtINT;/* ExtInt */ entry.vector =0 ; - entry.dest.physical.physical_dest =read_apic_id (); + entry.dest =read_apic_id ();/* * Add it to the IO-APIC irq-routing table:
@@ -2188,7 +2184,7 @@ static inline void __init unlock_ExtINT_logic(void) entry1.dest_mode =0 ;/* physical delivery */ entry1.mask =0 ;/* unmask IRQ now */ - entry1.dest.physical.physical_dest =hard_smp_processor_id (); + entry1.dest =hard_smp_processor_id (); entry1.delivery_mode = dest_ExtINT; entry1.polarity = entry0.polarity; entry1.trigger =0 ;
include/asm-x86/io_apic.h +0 -16
@@ -87,24 +87,8 @@ struct IO_APIC_route_entry { mask :1 ,/* 0: enabled, 1: disabled */ __reserved_2 : 15; -#ifdef CONFIG_X86_32 -union { -struct { -__u32 __reserved_1 :24 , - physical_dest :4 , - __reserved_2 :4 ; - } physical; - -struct { -__u32 __reserved_1 :24 , - logical_dest :8 ; - } logical; - } dest; -#else __u32 __reserved_3 : 24, dest : 8; -#endif - } __attribute__ ((packed));struct IR_IO_APIC_route_entry {
Signature · 1 line
1.5.4.5
PATCH 3/7 x86: make 32bit support per_cpu vector fix #1
use cpu_online_map as target cpus for bigsmp. just like 64 bit doing
also remove some unused TARGET_CPUS macro.
--- include/asm-x86/bigsmp/apic.h | 15 +++++---------- include/asm-x86/es7000/apic.h | 3 +-- include/asm-x86/numaq/apic.h | 2 -- include/asm-x86/summit/apic.h | 1 - 4 files changed, 6 insertions(+), 15 deletions(-)
include/asm-x86/bigsmp/apic.h +5 -10
@@ -9,22 +9,17 @@ static inline int apic_id_registered(void)return (1 ); } -/* Round robin the irqs amoung the online cpus */ static inline cpumask_t target_cpus (void ) { -static unsigned long cpu =NR_CPUS ; -do { -if (cpu >=NR_CPUS ) - cpu =first_cpu (cpu_online_map); -else - cpu =next_cpu (cpu, cpu_online_map); - }while (cpu >=NR_CPUS ); -return cpumask_of_cpu (cpu); +#ifdef CONFIG_SMP +return cpu_online_map; +#else +return cpumask_of_cpu (0 ); +#endif }#undef APIC_DEST_LOGICAL#define APIC_DEST_LOGICAL 0 -#define TARGET_CPUS (target_cpus())#define APIC_DFR_VALUE (APIC_DFR_FLAT)#define INT_DELIVERY_MODE (dest_Fixed)#define INT_DEST_MODE (0)/* phys delivery to target proc */
include/asm-x86/es7000/apic.h +1 -2
@@ -17,7 +17,6 @@ static inline cpumask_t target_cpus(void)return cpumask_of_cpu (smp_processor_id ());#endif } -#define TARGET_CPUS (target_cpus())#if definedCONFIG_ES7000_CLUSTERED_APIC #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
@@ -81,7 +80,7 @@ static inline void setup_apic_routing(void)int apic =per_cpu (x86_bios_cpu_apicid,smp_processor_id ());printk ("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n" , (apic_version[apic] ==0x14 ) ? -"Physical Cluster" :"Logical Cluster" , nr_ioapics,cpus_addr (TARGET_CPUS )[0 ]); +"Physical Cluster" :"Logical Cluster" , nr_ioapics,cpus_addr (target_cpus ())[0 ]); }static inline int multi_timer_check (int apic,int irq)
include/asm-x86/numaq/apic.h +0 -2
@@ -12,8 +12,6 @@ static inline cpumask_t target_cpus(void)return CPU_MASK_ALL ; } -#define TARGET_CPUS (target_cpus()) -#define NO_BALANCE_IRQ (1)#define esr_disable (1)
include/asm-x86/summit/apic.h +0 -1
@@ -22,7 +22,6 @@ static inline cpumask_t target_cpus(void)*/ return cpumask_of_cpu (0 ); } -#define TARGET_CPUS (target_cpus())#define INT_DELIVERY_MODE (dest_LowestPrio)#define INT_DEST_MODE 1/* logical delivery broadcast to all procs */
Signature · 1 line
1.5.4.5
PATCH 4/7 x86_64: rename irq_desc/irq_desc_with_new - fix
need to check if desc is null in smp_irq_move_cleanup
--- arch/x86/kernel/io_apic_64.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/x86/kernel/io_apic_64.c +3 -0
@@ -1950,6 +1950,9 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void) irq =__get_cpu_var (vector_irq)[vector]; desc =irq_desc (irq); +if (!desc) +continue ; + cfg =irq_cfg (irq);spin_lock (&desc->lock);if (!cfg->move_cleanup_count)
Signature · 1 line
1.5.4.5
PATCH 5/7 x86: make 32bit support per_cpu vector fix #2
need to check if desc is null in smp_irq_move_cleanup
also migration need to reset vector too, so copy __target_IO_APIC_irq from 64bit
--- arch/x86/kernel/io_apic_32.c | 188 +++++++++++++++++++++++++---------------- 1 files changed, 115 insertions(+), 73 deletions(-)
arch/x86/kernel/io_apic_32.c +115 -73
@@ -268,6 +268,7 @@ static struct irq_cfg *irq_cfg_with_new(unsigned int irq)return cfg; } +static int assign_irq_vector (int irq,cpumask_t mask);/* * Rough estimation of how many shared IRQs there are, can * be changed anytime.
@@ -437,6 +438,65 @@ static void ioapic_mask_entry(int apic, int pin)spin_unlock_irqrestore (&ioapic_lock, flags); } +#ifdef CONFIG_SMP +static void __target_IO_APIC_irq (unsigned int irq,unsigned int dest,u8 vector) +{ +int apic, pin; +struct irq_cfg *cfg; +struct irq_pin_list *entry; + + cfg =irq_cfg (irq); + entry = cfg->irq_2_pin; +for (;;) { +unsigned int reg; + +if (!entry) +break ; + + apic = entry->apic; + pin = entry->pin; +io_apic_write (apic,0x11 + pin*2 , dest); + reg =io_apic_read (apic,0x10 + pin*2 ); + reg &= ~IO_APIC_REDIR_VECTOR_MASK ; + reg |= vector; +io_apic_modify (apic,0x10 + pin *2 , reg); +if (!entry->next) +break ; + entry = entry->next; + } +} +static void set_ioapic_affinity_irq (unsigned int irq,struct irq_desc *desc,cpumask_t mask) +{ +struct irq_cfg *cfg; +unsigned long flags; +unsigned int dest; +cpumask_t tmp; + + cfg =irq_cfg (irq); + +cpus_and (tmp, mask, cpu_online_map); +if (cpus_empty (tmp)) +return ; + +if (assign_irq_vector (irq, mask)) +return ; + +cpus_and (tmp, cfg->domain, mask); + + dest =cpu_mask_to_apicid (tmp); +/* +* Only the high 8 bits are valid. +*/ + dest =SET_APIC_LOGICAL_ID (dest); + +spin_lock_irqsave (&ioapic_lock, flags); +__target_IO_APIC_irq (irq, dest, cfg->vector); + desc->affinity = mask; +spin_unlock_irqrestore (&ioapic_lock, flags); +} + +#endif /* CONFIG_SMP */ +/* * The common case is 1:1 IRQ<->pin mappings. Sometimes there are * shared ISA-space IRQs, so we have to support them. We are super
@@ -591,44 +651,6 @@ static void clear_IO_APIC(void)clear_IO_APIC_pin (apic, pin); } -#ifdef CONFIG_SMP -static void set_ioapic_affinity_irq (unsigned int irq,struct irq_desc *desc,cpumask_t cpumask) -{ -struct irq_cfg *cfg; -unsigned long flags; -int pin; -struct irq_pin_list *entry; -unsigned int apicid_value; -cpumask_t tmp; - - cfg =irq_cfg (irq); - entry = cfg->irq_2_pin; - -cpus_and (tmp, cpumask, cpu_online_map); -if (cpus_empty (tmp)) - tmp =TARGET_CPUS ; - -cpus_and (cpumask, tmp,CPU_MASK_ALL ); - - apicid_value =cpu_mask_to_apicid (cpumask); -/* Prepare to do the io_apic_write */ - apicid_value = apicid_value <<24 ; -spin_lock_irqsave (&ioapic_lock, flags); -for (;;) { -if (!entry) -break ; - pin = entry->pin; -io_apic_write (entry->apic,0x10 +1 + pin*2 , apicid_value); -if (!entry->next) -break ; - entry = entry->next; - } - desc->affinity = cpumask; -spin_unlock_irqrestore (&ioapic_lock, flags); -} - -#endif /* CONFIG_SMP */ -#ifndef CONFIG_SMP void send_IPI_self (int vector) {
@@ -793,34 +815,6 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin) }EXPORT_SYMBOL (IO_APIC_get_PCI_irq_vector); -/* -* This function currently is only a helper for the i386 smp boot process where -* we need to reprogram the ioredtbls to cater for the cpus which have come online -* so mask in all cases should simply be TARGET_CPUS -*/ -#ifdef CONFIG_SMP -void __init setup_ioapic_dest (void ) -{ -int pin, ioapic, irq, irq_entry; -struct irq_desc *desc; - -if (skip_ioapic_setup ==1 ) -return ; - -for (ioapic =0 ; ioapic < nr_ioapics; ioapic++) { -for (pin =0 ; pin < nr_ioapic_registers[ioapic]; pin++) { - irq_entry =find_irq_entry (ioapic, pin, mp_INT); -if (irq_entry ==-1 ) -continue ; - irq =pin_2_irq (irq_entry, ioapic, pin); - desc =irq_desc (irq); -set_ioapic_affinity_irq (irq, desc,TARGET_CPUS ); - } - - } -} -#endif -#if defined(CONFIG_EISA ) || defined(CONFIG_MCA )/* * EISA Edge/Level control register, ELCR
@@ -2003,6 +1997,9 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void) irq =__get_cpu_var (vector_irq)[vector]; desc =irq_desc (irq); +if (!desc) +continue ; + cfg =irq_cfg (irq);spin_lock (&desc->lock);if (!cfg->move_cleanup_count)
@@ -2695,15 +2692,15 @@ void arch_teardown_msi_irq(unsigned int irq)#ifdef CONFIG_SMP -static void target_ht_irq (unsigned int irq,unsigned int dest) +static void target_ht_irq (unsigned int irq,unsigned int dest,u8 vector) {struct ht_irq_msg msg;fetch_ht_irq_msg (irq, &msg); - msg.address_lo &= ~(HT_IRQ_LOW_DEST_ID_MASK ); + msg.address_lo &= ~(HT_IRQ_LOW_VECTOR_MASK |HT_IRQ_LOW_DEST_ID_MASK ); msg.address_hi &= ~(HT_IRQ_HIGH_DEST_ID_MASK ); - msg.address_lo |=HT_IRQ_LOW_DEST_ID (dest); + msg.address_lo |=HT_IRQ_LOW_VECTOR (vector) |HT_IRQ_LOW_DEST_ID (dest); msg.address_hi |=HT_IRQ_HIGH_DEST_ID (dest);write_ht_irq_msg (irq, &msg);
@@ -2711,18 +2708,22 @@ static void target_ht_irq(unsigned int irq, unsigned int dest)static void set_ht_irq_affinity (unsigned int irq,struct irq_desc *desc,cpumask_t mask) { +struct irq_cfg *cfg;unsigned int dest;cpumask_t tmp;cpus_and (tmp, mask, cpu_online_map);if (cpus_empty (tmp)) - tmp =TARGET_CPUS ; +return ; -cpus_and (mask, tmp,CPU_MASK_ALL ); +if (assign_irq_vector (irq, mask)) +return ; - dest =cpu_mask_to_apicid (mask); + cfg =irq_cfg (irq); +cpus_and (tmp, cfg->domain, mask); + dest =cpu_mask_to_apicid (tmp); -target_ht_irq (irq, dest); +target_ht_irq (irq, dest, cfg->vector); desc->affinity = mask; }#endif
@@ -2925,6 +2926,47 @@ int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity)#endif /* CONFIG_ACPI */ +/* +* This function currently is only a helper for the i386 smp boot process where +* we need to reprogram the ioredtbls to cater for the cpus which have come online +* so mask in all cases should simply be TARGET_CPUS +*/ +#ifdef CONFIG_SMP +void __init setup_ioapic_dest (void ) +{ +int pin, ioapic, irq, irq_entry; +struct irq_cfg *cfg; +struct irq_desc *desc; + +if (skip_ioapic_setup ==1 ) +return ; + +for (ioapic =0 ; ioapic < nr_ioapics; ioapic++) { +for (pin =0 ; pin < nr_ioapic_registers[ioapic]; pin++) { + irq_entry =find_irq_entry (ioapic, pin, mp_INT); +if (irq_entry ==-1 ) +continue ; + irq =pin_2_irq (irq_entry, ioapic, pin); + +/* setup_IO_APIC_irqs could fail to get vector for some device +* when you have too many devices, because at that time only boot +* cpu is online. +*/ + cfg =irq_cfg (irq); +if (!cfg->vector) +setup_IO_APIC_irq (ioapic, pin, irq, +irq_trigger (irq_entry), +irq_polarity (irq_entry)); +else { + desc =irq_desc (irq); +set_ioapic_affinity_irq (irq, desc,TARGET_CPUS ); + } + } + + } +} +#endif +static int __init parse_disable_timer_pin_1 (char *arg) { disable_timer_pin_1 =1 ;
Signature · 1 line
1.5.4.5
PATCH 6/7 x86: ordering functions in io_apic_32.c
try to make functions in the same order to io_apic_64.c
--- arch/x86/kernel/io_apic_32.c | 176 ++++++++++++++++++++++-------------------- 1 files changed, 93 insertions(+), 83 deletions(-)
arch/x86/kernel/io_apic_32.c +93 -83
@@ -1029,23 +1029,6 @@ static int pin_2_irq(int idx, int apic, int pin)return irq; } -static inline int IO_APIC_irq_trigger (int irq) -{ -int apic, idx, pin; - -for (apic =0 ; apic < nr_ioapics; apic++) { -for (pin =0 ; pin < nr_ioapic_registers[apic]; pin++) { - idx =find_irq_entry (apic, pin, mp_INT); -if ((idx !=-1 ) && (irq ==pin_2_irq (idx, apic, pin))) -return irq_trigger (idx); - } - } -/* -* nonexistent IRQs are edge default -*/ -return 0 ; -} -void lock_vector_lock (void ) {/* Used to the online set of cpus does not change
@@ -1190,6 +1173,23 @@ static struct irq_chip ioapic_chip;#define IOAPIC_EDGE 0#define IOAPIC_LEVEL 1 +static inline int IO_APIC_irq_trigger (int irq) +{ +int apic, idx, pin; + +for (apic =0 ; apic < nr_ioapics; apic++) { +for (pin =0 ; pin < nr_ioapic_registers[apic]; pin++) { + idx =find_irq_entry (apic, pin, mp_INT); +if ((idx !=-1 ) && (irq ==pin_2_irq (idx, apic, pin))) +return irq_trigger (idx); + } + } +/* +* nonexistent IRQs are edge default +*/ +return 0 ; +} +static void ioapic_register_intr (int irq,unsigned long trigger) {struct irq_desc *desc;
@@ -1926,55 +1926,6 @@ static unsigned int startup_ioapic_irq(unsigned int irq)return was_pending; } -static void irq_complete_move (unsigned int irq); -static void ack_ioapic_irq (unsigned int irq,struct irq_desc *desc) -{ -irq_complete_move (irq); -move_native_irq (irq, desc); -ack_APIC_irq (); -} - -static void ack_ioapic_quirk_irq (unsigned int irq,struct irq_desc *desc) -{ -unsigned long v; -int i; - -irq_complete_move (irq); -move_native_irq (irq, desc); -/* -* It appears there is an erratum which affects at least version 0x11 -* of I/O APIC (that's the 82093AA and cores integrated into various -* chipsets). Under certain conditions a level-triggered interrupt is -* erroneously delivered as edge-triggered one but the respective IRR -* bit gets set nevertheless. As a result the I/O unit expects an EOI -* message but it will never arrive and further interrupts are blocked -* from the source. The exact reason is so far unknown, but the -* phenomenon was observed when two consecutive interrupt requests -* from a given source get delivered to the same CPU and the source is -* temporarily disabled in between. -* -* A workaround is to simulate an EOI message manually. We achieve it -* by setting the trigger mode to edge and then to level when the edge -* trigger mode gets detected in the TMR of a local APIC for a -* level-triggered interrupt. We mask the source for the time of the -* operation to prevent an edge-triggered interrupt escaping meanwhile. -* The idea is from Manfred Spraul. --macro -*/ - i =irq_cfg (irq)->vector; - - v =apic_read (APIC_TMR + ((i & ~0x1f ) >>1 )); - -ack_APIC_irq (); - -if (!(v & (1 << (i &0x1f )))) { -atomic_inc (&irq_mis_count); -spin_lock (&ioapic_lock); -__mask_and_edge_IO_APIC_irq (irq); -__unmask_and_level_IO_APIC_irq (irq); -spin_unlock (&ioapic_lock); - } -} -static int ioapic_retrigger_irq (unsigned int irq) {send_IPI_self (irq_cfg (irq)->vector);
@@ -2040,13 +1991,61 @@ static void irq_complete_move(unsigned int irq)static inline void irq_complete_move (unsigned int irq) {}#endif +static void ack_apic_edge (unsigned int irq,struct irq_desc *desc) +{ +irq_complete_move (irq); +move_native_irq (irq, desc); +ack_APIC_irq (); +} + +static void ack_apic_level (unsigned int irq,struct irq_desc *desc) +{ +unsigned long v; +int i; + +irq_complete_move (irq); +move_native_irq (irq, desc); +/* +* It appears there is an erratum which affects at least version 0x11 +* of I/O APIC (that's the 82093AA and cores integrated into various +* chipsets). Under certain conditions a level-triggered interrupt is +* erroneously delivered as edge-triggered one but the respective IRR +* bit gets set nevertheless. As a result the I/O unit expects an EOI +* message but it will never arrive and further interrupts are blocked +* from the source. The exact reason is so far unknown, but the +* phenomenon was observed when two consecutive interrupt requests +* from a given source get delivered to the same CPU and the source is +* temporarily disabled in between. +* +* A workaround is to simulate an EOI message manually. We achieve it +* by setting the trigger mode to edge and then to level when the edge +* trigger mode gets detected in the TMR of a local APIC for a +* level-triggered interrupt. We mask the source for the time of the +* operation to prevent an edge-triggered interrupt escaping meanwhile. +* The idea is from Manfred Spraul. --macro +*/ + i =irq_cfg (irq)->vector; + + v =apic_read (APIC_TMR + ((i & ~0x1f ) >>1 )); + +ack_APIC_irq (); + +if (!(v & (1 << (i &0x1f )))) { +atomic_inc (&irq_mis_count); +spin_lock (&ioapic_lock); +__mask_and_edge_IO_APIC_irq (irq); +__unmask_and_level_IO_APIC_irq (irq); +spin_unlock (&ioapic_lock); + } +} +static struct irq_chip ioapic_chip__read_mostly = { .name ="IO-APIC" , .startup = startup_ioapic_irq, .mask = mask_IO_APIC_irq, .unmask = unmask_IO_APIC_irq, - .ack = ack_ioapic_irq, - .eoi = ack_ioapic_quirk_irq, + .ack = ack_apic_edge, + .eoi = ack_apic_level, #ifdef CONFIG_SMP .set_affinity = set_ioapic_affinity_irq, #endif
@@ -2094,11 +2093,6 @@ static inline void init_IO_APIC_traps(void)* The local APIC irq-chip implementation: */ -static void ack_lapic_irq (unsigned int irq,struct irq_desc *desc) -{ -ack_APIC_irq (); -} -static void mask_lapic_irq (unsigned int irq) {unsigned long v;
@@ -2115,6 +2109,11 @@ static void unmask_lapic_irq(unsigned int irq)apic_write (APIC_LVT0 , v & ~APIC_LVT_MASKED ); } +static void ack_lapic_irq (unsigned int irq,struct irq_desc *desc) +{ +ack_APIC_irq (); +} +static struct irq_chip lapic_chip__read_mostly = { .name ="local-APIC" , .mask = mask_lapic_irq,
@@ -2631,13 +2630,31 @@ static struct irq_chip msi_chip = { .name = "PCI-MSI", .unmask = unmask_msi_irq, .mask = mask_msi_irq, - .ack = ack_ioapic_irq, + .ack = ack_apic_edge, #ifdef CONFIG_SMP .set_affinity = set_msi_irq_affinity, #endif .retrigger = ioapic_retrigger_irq, }; + +static int setup_msi_irq (struct pci_dev *dev,struct msi_desc *desc,int irq) +{ +int ret; +struct msi_msg msg; + + ret =msi_compose_msg (dev, irq, &msg); +if (ret <0 ) +return ret; + +set_irq_msi (irq, desc); +write_msi_msg (irq, &msg); + +set_irq_chip_and_handler_name (irq, &msi_chip, handle_edge_irq,"edge" ); + +return 0 ; +} +static unsigned int build_irq_for_pci_dev (struct pci_dev *dev) {unsigned int irq;
@@ -2663,17 +2680,10 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)if (irq ==0 )return -1 ; - ret =msi_compose_msg (dev, irq, &msg);if (ret <0 ) {destroy_irq (irq);return ret; - } - -set_irq_msi (irq, desc); -write_msi_msg (irq, &msg); - -set_irq_chip_and_handler_name (irq, &msi_chip, handle_edge_irq, -"edge" ); + }return 0 ; }
@@ -2732,7 +2742,7 @@ static struct irq_chip ht_irq_chip = { .name = "PCI-HT", .mask = mask_ht_irq, .unmask = unmask_ht_irq, - .ack = ack_ioapic_irq, + .ack = ack_apic_edge,#ifdef CONFIG_SMP .set_affinity = set_ht_irq_affinity,#endif
Signature · 1 line
1.5.4.5
PATCH 7/7 x86: ordering functions in io_apic_64.c
try to make functions in the same order
--- arch/x86/kernel/io_apic_64.c | 67 ++++++++++++++++++++--------------------- 1 files changed, 33 insertions(+), 34 deletions(-)
arch/x86/kernel/io_apic_64.c +33 -34
@@ -409,40 +409,6 @@ static bool io_apic_level_ack_pending(unsigned int irq)return false; } -/* -* Synchronize the IO-APIC and the CPU by doing -* a dummy read from the IO-APIC -*/ -static inline void io_apic_sync (unsigned int apic) -{ -struct io_apic __iomem *io_apic =io_apic_base (apic); -readl (&io_apic->data); -} - -#define __DO_ACTION (R ,ACTION ,FINAL ) \ - \ -{ \ - int pin; \ - struct irq_cfg *cfg; \ - struct irq_pin_list *entry; \ - \ - cfg = irq_cfg(irq); \ - entry = cfg->irq_2_pin; \ - for (;;) { \ - unsigned int reg; \ - if (!entry) \ - break; \ - pin = entry->pin; \ - reg = io_apic_read(entry->apic, 0x10 + R + pin*2); \ - reg ACTION; \ - io_apic_modify(entry->apic, reg); \ - FINAL; \ - if (!entry->next) \ - break; \ - entry = entry->next; \ - } \ -} -union entry_union {struct {u32 w1, w2; };struct IO_APIC_route_entry entry;
@@ -625,6 +591,39 @@ static void __init replace_pin_at_irq(unsigned int irq,add_pin_to_irq (irq, newapic, newpin); } +/* +* Synchronize the IO-APIC and the CPU by doing +* a dummy read from the IO-APIC +*/ +static inline void io_apic_sync (unsigned int apic) +{ +struct io_apic __iomem *io_apic =io_apic_base (apic); +readl (&io_apic->data); +} + +#define __DO_ACTION (R ,ACTION ,FINAL ) \ + \ +{ \ + int pin; \ + struct irq_cfg *cfg; \ + struct irq_pin_list *entry; \ + \ + cfg = irq_cfg(irq); \ + entry = cfg->irq_2_pin; \ + for (;;) { \ + unsigned int reg; \ + if (!entry) \ + break; \ + pin = entry->pin; \ + reg = io_apic_read(entry->apic, 0x10 + R + pin*2); \ + reg ACTION; \ + io_apic_modify(entry->apic, reg); \ + FINAL; \ + if (!entry->next) \ + break; \ + entry = entry->next; \ + } \ +}#define DO_ACTION (name,R ,ACTION ,FINAL ) \ \
Signature · 1 line
1.5.4.5
Re: [PATCH 3/7] x86: make 32bit support per_cpu vector fix #1
In reply to Yinghai Luinclude/asm-x86/bigsmp/apic.h static inline int apic_id_registered(void) · line 18
Quoted 5 lines · Yinghai Lu
include/asm-x86/bigsmp/apic.h +5
-0+#ifdef CONFIG_SMP +return cpu_online_map; +#else +return cpumask_of_cpu (0 ); +#endif
unrelated sidenote - shouldnt the scheduler define cpu_online_map to cpumask_of_cpu(0) on UP, to avoid such ugly #ifdefs?
Ingo
Re: [PATCH 3/7] x86: make 32bit support per_cpu vector fix #1
Quoted 11 lines · Ingo Molnar
include/asm-x86/bigsmp/apic.h static inline int apic_id_registered(void) · line 18
Quoted 5 lines · Yinghai Lu
include/asm-x86/bigsmp/apic.h +5
-0+#ifdef CONFIG_SMP +return cpu_online_map; +#else +return cpumask_of_cpu (0 ); +#endif unrelated sidenote - shouldnt the scheduler define
cpu_online_maptocpumask_of_cpu(0)on UP, to avoid such ugly #ifdefs?
copy that from mach_default...
should double check if cpu_online_map is cpu_mask_of_cpu(0) if !CONFIG_SMP
YH
Re: [PATCH 3/7] x86: make 32bit support per_cpu vector fix #1
Quoted 13 lines · Yinghai Lu
Quoted 11 lines · Ingo Molnar
include/asm-x86/bigsmp/apic.h static inline int apic_id_registered(void) · line 18
Quoted 5 lines · Yinghai Lu
include/asm-x86/bigsmp/apic.h +5
-0+#ifdef CONFIG_SMP +return cpu_online_map; +#else +return cpumask_of_cpu (0 ); +#endif unrelated sidenote - shouldnt the scheduler define
cpu_online_maptocpumask_of_cpu(0)on UP, to avoid such ugly #ifdefs?
Quoted 1 line
copy that from
mach_default...
sure, that's the right approach - preserve existing code to reduce risk.
Quoted 1 line
should double check if
cpu_online_mapiscpu_mask_of_cpu(0)if !CONFIG_SMP
yeah. Separate clean-up patch i think.
Ingo
Ingo Molnar
AppliedQuoted 7 lines · Yinghai Lu
fix the 32bit with bigsmp
fix 64 bit with irq migration
ordering functions inio_apic_xx.cto do:
mergeio_apic_xx.c
applied to tip/irq/sparseirq - thanks Yinghai, great work!
What do you think about Eric's abstraction suggestion, that irq_desc's structure should be hidden from all but kernel/irq/* code. I think that's a sane suggestion. We do it in mm/slab.c too: no external code knows the structure of 'struct kmem_cache'.
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 7 lines · Yinghai Lu
fix the 32bit with bigsmp
fix 64 bit with irq migration
ordering functions inio_apic_xx.cto do:
mergeio_apic_xx.c
Quoted 6 lines
applied to tip/irq/sparseirq - thanks Yinghai, great work!
What do you think about Eric's abstraction suggestion, that irq_desc's structure should be hidden from all but
kernel/irq/*code. I think that's a sane suggestion. We do it inmm/slab.ctoo: no external code knows the structure of 'structkmem_cache'.
current arch code use irq_desc directly..., if need to irq_desc to them, need to provide set_irq(..., ...)
YH
Quoted 14 lines · Yinghai Lu
Quoted 13 lines · Ingo Molnar
Quoted 7 lines · Yinghai Lu
fix the 32bit with bigsmp
fix 64 bit with irq migration
ordering functions inio_apic_xx.cto do:
mergeio_apic_xx.capplied to tip/irq/sparseirq - thanks Yinghai, great work!
Quoted 7 lines
Quoted 4 lines
What do you think about Eric's abstraction suggestion, that irq_desc's structure should be hidden from all but
kernel/irq/*code. I think that's a sane suggestion. We do it inmm/slab.ctoo: no external code knows the structure of 'structkmem_cache'.current arch code use
irq_descdirectly..., if need toirq_descto them, need to provideset_irq(..., ...)
that's ok - we can do include/linux/irq_desc.h that isnt generally included by drivers via interrupt.h. Then later on we can eliminate that include file altogether.
here's the current field usage histogram:
3 desc->action
3 desc->depth
9 desc->affinity
15 desc->chip
22 desc->statusdesc->status: mostly IRQ_MOVE_PENDING related. irq-balancing code should be abstracted into kernel/irq/* perhaps?
desc->action / desc->depth / desc->action: i dont think those should be accessed by genirq arch irq code.
desc->chip: there's a get_irq_chip() method already. irq_chip is something that obviously is known to architecture code - it's the irq controller 'driver' that the architecture code provides.
Ingo
btw., one new thing i got in testing due to irq/sparseirq is this new lockdep splat:
[ 0.000000] Initializing CPU#0 [ 0.000000] found new irq_desc for irq 0 [ 0.000000] INFO: trying to register non-static key. [ 0.000000] the code is fine but needs lockdep annotation. [ 0.000000] turning off the locking correctness validator. [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.27-rc3-tip-00191-g98ccb89-dirty #1 [ 0.000000] [<c0153c22>] register_lock_class+0x3d2/0x400 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c0154f3a>] __lock_acquire+0x22a/0x5d0 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c0155351>] lock_acquire+0x71/0xa0 [ 0.000000] [<c016d61f>] ? set_irq_chip+0x3f/0x90 [ 0.000000] [<c070f148>] _spin_lock_irqsave+0x58/0x90 [ 0.000000] [<c016d61f>] ? set_irq_chip+0x3f/0x90 [ 0.000000] [<c016d61f>] set_irq_chip+0x3f/0x90 [ 0.000000] [<c016d7e0>] ? handle_level_irq+0x0/0xe0 [ 0.000000] [<c016da1a>] set_irq_chip_and_handler_name+0x1a/0x40 [ 0.000000] [<c0a396c1>] init_ISA_irqs+0x51/0xa0 [ 0.000000] [<c0a4a365>] pre_intr_init_hook+0x25/0x30 [ 0.000000] [<c0a39723>] native_init_IRQ+0x13/0x370 [ 0.000000] [<c015569c>] ? lock_release+0xcc/0x1d0 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c070dc22>] ? __mutex_unlock_slowpath+0x92/0x110 [ 0.000000] [<c070dcad>] ? mutex_unlock+0xd/0x10 [ 0.000000] [<c0135f62>] ? cpu_maps_update_done+0x12/0x20 [ 0.000000] [<c06c6743>] ? register_cpu_notifier+0x23/0x30 [ 0.000000] [<c011e8ae>] init_IRQ+0xe/0x10 [ 0.000000] [<c0a357a5>] start_kernel+0x1c5/0x340 [ 0.000000] [<c0a35280>] ? unknown_bootoption+0x0/0x210 [ 0.000000] [<c0a3506b>] i386_start_kernel+0x6b/0x80 [ 0.000000] ======================= [ 0.000000] found new irq_desc for irq 1 [ 0.000000] found new irq_desc for irq 2 [ 0.000000] found new irq_desc for irq 3
this:
static void init_one_irq_desc(struct irq_desc *desc)
{
memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
#ifdef CONFIG_TRACE_IRQFLAGS
lockdep_set_class(&desc->lock, &irq_desc_lock_class); #endif
}
looks wrong - it should be unconditional (i've done that via the patch below). I dont remember why we made early_init_irq_lock_class() dependent on CONFIG_TRACE_IRQFLAGS before. Peter, do you have any memories?
Ingo
--------------------------->
Quoted 1 line
From
bba3b43f2383c2fd06c4befee45ef30d5cf59d32Mon Sep 17 00:00:00 2001
From: Ingo Molnar <[email protected]>
Date: Fri, 15 Aug 2008 11:34:35 +0200
Subject: [PATCH] sparseirq: fix lockdep
-tip testing found this lockdep splat:
[ 0.000000] Initializing CPU#0 [ 0.000000] found new irq_desc for irq 0 [ 0.000000] INFO: trying to register non-static key. [ 0.000000] the code is fine but needs lockdep annotation. [ 0.000000] turning off the locking correctness validator. [ 0.000000] Pid: 0, comm: swapper Not tainted 2.6.27-rc3-tip-00191-g98ccb89-dirty #1 [ 0.000000] [<c0153c22>] register_lock_class+0x3d2/0x400 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c0154f3a>] __lock_acquire+0x22a/0x5d0 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c0155351>] lock_acquire+0x71/0xa0 [ 0.000000] [<c016d61f>] ? set_irq_chip+0x3f/0x90 [ 0.000000] [<c070f148>] _spin_lock_irqsave+0x58/0x90 [ 0.000000] [<c016d61f>] ? set_irq_chip+0x3f/0x90 [ 0.000000] [<c016d61f>] set_irq_chip+0x3f/0x90 [ 0.000000] [<c016d7e0>] ? handle_level_irq+0x0/0xe0 [ 0.000000] [<c016da1a>] set_irq_chip_and_handler_name+0x1a/0x40 [ 0.000000] [<c0a396c1>] init_ISA_irqs+0x51/0xa0 [ 0.000000] [<c0a4a365>] pre_intr_init_hook+0x25/0x30 [ 0.000000] [<c0a39723>] native_init_IRQ+0x13/0x370 [ 0.000000] [<c015569c>] ? lock_release+0xcc/0x1d0 [ 0.000000] [<c0104d87>] ? mcount_call+0x5/0xa [ 0.000000] [<c070dc22>] ? __mutex_unlock_slowpath+0x92/0x110 [ 0.000000] [<c070dcad>] ? mutex_unlock+0xd/0x10 [ 0.000000] [<c0135f62>] ? cpu_maps_update_done+0x12/0x20 [ 0.000000] [<c06c6743>] ? register_cpu_notifier+0x23/0x30 [ 0.000000] [<c011e8ae>] init_IRQ+0xe/0x10 [ 0.000000] [<c0a357a5>] start_kernel+0x1c5/0x340 [ 0.000000] [<c0a35280>] ? unknown_bootoption+0x0/0x210 [ 0.000000] [<c0a3506b>] i386_start_kernel+0x6b/0x80 [ 0.000000] ======================= [ 0.000000] found new irq_desc for irq 1 [ 0.000000] found new irq_desc for irq 2 [ 0.000000] found new irq_desc for irq 3
this:
static void init_one_irq_desc(struct irq_desc *desc)
{
memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
#ifdef CONFIG_TRACE_IRQFLAGS
lockdep_set_class(&desc->lock, &irq_desc_lock_class); #endif
}
should be unconditional.
--- kernel/irq/handle.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
kernel/irq/handle.c +0 -2
@@ -75,9 +75,7 @@ static struct irq_desc irq_desc_init = {static void init_one_irq_desc (struct irq_desc *desc) {memcpy (desc, &irq_desc_init,sizeof (struct irq_desc )); -#ifdef CONFIG_TRACE_IRQFLAGS lockdep_set_class (&desc->lock, &irq_desc_lock_class); -#endif }extern int after_bootmem;
Quoted 4 lines · Ingo Molnar
looks wrong - it should be unconditional (i've done that via the patch below). I dont remember why we made
early_init_irq_lock_class()dependent onCONFIG_TRACE_IRQFLAGSbefore. Peter, do you have any memories?
Nope, git suggests I poke you about it.. :-)
commit 243c7621aac4ed1aa79524c9a1cecf7c05a28124
Author: Ingo Molnar <[email protected]> Date: Mon Jul 3 00:25:06 2006 -0700
[PATCH] lockdep: annotate genirq
Teach special (recursive) locking code to the lock validator. Has no effect on non-lockdep kernels.
include/linux/lockdep.h +6 -0
@@ -270,6 +270,12 @@ static inline int lockdep_internal(void)struct lock_class_key { };#endif /* !LOCKDEP */ +#if defined(CONFIG_TRACE_IRQFLAGS ) && defined(CONFIG_GENERIC_HARDIRQS ) +extern void early_init_irq_lock_class (void ); +#else +# define early_init_irq_lock_class () do { } while (0) +#endif +#ifdef CONFIG_TRACE_IRQFLAGS extern void early_boot_irqs_off (void );extern void early_boot_irqs_on (void );
init/main.c +1 -0
@@ -466,6 +466,7 @@ asmlinkage void __init start_kernel(void)local_irq_disable ();early_boot_irqs_off (); +early_init_irq_lock_class ();/* * Interrupts are still disabled. Do necessary setups, then
kernel/irq/handle.c +16 -0
@@ -249,3 +249,19 @@ out:return 1 ; } +#ifdef CONFIG_TRACE_IRQFLAGS + +/* +* lockdep: we want to handle all irq_desc locks as a single lock-class: +*/ +static struct lock_class_key irq_desc_lock_class; + +void early_init_irq_lock_class (void ) +{ +int i; + +for (i =0 ; i <NR_IRQS ; i++) +lockdep_set_class (&irq_desc[i].lock, &irq_desc_lock_class); +} + +#endif
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Ingo Molnar
looks wrong - it should be unconditional (i've done that via the patch below). I dont remember why we made
early_init_irq_lock_class()dependent onCONFIG_TRACE_IRQFLAGSbefore. Peter, do you have any memories?Nope, git suggests I poke you about it.. :-)
muhaha - i dont even know that guy who did this sloppy commit 2 years ago - "Ingo Molnar", or however he is called.
I believe my (mistaken) thinking would have been that desc->irq lockdep class does not matter as long as we dont do irq-tracing. Which might have been borderline correct then but is wrong now, for things like lockstat?
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Ingo Molnar
looks wrong - it should be unconditional (i've done that via the patch below). I dont remember why we made
early_init_irq_lock_class()dependent onCONFIG_TRACE_IRQFLAGSbefore. Peter, do you have any memories?Nope, git suggests I poke you about it.. :-)
Quoted 7 lines
muhaha - i dont even know that guy who did this sloppy commit 2 years ago - "Ingo Molnar", or however he is called.
I believe my (mistaken) thinking would have been that
desc->irqlockdep class does not matter as long as we dont do irq-tracing. Which might have been borderline correct then but is wrong now, for things like lockstat?
/me pokes a bit at kconfig dependancies, and yes, it seems you're right
- lockstat doesn't require irq tracing..
Quoted 15 lines · Peter Zijlstra
Quoted 14 lines · Ingo Molnar
Quoted 8 lines · Peter Zijlstra
Quoted 4 lines · Ingo Molnar
looks wrong - it should be unconditional (i've done that via the patch below). I dont remember why we made
early_init_irq_lock_class()dependent onCONFIG_TRACE_IRQFLAGSbefore. Peter, do you have any memories?Nope, git suggests I poke you about it.. :-)
muhaha - i dont even know that guy who did this sloppy commit 2 years ago - "Ingo Molnar", or however he is called.
Quoted 7 lines
Quoted 4 lines
I believe my (mistaken) thinking would have been that
desc->irqlockdep class does not matter as long as we dont do irq-tracing. Which might have been borderline correct then but is wrong now, for things like lockstat?/me pokes a bit at kconfig dependancies, and yes, it seems you're right
- lockstat doesn't require irq tracing..
can you check if
#ifdef CONFIG_TRACE_IRQFLAGS
void early_init_irq_lock_class(void)
{
#ifndef CONFIG_HAVE_DYN_ARRAY
int i;
for (i = 0; i < nr_irqs; i++)
lockdep_set_class(&irq_descX[i].lock, &irq_desc_lock_class);#endif
}
#endif
in kernel/irq/handle.c is right too?
YH