From owner-svn-src-all@FreeBSD.ORG Fri Oct 25 03:55:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DBCC8D88; Fri, 25 Oct 2013 03:55:52 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AE4B7278B; Fri, 25 Oct 2013 03:55:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9P3tqXP077119; Fri, 25 Oct 2013 03:55:52 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9P3tq4T077118; Fri, 25 Oct 2013 03:55:52 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310250355.r9P3tq4T077118@svn.freebsd.org> From: Nathan Whitehorn Date: Fri, 25 Oct 2013 03:55:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257093 - head/sys/powerpc/powermac X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 03:55:52 -0000 Author: nwhitehorn Date: Fri Oct 25 03:55:52 2013 New Revision: 257093 URL: http://svnweb.freebsd.org/changeset/base/257093 Log: Be a little more suspicious of thermal sensors, which can have single crazy readings occasionally. One wild reading should not be enough to trigger a shutdown, so instead wait for several concerning readings in a row. PR: powerpc/180593 Submitted by: Julio Merino MFC after: 1 week Modified: head/sys/powerpc/powermac/powermac_thermal.c Modified: head/sys/powerpc/powermac/powermac_thermal.c ============================================================================== --- head/sys/powerpc/powermac/powermac_thermal.c Fri Oct 25 03:18:56 2013 (r257092) +++ head/sys/powerpc/powermac/powermac_thermal.c Fri Oct 25 03:55:52 2013 (r257093) @@ -68,6 +68,8 @@ struct pmac_fan_le { struct pmac_sens_le { struct pmac_therm *sensor; int last_val; +#define MAX_CRITICAL_COUNT 6 + int critical_count; SLIST_ENTRY(pmac_sens_le) entries; }; static SLIST_HEAD(pmac_fans, pmac_fan_le) fans = SLIST_HEAD_INITIALIZER(fans); @@ -106,14 +108,27 @@ pmac_therm_manage_fans(void) sensor->last_val = temp; if (sensor->last_val > sensor->sensor->max_temp) { + sensor->critical_count++; printf("WARNING: Current temperature (%s: %d.%d C) " - "exceeds critical temperature (%d.%d C)! " - "Shutting down!\n", sensor->sensor->name, - (sensor->last_val - ZERO_C_TO_K) / 10, - (sensor->last_val - ZERO_C_TO_K) % 10, - (sensor->sensor->max_temp - ZERO_C_TO_K) / 10, - (sensor->sensor->max_temp - ZERO_C_TO_K) % 10); - shutdown_nice(RB_POWEROFF); + "exceeds critical temperature (%d.%d C); " + "count=%d\n", + sensor->sensor->name, + (sensor->last_val - ZERO_C_TO_K) / 10, + (sensor->last_val - ZERO_C_TO_K) % 10, + (sensor->sensor->max_temp - ZERO_C_TO_K) / 10, + (sensor->sensor->max_temp - ZERO_C_TO_K) % 10, + sensor->critical_count); + if (sensor->critical_count >= MAX_CRITICAL_COUNT) { + printf("WARNING: %s temperature exceeded " + "critical temperature %d times in a row; " + "shutting down!\n", + sensor->sensor->name, + sensor->critical_count); + shutdown_nice(RB_POWEROFF); + } + } else { + if (sensor->critical_count > 0) + sensor->critical_count--; } } @@ -177,6 +192,8 @@ pmac_thermal_sensor_register(struct pmac list_entry = malloc(sizeof(struct pmac_sens_le), M_PMACTHERM, M_ZERO | M_WAITOK); list_entry->sensor = sensor; + list_entry->last_val = 0; + list_entry->critical_count = 0; SLIST_INSERT_HEAD(&sensors, list_entry, entries); }