2012/12/10 Vadim Zhukov <persg...@gmail.com>:
> 2012/12/10 Christian Schulte <c...@schulte.it>:
>> Am 12/10/12 05:00, schrieb Vadim Zhukov:
>>> 10.12.2012 1:43 пользователь "Christian Schulte" 
>>> <c...@schulte.it> написал:
>>>>
>>>> Am 12/09/12 20:58, schrieb Vadim Zhukov:
>>>>> Hello all.
>>>>>
>>>>> This is a bit improved version of the patch showed up on tech@ in...
>>>>> er-r-r... don't mind. This makes my ThinkPad usable under high load
>>>>> for more than a year, and should not cause problems mentioned before
>>>>> (spinning higher and lower constantly) by using two temperature marks
>>>>> instead of one.
>>>>>
>>>>> I also found that disengaged mode should be enabled separately off
>>>>> other modes, so now Alexander Polyakov's X100e should behave correctly.
>>>>>
>>>>> Any ThinkPad users willing to test?
>>>>
>>>> Hello,
>>>>
>>>> I am using a previous version of the patch with some temperature
>>>> constants modified to match the temperatures my R60 produces. My R60
>>>> overheats (screen starts to flicker - system freezes) even when running
>>>> the fan in disengaged mode constantly. I bet the patch will only
>>>> increase the time it takes for the system to overheat. Ever run at 100%
>>>> load for a few hours with a disengaged fan without problems ?
>>>
>>> Well, I didn't need disengaged mode on X60 Tablet, it overhearted rarely,
>>> especially if you clean up fan at least once a year. And X201i with i5 runs
>>> fine with this patch, if you doesn't place it on the wool. Could you please
>>> show "dmesg" and "sysctl hw.sensors" output from your system with any
>>> version of the patch being applied?
>>>
>>
>> I did not manage to solve the thermal problems I am having with the R60
>> in any way. Without your patch, I cannot use the machine for more than
>> 10 minutes without overheating even when nearly idle. It also happened
>> when the machine was brandnew. The problem was there right from the
>> start. Replaced the fan two times already due to defects.
>>
>> With the latest patch applied I noticed the following:
>>
>> hw.sensors.acpithinkpad0.fan0=2652 RPM
>> hw.sensors.acpithinkpad0.raw0=128 (fan mode: disengaged), WARNING
>>
>> It reads (fan mode: disengaged) although the fan isn't spinning
>> full-speed. It does start spinning full-speed when getting hot. So the
>> fan-mode string seems to not get updated correctly when switching from
>> disengaged mode back to auto or somethng like that.
>
> Thanks, somehow I missed the obvious path in the source...
>
>> dmesg and sysctl hw.sensors with your latest patch applied.
>
> Thanks again.
>
>> Script started on Mon Dec 10 05:44:39 2012
>> # uptime
>>  5:44AM  up  5:30, 0 users, load averages: 0.12, 0.20, 0.26
>> # dmesg
>> OpenBSD 5.2-current (GENERIC.MP) #1: Mon Dec 10 00:05:29 CET 2012
>>     r...@r60.schulte.it:/usr/src/sys/arch/i386/compile/GENERIC.MP
>> cpu0: Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz ("GenuineIntel" 686-class)
>> 1.83 GHz
>> cpu0:
>> FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,LONG,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,LAHF,PERF
>>
>> real mem  = 3219517440 (3070MB)
>> avail mem = 3155935232 (3009MB)
>> mainbus0 at root
>> bios0 at mainbus0: AT/286+ BIOS, date 08/28/09, BIOS32 rev. 0 @ 0xfd690,
>> SMBIOS rev. 2.4 @ 0xe0010 (68 entries)
>> bios0: vendor LENOVO version "7CETD3WW (2.23 )" date 08/28/2009
>> bios0: LENOVO 9461DXG
>> acpi0 at bios0: rev 2
>> acpi0: sleep states S0 S3 S4 S5
>> acpi0: tables DSDT FACP SSDT ECDT TCPA APIC MCFG HPET SLIC BOOT SSDT
>> SSDT SSDT SSDT
>> acpi0: wakeup devices LID_(S3) SLPB(S3) LURT(S3) DURT(S3) EXP0(S4)
>> EXP1(S4) EXP2(S4) EXP3(S4) PCI1(S4) USB0(S3) USB1(S3) USB2(S3) USB7(S3)
>> HDEF(S4)
>> acpitimer0 at acpi0: 3579545 Hz, 24 bits
>> acpiec0 at acpi0
>> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
>> cpu0 at mainbus0: apid 0 (boot processor)
>> cpu0: apic clock running at 166MHz
>> cpu1 at mainbus0: apid 1 (application processor)
>> cpu1: Intel(R) Core(TM)2 CPU T5600 @ 1.83GHz ("GenuineIntel" 686-class)
>> 1.83 GHz
>> cpu1:
>> FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,LONG,SSE3,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,LAHF,PERF
>>
>> ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 24 pins
>> ioapic0: misconfigured as apic 2, remapped to apid 1
>> acpimcfg0 at acpi0 addr 0xf0000000, bus 0-63
>> acpihpet0 at acpi0: 14318179 Hz
>> acpiprt0 at acpi0: bus 0 (PCI0)
>> acpiprt1 at acpi0: bus 1 (AGP_)
>> acpiprt2 at acpi0: bus 2 (EXP0)
>> acpiprt3 at acpi0: bus 3 (EXP1)
>> acpiprt4 at acpi0: bus 4 (EXP2)
>> acpiprt5 at acpi0: bus 12 (EXP3)
>> acpiprt6 at acpi0: bus 21 (PCI1)
>> acpicpu0 at acpi0: C3, C2, C1, PSS
>> acpicpu1 at acpi0: C3, C2, C1, PSS
>> acpipwrres0 at acpi0: PUBS
>> acpitz0 at acpi0: critical temperature is 127 degC
>> acpitz1 at acpi0: critical temperature is 100 degC
>
> I'm thinking about looking for acpitz* internals critical temperature
> in acpithinkpad_attach(), and using it for heuristics to detect high
> and low temperature marks. But direct messing with acpitz(4)
> structures is indeed ugly... Can any kernel drivers hacker give an
> advice here, please?

Ping. Updated patch (fixing a printout bug spotted by Christian Schulte)
is below.

I have two successful reports for this version, including myself, and
at least one successful report for previous one (with only one
OUCH_MARK). May this deserve a commit? *SHREKCATSMILE*

--
  WBR,
    Vadim Zhukov


Index: acpithinkpad.c
===================================================================
RCS file: /cvs/src/sys/dev/acpi/acpithinkpad.c,v
retrieving revision 1.28
diff -u -p -r1.28 acpithinkpad.c
--- acpithinkpad.c      6 Jun 2011 06:13:46 -0000       1.28
+++ acpithinkpad.c      25 Dec 2012 15:19:25 -0000
@@ -76,11 +76,25 @@
 #define        THINKPAD_POWER_CHANGED          0x6030
 #define        THINKPAD_SWITCH_WIRELESS        0x7000
 
-#define THINKPAD_NSENSORS 9
-#define THINKPAD_NTEMPSENSORS 8
+#define THINKPAD_NSENSORS      10
+#define THINKPAD_NTEMPSENSORS   8
+
+#define THINKPAD_SENSOR_FANRPM (THINKPAD_NTEMPSENSORS + 0)
+#define THINKPAD_SENSOR_FANMODE        (THINKPAD_NTEMPSENSORS + 1)
 
 #define THINKPAD_ECOFFSET_FANLO                0x84
 #define THINKPAD_ECOFFSET_FANHI                0x85
+#define THINKPAD_ECOFFSET_FANMODE      0x2f
+
+/* not used: #define THINKPAD_FANMODE_MIN              0x00 */
+#define THINKPAD_FANMODE_MAX           0x07
+#define THINKPAD_FANMODE_AUTO          0x80
+#define THINKPAD_FANMODE_DISENGAGED    0x40
+#define THINKPAD_FANMODE_FORCEMAX      (THINKPAD_FANMODE_MAX | 
THINKPAD_FANMODE_DISENGAGED)
+
+/* critical temperature marks, in Celsius */
+#define THINKPAD_TEMP_OUCH_HMARK       80
+#define THINKPAD_TEMP_OUCH_LMARK       70
 
 struct acpithinkpad_softc {
        struct device            sc_dev;
@@ -90,7 +104,10 @@ struct acpithinkpad_softc {
        struct aml_node         *sc_devnode;
 
        struct ksensor           sc_sens[THINKPAD_NSENSORS];
+#define sc_sensfanmode          sc_sens[THINKPAD_SENSOR_FANMODE]
        struct ksensordev        sc_sensdev;
+
+       u_int8_t                 sc_fanmodeinit;
 };
 
 extern void acpiec_read(struct acpiec_softc *, u_int8_t, int, u_int8_t *);
@@ -108,7 +125,7 @@ int thinkpad_volume_mute(struct acpithin
 int    thinkpad_brightness_up(struct acpithinkpad_softc *);
 int    thinkpad_brightness_down(struct acpithinkpad_softc *);
 
-void    thinkpad_sensor_attach(struct acpithinkpad_softc *sc);
+void    thinkpad_sensor_attach(struct acpithinkpad_softc *);
 void    thinkpad_sensor_refresh(void *);
 
 #if NAUDIO > 0 && NWSKBD > 0
@@ -165,8 +182,14 @@ thinkpad_sensor_attach(struct acpithinkp
        }
 
        /* Add fan probe */
-       sc->sc_sens[i].type = SENSOR_FANRPM;
-       sensor_attach(&sc->sc_sensdev, &sc->sc_sens[i]);
+       sc->sc_sens[THINKPAD_SENSOR_FANRPM].type = SENSOR_FANRPM;
+       sensor_attach(&sc->sc_sensdev, &sc->sc_sens[THINKPAD_SENSOR_FANRPM]);
+
+       /* Add fan mode indicator */
+       sc->sc_sens[THINKPAD_SENSOR_FANMODE].type = SENSOR_INTEGER;
+       sensor_attach(&sc->sc_sensdev, &sc->sc_sens[THINKPAD_SENSOR_FANMODE]);
+       acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANMODE, 1,
+           &sc->sc_fanmodeinit);
 
        sensordev_install(&sc->sc_sensdev);
 }
@@ -176,8 +199,10 @@ thinkpad_sensor_refresh(void *arg)
 {
        struct acpithinkpad_softc *sc = arg;
        u_int8_t lo, hi, i;
-       int64_t tmp;
+       int64_t tmp, maxtmp = -127;    /* minimal correct value, see below */
+       int updatemode = 0;            /* should we bother BIOS? */
        char sname[5];
+       const char *desc;
 
        /* Refresh sensor readings */
        for (i=0; i<THINKPAD_NTEMPSENSORS; i++) {
@@ -185,14 +210,60 @@ thinkpad_sensor_refresh(void *arg)
                aml_evalinteger(sc->sc_acpi, sc->sc_ec->sc_devnode,
                    sname, 0, 0, &tmp);
                sc->sc_sens[i].value = (tmp * 1000000) + 273150000;
-               if (tmp > 127 || tmp < -127)
+               if (tmp > 127 || tmp < -127) {
                        sc->sc_sens[i].flags = SENSOR_FINVALID;
+                       sc->sc_sens[i].status = SENSOR_S_UNKNOWN;
+               }
+               if ((sc->sc_sens[i].flags & SENSOR_FINVALID) == SENSOR_FINVALID)
+                       continue;
+               if (tmp > maxtmp)
+                       maxtmp = tmp;
+               if (tmp > THINKPAD_TEMP_OUCH_HMARK)
+                       sc->sc_sens[i].status = SENSOR_S_CRIT;
+               else if (tmp > THINKPAD_TEMP_OUCH_LMARK)
+                       sc->sc_sens[i].status = SENSOR_S_WARN;
+               else
+                       sc->sc_sens[i].status = SENSOR_S_OK;
        }
 
        /* Read fan RPM */
        acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANLO, 1, &lo);
        acpiec_read(sc->sc_ec, THINKPAD_ECOFFSET_FANHI, 1, &hi);
-       sc->sc_sens[i].value = ((hi << 8L) + lo);
+       sc->sc_sens[THINKPAD_SENSOR_FANRPM].value = ((hi << 8L) + lo);
+
+       /*
+        * Update fan mode based on max temperature seen.
+        * If temperature is between THINKPAD_TEMP_OUCH_LMARK and
+        * THINKPAD_TEMP_OUCH_HMARK, we try to avoid setting fan mode
+        * to avoid extra spinning.
+        */
+       
+       if (maxtmp > THINKPAD_TEMP_OUCH_HMARK) {
+               sc->sc_sensfanmode.value = THINKPAD_FANMODE_FORCEMAX;
+               sc->sc_sensfanmode.status = SENSOR_S_CRIT;
+               desc = "disengaged";
+               updatemode = 1;
+       } else if (maxtmp <= THINKPAD_TEMP_OUCH_LMARK) {
+               sc->sc_sensfanmode.value = sc->sc_fanmodeinit;
+               sc->sc_sensfanmode.status = SENSOR_S_OK;
+               desc = "auto";
+               updatemode = 1;
+       } else {
+               if (sc->sc_sensfanmode.status == SENSOR_S_UNSPEC) {
+                       /* Better safe than sorry */
+                       sc->sc_sensfanmode.value = THINKPAD_FANMODE_FORCEMAX;
+                       desc = "disengaged";
+                       updatemode = 1;
+               }
+               sc->sc_sensfanmode.status = SENSOR_S_WARN;
+       }
+
+       if (updatemode) {
+               snprintf(sc->sc_sensfanmode.desc,
+                   sizeof(sc->sc_sensfanmode.desc), "fan mode: %s", desc);
+               acpiec_write(sc->sc_ec, THINKPAD_ECOFFSET_FANMODE, 1,
+                   (u_int8_t*)&sc->sc_sensfanmode.value);
+       }
 }
 
 void

Reply via email to