Skip to content

Commit 5e000b5

Browse files
committed
intr/powerpc: implement skeleton interrupt event interface
These reduce the number of kernel object methods used when handling interrupts. While reasonably fast they are slower than indirect function calls. Having these on the drivers potentially allows the compiler to inline the functions. More significantly, this distinctly reduces the odds of collisions in the object method cache.
1 parent 7c38db8 commit 5e000b5

File tree

7 files changed

+240
-0
lines changed

7 files changed

+240
-0
lines changed

sys/powerpc/mpc85xx/atpic.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ static int atpic_isa_attach(device_t);
6969
static void atpic_isa_identify(driver_t *, device_t);
7070
static int atpic_isa_probe(device_t);
7171

72+
static intr_event_post_filter_t atpic_post_filter;
73+
static intr_event_post_ithread_t atpic_post_ithread;
74+
static intr_event_pre_ithread_t atpic_pre_ithread;
75+
7276
static void atpic_config(device_t, u_int, enum intr_trigger,
7377
enum intr_polarity);
7478
static void atpic_dispatch(device_t, struct trapframe *);
@@ -87,6 +91,11 @@ static device_method_t atpic_isa_methods[] = {
8791
DEVMETHOD(device_probe, atpic_isa_probe),
8892
DEVMETHOD(device_attach, atpic_isa_attach),
8993

94+
/* Interrupt event interface */
95+
DEVMETHOD(intr_event_post_filter, atpic_post_filter),
96+
DEVMETHOD(intr_event_post_ithread, atpic_post_ithread),
97+
DEVMETHOD(intr_event_pre_ithread, atpic_pre_ithread),
98+
9099
/* PIC interface */
91100
DEVMETHOD(pic_config, atpic_config),
92101
DEVMETHOD(pic_dispatch, atpic_dispatch),
@@ -234,6 +243,32 @@ atpic_isa_attach(device_t dev)
234243
return (error);
235244
}
236245

246+
/*
247+
* Interrupt event interface.
248+
*/
249+
250+
static void
251+
atpic_post_filter(device_t pic, interrupt_t *i)
252+
{
253+
254+
atpic_eoi(pic, i->intline);
255+
}
256+
257+
static void
258+
atpic_post_ithread(device_t pic, interrupt_t *i)
259+
{
260+
261+
atpic_unmask(pic, i->intline);
262+
}
263+
264+
static void
265+
atpic_pre_ithread(device_t pic, interrupt_t *i)
266+
{
267+
268+
atpic_mask(pic, i->intline);
269+
atpic_eoi(pic, i->intline);
270+
}
271+
237272
/*
238273
* PIC interface.
239274
*/

sys/powerpc/powermac/hrowpic.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
static int hrowpic_probe(device_t);
6464
static int hrowpic_attach(device_t);
6565

66+
static intr_event_post_filter_t hrowpic_post_filter;
67+
static intr_event_post_ithread_t hrowpic_post_ithread;
68+
static intr_event_pre_ithread_t hrowpic_pre_ithread;
69+
6670
static void hrowpic_dispatch(device_t, struct trapframe *);
6771
static void hrowpic_enable(device_t, u_int, u_int, void **);
6872
static void hrowpic_eoi(device_t, u_int, void *);
@@ -75,6 +79,11 @@ static device_method_t hrowpic_methods[] = {
7579
DEVMETHOD(device_probe, hrowpic_probe),
7680
DEVMETHOD(device_attach, hrowpic_attach),
7781

82+
/* Interrupt event interface */
83+
DEVMETHOD(intr_event_post_filter, hrowpic_post_filter),
84+
DEVMETHOD(intr_event_post_ithread, hrowpic_post_ithread),
85+
DEVMETHOD(intr_event_pre_ithread, hrowpic_pre_ithread),
86+
7887
/* PIC interface */
7988
DEVMETHOD(pic_dispatch, hrowpic_dispatch),
8089
DEVMETHOD(pic_enable, hrowpic_enable),
@@ -199,6 +208,32 @@ hrowpic_toggle_irq(struct hrowpic_softc *sc, int irq, int enable)
199208
hrowpic_write_reg(sc, HPIC_ENABLE, roffset, sc->sc_softreg[roffset]);
200209
}
201210

211+
/*
212+
* Interrupt event methods.
213+
*/
214+
215+
static void
216+
hrowpic_post_filter(device_t pic, interrupt_t *i)
217+
{
218+
219+
hrowpic_eoi(pic, i->intline, i->priv);
220+
}
221+
222+
static void
223+
hrowpic_post_ithread(device_t pic, interrupt_t *i)
224+
{
225+
226+
hrowpic_unmask(pic, i->intline, i->priv);
227+
}
228+
229+
static void
230+
hrowpic_pre_ithread(device_t pic, interrupt_t *i)
231+
{
232+
233+
hrowpic_mask(pic, i->intline, i->priv);
234+
hrowpic_eoi(pic, i->intline, i->priv);
235+
}
236+
202237
/*
203238
* PIC I/F methods.
204239
*/

sys/powerpc/powernv/opal_pci.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ static int opalpci_map_msi(device_t dev, device_t child,
8888
int irq, uint64_t *addr, uint32_t *data);
8989
static int opalpci_route_interrupt(device_t bus, device_t dev, int pin);
9090

91+
/*
92+
* Interrupt event interface.
93+
*/
94+
static intr_event_post_filter_t opalpic_post_filter;
95+
static intr_event_post_ithread_t opalpic_post_ithread;
96+
static intr_event_pre_ithread_t opalpic_pre_ithread;
97+
9198
/*
9299
* MSI PIC interface.
93100
*/
@@ -143,6 +150,11 @@ static device_method_t opalpci_methods[] = {
143150
DEVMETHOD(pcib_map_msi, opalpci_map_msi),
144151
DEVMETHOD(pcib_route_interrupt, opalpci_route_interrupt),
145152

153+
/* Interrupt event interface */
154+
DEVMETHOD(intr_event_post_filter, opalpic_post_filter),
155+
DEVMETHOD(intr_event_post_ithread, opalpic_post_ithread),
156+
DEVMETHOD(intr_event_pre_ithread, opalpic_pre_ithread),
157+
146158
/* PIC interface for MSIs */
147159
DEVMETHOD(pic_enable, opalpic_pic_enable),
148160
DEVMETHOD(pic_eoi, opalpic_pic_eoi),
@@ -691,6 +703,27 @@ opalpci_map_msi(device_t dev, device_t child, int irq, uint64_t *addr,
691703
return ((err == 0) ? 0 : ENXIO);
692704
}
693705

706+
static void
707+
opalpic_post_filter(device_t pic, interrupt_t *i)
708+
{
709+
710+
opalpic_pic_eoi(pic, i->intline, i->priv);
711+
}
712+
713+
static void
714+
opalpic_post_ithread(device_t pic, interrupt_t *i)
715+
{
716+
717+
KASSERT(false, ("function \"%s\" not implemented", __func__));
718+
}
719+
720+
static void
721+
opalpic_pre_ithread(device_t pic, interrupt_t *i)
722+
{
723+
/* no masking function? */
724+
opalpic_pic_eoi(pic, i->intline, i->priv);
725+
}
726+
694727
static void
695728
opalpic_pic_enable(device_t dev, u_int irq, u_int vector, void **priv)
696729
{

sys/powerpc/powernv/xive.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ static int xive_attach(device_t);
111111
static int xics_probe(device_t);
112112
static int xics_attach(device_t);
113113

114+
static intr_event_post_filter_t xive_post_filter;
115+
static intr_event_post_ithread_t xive_post_ithread;
116+
static intr_event_pre_ithread_t xive_pre_ithread;
117+
114118
static void xive_bind(device_t, u_int, cpuset_t, void **);
115119
static void xive_dispatch(device_t, struct trapframe *);
116120
static void xive_enable(device_t, u_int, u_int, void **);
@@ -126,6 +130,11 @@ static device_method_t xive_methods[] = {
126130
DEVMETHOD(device_probe, xive_probe),
127131
DEVMETHOD(device_attach, xive_attach),
128132

133+
/* Interrupt event interface */
134+
DEVMETHOD(intr_event_post_filter, xive_post_filter),
135+
DEVMETHOD(intr_event_post_ithread, xive_post_ithread),
136+
DEVMETHOD(intr_event_pre_ithread, xive_pre_ithread),
137+
129138
/* PIC interface */
130139
DEVMETHOD(pic_bind, xive_bind),
131140
DEVMETHOD(pic_dispatch, xive_dispatch),
@@ -421,6 +430,32 @@ xics_attach(device_t dev)
421430
return (0);
422431
}
423432

433+
/*
434+
* Interrupt event methods.
435+
*/
436+
437+
static void
438+
xive_post_filter(device_t pic, interrupt_t *i)
439+
{
440+
441+
xive_eoi(pic, i->intline, i->priv);
442+
}
443+
444+
static void
445+
xive_post_ithread(device_t pic, interrupt_t *i)
446+
{
447+
448+
xive_unmask(pic, i->intline, i->priv);
449+
}
450+
451+
static void
452+
xive_pre_ithread(device_t pic, interrupt_t *i)
453+
{
454+
455+
xive_mask(pic, i->intline, i->priv);
456+
xive_eoi(pic, i->intline, i->priv);
457+
}
458+
424459
/*
425460
* PIC I/F methods.
426461
*/

sys/powerpc/powerpc/openpic.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,43 @@ openpic_resume(device_t dev)
454454
return (0);
455455
}
456456

457+
/*
458+
* Interrupt event methods
459+
*/
460+
461+
static void
462+
openpic_post_filter(device_t pic, interrupt_t *i)
463+
{
464+
465+
openpic_eoi(pic, i->intline, i->priv);
466+
}
467+
468+
static void
469+
openpic_post_ithread(device_t pic, interrupt_t *i)
470+
{
471+
472+
openpic_unmask(pic, i->intline, i->priv);
473+
}
474+
475+
static void
476+
openpic_pre_ithread(device_t pic, interrupt_t *i)
477+
{
478+
479+
openpic_mask(pic, i->intline, i->priv);
480+
openpic_eoi(pic, i->intline, i->priv);
481+
}
482+
483+
457484
static device_method_t openpic_methods[] = {
458485
/* Device interface */
459486
DEVMETHOD(device_suspend, openpic_suspend),
460487
DEVMETHOD(device_resume, openpic_resume),
461488

489+
/* Interrupt event interface */
490+
DEVMETHOD(intr_event_post_filter, openpic_post_filter),
491+
DEVMETHOD(intr_event_post_ithread, openpic_post_ithread),
492+
DEVMETHOD(intr_event_pre_ithread, openpic_pre_ithread),
493+
462494
/* PIC interface */
463495
DEVMETHOD(pic_bind, openpic_bind),
464496
DEVMETHOD(pic_config, openpic_config),

sys/powerpc/ps3/ps3pic.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ static void ps3pic_identify(driver_t *driver, device_t parent);
4848
static int ps3pic_probe(device_t);
4949
static int ps3pic_attach(device_t);
5050

51+
static intr_event_post_filter_t ps3picpost_filter;
52+
static intr_event_post_ithread_t ps3pic_post_ithread;
53+
static intr_event_pre_ithread_t ps3pic_pre_ithread;
54+
5155
static void ps3pic_dispatch(device_t, struct trapframe *);
5256
static void ps3pic_enable(device_t, u_int, u_int, void **);
5357
static void ps3pic_eoi(device_t, u_int, void *);
@@ -72,6 +76,11 @@ static device_method_t ps3pic_methods[] = {
7276
DEVMETHOD(device_probe, ps3pic_probe),
7377
DEVMETHOD(device_attach, ps3pic_attach),
7478

79+
/* Interrupt event interface */
80+
DEVMETHOD(intr_event_post_filter, ps3pic_post_filter),
81+
DEVMETHOD(intr_event_post_ithread, ps3pic_post_ithread),
82+
DEVMETHOD(intr_event_pre_ithread, ps3pic_pre_ithread),
83+
7584
/* PIC interface */
7685
DEVMETHOD(pic_dispatch, ps3pic_dispatch),
7786
DEVMETHOD(pic_enable, ps3pic_enable),
@@ -147,6 +156,32 @@ ps3pic_attach(device_t dev)
147156
return (0);
148157
}
149158

159+
/*
160+
* Interrupt event methods.
161+
*/
162+
163+
static void
164+
ps3pic_post_filter(device_t pic, interrupt_t *i)
165+
{
166+
167+
ps3pic_eoi(pic, i->intline, i->priv);
168+
}
169+
170+
static void
171+
ps3pic_post_ithread(device_t pic, interrupt_t *i)
172+
{
173+
174+
ps3pic_unmask(pic, i->intline, i->priv);
175+
}
176+
177+
static void
178+
ps3pic_pre_ithread(device_t pic, interrupt_t *i)
179+
{
180+
181+
ps3pic_mask(pic, i->intline, i->priv);
182+
ps3pic_eoi(pic, i->intline, i->priv);
183+
}
184+
150185
/*
151186
* PIC I/F methods.
152187
*/

sys/powerpc/pseries/xics.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ static int xicp_attach(device_t);
6666
static int xics_probe(device_t);
6767
static int xics_attach(device_t);
6868

69+
static intr_event_post_filter_t xicp_post_filter;
70+
static intr_event_post_ithread_t xicp_post_ithread;
71+
static intr_event_pre_ithread_t xicp_pre_ithread;
72+
6973
static void xicp_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv);
7074
static void xicp_dispatch(device_t, struct trapframe *);
7175
static void xicp_enable(device_t, u_int, u_int, void **priv);
@@ -84,6 +88,11 @@ static device_method_t xicp_methods[] = {
8488
DEVMETHOD(device_probe, xicp_probe),
8589
DEVMETHOD(device_attach, xicp_attach),
8690

91+
/* Interrupt event interface */
92+
DEVMETHOD(intr_event_post_filter, xicp_post_filter),
93+
DEVMETHOD(intr_event_post_ithread, xicp_post_ithread),
94+
DEVMETHOD(intr_event_pre_ithread, xicp_pre_ithread),
95+
8796
/* PIC interface */
8897
DEVMETHOD(pic_bind, xicp_bind),
8998
DEVMETHOD(pic_dispatch, xicp_dispatch),
@@ -302,6 +311,32 @@ xicp_setup_priv(struct xicp_softc *sc, u_int irq, void **priv)
302311
return (*priv);
303312
}
304313

314+
/*
315+
* Interrupt event methods.
316+
*/
317+
318+
static void
319+
xicp_post_filter(device_t pic, interrupt_t *i)
320+
{
321+
322+
xicp_eoi(pic, i->intline, i->priv);
323+
}
324+
325+
static void
326+
xicp_post_ithread(device_t pic, interrupt_t *i)
327+
{
328+
329+
xicp_unmask(pic, i->intline, i->priv);
330+
}
331+
332+
static void
333+
xicp_pre_ithread(device_t pic, interrupt_t *i)
334+
{
335+
336+
xicp_mask(pic, i->intline, i->priv);
337+
xicp_eoi(pic, i->intline, i->priv);
338+
}
339+
305340
/*
306341
* PIC I/F methods.
307342
*/

0 commit comments

Comments
 (0)