linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: len.brown@intel.com, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [APIC] Avoid change apic_id failure panic
Date: Thu, 3 Jun 2004 20:13:13 +1000	[thread overview]
Message-ID: <20040603101313.GB6578@gondor.apana.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

Hi:

I've received two reports at http://bugs.debian.org/251207 where
ioapic caused machines to lock up during booting due to the
change apic_id panic in arch/i386/kernel/io_apic.c.

Since it appears that we can avoid panicking at all, I think we
should replace the panic calls with the following patch which
attempts to continue after the failure.

I've also done the same thing to the other panic() call in the
same function.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 2867 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/05/21 23:24:33+10:00 herbert@gondor.apana.org.au 
#   [APIC] Avoid panic in io_apic_get_unique_id.
# 
# arch/i386/kernel/mpparse.c
#   2004/05/21 23:24:02+10:00 herbert@gondor.apana.org.au +9 -2
#   Avoid panic in io_apic_get_unique_id.
# 
# arch/i386/kernel/io_apic.c
#   2004/05/21 23:24:02+10:00 herbert@gondor.apana.org.au +12 -7
#   Avoid panic in io_apic_get_unique_id.
# 
diff -Nru a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
--- a/arch/i386/kernel/io_apic.c	2004-06-03 20:02:42 +10:00
+++ b/arch/i386/kernel/io_apic.c	2004-06-03 20:02:42 +10:00
@@ -2365,8 +2365,10 @@
 				break;
 		}
 
-		if (i == IO_APIC_MAX_ID)
-			panic("Max apic_id exceeded!\n");
+		if (i == IO_APIC_MAX_ID) {
+			printk(KERN_ERR "Max apic_id exceeded!\n");
+			return -1;
+		}
 
 		printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, "
 			"trying %d\n", ioapic, apic_id, i);
@@ -2374,9 +2376,6 @@
 		apic_id = i;
 	} 
 
-	tmp = apicid_to_cpu_present(apic_id);
-	physids_or(apic_id_map, apic_id_map, tmp);
-
 	if (reg_00.bits.ID != apic_id) {
 		reg_00.bits.ID = apic_id;
 
@@ -2386,9 +2385,15 @@
 		spin_unlock_irqrestore(&ioapic_lock, flags);
 
 		/* Sanity check */
-		if (reg_00.bits.ID != apic_id)
-			panic("IOAPIC[%d]: Unable change apic_id!\n", ioapic);
+		if (reg_00.bits.ID != apic_id) {
+			printk(KERN_ERR "IOAPIC[%d]: Unable change apic_id!\n",
+			       ioapic);
+			return -1;
+		}
 	}
+
+	tmp = apicid_to_cpu_present(apic_id);
+	physids_or(apic_id_map, apic_id_map, tmp);
 
 	printk(KERN_INFO "IOAPIC[%d]: Assigned apic_id %d\n", ioapic, apic_id);
 
diff -Nru a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
--- a/arch/i386/kernel/mpparse.c	2004-06-03 20:02:41 +10:00
+++ b/arch/i386/kernel/mpparse.c	2004-06-03 20:02:41 +10:00
@@ -881,6 +881,7 @@
 	u32			gsi_base)
 {
 	int			idx = 0;
+	int			apicid;
 
 	if (nr_ioapics >= MAX_IO_APICS) {
 		printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
@@ -893,14 +894,19 @@
 		return;
 	}
 
-	idx = nr_ioapics++;
+	idx = nr_ioapics;
 
 	mp_ioapics[idx].mpc_type = MP_IOAPIC;
 	mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
 	mp_ioapics[idx].mpc_apicaddr = address;
 
 	set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
-	mp_ioapics[idx].mpc_apicid = io_apic_get_unique_id(idx, id);
+	apicid = io_apic_get_unique_id(idx, id);
+	if (apicid < 0) {
+		clear_fixmap(FIX_IO_APIC_BASE_0 + idx);
+		return;
+	}
+	mp_ioapics[idx].mpc_apicid = apicid;
 	mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
 	
 	/* 
@@ -912,6 +918,7 @@
 	mp_ioapic_routing[idx].gsi_end = gsi_base + 
 		io_apic_get_redir_entries(idx);
 
+	nr_ioapics++;
 	printk("IOAPIC[%d]: apic_id %d, version %d, address 0x%lx, "
 		"GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid, 
 		mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr,

             reply	other threads:[~2004-06-03 10:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-03 10:13 Herbert Xu [this message]
2004-06-03 23:20 ` [APIC] Avoid change apic_id failure panic Andrew Morton
2004-06-03 23:37   ` William Lee Irwin III
2004-06-03 23:44     ` Andrew Morton
2004-06-03 23:48       ` William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040603101313.GB6578@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=akpm@osdl.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).