Real-Time Preemption, -RT-2.6.12-final-V0.7.50-24
Hi Ingo
I've refined io_apic.c a little more:
- merged all ioapic data into a struct ioapic_data_struct
- Allocate the ioapic cache memory from bootmem. Allocate only, what is needed ((nr of registers + 5)*sizeod(u64)).
- Removed "cache overrun by reg out of bounds" check.
this should never happen, as reg is calculated out of irq_2_pin[irq].pin.
- Do the index lookup
struct ioapic_data_struct *ioapic = ioapic_data[apic]; as early and as rarely as possible. In the consequence many functions parameter changed from io_apic_*(unsigned int apic,....
to
io_apic_*(struct ioapic_data_struct *ioapic,....
- New function setup_IO_APIC_early(int _ioapic).
It does the setup of the ioapic's struct ioapic_data_struct. if IOAPIC_CACHE is defined, it calls the also new function ioapic_cache_init().
ioapic_cache_init() initializes the cache completely. Thereby we may safely omit to query a caches elements validity before reading it.
Works fine here applied against -51-27
Karsten
arch/i386/kernel/io_apic.c renamed from linux-2.6.12-RT-51-23/arch/i386/kernel/io_apic.c +174 -165
@@ -31,6 +31,7 @@#include <linux/mc146818rtc.h> #include <linux/compiler.h> #include <linux/acpi.h> +#include <linux/bootmem.h> #include <linux/sysdev.h> #include <asm/io.h>
@@ -55,11 +56,6 @@int sis_apic_bug =-1 ;/* -* # of IRQ routing registers -*/ -int nr_ioapic_registers[MAX_IO_APICS ]; - -/* * Rough estimation of how many shared IRQs there are, can * be changed anytime. */
@@ -132,88 +128,74 @@# define IOAPIC_CACHE #endif -#ifdef IOAPIC_CACHE -# define MAX_IOAPIC_CACHE 512 -/* -* Cache register values: -*/ -static struct { -unsigned int reg; -unsigned int val[MAX_IOAPIC_CACHE ]; -} io_apic_cache[MAX_IO_APICS ] -____cacheline_aligned_in_smp ; + +struct ioapic_data_struct { +struct sys_device dev; +int nr_registers;// # of IRQ routing registers +volatile unsigned int *base; +struct IO_APIC_route_entry *entry; +#ifdef IOAPIC_CACHE +unsigned int reg_set; +u32 cached_val[0 ];#endif +}; -volatile unsigned int *io_apic_base[MAX_IO_APICS ]; +static struct ioapic_data_struct *ioapic_data[MAX_IO_APICS ]; -static inline unsigned int __raw_io_apic_read (unsigned int apic,unsigned int reg) + +static inline unsigned int __raw_io_apic_read (struct ioapic_data_struct *ioapic,unsigned int reg) { -volatile unsigned int *io_apic; -#ifdef IOAPIC_CACHE - io_apic_cache[apic].reg = reg; -#endif - io_apic = io_apic_base[apic]; - io_apic[0 ] = reg; -return io_apic[4 ]; +# ifdef IOAPIC_CACHE + ioapic->reg_set = reg; +# endif + ioapic->base[0 ] = reg; +return ioapic->base[4 ]; } -unsigned int raw_io_apic_read (unsigned int apic,unsigned int reg) + +# ifdef IOAPIC_CACHE +static void __init ioapic_cache_init (struct ioapic_data_struct *ioapic) { -unsigned int val =__raw_io_apic_read (apic, reg); +int reg; +for (reg =0 ; reg < (ioapic->nr_registers +10 ); reg++) + ioapic->cached_val[reg] =__raw_io_apic_read (ioapic, reg); +} +# endif -#ifdef IOAPIC_CACHE - io_apic_cache[apic].val[reg] = val; -#endif + +static unsigned int raw_io_apic_read (struct ioapic_data_struct *ioapic,unsigned int reg) +{ +unsigned int val =__raw_io_apic_read (ioapic, reg); + +# ifdef IOAPIC_CACHE + ioapic->cached_val[reg] = val; +# endif return val; } -unsigned int io_apic_read (unsigned int apic,unsigned int reg) +static unsigned int io_apic_read (struct ioapic_data_struct *ioapic,unsigned int reg) { -#ifdef IOAPIC_CACHE -if (unlikely (reg >=MAX_IOAPIC_CACHE )) { -static int once =1 ; - -if (once) { - once =0 ; -printk ("WARNING: ioapic register cache overflow: %d.\n" , - reg); -dump_stack (); - } -return __raw_io_apic_read (apic, reg); - } -if (io_apic_cache[apic].val[reg] && !sis_apic_bug) { - io_apic_cache[apic].reg =-1 ; -return io_apic_cache[apic].val[reg]; +# ifdef IOAPIC_CACHE +if (likely (!sis_apic_bug)) { + ioapic->reg_set =-1 ; +return ioapic->cached_val[reg]; } -#endif -return raw_io_apic_read (apic, reg); +# endif +return raw_io_apic_read (ioapic, reg); } -void io_apic_write (unsigned int apic,unsigned int reg,unsigned int val) +static void io_apic_write (struct ioapic_data_struct *ioapic,unsigned int reg,unsigned int val) { -volatile unsigned int *io_apic; -#ifdef IOAPIC_CACHE -if (unlikely (reg >=MAX_IOAPIC_CACHE )) { -static int once =1 ; - -if (once) { - once =0 ; -printk ("WARNING: ioapic register cache overflow: %d.\n" , - reg); -dump_stack (); - } - }else - io_apic_cache[apic].val[reg] = val; -#endif - io_apic = io_apic_base[apic]; -#ifdef IOAPIC_CACHE - io_apic_cache[apic].reg = reg; -#endif - io_apic[0 ] = reg; - io_apic[4 ] = val; +# ifdef IOAPIC_CACHE + ioapic->cached_val[reg] = val; + ioapic->reg_set = reg; +# endif + ioapic->base[0 ] = reg; + ioapic->base[4 ] = val; } +/* * Some systems need a POST flush or else level-triggered interrupts * generate lots of spurious interrupts due to the POST-ed write not
@@ -231,44 +213,42 @@* * Older SiS APIC requires we rewrite the index regiser */ -void io_apic_modify (unsigned int apic,unsigned int reg,unsigned int val) +static void io_apic_modify (struct ioapic_data_struct *ioapic,unsigned int reg,unsigned int val) { -volatile unsigned int *io_apic; -#ifdef IOAPIC_CACHE - io_apic_cache[apic].val[reg] = val; -#endif - io_apic = io_apic_base[apic];#ifdef IOAPIC_CACHE -if (io_apic_cache[apic].reg != reg || sis_apic_bug) { - io_apic_cache[apic].reg = reg; + ioapic->cached_val[reg] = val; +if (ioapic->reg_set != reg || sis_apic_bug) { + ioapic->reg_set = reg;#else if (unlikely (sis_apic_bug)) {#endif - io_apic[0 ] = reg; + ioapic->base[0 ] = reg; } - io_apic[4 ] = val; + ioapic->base[4 ] = val;#ifndef IOAPIC_POSTFLUSH if (unlikely(sis_apic_bug))#endif /* * Force POST flush by reading: */ - val = io_apic[4 ]; + val = ioapic->base[4 ]; }static void __modify_IO_APIC_irq (unsigned int irq,unsigned long enable,unsigned long disable) {struct irq_pin_list *entry = irq_2_pin + irq;unsigned int pin, val; +struct ioapic_data_struct *ioapic;for (;;) { pin = entry->pin;if (pin ==-1 )break ; - val =io_apic_read (entry->apic,0x10 + pin*2 ); + ioapic = ioapic_data[entry->apic]; + val =io_apic_read (ioapic,0x10 + pin*2 ); val &= ~disable; val |= enable; -io_apic_modify (entry->apic,0x10 + pin*2 , val); +io_apic_modify (ioapic,0x10 + pin*2 , val);if (!entry->next)break ; entry = irq_2_pin + entry->next;
@@ -305,15 +285,15 @@spin_unlock_irqrestore (&ioapic_lock, flags); } -static void clear_IO_APIC_pin (unsigned int apic,unsigned int pin) +static void clear_IO_APIC_pin (struct ioapic_data_struct *ioapic,unsigned int pin) {struct IO_APIC_route_entry entry;unsigned long flags;/* Check delivery_mode to be sure we're not clearing an SMI pin */ spin_lock_irqsave (&ioapic_lock, flags); - *(((int *)&entry) +0 ) =io_apic_read (apic,0x10 +2 * pin); - *(((int *)&entry) +1 ) =io_apic_read (apic,0x11 +2 * pin); + *(((int *)&entry) +0 ) =io_apic_read (ioapic,0x10 +2 * pin); + *(((int *)&entry) +1 ) =io_apic_read (ioapic,0x11 +2 * pin);spin_unlock_irqrestore (&ioapic_lock, flags);if (entry.delivery_mode == dest_SMI)return ;
@@ -324,8 +304,8 @@memset (&entry,0 ,sizeof (entry)); entry.mask =1 ;spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (apic,0x10 +2 * pin, *(((int *)&entry) +0 )); -io_apic_write (apic,0x11 +2 * pin, *(((int *)&entry) +1 )); +io_apic_write (ioapic,0x10 +2 * pin, *(((int *)&entry) +0 )); +io_apic_write (ioapic,0x11 +2 * pin, *(((int *)&entry) +1 ));spin_unlock_irqrestore (&ioapic_lock, flags); }
@@ -334,11 +314,12 @@int apic, pin;for (apic =0 ; apic < nr_ioapics; apic++) { +struct ioapic_data_struct *ioapic = ioapic_data[apic];#ifdef IOAPIC_CACHE - io_apic_cache[apic].reg =-1 ; + ioapic->reg_set =-1 ;#endif -for (pin =0 ; pin < nr_ioapic_registers[apic]; pin++) -clear_IO_APIC_pin (apic, pin); +for (pin =0 ; pin < ioapic->nr_registers; pin++) +clear_IO_APIC_pin (ioapic, pin); } }
@@ -357,7 +338,7 @@ pin = entry->pin;if (pin ==-1 )break ; -io_apic_write (entry->apic,0x10 +1 + pin*2 , apicid_value); +io_apic_write (ioapic_data[entry->apic],0x10 +1 + pin*2 , apicid_value);if (!entry->next)break ; entry = irq_2_pin + entry->next;
@@ -947,7 +928,7 @@return ;for (ioapic =0 ; ioapic < nr_ioapics; ioapic++) { -for (pin =0 ; pin < nr_ioapic_registers[ioapic]; pin++) { +for (pin =0 ; pin < ioapic_data[ioapic]->nr_registers; pin++) { irq_entry =find_irq_entry (ioapic, pin, mp_INT);if (irq_entry ==-1 )continue ;
@@ -1190,7 +1171,7 @@*/ i = irq =0 ;while (i < apic) - irq += nr_ioapic_registers[i++]; + irq += ioapic_data[i++]->nr_registers; irq += pin;/*
@@ -1233,7 +1214,7 @@int apic, idx, pin;for (apic =0 ; apic < nr_ioapics; apic++) { -for (pin =0 ; pin < nr_ioapic_registers[apic]; pin++) { +for (pin =0 ; pin < ioapic_data[apic]->nr_registers; pin++) { idx =find_irq_entry (apic,pin,mp_INT);if ((idx !=-1 ) && (irq ==pin_2_irq (idx,apic,pin)))return irq_trigger (idx);
@@ -1305,11 +1286,13 @@struct IO_APIC_route_entry entry;int apic, pin, idx, irq, first_notcon =1 , vector;unsigned long flags; +struct ioapic_data_struct *ioapic;apic_printk (APIC_VERBOSE ,KERN_DEBUG "init IO_APIC IRQs\n" );for (apic =0 ; apic < nr_ioapics; apic++) { -for (pin =0 ; pin < nr_ioapic_registers[apic]; pin++) { + ioapic = ioapic_data[apic]; +for (pin =0 ; pin < ioapic->nr_registers; pin++) {/* * add it to the IO-APIC irq-routing table:
@@ -1366,8 +1349,8 @@disable_8259A_irq (irq); }spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (apic,0x11 +2 *pin, *(((int *)&entry)+1 )); -io_apic_write (apic,0x10 +2 *pin, *(((int *)&entry)+0 )); +io_apic_write (ioapic,0x11 +2 *pin, *(((int *)&entry)+1 )); +io_apic_write (ioapic,0x10 +2 *pin, *(((int *)&entry)+0 ));spin_unlock_irqrestore (&ioapic_lock, flags); } }
@@ -1432,6 +1415,7 @@union IO_APIC_reg_02 reg_02;union IO_APIC_reg_03 reg_03;unsigned long flags; +struct ioapic_data_struct *ioapic;if (apic_verbosity ==APIC_QUIET )return ;
@@ -1439,7 +1423,7 @@printk (KERN_DEBUG "number of MP IRQ sources: %d.\n" , mp_irq_entries);for (i =0 ; i < nr_ioapics; i++)printk (KERN_DEBUG "number of IO-APIC #%d registers: %d.\n" , - mp_ioapics[i].mpc_apicid, nr_ioapic_registers[i]); + mp_ioapics[i].mpc_apicid, ioapic_data[i]->nr_registers);/* * We are a bit conservative about what we expect. We have to
@@ -1448,14 +1432,14 @@printk (KERN_INFO "testing the IO APIC.......................\n" );for (apic =0 ; apic < nr_ioapics; apic++) { - + ioapic = ioapic_data[apic];spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (apic,0 ); - reg_01.raw =io_apic_read (apic,1 ); + reg_00.raw =io_apic_read (ioapic,0 ); + reg_01.raw =io_apic_read (ioapic,1 );if (reg_01.bits.version >=0x10 ) - reg_02.raw =io_apic_read (apic,2 ); + reg_02.raw =io_apic_read (ioapic,2 );if (reg_01.bits.version >=0x20 ) - reg_03.raw =io_apic_read (apic,3 ); + reg_03.raw =io_apic_read (ioapic,3 );spin_unlock_irqrestore (&ioapic_lock, flags);printk (KERN_DEBUG "IO APIC #%d......\n" , mp_ioapics[apic].mpc_apicid);
@@ -1526,8 +1510,8 @@struct IO_APIC_route_entry entry;spin_lock_irqsave (&ioapic_lock, flags); - *(((int *)&entry)+0 ) =raw_io_apic_read (apic,0x10 +i*2 ); - *(((int *)&entry)+1 ) =raw_io_apic_read (apic,0x11 +i*2 ); + *(((int *)&entry)+0 ) =raw_io_apic_read (ioapic,0x10 +i*2 ); + *(((int *)&entry)+1 ) =raw_io_apic_read (ioapic,0x11 +i*2 );spin_unlock_irqrestore (&ioapic_lock, flags); printk(KERN_DEBUG " %02x %03X %02X ",
@@ -1720,9 +1704,7 @@static void __init enable_IO_APIC (void ) { -union IO_APIC_reg_01 reg_01;int i; -unsigned long flags;for (i =0 ; i <PIN_MAP_SIZE ; i++) { irq_2_pin[i].pin =-1 ;
@@ -1733,16 +1715,6 @@ pirq_entries[i] =-1 ;/* -* The number of IO-APIC IRQ registers (== #pins): -*/ -for (i =0 ; i < nr_ioapics; i++) { -spin_lock_irqsave (&ioapic_lock, flags); - reg_01.raw =io_apic_read (i,1 ); -spin_unlock_irqrestore (&ioapic_lock, flags); - nr_ioapic_registers[i] = reg_01.bits.entries+1 ; - } - -/* * Do not trust the IO-APIC being empty at bootup */ clear_IO_APIC ();
@@ -1777,6 +1749,7 @@int i;unsigned char old_id;unsigned long flags; +struct ioapic_data_struct *ioapic;/* * This is broken; anything with a real cpu count has to
@@ -1788,10 +1761,10 @@* Set the IOAPIC ID to the value stored in the MPC table. */ for (apic =0 ; apic < nr_ioapics; apic++) { - + ioapic = ioapic_data[apic];/* Read the register 0 value */ spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (apic,0 ); + reg_00.raw =io_apic_read (ioapic,0 );spin_unlock_irqrestore (&ioapic_lock, flags); old_id = mp_ioapics[apic].mpc_apicid;
@@ -1856,14 +1829,14 @@ reg_00.bits.ID = mp_ioapics[apic].mpc_apicid;spin_lock_irqsave (&ioapic_lock, flags); -io_apic_write (apic,0 , reg_00.raw); +io_apic_write (ioapic,0 , reg_00.raw);spin_unlock_irqrestore (&ioapic_lock, flags);/* * Sanity check */ spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (apic,0 ); + reg_00.raw =io_apic_read (ioapic,0 );spin_unlock_irqrestore (&ioapic_lock, flags);if (reg_00.bits.ID != mp_ioapics[apic].mpc_apicid)printk ("could not set ID!\n" );
@@ -2230,7 +2203,7 @@* cycles as some i82489DX-based boards have glue logic that keeps the * 8259A interrupt line asserted until INTA. --macro */ -static inline void unlock_ExtINT_logic (void ) +static void __init unlock_ExtINT_logic (void ) {int pin, i;struct IO_APIC_route_entry entry0, entry1;
@@ -2291,7 +2264,7 @@* is so screwy. Thanks to Brian Perkins for testing/hacking this beast * fanatically on his truly buggy board. */ -static inline void check_timer (void ) +static void __init check_timer (void ) {int pin1, pin2;int vector;
@@ -2402,6 +2375,43 @@ "report. Then try booting with the 'noapic' option"); } +void __init setup_IO_APIC_early (int _ioapic) +{ +union IO_APIC_reg_01 reg_01; +unsigned long flags; +int size, nr_ioapic_registers; +volatile int *ioapic; +if (ioapic_data[_ioapic]) { +printk ("been in %s before !!!!!\n" , __FUNCTION__); +return ; + } + +/* +* The number of IO-APIC IRQ registers (== #pins): +*/ + ioapic =IO_APIC_BASE (_ioapic); +spin_lock_irqsave (&ioapic_lock, flags); + ioapic[0 ] =1 ; + reg_01.raw = ioapic[4 ]; +spin_unlock_irqrestore (&ioapic_lock, flags); + nr_ioapic_registers = reg_01.bits.entries+1 ; + +/* +* Initialsize ioapic_data struct: +*/ + size =sizeof (struct ioapic_data_struct ); +#ifdef IOAPIC_CACHE + size +=0x10 *sizeof (u32) + nr_ioapic_registers *sizeof (struct IO_APIC_route_entry ); +#endif + ioapic_data[_ioapic] =alloc_bootmem (size); +memset (ioapic_data[_ioapic],0 , size); + ioapic_data[_ioapic]->nr_registers = nr_ioapic_registers; + ioapic_data[_ioapic]->base = ioapic; +#ifdef IOAPIC_CACHE +ioapic_cache_init (ioapic_data[_ioapic]); +#endif +} +/* * * IRQ's that are handled by the PIC in the MPS IOAPIC case.
@@ -2449,25 +2459,22 @@late_initcall (io_apic_bug_finalize); -struct sysfs_ioapic_data { -struct sys_device dev; -struct IO_APIC_route_entry entry[0 ]; -}; -static struct sysfs_ioapic_data * mp_ioapic_data[MAX_IO_APICS ]; -static int ioapic_suspend (struct sys_device *dev,pm_message_t state) {struct IO_APIC_route_entry *entry; -struct sysfs_ioapic_data *data; +struct ioapic_data_struct *data;unsigned long flags;int i; +struct ioapic_data_struct *ioapic; - data = container_of(dev, struct sysfs_ioapic_data, dev); + data = container_of(dev, struct ioapic_data_struct, dev); entry = data->entry; + + ioapic = ioapic_data[dev->id];spin_lock_irqsave (&ioapic_lock, flags); -for (i =0 ; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) { - *(((int *)entry) +1 ) =io_apic_read (dev->id,0x11 +2 * i); - *(((int *)entry) +0 ) =io_apic_read (dev->id,0x10 +2 * i); +for (i =0 ; i < ioapic_data[dev->id]->nr_registers; i ++, entry ++) { + *(((int *)entry) +1 ) =io_apic_read (ioapic,0x11 +2 * i); + *(((int *)entry) +0 ) =io_apic_read (ioapic,0x10 +2 * i); }spin_unlock_irqrestore (&ioapic_lock, flags);
@@ -2477,23 +2484,25 @@static int ioapic_resume (struct sys_device *dev) {struct IO_APIC_route_entry *entry; -struct sysfs_ioapic_data *data; +struct ioapic_data_struct *data;unsigned long flags;union IO_APIC_reg_00 reg_00;int i; - - data = container_of(dev, struct sysfs_ioapic_data, dev); +struct ioapic_data_struct *ioapic; + + data = container_of(dev, struct ioapic_data_struct, dev); entry = data->entry; + ioapic = ioapic_data[dev->id];spin_lock_irqsave (&ioapic_lock, flags); - reg_00.raw =io_apic_read (dev->id,0 ); + reg_00.raw =io_apic_read (ioapic,0 );if (reg_00.bits.ID != mp_ioapics[dev->id].mpc_apicid) { reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid; -io_apic_write (dev->id,0 , reg_00.raw); +io_apic_write (ioapic,0 , reg_00.raw); } -for (i =0 ; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) { -io_apic_write (dev->id,0x11 +2 *i, *(((int *)entry)+1 )); -io_apic_write (dev->id,0x10 +2 *i, *(((int *)entry)+0 )); +for (i =0 ; i < ioapic_data[dev->id]->nr_registers; i ++, entry ++) { +io_apic_write (ioapic,0x11 +2 *i, *(((int *)entry)+1 )); +io_apic_write (ioapic,0x10 +2 *i, *(((int *)entry)+0 )); }spin_unlock_irqrestore (&ioapic_lock, flags);
@@ -2516,21 +2525,20 @@return error;for (i =0 ; i < nr_ioapics; i++ ) { - size =sizeof (struct sys_device ) + nr_ioapic_registers[i] - *sizeof (struct IO_APIC_route_entry ); - mp_ioapic_data[i] =kmalloc (size,GFP_KERNEL ); -if (!mp_ioapic_data[i]) { + size = ioapic_data[i]->nr_registers *sizeof (struct IO_APIC_route_entry ); + ioapic_data[i]->entry =kmalloc (size,GFP_KERNEL ); +if (!ioapic_data[i]->entry) {printk (KERN_ERR "Can't suspend/resume IOAPIC %d\n" , i);continue ; } -memset (mp_ioapic_data[i],0 , size); - dev = &mp_ioapic_data[i]->dev; +memset (ioapic_data[i]->entry,0 , size); + dev = &ioapic_data[i]->dev; dev->id = i; dev->cls = &ioapic_sysdev_class; error =sysdev_register (dev);if (error) { -kfree (mp_ioapic_data[i]); - mp_ioapic_data[i] =NULL ; +kfree (ioapic_data[i]->entry); + ioapic_data[i]->entry =NULL ;printk (KERN_ERR "Can't suspend/resume IOAPIC %d\n" , i);continue ; }
@@ -2547,13 +2555,14 @@#ifdef CONFIG_ACPI_BOOT -int __init io_apic_get_unique_id (int ioapic,int apic_id) +int __init io_apic_get_unique_id (int apic,int apic_id) {union IO_APIC_reg_00 reg_00;static physid_mask_t apic_id_map =PHYSID_MASK_NONE ;physid_mask_t tmp;unsigned long flags;int i =0 ; +struct ioapic_data_struct *ioapic = ioapic_data[apic];/* * The P4 platform supports up to 256 APIC IDs on two separate APIC
@@ -2573,7 +2582,7 @@if (apic_id >=get_physical_broadcast ()) {printk (KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " -"%d\n" , ioapic, apic_id, reg_00.bits.ID); +"%d\n" , apic, apic_id, reg_00.bits.ID); apic_id = reg_00.bits.ID; }
@@ -2592,7 +2601,7 @@panic ("Max apic_id exceeded!\n" );printk (KERN_WARNING "IOAPIC[%d]: apic_id %d already used, " -"trying %d\n" , ioapic, apic_id, i); +"trying %d\n" , apic, apic_id, i); apic_id = i; }
@@ -2610,50 +2619,50 @@/* Sanity check */ if (reg_00.bits.ID != apic_id) -panic ("IOAPIC[%d]: Unable change apic_id!\n" , ioapic); +panic ("IOAPIC[%d]: Unable change apic_id!\n" , apic); }apic_printk (APIC_VERBOSE ,KERN_INFO -"IOAPIC[%d]: Assigned apic_id %d\n" , ioapic, apic_id); +"IOAPIC[%d]: Assigned apic_id %d\n" , apic, apic_id);return apic_id; } -int __init io_apic_get_version (int ioapic) +int __init io_apic_get_version (int apic) {union IO_APIC_reg_01 reg_01;unsigned long flags;spin_lock_irqsave (&ioapic_lock, flags); - reg_01.raw =io_apic_read (ioapic,1 ); + reg_01.raw =io_apic_read (ioapic_data[apic],1 );spin_unlock_irqrestore (&ioapic_lock, flags);return reg_01.bits.version; } -int __init io_apic_get_redir_entries (int ioapic) +int __init io_apic_get_redir_entries (int apic) {union IO_APIC_reg_01 reg_01;unsigned long flags;spin_lock_irqsave (&ioapic_lock, flags); - reg_01.raw =io_apic_read (ioapic,1 ); + reg_01.raw =io_apic_read (ioapic_data[apic],1 );spin_unlock_irqrestore (&ioapic_lock, flags);return reg_01.bits.entries; } -int io_apic_set_pci_routing (int ioapic,int pin,int irq,int edge_level,int active_high_low) +int io_apic_set_pci_routing (int apic,int pin,int irq,int edge_level,int active_high_low) {struct IO_APIC_route_entry entry;unsigned long flags; - +struct ioapic_data_struct *ioapic = ioapic_data[apic];if (!IO_APIC_IRQ (irq)) {printk (KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n" , - ioapic); + apic);return -EINVAL ; }
@@ -2676,18 +2685,18 @@* IRQs < 16 are already in the irq_2_pin[] map */ if (irq >=16 ) -add_pin_to_irq (irq, ioapic, pin); +add_pin_to_irq (irq, apic, pin); entry.vector =assign_irq_vector (irq);apic_printk (APIC_DEBUG ,KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry " -"(%d-%d -> 0x%x -> IRQ %d Mode:%i Active:%i)\n" , ioapic, - mp_ioapics[ioapic].mpc_apicid, pin, entry.vector, irq, +"(%d-%d -> 0x%x -> IRQ %d Mode:%i Active:%i)\n" , apic, + mp_ioapics[apic].mpc_apicid, pin, entry.vector, irq, edge_level, active_high_low);ioapic_register_intr (irq, entry.vector, edge_level); -if (!ioapic && (irq <16 )) +if (!apic && (irq <16 ))disable_8259A_irq (irq);spin_lock_irqsave (&ioapic_lock, flags);
arch/i386/kernel/mpparse.c renamed from linux-2.6.12-RT-51-23/arch/i386/kernel/mpparse.c +2 -2
@@ -263,7 +263,7 @@return ; } mp_ioapics[nr_ioapics] = *m; - io_apic_base[nr_ioapics] =IO_APIC_BASE (nr_ioapics); +setup_IO_APIC_early (nr_ioapics); nr_ioapics++; }
@@ -915,7 +915,7 @@ mp_ioapics[idx].mpc_apicaddr = address;set_fixmap_nocache (FIX_IO_APIC_BASE_0 + idx, address); - io_apic_base[idx] =IO_APIC_BASE (idx); +setup_IO_APIC_early (idx); mp_ioapics[idx].mpc_apicid =io_apic_get_unique_id (idx, id); mp_ioapics[idx].mpc_apicver =io_apic_get_version (idx);
include/asm-i386/io_apic.h renamed from linux-2.6.12-RT-51-23/include/asm-i386/io_apic.h +1 -6
@@ -155,15 +155,14 @@/* MP IRQ source entries */ extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES ]; -extern volatile unsigned int *io_apic_base[MAX_IO_APICS ]; -/* non-0 if default (table-less) MP configuration */ extern int mpc_default_type; -extern unsigned int raw_io_apic_read (unsigned int apic,unsigned int reg); -extern unsigned int io_apic_read (unsigned int apic,unsigned int reg); -extern void io_apic_write (unsigned int apic,unsigned int reg,unsigned int value); -extern void io_apic_modify (unsigned int apic,unsigned int reg,unsigned int value); +extern void setup_IO_APIC_early (int ioapic);extern int sis_apic_bug;/* 1 if "noapic" boot option passed */
Quoted 3 lines · Karsten Wiese
Hi Ingo
I've refined
io_apic.ca little more:
great. I've applied these changes and have released the -28 patch. (note that the last chunk of your patch was malformed, have applied it by hand.)
i'm wondering what your thoughts are about IOAPIC_POSTFLUSH - i had to turn it on unconditionally again, to get rid of spurious interrupts and outright interrupt storms (and resulting lockups) on some systems. IOAPIC_POSTFLUSH is now causing much of the IO-APIC related IRQ handling overhead.
Ingo
Quoted 10 lines · Ingo Molnar
Quoted 3 lines · Karsten Wiese
Hi Ingo
I've refined
io_apic.ca little more:great. I've applied these changes and have released the -28 patch. (note that the last chunk of your patch was malformed, have applied it by hand.)
Quoted 5 lines
i'm wondering what your thoughts are about
IOAPIC_POSTFLUSH- i had to turn it on unconditionally again, to get rid of spurious interrupts and outright interrupt storms (and resulting lockups) on some systems.IOAPIC_POSTFLUSHis now causing much of the IO-APIC related IRQ handling overhead.
I observed a situation on a dual xeon where IOAPIC_POSTFLUSH , if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.
This would only happen in PREEMPT_RT .
Daniel
Quoted 8 lines · Daniel Walker
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.This would only happen in
PREEMPT_RT.
does it happen with the latest kernel too? There were a couple of things broken in the IOAPIC code in various earlier versions.
Ingo
Quoted 9 lines · Ingo Molnar
Quoted 7 lines · Daniel Walker
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.
Quoted 4 lines
Quoted 1 line
This would only happen in
PREEMPT_RT.does it happen with the latest kernel too? There were a couple of things broken in the IOAPIC code in various earlier versions.
I haven't tested it recently . This was on an older version of RT though . I could try it if it's interesting ? Or do you think it's already fixed?
Daniel
Quoted 3 lines · Daniel Walker
I haven't tested it recently . This was on an older version of RT though . I could try it if it's interesting ? Or do you think it's already fixed?
it would be definitely interesting to see how robust the latest IO-APIC code is.
Ingo
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Daniel Walker
I haven't tested it recently . This was on an older version of RT though . I could try it if it's interesting ? Or do you think it's already fixed?
it would be definitely interesting to see how robust the latest IO-APIC code is.
I'm sure you test that all the time, but I'll try it ..
Daniel
Quoted 11 lines · Daniel Walker
Quoted 8 lines · Ingo Molnar
Quoted 3 lines · Daniel Walker
I haven't tested it recently . This was on an older version of RT though . I could try it if it's interesting ? Or do you think it's already fixed?
it would be definitely interesting to see how robust the latest IO-APIC code is.
I'm sure you test that all the time, but I'll try it ..
I tried it, and it appears to be fixed in current RT ..
Daniel
Quoted 8 lines · Daniel Walker
Quoted 7 lines · Daniel Walker
Quoted 6 lines · Ingo Molnar
Quoted 3 lines · Daniel Walker
I haven't tested it recently . This was on an older version of RT though . I could try it if it's interesting ? Or do you think it's already fixed?
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be definitely interesting to see how robust the latest IO-APIC code is.
I'm sure you test that all the time, but I'll try it ..
I tried it, and it appears to be fixed in current RT ..
cool, thanks.
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Daniel Walker
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.This would only happen in
PREEMPT_RT.does it happen with the latest kernel too? There were a couple of things broken in the IOAPIC code in various earlier versions.
Ingo
Is this why I have been able to boot the latest versions without the noapic option (and without noticeable keyboard repeat problems) or has it just been dumb luck?
Signature · 1 line
kr
Quoted 14 lines · K.R. Foley
Quoted 13 lines · Ingo Molnar
Quoted 8 lines · Daniel Walker
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.This would only happen in
PREEMPT_RT.
Quoted 8 lines
Quoted 4 lines
does it happen with the latest kernel too? There were a couple of things broken in the IOAPIC code in various earlier versions.
Ingo
Is this why I have been able to boot the latest versions without the noapic option (and without noticeable keyboard repeat problems) or has it just been dumb luck?
yes, i think it's related - the IO-APIC code is now more robust than ever, and that's why any known-broken system would be important to re-check.
Ingo
Quoted 16 lines · Ingo Molnar
Quoted 13 lines · K.R. Foley
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Daniel Walker
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.This would only happen in
PREEMPT_RT.does it happen with the latest kernel too? There were a couple of things broken in the IOAPIC code in various earlier versions.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Ingo
Is this why I have been able to boot the latest versions without the noapic option (and without noticeable keyboard repeat problems) or has it just been dumb luck?
yes, i think it's related - the IO-APIC code is now more robust than ever, and that's why any known-broken system would be important to re-check.
Ingo
Well I have booted -27 a couple of times and -28 once now without supplying the noapic boot option and I haven't seen any of the keyboard repeat problems that I reported late last week. This was on my dual 2.6 Xeon w/HT. I have never seen this behavior on any of my older systems. Because of the fact that the problem showed up sporadically, I can't say for sure that it is gone. However, so far so good. I will report any changes that I see.
Signature · 1 line
kr
Quoted 9 lines · Ingo Molnar
Quoted 3 lines · K.R. Foley
Is this why I have been able to boot the latest versions without the noapic option (and without noticeable keyboard repeat problems) or has it just been dumb luck?
yes, i think it's related - the IO-APIC code is now more robust than ever, and that's why any known-broken system would be important to re-check.
Just brought the SIS based Xeon box up on -51-28 with CONFIG_IOAPIC_FAST and without the noapic option, and all is well. On -50-43, noapic was needed to avoid the spurious interrupt and APIC error on CPU0 messages.
Are there any non-SIS chipsets out there that need the sis_apic_bug checks? What about IOAPIC_POSTFLUSH?
--ww
Am Dienstag, 12. Juli 2005 16:25 schrieb Daniel Walker:
Quoted 17 lines · Ingo Molnar
Quoted 10 lines · Karsten Wiese
Quoted 4 lines
Hi Ingo
I've refined
io_apic.ca little more:great. I've applied these changes and have released the -28 patch. (note that the last chunk of your patch was malformed, have applied it by hand.)
Quoted 5 lines
i'm wondering what your thoughts are about
IOAPIC_POSTFLUSH- i had to turn it on unconditionally again, to get rid of spurious interrupts and outright interrupt storms (and resulting lockups) on some systems.IOAPIC_POSTFLUSHis now causing much of the IO-APIC related IRQ handling overhead.
Quoted 8 lines
I observed a situation on a dual xeon where
IOAPIC_POSTFLUSH, if on, would actually cause spurious interrupts. It was odd cause it's suppose to stop them .. If there was a lot of interrupt traffic on one IRQ , it would cause interrupt traffic on another IRQ. This would result in "nobody cared" messages , and the storming IRQ line would get shutdown.This would only happen in
PREEMPT_RT.
i've only tested on 2005ish Ahlon64_UP@k8T800: it doesn't need any of the quirks
IOAPIC_POSTFLUSH, sis_bug, level-edge cleanup.IOAPIC_POSTFLUSH caused no negative influence neither.
i've an io_apic_one.c here, that doesn't have any of the quirks and is stripped down to handle just one ioapic. It runs just fine on PREEMPT_RT.
Could be used as a "Do i crash/suffer without the quirks?" test for 1 ioapic equipped machines. Should i post it?
On vanilla level-interrupts behave "nervously" showing the "doubled rate" effect:
For level interrupts vanilla just sends an EOI to the apic. Nothing else should be necessary (io)apic wise. Only here, when the edge-level triggered hardware-handler acknowledges its client
(== resets the interrupt line) the doubled level interrupt is triggered on the same pin. Thus the same interrupt routine runs again as soon as EOI has been sent and IFlag is open again. hardware-handler receives it, does nothing and returns with "uninterested" <<insert correct macro here<. everything works correctly though. its just some cycles wasted.
Odd, no? I found that the correct interrupt handling can be achieve by obeying the PREEMPT_RT method:
level-interrupt triggers
ioapic pin is masked
harware-handler deasserts pin/line
apic gets eoi
ioapic pin is unmasked
this could be optimized by ioapic caching , but there must be some configuration tweak...... that i don't know of. there are no via docs for me. erm.. anybody sends me a link _offlist_ ?-) Or even _knows that tweak_ ?
And again IOAPIC_POSTFLUSH has no influence here on the doubled interrupt (VIA K8T800 only ?) bug.
Karsten
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de
Quoted 7 lines · Karsten Wiese
i've only tested on 2005ish Ahlon64_UP@k8T800: it doesn't need any of the quirks
IOAPIC_POSTFLUSH,sis_bug, level-edge cleanup.IOAPIC_POSTFLUSHcaused no negative influence neither.
i've anio_apic_one.chere, that doesn't have any of the quirks and is stripped down to handle just one ioapic. It runs just fine onPREEMPT_RT.
Could be used as a "Do i crash/suffer without the quirks?" test for 1 ioapic equipped machines. Should i post it?
Please do. I'll give it a spin on several machines and let you know how it goes ;-}
--ww
Am Mittwoch, 13. Juli 2005 02:08 schrieb William Weston:
Quoted 10 lines · Karsten Wiese
Quoted 8 lines
i've only tested on 2005ish Ahlon64_UP@k8T800: it doesn't need any of the quirks
IOAPIC_POSTFLUSH,sis_bug, level-edge cleanup.IOAPIC_POSTFLUSHcaused no negative influence neither.
i've anio_apic_one.chere, that doesn't have any of the quirks and is stripped down to handle just one ioapic. It runs just fine onPREEMPT_RT.
Could be used as a "Do i crash/suffer without the quirks?" test for 1 ioapic equipped machines. Should i post it?
Quoted 3 lines
Please do. I'll give it a spin on several machines and let you know how it goes ;-}
This is it. Apply it on top of -51-30 and 'make oldconfig'. You'll be asked about the new CONFIG_ONE_IOAPIC. Answering yes, io_apic_one.c will be used, which is
((io_apic.c minus quirks) minus multi_io_apic_capability)
.
It'll propably crash some machines, as the quirks are there for some reason... With CONFIG_ONE_IOAPIC unset, you'll get the same kernel as with my previously sent patch.
have fun :-)
Karsten
Quoted 7 lines · Karsten Wiese
This is it. Apply it on top of -51-30 and 'make oldconfig'. You'll be asked about the new
CONFIG_ONE_IOAPIC. Answering yes,io_apic_one.cwill be used, which is ((io_apic.cminus quirks) minusmulti_io_apic_capability) . It'll propably crash some machines, as the quirks are there for some reason... WithCONFIG_ONE_IOAPICunset, you'll get the same kernel as with my previously sent patch. have fun :-)
this could only be offered if it's merged into the existing io_apic.c. The current IOAPIC_FAST option will go away eventually, but ONE_IOAPIC would/could be intentionally incompatible.
Ingo