Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Thu, 4 Mar 2010
 02:40:28 -0700
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id o249eR9u000972	for
 <andy.sharp@lsi.com>; Thu, 4 Mar 2010 01:40:28 -0800
Received: from psmtp.com (na3sys009amx201.postini.com [74.125.149.41])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id o249eNF6017495	for
 <andy.sharp@lsi.com>; Thu, 4 Mar 2010 01:40:26 -0800 (PST)
Received: from source ([78.24.191.182]) by na3sys009amx201.postini.com
 ([74.125.148.14]) with SMTP;	Thu, 04 Mar 2010 09:40:26 GMT
Received: from localhost.localdomain ([127.0.0.1]:56038 "EHLO
        eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL)        by
 eddie.linux-mips.org with ESMTP id S1491851Ab0CDJkF (ORCPT
        <rfc822;andy.sharp@lsi.com>); Thu, 4 Mar 2010 10:40:05 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 04 Mar 2010 10:39:47
 +0100 (CET)
Received: from mail.windriver.com ([147.11.1.11]:49564 "EHLO
        mail.windriver.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org
        with ESMTP id S1491187Ab0CDJjo (ORCPT
        <rfc822;linux-mips@linux-mips.org>); Thu, 4 Mar 2010 10:39:44 +0100
Received: from localhost.localdomain (pek-lpgbuild1.wrs.com [128.224.153.29])
        by mail.windriver.com (8.14.3/8.14.3) with ESMTP id o249dXVZ024419;
        Thu, 4 Mar 2010 01:39:36 -0800 (PST)
From: Yang Shi <yang.shi@windriver.com>
To: "ralf@linux-mips.org" <ralf@linux-mips.org>
CC: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Thu, 4 Mar 2010 02:39:33 -0700
Subject: [PATCH] MIPS: Protect current_cpu_data with preempt disable in
 delay()
Thread-Topic: [PATCH] MIPS: Protect current_cpu_data with preempt disable in
 delay()
Thread-Index: Acq7frnOgzxMKy4xROK2VODSt4Hq9A==
Message-ID: <1267695573-27360-1-git-send-email-yang.shi@windriver.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <yang.shi@windriver.com> [22/1] 
x-pstn-neptune: 0/0/0.00/0
x-list: linux-mips
x-original-sender: yang.shi@windriver.com
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

During machine restart with reboot command, get the following
bug info:

BUG: using smp_processor_id() in preemptible [00000000] code: reboot/1989
caller is __udelay+0x14/0x70
Call Trace:
[<ffffffff8110ad28>] dump_stack+0x8/0x34
[<ffffffff812dde04>] debug_smp_processor_id+0xf4/0x110
[<ffffffff812d90bc>] __udelay+0x14/0x70
[<ffffffff81378274>] md_notify_reboot+0x12c/0x148
[<ffffffff81161054>] notifier_call_chain+0x64/0xc8
[<ffffffff811614dc>] __blocking_notifier_call_chain+0x64/0xc0
[<ffffffff8115566c>] kernel_restart_prepare+0x1c/0x38
[<ffffffff811556cc>] kernel_restart+0x14/0x50
[<ffffffff8115581c>] SyS_reboot+0x10c/0x1f0
[<ffffffff81103684>] handle_sysn32+0x44/0x84

The root cause is that current_cpu_data is accessed in preemptible
context, so protect it with preempt_disable/preempt_enable pair
in delay().

Signed-off-by: Yang Shi <yang.shi@windriver.com>
---
 arch/mips/lib/delay.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/mips/lib/delay.c b/arch/mips/lib/delay.c
index 6b3b1de..dc38064 100644
--- a/arch/mips/lib/delay.c
+++ b/arch/mips/lib/delay.c
@@ -41,7 +41,11 @@ EXPORT_SYMBOL(__delay);
=20
 void __udelay(unsigned long us)
 {
-	unsigned int lpj =3D current_cpu_data.udelay_val;
+	unsigned int lpj;
+
+	preempt_disable();
+	lpj =3D current_cpu_data.udelay_val;
+	preempt_enable();
=20
 	__delay((us * 0x000010c7ull * HZ * lpj) >> 32);
 }
--=20
1.6.3.3


