Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757500AbYJFXYl (ORCPT ); Mon, 6 Oct 2008 19:24:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755908AbYJFXV5 (ORCPT ); Mon, 6 Oct 2008 19:21:57 -0400 Received: from mail.suse.de ([195.135.220.2]:40836 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756828AbYJFXV4 (ORCPT ); Mon, 6 Oct 2008 19:21:56 -0400 Date: Mon, 6 Oct 2008 16:17:17 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Ingo Molnar Subject: [patch 09/28] rtc: fix deadlock Message-ID: <20081006231717.GJ20567@suse.de> References: <20081006225949.357365087@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="rtc-fix-deadlock.patch" In-Reply-To: <20081006231639.GA20567@suse.de> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2299 Lines: 72 2.6.25-stable review patch. If anyone has any objections, please let us know. ------------------ From: Ingo Molnar commit 38c052f8cff1bd323ccfa968136a9556652ee420 upstream if get_rtc_time() is _ever_ called with IRQs off, we deadlock badly in it, waiting for jiffies to increment. So make the code more robust by doing an explicit mdelay(20). This solves a very hard to reproduce/debug hard lockup reported by Mikael Pettersson. Reported-by: Mikael Pettersson Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- include/asm-generic/rtc.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) --- a/include/asm-generic/rtc.h +++ b/include/asm-generic/rtc.h @@ -17,6 +17,7 @@ #include #include #include +#include #define RTC_PIE 0x40 /* periodic interrupt enable */ #define RTC_AIE 0x20 /* alarm interrupt enable */ @@ -45,7 +46,6 @@ static inline unsigned char rtc_is_updat static inline unsigned int get_rtc_time(struct rtc_time *time) { - unsigned long uip_watchdog = jiffies; unsigned char ctrl; unsigned long flags; @@ -55,19 +55,15 @@ static inline unsigned int get_rtc_time( /* * read RTC once any update in progress is done. The update - * can take just over 2ms. We wait 10 to 20ms. There is no need to + * can take just over 2ms. We wait 20ms. There is no need to * to poll-wait (up to 1s - eeccch) for the falling edge of RTC_UIP. * If you need to know *exactly* when a second has started, enable * periodic update complete interrupts, (via ioctl) and then * immediately read /dev/rtc which will block until you get the IRQ. * Once the read clears, read the RTC time (again via ioctl). Easy. */ - - if (rtc_is_updating() != 0) - while (jiffies - uip_watchdog < 2*HZ/100) { - barrier(); - cpu_relax(); - } + if (rtc_is_updating()) + mdelay(20); /* * Only the values that we read from the RTC are set. We leave -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/