From owner-freebsd-acpi@FreeBSD.ORG Thu Apr 24 22:01:35 2008 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E3251065672 for ; Thu, 24 Apr 2008 22:01:35 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by mx1.freebsd.org (Postfix) with ESMTP id 201CC8FC1E for ; Thu, 24 Apr 2008 22:01:34 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ug-out-1314.google.com with SMTP id y2so900196uge.37 for ; Thu, 24 Apr 2008 15:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; bh=0h1wWBwccUMzS3Z+JPAlLrgzTyvd/Jx0oRgiqdO2pBY=; b=Uymo7q0MAtxEqluYJSKkH/h0KKQ9FlcGvV90lGCevavyy8NoCjLcl3jX78LWaGRh1jEAJnP2/BFlGfazH1jymUkutYGI2wP/FoMhgI9aYiSz+t0ZxdLq+Jwnmg78G7nDNHKVvLwkFZY4/NrGytYKKvKQBYQtO6NU/wHkoyyOT0s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer:sender; b=I/bBLy1bJqbBV7Ib9KE0cYD4S480+rWh7klN+xvZVFCFXycfv81uDT1zOxeqopBTS9cXaO9o9rl9rJ0sg276V5/pUPayA5Gfc04ml5WYdjyZDDT6floKfUJ/Vp9HWCrUBy6niCPbIyQx+9QaBB/s8OVB8uSaEe2UwX4wZK0TYOo= Received: by 10.67.26.7 with SMTP id d7mr10591082ugj.23.1209074493200; Thu, 24 Apr 2008 15:01:33 -0700 (PDT) Received: from ?89.214.131.181? ( [89.214.131.181]) by mx.google.com with ESMTPS id 6sm1067760ugc.60.2008.04.24.15.01.28 (version=SSLv3 cipher=OTHER); Thu, 24 Apr 2008 15:01:31 -0700 (PDT) Message-Id: <4D198421-0D21-4DD6-9B1B-A2A8B1EB4B63@FreeBSD.org> From: Rui Paulo To: Andriy Gapon In-Reply-To: <4810F8DB.3090507@icyb.net.ua> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Thu, 24 Apr 2008 23:01:25 +0100 References: <480F8E2E.8000502@icyb.net.ua> <480F921D.3050505@root.org> <480FBA31.2050202@icyb.net.ua> <4810F8DB.3090507@icyb.net.ua> X-Mailer: Apple Mail (2.919.2) Sender: Rui Paulo Cc: freebsd-acpi@freebsd.org Subject: Re: initial value of tz_active X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2008 22:01:35 -0000 On 24 Apr 2008, at 22:17, Andriy Gapon wrote: > on 24/04/2008 01:37 Andriy Gapon said the following: >> I agree - this is a better approach. >> On a technical level - maybe use TZ_ACTIVE_UNKNOWN=-2 instead of a >> new >> variable. >> I'll try to work on this somewhere in the middle of May. > > I've couple of spare hours this evening, so I decided to not delay > this > small thing until after the vacation. > Result is attached. > My short testing shows that the patch does the job and doesn't > introduce > any problems. > > -- > Andriy Gapon > diff --git a/sys/dev/acpica/acpi_thermal.c b/sys/dev/acpica/ > acpi_thermal.c > index 18432ee..f87d6df 100644 > --- a/sys/dev/acpica/acpi_thermal.c > +++ b/sys/dev/acpica/acpi_thermal.c > @@ -90,6 +90,7 @@ struct acpi_tz_softc { > int tz_temperature; /*Current temperature*/ > int tz_active; /*Current active cooling*/ > #define TZ_ACTIVE_NONE -1 > +#define TZ_ACTIVE_UNKNOWN -2 > int tz_requested; /*Minimum active cooling*/ > int tz_thflags; /*Current temp-related flags*/ > #define TZ_THFLAG_NONE 0 > @@ -202,7 +203,7 @@ acpi_tz_attach(device_t dev) > sc->tz_dev = dev; > sc->tz_handle = acpi_get_handle(dev); > sc->tz_requested = TZ_ACTIVE_NONE; > - sc->tz_active = TZ_ACTIVE_NONE; > + sc->tz_active = TZ_ACTIVE_UNKNOWN; > sc->tz_thflags = TZ_THFLAG_NONE; > sc->tz_cooling_proc = NULL; > sc->tz_cooling_proc_running = FALSE; > @@ -520,6 +521,7 @@ acpi_tz_monitor(void *Context) > * minimum cooling run time if requested. > */ > if (acpi_tz_min_runtime > 0 && sc->tz_active != TZ_ACTIVE_NONE && > + sc->tz_active != TZ_ACTIVE_UNKNOWN && > (newactive == TZ_ACTIVE_NONE || newactive > sc->tz_active)) { > > getnanotime(&curtime); > @@ -543,6 +545,22 @@ acpi_tz_monitor(void *Context) > newflags |= TZ_THFLAG_CRT; > > /* If the active cooling state has changed, we have to switch > things. */ > + if (sc->tz_active == TZ_ACTIVE_UNKNOWN) { > + /* We don't know which cooling device is on or off, Please make this: "/*" " * We don't ..." to comply with style. > > + * so stop them all, because we now know which > + * should be on (if any). > + */ > + for (i = 0; i < TZ_NUMLEVELS; i++) { > + if (sc->tz_zone.al[i].Pointer != NULL) { > + acpi_ForeachPackageObject( > + (ACPI_OBJECT *)sc->tz_zone.al[i].Pointer, > + acpi_tz_switch_cooler_off, sc); > + } > + } > + /* now we know that all devices are off */ > + sc->tz_active = TZ_ACTIVE_NONE; > + } > + > if (newactive != sc->tz_active) { > /* Turn off the cooling devices that are on, if any are */ > if (sc->tz_active != TZ_ACTIVE_NONE) > Looks good to me. Regards, -- Rui Paulo