Skip to content

Commit 28536c8

Browse files
committed
Kill is_minlevel & is_maxlevel from intrsource{}.
This is a step into turning intrsource{} MI and getting rid of the IPL leftovers.
1 parent eed172d commit 28536c8

File tree

7 files changed

+14
-109
lines changed

7 files changed

+14
-109
lines changed

sys/arch/amd64/amd64/acpi_machdep.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,9 @@ acpi_sleep_clocks(struct acpi_softc *sc, int state)
251251
void
252252
acpi_resume_clocks(struct acpi_softc *sc)
253253
{
254-
extern struct mutex intr_lock;
255254
#if NISA > 0
256255
i8259_default_setup();
257256
#endif
258-
mtx_enter(&intr_lock);
259-
intr_calculatemasks(curcpu());
260-
mtx_leave(&intr_lock);
261257

262258
#if NIOAPIC > 0
263259
ioapic_enable();

sys/arch/amd64/amd64/genassym.cf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ member is_pic
122122
member is_flags
123123
member is_pin
124124
member is_type
125-
member is_maxlevel
126125

127126
struct intrhand
128127
member ih_fun

sys/arch/amd64/amd64/intr.c

Lines changed: 8 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -132,62 +132,6 @@ x86_nmi(void)
132132
return(0);
133133
}
134134

135-
/*
136-
* Recalculate the interrupt masks from scratch.
137-
*
138-
* Must be called with intr_lock held.
139-
*/
140-
void
141-
intr_calculatemasks(struct cpu_info *ci)
142-
{
143-
int irq, level;
144-
u_int64_t unusedirqs, intrlevel[MAX_INTR_SOURCES];
145-
struct intrhand *q;
146-
147-
MUTEX_ASSERT_LOCKED(&intr_lock);
148-
149-
/* First, figure out which levels each IRQ uses. */
150-
unusedirqs = 0xffffffffffffffffUL;
151-
for (irq = 0; irq < MAX_INTR_SOURCES; irq++) {
152-
int levels = 0;
153-
154-
if (ci->ci_isources[irq] == NULL) {
155-
intrlevel[irq] = 0;
156-
continue;
157-
}
158-
for (q = ci->ci_isources[irq]->is_handlers; q; q = q->ih_next)
159-
levels |= (1 << q->ih_level);
160-
intrlevel[irq] = levels;
161-
if (levels)
162-
unusedirqs &= ~(1UL << irq);
163-
}
164-
165-
/* Then figure out which IRQs use each level. */
166-
for (level = 0; level < NIPL; level++) {
167-
u_int64_t irqs = 0;
168-
for (irq = 0; irq < MAX_INTR_SOURCES; irq++)
169-
if (intrlevel[irq] & (1 << level))
170-
irqs |= (1UL << irq);
171-
}
172-
173-
for (irq = 0; irq < MAX_INTR_SOURCES; irq++) {
174-
int maxlevel = IPL_NONE;
175-
int minlevel = IPL_HIGH;
176-
177-
if (ci->ci_isources[irq] == NULL)
178-
continue;
179-
for (q = ci->ci_isources[irq]->is_handlers; q;
180-
q = q->ih_next) {
181-
if (q->ih_level < minlevel)
182-
minlevel = q->ih_level;
183-
if (q->ih_level > maxlevel)
184-
maxlevel = q->ih_level;
185-
}
186-
ci->ci_isources[irq]->is_maxlevel = maxlevel;
187-
ci->ci_isources[irq]->is_minlevel = minlevel;
188-
}
189-
}
190-
191135
/*
192136
* Allocate an interrupt slot on the given cpu.
193137
* - Called with intr_lock held.
@@ -305,20 +249,10 @@ intr_allocate_slot(struct pic *pic, int legacy_irq, int pin, int level,
305249
duplicate:
306250
if (pic == &i8259_pic)
307251
idtvec = ICU_OFFSET + legacy_irq;
308-
else {
309-
#ifdef IOAPIC_HWMASK
310-
if (level > isp->is_maxlevel) {
311-
#else
312-
if (isp->is_minlevel == 0 || level < isp->is_minlevel) {
313-
#endif
314-
idtvec = idt_vec_alloc(APIC_LEVEL(level),
315-
IDT_INTR_HIGH);
316-
if (idtvec == 0) {
317-
return (EBUSY);
318-
}
319-
} else
320-
idtvec = isp->is_idtvec;
321-
}
252+
else if (isp->is_idtvec == 0)
253+
idtvec = idt_vec_alloc();
254+
else
255+
idtvec = isp->is_idtvec;
322256
} else {
323257
other:
324258
/*
@@ -342,7 +276,7 @@ intr_allocate_slot(struct pic *pic, int legacy_irq, int pin, int level,
342276
}
343277
return (EBUSY);
344278
found:
345-
idtvec = idt_vec_alloc(APIC_LEVEL(level), IDT_INTR_HIGH);
279+
idtvec = idt_vec_alloc();
346280
if (idtvec == 0) {
347281
free(ci->ci_isources[slot], M_DEVBUF);
348282
ci->ci_isources[slot] = NULL;
@@ -474,9 +408,6 @@ intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level,
474408

475409
*p = ih;
476410

477-
intr_calculatemasks(ci);
478-
479-
480411
if (source->is_idtvec != idt_vec) {
481412
if (source->is_idtvec != 0 && source->is_idtvec != idt_vec)
482413
idt_vec_free(source->is_idtvec);
@@ -541,7 +472,6 @@ intr_disestablish(struct intrhand *ih)
541472

542473
*p = q->ih_next;
543474

544-
intr_calculatemasks(ci);
545475
if (source->is_handlers == NULL)
546476
pic->pic_delroute(pic, ci, ih->ih_pin, idtvec, source->is_type);
547477
else
@@ -594,7 +524,7 @@ intr_handler(struct intrframe *frame, struct intrhand *ih)
594524

595525
/*
596526
* Fake interrupt handler structures for the benefit of symmetry with
597-
* other interrupt sources, and the benefit of intr_calculatemasks()
527+
* other interrupt sources.
598528
*/
599529
struct intrhand fake_softclock_intrhand;
600530
struct intrhand fake_softnet_intrhand;
@@ -635,9 +565,6 @@ cpu_intr_init(struct cpu_info *ci)
635565
ci->ci_isources[LIR_TIMER] = isp;
636566
#endif
637567

638-
mtx_enter(&intr_lock);
639-
intr_calculatemasks(ci);
640-
mtx_leave(&intr_lock);
641568
}
642569

643570
void
@@ -660,9 +587,9 @@ intr_printconfig(void)
660587
isp = ci->ci_isources[i];
661588
if (isp == NULL)
662589
continue;
663-
printf("cpu%u source %d is pin %d from pic %s maxlevel %d\n",
590+
printf("cpu%u source %d is pin %d from pic %s\n",
664591
ci->ci_apicid, i, isp->is_pin,
665-
isp->is_pic->pic_name, isp->is_maxlevel);
592+
isp->is_pic->pic_name);
666593
for (ih = isp->is_handlers; ih != NULL;
667594
ih = ih->ih_next)
668595
printf("\thandler %p level %d\n",

sys/arch/amd64/amd64/machdep.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,21 +1742,22 @@ need_resched(struct cpu_info *ci)
17421742
}
17431743

17441744
/*
1745-
* Allocate an IDT vector slot within the given range.
1745+
* Allocate an IDT vector suitable for interrupts.
17461746
* - only allocated from interrupt code, which is already locked
17471747
*/
17481748

17491749
int
1750-
idt_vec_alloc(int low, int high)
1750+
idt_vec_alloc(void)
17511751
{
17521752
int vec;
17531753

1754-
for (vec = low; vec <= high; vec++) {
1754+
for (vec = IDT_INTR_LOW; vec <= IDT_INTR_HIGH; vec++) {
17551755
if (idt_allocmap[vec] == 0) {
17561756
idt_allocmap[vec] = 1;
17571757
return vec;
17581758
}
17591759
}
1760+
17601761
return 0;
17611762
}
17621763

sys/arch/amd64/include/intr.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ struct intrstub {
6464
};
6565

6666
struct intrsource {
67-
int is_maxlevel; /* max. IPL for this source */
6867
int is_pin; /* IRQ for legacy; pin for IO APIC */
6968
void (*is_run)(struct intrsource *); /* Run callback to this source */
7069
struct intrhand *is_handlers; /* handler chain */
@@ -73,7 +72,6 @@ struct intrsource {
7372
int is_flags; /* see below */
7473
int is_type; /* level, edge */
7574
int is_idtvec;
76-
int is_minlevel;
7775
volatile int is_scheduled; /* proc is runnable */
7876
struct proc *is_proc; /* ithread proc */
7977
TAILQ_ENTRY(intrsource) entry; /* entry in ithreads list */
@@ -112,11 +110,6 @@ int spllower(int);
112110
int splraise(int);
113111
void softintr(int);
114112

115-
/*
116-
* Convert spl level to local APIC level
117-
*/
118-
#define APIC_LEVEL(l) ((l) << 4)
119-
120113
/*
121114
* compiler barrier: prevent reordering of instructions.
122115
* XXX something similar will move to <sys/cdefs.h>

sys/arch/amd64/include/segments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void set_sys_segment(struct sys_segment_descriptor *, void *, size_t,
163163
int, int, int);
164164
void set_mem_segment(struct mem_segment_descriptor *, void *, size_t,
165165
int, int, int, int, int);
166-
int idt_vec_alloc(int, int);
166+
int idt_vec_alloc(void);
167167
void idt_vec_set(int, void (*)(void));
168168
void idt_vec_free(int);
169169
void cpu_init_idt(void);

sys/kern/kern_ithread.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ ithread(void *v_is)
101101
void
102102
ithread_run(struct intrsource *is)
103103
{
104-
#ifdef ITHREAD_DEBUG
105-
struct cpu_info *ci = curcpu();
106-
#endif
107104
struct proc *p = is->is_proc;
108105

109106
if (p == NULL) {
@@ -113,9 +110,7 @@ ithread_run(struct intrsource *is)
113110
return;
114111
}
115112

116-
DPRINTF(10, "ithread accepted interrupt pin %d "
117-
"(ilevel = %d, maxlevel = %d)\n",
118-
is->is_pin, ci->ci_ilevel, is->is_maxlevel);
113+
DPRINTF(10, "ithread accepted interrupt pin %d\n", is->is_pin);
119114

120115
SCHED_LOCK(); /* implies crit_enter() ! */
121116

@@ -225,7 +220,6 @@ ithread_softregister(int level, int (*handler)(void *), void *arg, int flags)
225220

226221
is->is_type = IST_LEVEL; /* XXX more like level than EDGE */
227222
is->is_pic = &softintr_pic;
228-
is->is_minlevel = IPL_HIGH;
229223

230224
ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT | M_ZERO);
231225
if (ih == NULL)
@@ -242,11 +236,6 @@ ithread_softregister(int level, int (*handler)(void *), void *arg, int flags)
242236
ih->ih_next = is->is_handlers;
243237
is->is_handlers = ih;
244238

245-
if (ih->ih_level > is->is_maxlevel)
246-
is->is_maxlevel = ih->ih_level;
247-
if (ih->ih_level < is->is_minlevel) /* XXX minlevel will be gone */
248-
is->is_minlevel = ih->ih_level;
249-
250239
ithread_register(is);
251240

252241
return (is);

0 commit comments

Comments
 (0)