x86 suspend/resume: suspend pics and pseudo-pics in reverse order

- change 'pics' from STAILQ to TAILQ
- ensure that Local APIC is always first in 'pics'

Reviewed by:	jhb
Tested by:	Sergey V. Dyatko <sergey.dyatko@gmail.com>,
		KAHO Toshikazu <kaho@elam.kais.kyoto-u.ac.jp>
MFC after:	12 days
This commit is contained in:
avg 2013-02-02 12:02:42 +00:00
parent 8e238c660c
commit 09a43450b8
4 changed files with 17 additions and 10 deletions

View File

@ -94,7 +94,7 @@ struct pic {
int (*pic_config_intr)(struct intsrc *, enum intr_trigger,
enum intr_polarity);
int (*pic_assign_cpu)(struct intsrc *, u_int apic_id);
STAILQ_ENTRY(pic) pics;
TAILQ_ENTRY(pic) pics;
};
/* Flags for pic_disable_source() */

View File

@ -94,7 +94,7 @@ struct pic {
int (*pic_config_intr)(struct intsrc *, enum intr_trigger,
enum intr_polarity);
int (*pic_assign_cpu)(struct intsrc *, u_int apic_id);
STAILQ_ENTRY(pic) pics;
TAILQ_ENTRY(pic) pics;
};
/* Flags for pic_disable_source() */

View File

@ -78,7 +78,7 @@ static int intrcnt_index;
static struct intsrc *interrupt_sources[NUM_IO_INTS];
static struct mtx intr_table_lock;
static struct mtx intrcnt_lock;
static STAILQ_HEAD(, pic) pics;
static TAILQ_HEAD(pics_head, pic) pics;
#ifdef SMP
static int assign_cpu;
@ -102,7 +102,7 @@ intr_pic_registered(struct pic *pic)
{
struct pic *p;
STAILQ_FOREACH(p, &pics, pics) {
TAILQ_FOREACH(p, &pics, pics) {
if (p == pic)
return (1);
}
@ -124,7 +124,7 @@ intr_register_pic(struct pic *pic)
if (intr_pic_registered(pic))
error = EBUSY;
else {
STAILQ_INSERT_TAIL(&pics, pic, pics);
TAILQ_INSERT_TAIL(&pics, pic, pics);
error = 0;
}
mtx_unlock(&intr_table_lock);
@ -287,7 +287,7 @@ intr_resume(void)
atpic_reset();
#endif
mtx_lock(&intr_table_lock);
STAILQ_FOREACH(pic, &pics, pics) {
TAILQ_FOREACH(pic, &pics, pics) {
if (pic->pic_resume != NULL)
pic->pic_resume(pic);
}
@ -300,7 +300,7 @@ intr_suspend(void)
struct pic *pic;
mtx_lock(&intr_table_lock);
STAILQ_FOREACH(pic, &pics, pics) {
TAILQ_FOREACH_REVERSE(pic, &pics, pics_head, pics) {
if (pic->pic_suspend != NULL)
pic->pic_suspend(pic);
}
@ -381,7 +381,7 @@ intr_init(void *dummy __unused)
intrcnt_setname("???", 0);
intrcnt_index = 1;
STAILQ_INIT(&pics);
TAILQ_INIT(&pics);
mtx_init(&intr_table_lock, "intr sources", NULL, MTX_DEF);
mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN);
}

View File

@ -1360,11 +1360,19 @@ apic_setup_io(void *dummy __unused)
if (best_enum == NULL)
return;
/*
* Local APIC must be registered before other PICs and pseudo PICs
* for proper suspend/resume order.
*/
#ifndef XEN
intr_register_pic(&lapic_pic);
#endif
retval = best_enum->apic_setup_io();
if (retval != 0)
printf("%s: Failed to setup I/O APICs: returned %d\n",
best_enum->apic_name, retval);
#ifdef XEN
return;
#endif
@ -1373,7 +1381,6 @@ apic_setup_io(void *dummy __unused)
* properly program the LINT pins.
*/
lapic_setup(1);
intr_register_pic(&lapic_pic);
if (bootverbose)
lapic_dump("BSP");