@@ -88,11 +88,7 @@ static struct timeout_task intrbalance_task;
8888static struct sx intrsrc_lock ;
8989static struct mtx intrpic_lock ;
9090static struct mtx intrcnt_lock ;
91- struct pic_entr {
92- TAILQ_ENTRY (pic_entr ) pics ;
93- x86pic_t pic ;
94- };
95- static TAILQ_HEAD (pics_head , pic_entr ) pics = TAILQ_HEAD_INITIALIZER (pics );
91+ static pic_base_softc_t pics = { NULL , NULL };
9692u_int num_io_irqs ;
9793
9894#if defined(SMP ) && !defined(EARLY_AP_STARTUP )
@@ -123,7 +119,7 @@ static void intrcnt_register(struct intsrc *is);
123119/*
124120 * SYSINIT levels for SI_SUB_INTR:
125121 *
126- * SI_ORDER_FIRST: Initialize locks and pics TAILQ , xen_hvm_cpu_init
122+ * SI_ORDER_FIRST: Initialize locks and pics list , xen_hvm_cpu_init
127123 * SI_ORDER_SECOND: Xen PICs
128124 * SI_ORDER_THIRD: Add I/O APIC PICs, alloc MSI and Xen IRQ ranges
129125 * SI_ORDER_FOURTH: Add 8259A PICs
@@ -135,11 +131,13 @@ static void intrcnt_register(struct intsrc *is);
135131static int
136132intr_pic_registered (device_t pic )
137133{
138- struct pic_entr * p ;
134+ device_t p = pics . next ;
139135
140- TAILQ_FOREACH (p , & pics , pics ) {
141- if (p -> pic == pic )
136+ /* TAILQ_FOREACH(p, &pics, pics) { */
137+ while (p ) {
138+ if (p == pic )
142139 return (1 );
140+ p = ((pic_base_softc_t * )device_get_softc (p ))-> next ;
143141 }
144142 return (0 );
145143}
@@ -176,9 +174,6 @@ intr_create_pic(const char *name, u_int unit, driver_t *driver)
176174void
177175intr_register_pic (device_t pic )
178176{
179- struct pic_entr * entr = malloc (sizeof (* entr ), M_INTR , M_WAITOK );
180-
181- entr -> pic = pic ;
182177
183178 mtx_lock (& intrpic_lock );
184179 if (__predict_false (intr_pic_registered (pic )))
@@ -189,8 +184,17 @@ intr_register_pic(device_t pic)
189184#endif
190185 ("ERROR: %s: called with already registered PIC" ,
191186 __func__ );
192- else
193- TAILQ_INSERT_TAIL (& pics , entr , pics );
187+ else {
188+ device_t p = pics .prev ;
189+ pic_base_softc_t * softc = device_get_softc (pic );
190+ softc -> next = NULL ;
191+ softc -> prev = p ;
192+ if (p != NULL )
193+ ((pic_base_softc_t * )device_get_softc (p ))-> next = pic ;
194+ else
195+ pics .next = pic ;
196+ pics .prev = pic ;
197+ }
194198 mtx_unlock (& intrpic_lock );
195199}
196200
@@ -201,7 +205,7 @@ intr_register_pic(device_t pic)
201205static void
202206intr_init_sources (void * arg )
203207{
204- struct pic_entr * pic ;
208+ device_t pic = pics . next ;
205209
206210 MPASS (num_io_irqs > 0 );
207211
@@ -240,8 +244,10 @@ intr_init_sources(void *arg)
240244 * single-threaded at this point in startup so the list of
241245 * PICs shouldn't change.
242246 */
243- TAILQ_FOREACH (pic , & pics , pics )
244- PIC_REGISTER_SOURCES (pic -> pic );
247+ while (pic ) {
248+ PIC_REGISTER_SOURCES (pic );
249+ pic = ((pic_base_softc_t * )device_get_softc (pic ))-> next ;
250+ }
245251}
246252SYSINIT (intr_init_sources , SI_SUB_INTR , SI_ORDER_FOURTH + 1 , intr_init_sources ,
247253 NULL );
@@ -290,7 +296,7 @@ intr_disable_all(void)
290296 is = interrupt_sources [v ];
291297 if (is == NULL )
292298 continue ;
293- PIC_DISABLE_INTR (is -> is_event .ie_pic , is );
299+ PIC_DISABLE_INTR (is -> is_event .ie_pic , is , PIC_EOI );
294300 }
295301}
296302
@@ -338,7 +344,8 @@ intr_remove_handler(struct intsrc *isrc, struct intr_handler *handler)
338344 sx_xlock (& intrsrc_lock );
339345 isrc -> is_handlers -- ;
340346 if (isrc -> is_handlers == 0 )
341- PIC_DISABLE_INTR (isrc -> is_event .ie_pic , isrc );
347+ PIC_DISABLE_INTR (isrc -> is_event .ie_pic , isrc ,
348+ PIC_NO_EOI );
342349 intrcnt_updatename (isrc );
343350 sx_xunlock (& intrsrc_lock );
344351 }
@@ -422,25 +429,29 @@ intr_execute_handlers(struct intsrc *isrc, struct trapframe *frame)
422429void
423430intr_resume (bool suspend_cancelled )
424431{
425- struct pic_entr * pic ;
432+ device_t pic = pics . next ;
426433
427434#ifndef DEV_ATPIC
428435 atpic_reset ();
429436#endif
430437 mtx_lock (& intrpic_lock );
431- TAILQ_FOREACH (pic , & pics , pics )
432- PIC_RESUME (pic -> pic , suspend_cancelled );
438+ while (pic ) {
439+ PIC_RESUME (pic , suspend_cancelled );
440+ pic = ((pic_base_softc_t * )device_get_softc (pic ))-> next ;
441+ }
433442 mtx_unlock (& intrpic_lock );
434443}
435444
436445void
437446intr_suspend (void )
438447{
439- struct pic_entr * pic ;
448+ device_t pic = pics . prev ;
440449
441450 mtx_lock (& intrpic_lock );
442- TAILQ_FOREACH_REVERSE (pic , & pics , pics_head , pics )
443- PIC_SUSPEND (pic -> pic );
451+ while (pic ) {
452+ PIC_SUSPEND (pic );
453+ pic = ((pic_base_softc_t * )device_get_softc (pic ))-> prev ;
454+ }
444455 mtx_unlock (& intrpic_lock );
445456}
446457
@@ -487,7 +498,8 @@ static device_method_t pic_base_methods[] = {
487498 DEVMETHOD_END
488499};
489500
490- PUBLIC_DEFINE_CLASSN (pic_base , pic_base_class , pic_base_methods , 0 );
501+ PUBLIC_DEFINE_CLASSN (pic_base , pic_base_class , pic_base_methods ,
502+ sizeof (pic_base_softc_t ));
491503
492504static void
493505intrcnt_setname (const char * name , int index )
0 commit comments