Skip to content

Commit f5b9ed7

Browse files
Ingo MolnarLinus Torvalds
authored andcommitted
[PATCH] genirq: convert the i386 architecture to irq-chips
This patch converts all the i386 PIC controllers (except VisWS and Voyager, which I could not test - but which should still work as old-style IRQ layers) to the new and simpler irq-chip interrupt handling layer. [akpm@osdl.org: build fix] [mingo@elte.hu: enable fasteoi handler for i386 level-triggered IO-APIC irqs] Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Roland Dreier <rolandd@cisco.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent f29bd1b commit f5b9ed7

4 files changed

Lines changed: 80 additions & 146 deletions

File tree

‎arch/i386/kernel/i8259.c‎

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,15 @@
3434
* moves to arch independent land
3535
*/
3636

37-
DEFINE_SPINLOCK(i8259A_lock);
38-
39-
static void end_8259A_irq (unsigned int irq)
40-
{
41-
if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
42-
irq_desc[irq].action)
43-
enable_8259A_irq(irq);
44-
}
45-
46-
#define shutdown_8259A_irq disable_8259A_irq
47-
4837
static int i8259A_auto_eoi;
49-
38+
DEFINE_SPINLOCK(i8259A_lock);
5039
static void mask_and_ack_8259A(unsigned int);
5140

52-
unsigned int startup_8259A_irq(unsigned int irq)
53-
{
54-
enable_8259A_irq(irq);
55-
return 0; /* never anything pending */
56-
}
57-
58-
static struct hw_interrupt_type i8259A_irq_type = {
59-
.typename = "XT-PIC",
60-
.startup = startup_8259A_irq,
61-
.shutdown = shutdown_8259A_irq,
62-
.enable = enable_8259A_irq,
63-
.disable = disable_8259A_irq,
64-
.ack = mask_and_ack_8259A,
65-
.end = end_8259A_irq,
41+
static struct irq_chip i8259A_chip = {
42+
.name = "XT-PIC",
43+
.mask = disable_8259A_irq,
44+
.unmask = enable_8259A_irq,
45+
.mask_ack = mask_and_ack_8259A,
6646
};
6747

6848
/*
@@ -133,7 +113,7 @@ void make_8259A_irq(unsigned int irq)
133113
{
134114
disable_irq_nosync(irq);
135115
io_apic_irqs &= ~(1<<irq);
136-
irq_desc[irq].chip = &i8259A_irq_type;
116+
set_irq_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
137117
enable_irq(irq);
138118
}
139119

@@ -327,12 +307,12 @@ void init_8259A(int auto_eoi)
327307
outb_p(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR); /* (slave's support for AEOI in flat mode is to be investigated) */
328308
if (auto_eoi)
329309
/*
330-
* in AEOI mode we just have to mask the interrupt
310+
* In AEOI mode we just have to mask the interrupt
331311
* when acking.
332312
*/
333-
i8259A_irq_type.ack = disable_8259A_irq;
313+
i8259A_chip.mask_ack = disable_8259A_irq;
334314
else
335-
i8259A_irq_type.ack = mask_and_ack_8259A;
315+
i8259A_chip.mask_ack = mask_and_ack_8259A;
336316

337317
udelay(100); /* wait for 8259A to initialize */
338318

@@ -389,12 +369,13 @@ void __init init_ISA_irqs (void)
389369
/*
390370
* 16 old-style INTA-cycle interrupts:
391371
*/
392-
irq_desc[i].chip = &i8259A_irq_type;
372+
set_irq_chip_and_handler(i, &i8259A_chip,
373+
handle_level_irq);
393374
} else {
394375
/*
395376
* 'high' PCI IRQs filled in on demand
396377
*/
397-
irq_desc[i].chip = &no_irq_type;
378+
irq_desc[i].chip = &no_irq_chip;
398379
}
399380
}
400381
}

‎arch/i386/kernel/io_apic.c‎

Lines changed: 56 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,7 @@ int assign_irq_vector(int irq)
12191219
return vector;
12201220
}
12211221

1222-
static struct hw_interrupt_type ioapic_level_type;
1223-
static struct hw_interrupt_type ioapic_edge_type;
1222+
static struct irq_chip ioapic_chip;
12241223

12251224
#define IOAPIC_AUTO -1
12261225
#define IOAPIC_EDGE 0
@@ -1234,9 +1233,11 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
12341233

12351234
if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
12361235
trigger == IOAPIC_LEVEL)
1237-
irq_desc[idx].chip = &ioapic_level_type;
1236+
set_irq_chip_and_handler(idx, &ioapic_chip,
1237+
handle_fasteoi_irq);
12381238
else
1239-
irq_desc[idx].chip = &ioapic_edge_type;
1239+
set_irq_chip_and_handler(idx, &ioapic_chip,
1240+
handle_edge_irq);
12401241
set_intr_gate(vector, interrupt[idx]);
12411242
}
12421243

@@ -1346,7 +1347,8 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
13461347
* The timer IRQ doesn't have to know that behind the
13471348
* scene we have a 8259A-master in AEOI mode ...
13481349
*/
1349-
irq_desc[0].chip = &ioapic_edge_type;
1350+
irq_desc[0].chip = &ioapic_chip;
1351+
set_irq_handler(0, handle_edge_irq);
13501352

13511353
/*
13521354
* Add it to the IO-APIC irq-routing table:
@@ -1918,15 +1920,19 @@ static int __init timer_irq_works(void)
19181920
*/
19191921

19201922
/*
1923+
* Startup quirk:
1924+
*
19211925
* Starting up a edge-triggered IO-APIC interrupt is
19221926
* nasty - we need to make sure that we get the edge.
19231927
* If it is already asserted for some reason, we need
19241928
* return 1 to indicate that is was pending.
19251929
*
19261930
* This is not complete - we should be able to fake
19271931
* an edge even if it isn't on the 8259A...
1932+
*
1933+
* (We do this for level-triggered IRQs too - it cannot hurt.)
19281934
*/
1929-
static unsigned int startup_edge_ioapic_irq(unsigned int irq)
1935+
static unsigned int startup_ioapic_irq(unsigned int irq)
19301936
{
19311937
int was_pending = 0;
19321938
unsigned long flags;
@@ -1943,42 +1949,13 @@ static unsigned int startup_edge_ioapic_irq(unsigned int irq)
19431949
return was_pending;
19441950
}
19451951

1946-
/*
1947-
* Once we have recorded IRQ_PENDING already, we can mask the
1948-
* interrupt for real. This prevents IRQ storms from unhandled
1949-
* devices.
1950-
*/
1951-
static void ack_edge_ioapic_irq(unsigned int irq)
1952+
static void ack_ioapic_irq(unsigned int irq)
19521953
{
19531954
move_irq(irq);
1954-
if ((irq_desc[irq].status & (IRQ_PENDING | IRQ_DISABLED))
1955-
== (IRQ_PENDING | IRQ_DISABLED))
1956-
mask_IO_APIC_irq(irq);
19571955
ack_APIC_irq();
19581956
}
19591957

1960-
/*
1961-
* Level triggered interrupts can just be masked,
1962-
* and shutting down and starting up the interrupt
1963-
* is the same as enabling and disabling them -- except
1964-
* with a startup need to return a "was pending" value.
1965-
*
1966-
* Level triggered interrupts are special because we
1967-
* do not touch any IO-APIC register while handling
1968-
* them. We ack the APIC in the end-IRQ handler, not
1969-
* in the start-IRQ-handler. Protection against reentrance
1970-
* from the same interrupt is still provided, both by the
1971-
* generic IRQ layer and by the fact that an unacked local
1972-
* APIC does not accept IRQs.
1973-
*/
1974-
static unsigned int startup_level_ioapic_irq (unsigned int irq)
1975-
{
1976-
unmask_IO_APIC_irq(irq);
1977-
1978-
return 0; /* don't check for pending */
1979-
}
1980-
1981-
static void end_level_ioapic_irq (unsigned int irq)
1958+
static void ack_ioapic_quirk_irq(unsigned int irq)
19821959
{
19831960
unsigned long v;
19841961
int i;
@@ -2018,35 +1995,27 @@ static void end_level_ioapic_irq (unsigned int irq)
20181995
}
20191996
}
20201997

2021-
#ifdef CONFIG_PCI_MSI
2022-
static unsigned int startup_edge_ioapic_vector(unsigned int vector)
1998+
static unsigned int startup_ioapic_vector(unsigned int vector)
20231999
{
20242000
int irq = vector_to_irq(vector);
20252001

2026-
return startup_edge_ioapic_irq(irq);
2002+
return startup_ioapic_irq(irq);
20272003
}
20282004

2029-
static void ack_edge_ioapic_vector(unsigned int vector)
2005+
static void ack_ioapic_vector(unsigned int vector)
20302006
{
20312007
int irq = vector_to_irq(vector);
20322008

20332009
move_native_irq(vector);
2034-
ack_edge_ioapic_irq(irq);
2010+
ack_ioapic_irq(irq);
20352011
}
20362012

2037-
static unsigned int startup_level_ioapic_vector (unsigned int vector)
2038-
{
2039-
int irq = vector_to_irq(vector);
2040-
2041-
return startup_level_ioapic_irq (irq);
2042-
}
2043-
2044-
static void end_level_ioapic_vector (unsigned int vector)
2013+
static void ack_ioapic_quirk_vector(unsigned int vector)
20452014
{
20462015
int irq = vector_to_irq(vector);
20472016

20482017
move_native_irq(vector);
2049-
end_level_ioapic_irq(irq);
2018+
ack_ioapic_quirk_irq(irq);
20502019
}
20512020

20522021
static void mask_IO_APIC_vector (unsigned int vector)
@@ -2063,7 +2032,12 @@ static void unmask_IO_APIC_vector (unsigned int vector)
20632032
unmask_IO_APIC_irq(irq);
20642033
}
20652034

2066-
#ifdef CONFIG_SMP
2035+
/*
2036+
* Oh just glorious. If CONFIG_PCI_MSI we've done
2037+
* #define set_ioapic_affinity set_ioapic_affinity_vector
2038+
*/
2039+
#if defined (CONFIG_SMP) && defined(CONFIG_X86_IO_APIC) && \
2040+
defined(CONFIG_PCI_MSI)
20672041
static void set_ioapic_affinity_vector (unsigned int vector,
20682042
cpumask_t cpu_mask)
20692043
{
@@ -2073,50 +2047,29 @@ static void set_ioapic_affinity_vector (unsigned int vector,
20732047
set_ioapic_affinity_irq(irq, cpu_mask);
20742048
}
20752049
#endif
2076-
#endif
20772050

2078-
static int ioapic_retrigger(unsigned int irq)
2051+
static int ioapic_retrigger_vector(unsigned int vector)
20792052
{
2053+
int irq = vector_to_irq(vector);
2054+
20802055
send_IPI_self(IO_APIC_VECTOR(irq));
20812056

20822057
return 1;
20832058
}
20842059

2085-
/*
2086-
* Level and edge triggered IO-APIC interrupts need different handling,
2087-
* so we use two separate IRQ descriptors. Edge triggered IRQs can be
2088-
* handled with the level-triggered descriptor, but that one has slightly
2089-
* more overhead. Level-triggered interrupts cannot be handled with the
2090-
* edge-triggered handler, without risking IRQ storms and other ugly
2091-
* races.
2092-
*/
2093-
static struct hw_interrupt_type ioapic_edge_type __read_mostly = {
2094-
.typename = "IO-APIC-edge",
2095-
.startup = startup_edge_ioapic,
2096-
.shutdown = shutdown_edge_ioapic,
2097-
.enable = enable_edge_ioapic,
2098-
.disable = disable_edge_ioapic,
2099-
.ack = ack_edge_ioapic,
2100-
.end = end_edge_ioapic,
2060+
static struct irq_chip ioapic_chip __read_mostly = {
2061+
.name = "IO-APIC",
2062+
.startup = startup_ioapic_vector,
2063+
.mask = mask_IO_APIC_vector,
2064+
.unmask = unmask_IO_APIC_vector,
2065+
.ack = ack_ioapic_vector,
2066+
.eoi = ack_ioapic_quirk_vector,
21012067
#ifdef CONFIG_SMP
21022068
.set_affinity = set_ioapic_affinity,
21032069
#endif
2104-
.retrigger = ioapic_retrigger,
2070+
.retrigger = ioapic_retrigger_vector,
21052071
};
21062072

2107-
static struct hw_interrupt_type ioapic_level_type __read_mostly = {
2108-
.typename = "IO-APIC-level",
2109-
.startup = startup_level_ioapic,
2110-
.shutdown = shutdown_level_ioapic,
2111-
.enable = enable_level_ioapic,
2112-
.disable = disable_level_ioapic,
2113-
.ack = mask_and_ack_level_ioapic,
2114-
.end = end_level_ioapic,
2115-
#ifdef CONFIG_SMP
2116-
.set_affinity = set_ioapic_affinity,
2117-
#endif
2118-
.retrigger = ioapic_retrigger,
2119-
};
21202073

21212074
static inline void init_IO_APIC_traps(void)
21222075
{
@@ -2150,42 +2103,41 @@ static inline void init_IO_APIC_traps(void)
21502103
make_8259A_irq(irq);
21512104
else
21522105
/* Strange. Oh, well.. */
2153-
irq_desc[irq].chip = &no_irq_type;
2106+
irq_desc[irq].chip = &no_irq_chip;
21542107
}
21552108
}
21562109
}
21572110

2158-
static void enable_lapic_irq (unsigned int irq)
2159-
{
2160-
unsigned long v;
2111+
/*
2112+
* The local APIC irq-chip implementation:
2113+
*/
21612114

2162-
v = apic_read(APIC_LVT0);
2163-
apic_write_around(APIC_LVT0, v & ~APIC_LVT_MASKED);
2115+
static void ack_apic(unsigned int irq)
2116+
{
2117+
ack_APIC_irq();
21642118
}
21652119

2166-
static void disable_lapic_irq (unsigned int irq)
2120+
static void mask_lapic_irq (unsigned int irq)
21672121
{
21682122
unsigned long v;
21692123

21702124
v = apic_read(APIC_LVT0);
21712125
apic_write_around(APIC_LVT0, v | APIC_LVT_MASKED);
21722126
}
21732127

2174-
static void ack_lapic_irq (unsigned int irq)
2128+
static void unmask_lapic_irq (unsigned int irq)
21752129
{
2176-
ack_APIC_irq();
2177-
}
2130+
unsigned long v;
21782131

2179-
static void end_lapic_irq (unsigned int i) { /* nothing */ }
2132+
v = apic_read(APIC_LVT0);
2133+
apic_write_around(APIC_LVT0, v & ~APIC_LVT_MASKED);
2134+
}
21802135

2181-
static struct hw_interrupt_type lapic_irq_type __read_mostly = {
2182-
.typename = "local-APIC-edge",
2183-
.startup = NULL, /* startup_irq() not used for IRQ0 */
2184-
.shutdown = NULL, /* shutdown_irq() not used for IRQ0 */
2185-
.enable = enable_lapic_irq,
2186-
.disable = disable_lapic_irq,
2187-
.ack = ack_lapic_irq,
2188-
.end = end_lapic_irq
2136+
static struct irq_chip lapic_chip __read_mostly = {
2137+
.name = "local-APIC-edge",
2138+
.mask = mask_lapic_irq,
2139+
.unmask = unmask_lapic_irq,
2140+
.eoi = ack_apic,
21892141
};
21902142

21912143
static void setup_nmi (void)
@@ -2356,7 +2308,7 @@ static inline void check_timer(void)
23562308
printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
23572309

23582310
disable_8259A_irq(0);
2359-
irq_desc[0].chip = &lapic_irq_type;
2311+
set_irq_chip_and_handler(0, &lapic_chip, handle_fasteoi_irq);
23602312
apic_write_around(APIC_LVT0, APIC_DM_FIXED | vector); /* Fixed mode */
23612313
enable_8259A_irq(0);
23622314

0 commit comments

Comments
 (0)