Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 10 Sep 2008 01:11:42 -0700
Received: from ausesmta2-3.messageone.com ([64.20.241.45]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 10 Sep 2008 01:11:41 -0700
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])
	by ausesmta2-3.messageone.com (8.13.8/8.13.8) with ESMTP id m8A8Bejn000529
	for <andy.sharp@onstor.com>; Wed, 10 Sep 2008 03:11:41 -0500
Received: from localhost.localdomain ([127.0.0.1]:49074 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S36918218AbYIJHJi (ORCPT <rfc822;andy.sharp@onstor.com>);
	Wed, 10 Sep 2008 08:09:38 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 10 Sep 2008 08:09:21 +0100 (BST)
Received: from mail.free-electrons.com ([88.191.76.200]:29381 "EHLO
	mail.free-electrons.com") by ftp.linux-mips.org with ESMTP
	id S32728777AbYIJHJS (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 10 Sep 2008 08:09:18 +0100
Received: by mail.free-electrons.com (Postfix, from userid 106)
	id A586AE5C1; Tue,  9 Sep 2008 10:16:03 +0200 (CEST)
Received: from surf (humanoidz.org [82.247.183.72])
	by mail.free-electrons.com (Postfix) with ESMTPSA id 30235E5AC;
	Tue,  9 Sep 2008 10:15:55 +0200 (CEST)
Received: from thomas by surf with local (Exim 4.69)
	(envelope-from <thomas.petazzoni@enix.org>)
	id 1KcyNi-0000vf-3E; Tue, 09 Sep 2008 10:15:26 +0200
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: ralf@linux-mips.org
Cc: ths@networkno.de, linux-mips@linux-mips.org, michael@free-electrons.com,
        Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Subject: [PATCH 1/1] mips: clear IV bit in CP0 cause if the CPU doesn't support divec
Date: 	Tue,  9 Sep 2008 10:15:25 +0200
Message-Id: <1220948125-3550-1-git-send-email-thomas.petazzoni@free-electrons.com>
X-Mailer: git-send-email 1.5.4.3
In-Reply-To: <>
References: <>
X-archive-position: 20429
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: thomas.petazzoni@free-electrons.com
Precedence: bulk
X-list: 	linux-mips
X-MessageOne-Virus-Version: vendor=fsecure engine=4.65.7161:2.4.4,1.2.40,4.0.164 definitions=2008-09-10_02:2008-09-02,2008-09-10,2008-09-10 signatures=0
X-MessageOne-Virus-Scanned: Clean
X-MessageOne-Envelope-Sender: linux-mips-bounce@linux-mips.org
X-MessageOne-Spam-Details: rule=m773emszm_notspam policy=m773emszm score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=1 classifier=spam adjust=0 reason=mlx engine=3.1.0-0805090000 definitions=main-0809100007
X-MessageOne-Spam-Score: 0
X-MessageOne-Spam-Bar: 
Return-Path: linux-mips-bounce@linux-mips.org
X-OriginalArrivalTime: 10 Sep 2008 08:11:42.0145 (UTC) FILETIME=[DB9F9310:01C9131C]

When the kernel thinks that the CPU doesn't support the divec feature
(cpu_has_divec is false), reset the corresponding IV bit in the CP0
cause register, so that things will work correctly if the bootloader
had a different idea of the CPU support of the divec feature.

The problem has been found while trying to boot a 2.6.24 kernel for
the Qemu board using U-Boot inside Qemu. For the same CPU type, U-Boot
thinks that divec is supported, and the kernel doesn't. So U-Boot sets
the IV bit, but when the kernel boots and doesn't reset the IV bit,
things break when the first interrupts occur. The Qemu board has been
removed from the kernel in 2.6.25, but the problem might also occur
with other platforms.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Thiemo Seufer <ths@networkno.de>
Cc: linux-mips@linux-mips.org
---
 arch/mips/kernel/traps.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 6bee290..8b1e507 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1467,6 +1467,9 @@ void __cpuinit per_cpu_trap_init(void)
 		} else
 			set_c0_cause(CAUSEF_IV);
 	}
+	else {
+		clear_c0_cause(CAUSEF_IV);
+	}
 
 	/*
 	 * Before R2 both interrupt numbers were fixed to 7, so on R2 only:
-- 
1.5.4.3


