Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965229Ab1C3Vbo (ORCPT ); Wed, 30 Mar 2011 17:31:44 -0400 Received: from mga09.intel.com ([134.134.136.24]:6140 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965007Ab1C3VIs (ORCPT ); Wed, 30 Mar 2011 17:08:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.63,270,1299484800"; d="scan'208";a="727133561" From: Andi Kleen References: <20110330203.501921634@firstfloor.org> In-Reply-To: <20110330203.501921634@firstfloor.org> To: tglx@linutronix.de, ak@linux.intel.com, gregkh@suse.de, linux-kernel@vger.kernel.org, stable@kernel.org, tim.bird@am.sony.com Subject: [PATCH] [164/275] clockevents: Prevent oneshot mode when broadcast device is periodic Message-Id: <20110330210646.675223E1A05@tassilo.jf.intel.com> Date: Wed, 30 Mar 2011 14:06:46 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3890 Lines: 98 2.6.35-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner commit 3a142a0672b48a853f00af61f184c7341ac9c99d upstream. When the per cpu timer is marked CLOCK_EVT_FEAT_C3STOP, then we only can switch into oneshot mode, when the backup broadcast device supports oneshot mode as well. Otherwise we would try to switch the broadcast device into an unsupported mode unconditionally. This went unnoticed so far as the current available broadcast devices support oneshot mode. Seth unearthed this problem while debugging and working around an hpet related BIOS wreckage. Add the necessary check to tick_is_oneshot_available(). Reported-and-tested-by: Seth Forshee Signed-off-by: Thomas Gleixner Signed-off-by: Andi Kleen LKML-Reference: Signed-off-by: Greg Kroah-Hartman --- kernel/time/tick-broadcast.c | 10 ++++++++++ kernel/time/tick-common.c | 6 +++++- kernel/time/tick-internal.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) Index: linux-2.6.35.y/kernel/time/tick-broadcast.c =================================================================== --- linux-2.6.35.y.orig/kernel/time/tick-broadcast.c 2011-03-29 22:50:59.394738656 -0700 +++ linux-2.6.35.y/kernel/time/tick-broadcast.c 2011-03-29 23:03:01.661257663 -0700 @@ -600,4 +600,14 @@ return tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT; } +/* + * Check whether the broadcast device supports oneshot. + */ +bool tick_broadcast_oneshot_available(void) +{ + struct clock_event_device *bc = tick_broadcast_device.evtdev; + + return bc ? bc->features & CLOCK_EVT_FEAT_ONESHOT : false; +} + #endif Index: linux-2.6.35.y/kernel/time/tick-common.c =================================================================== --- linux-2.6.35.y.orig/kernel/time/tick-common.c 2011-03-29 22:50:59.393738682 -0700 +++ linux-2.6.35.y/kernel/time/tick-common.c 2011-03-29 23:03:01.662257637 -0700 @@ -51,7 +51,11 @@ { struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev; - return dev && (dev->features & CLOCK_EVT_FEAT_ONESHOT); + if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT)) + return 0; + if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) + return 1; + return tick_broadcast_oneshot_available(); } /* Index: linux-2.6.35.y/kernel/time/tick-internal.h =================================================================== --- linux-2.6.35.y.orig/kernel/time/tick-internal.h 2011-03-29 22:50:59.393738682 -0700 +++ linux-2.6.35.y/kernel/time/tick-internal.h 2011-03-29 23:03:01.669257458 -0700 @@ -36,6 +36,7 @@ extern int tick_resume_broadcast_oneshot(struct clock_event_device *bc); extern int tick_broadcast_oneshot_active(void); extern void tick_check_oneshot_broadcast(int cpu); +bool tick_broadcast_oneshot_available(void); # else /* BROADCAST */ static inline void tick_broadcast_setup_oneshot(struct clock_event_device *bc) { @@ -46,6 +47,7 @@ static inline void tick_shutdown_broadcast_oneshot(unsigned int *cpup) { } static inline int tick_broadcast_oneshot_active(void) { return 0; } static inline void tick_check_oneshot_broadcast(int cpu) { } +static inline bool tick_broadcast_oneshot_available(void) { return true; } # endif /* !BROADCAST */ #else /* !ONESHOT */ @@ -76,6 +78,7 @@ return 0; } static inline int tick_broadcast_oneshot_active(void) { return 0; } +static inline bool tick_broadcast_oneshot_available(void) { return false; } #endif /* !TICK_ONESHOT */ /* -- 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/