Re: svn commit: r197102 - head/sys/dev/amdtemp

2009-09-14 Thread Jung-uk Kim
On Monday 14 September 2009 04:08 pm, Jung-uk Kim wrote:
> Please try the attached patch.  I tried to implement all the quirks
> in Revision Guide carefully but I must admit that I haven't tried
> it on anything earlier than Revision F.

This patch has one typo:

+   /*
+* Errata #154: Incorect Diode Offset
+*/
+   if (cpu_id == 0x20f32) {
+   do_cpuid(0x8001, regs);
+   if ((regs[1] && 0xfff) == 0x2c)
 ^^
 &
+   sc->sc_flags |= AMDTEMP_FLAG_DO_QUIRK;
+   }

Today is not my day. :-(

Sorry again,

Jung-uk Kim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r197102 - head/sys/dev/amdtemp

2009-09-14 Thread Jung-uk Kim
On Monday 14 September 2009 12:38 pm, Jung-uk Kim wrote:
> On Monday 14 September 2009 12:29 pm, Jung-uk Kim wrote:
> > On Sunday 13 September 2009 12:12 pm, Kris Kennaway wrote:
> > > Jung-uk Kim wrote:
> > > > Author: jkim
> > > > Date: Fri Sep 11 21:47:44 2009
> > > > New Revision: 197102
> > > > URL: http://svn.freebsd.org/changeset/base/197102
> > > >
> > > > Log:
> > > >   Improve amdtemp(4) significantly:
> > > >
> > > >   - Improve newer AMD processor support (Family 0Fh Revision
> > > > F and later). - Adjust offset if DiodeOffet is set and valid.
> > > > Note it is experimental but it seems to give us more
> > > > realistic temperatures.  Newer Linux driver blindly adds 21C
> > > > for Family 0Fh desktop processors, however. - Always populate
> > > > dev.cpu and dev.amdtemp sysctl trees regardless of probe
> > > > order for consistency.  Previously, dev.cpu.N.temperature was
> > > > not populated if amdtemp was loaded later than ACPI CPU
> > > > driver and temperatures were not accessible from
> > > > dev.amdtemp.N.sensor0 tree for Family 10h/11h processors. -
> > > > Read the CPUID from PCI register instead of CPUID instruction
> > > > to prevent possible revision mismatches on multi-socket
> > > > system.
> > > >   - Change macros and variables to make them closer to AMD
> > > > documents. - Fix style(9) nits and improve comments.
> > >
> > > It no longer appears to work for me.  The old version reported:
> > >
> > > dev.amdtemp.0.%desc: AMD K8 Thermal Sensors
> > > dev.amdtemp.0.%driver: amdtemp
> > > dev.amdtemp.0.%parent: hostb9
> > > dev.amdtemp.0.sensor0.core0: 38.0C
> > > dev.amdtemp.0.sensor0.core1: 45.0C
> > > dev.amdtemp.0.sensor1.core0: 38.0C
> > > dev.amdtemp.0.sensor1.core1: 45.0C
> > > dev.cpu.0.temperature: 38.0C
> > > dev.cpu.1.temperature: 38.0C
> > >
> > > but none of those sysctl nodes are now present.
> > >
> > > CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+
> > > (2400.10-MHz K8-class CPU)
> > >Origin = "AuthenticAMD"  Id = 0x20f32  Stepping = 2
> > >
> > > Features=0x178bfbff > >,M TR R,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
> > > Features2=0x1
> > >AMD
> > > Features=0xe2500800
> > > AMD Features2=0x3
> > > ACPI APIC Table: 
> >
> > Arg...  This is a Socket 939, Revision E processor and Revision
> > C/D/E seems to have different DiodeOffset encoding.  Please try
> > the attached patch until I fix it properly.
>
> Please ignore this patch.  I need some time to think and fix it
> properly.  There are too many families and revisions. :-(

Please try the attached patch.  I tried to implement all the quirks in 
Revision Guide carefully but I must admit that I haven't tried it on 
anything earlier than Revision F.

Thanks,

Jung-uk Kim
--- sys/dev/amdtemp/amdtemp.c
+++ sys/dev/amdtemp/amdtemp.c
@@ -42,6 +42,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -58,10 +59,14 @@
 
 struct amdtemp_softc {
device_tsc_dev;
-   uint32_tsc_mask;
+   int sc_flags;
+#defineAMDTEMP_FLAG_DO_QUIRK   0x01/* DiodeOffset is incorrect. */
+#defineAMDTEMP_FLAG_DO_ZERO0x02/* DiodeOffset starts from 0C. 
*/
+#defineAMDTEMP_FLAG_DO_SIGN0x04/* DiodeOffsetSignBit is 
present. */
+#defineAMDTEMP_FLAG_CSWAP  0x08/* Core0/Core1 selector is 
swapped. */
+#defineAMDTEMP_FLAG_10BIT  0x10/* CurTmp is 10-bit wide. */
int sc_ncores;
int sc_ntemps;
-   int sc_swap;
int32_t (*sc_gettemp)(device_t, amdsensor_t);
struct sysctl_oid *sc_sysctl_cpu[MAXCPU];
struct intr_config_hook sc_ich;
@@ -168,30 +173,22 @@
 static int
 amdtemp_probe(device_t dev)
 {
-   uint32_t cpuid, family, model, temp;
+   uint32_t family, model;
 
if (resource_disabled("amdtemp", 0))
return (ENXIO);
 
-   cpuid = pci_read_config(dev, AMDTEMP_CPUID, 4);
-   family = CPUID_TO_FAMILY(cpuid);
-   model = CPUID_TO_MODEL(cpuid);
+   family = CPUID_TO_FAMILY(cpu_id);
+   model = CPUID_TO_MODEL(cpu_id);
 
switch (family) {
case 0x0f:
-   if ((model == 0x04 && (cpuid & CPUID_STEPPING) == 0) ||
-   (model == 0x05 && (cpuid & CPUID_STEPPING) <= 1))
+   if ((model == 0x04 && (cpu_id & CPUID_STEPPING) == 0) ||
+   (model == 0x05 && (cpu_id & CPUID_STEPPING) <= 1))
return (ENXIO);
break;
case 0x10:
case 0x11:
-   /*
-* DiodeOffset must be non-zero if thermal diode is supported.
-*/
-   temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
-   temp = (temp >> 8) & 0x7f;
-   if (temp == 0)
-   return (ENXIO);
break;
default:
return (ENXIO);
@@ -207,34 +204,59 @@
struct amdtemp_softc *sc = 

Re: svn commit: r197102 - head/sys/dev/amdtemp

2009-09-14 Thread Jung-uk Kim
On Monday 14 September 2009 12:29 pm, Jung-uk Kim wrote:
> On Sunday 13 September 2009 12:12 pm, Kris Kennaway wrote:
> > Jung-uk Kim wrote:
> > > Author: jkim
> > > Date: Fri Sep 11 21:47:44 2009
> > > New Revision: 197102
> > > URL: http://svn.freebsd.org/changeset/base/197102
> > >
> > > Log:
> > >   Improve amdtemp(4) significantly:
> > >
> > >   - Improve newer AMD processor support (Family 0Fh Revision F
> > > and later). - Adjust offset if DiodeOffet is set and valid. 
> > > Note it is experimental but it seems to give us more realistic
> > > temperatures.  Newer Linux driver blindly adds 21C for Family
> > > 0Fh desktop processors, however. - Always populate dev.cpu and
> > > dev.amdtemp sysctl trees regardless of probe order for
> > > consistency.  Previously, dev.cpu.N.temperature was not
> > > populated if amdtemp was loaded later than ACPI CPU driver and
> > > temperatures were not accessible from dev.amdtemp.N.sensor0
> > > tree for Family 10h/11h processors. - Read the CPUID from PCI
> > > register instead of CPUID instruction to prevent possible
> > > revision mismatches on multi-socket system.
> > >   - Change macros and variables to make them closer to AMD
> > > documents. - Fix style(9) nits and improve comments.
> >
> > It no longer appears to work for me.  The old version reported:
> >
> > dev.amdtemp.0.%desc: AMD K8 Thermal Sensors
> > dev.amdtemp.0.%driver: amdtemp
> > dev.amdtemp.0.%parent: hostb9
> > dev.amdtemp.0.sensor0.core0: 38.0C
> > dev.amdtemp.0.sensor0.core1: 45.0C
> > dev.amdtemp.0.sensor1.core0: 38.0C
> > dev.amdtemp.0.sensor1.core1: 45.0C
> > dev.cpu.0.temperature: 38.0C
> > dev.cpu.1.temperature: 38.0C
> >
> > but none of those sysctl nodes are now present.
> >
> > CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ (2400.10-MHz
> > K8-class CPU)
> >Origin = "AuthenticAMD"  Id = 0x20f32  Stepping = 2
> >
> > Features=0x178bfbff >TR R,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
> > Features2=0x1
> >AMD
> > Features=0xe2500800 AMD
> > Features2=0x3
> > ACPI APIC Table: 
>
> Arg...  This is a Socket 939, Revision E processor and Revision
> C/D/E seems to have different DiodeOffset encoding.  Please try the
> attached patch until I fix it properly.

Please ignore this patch.  I need some time to think and fix it 
properly.  There are too many families and revisions. :-(

Sorry,

Jung-uk Kim
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r197102 - head/sys/dev/amdtemp

2009-09-14 Thread Jung-uk Kim
On Sunday 13 September 2009 12:12 pm, Kris Kennaway wrote:
> Jung-uk Kim wrote:
> > Author: jkim
> > Date: Fri Sep 11 21:47:44 2009
> > New Revision: 197102
> > URL: http://svn.freebsd.org/changeset/base/197102
> >
> > Log:
> >   Improve amdtemp(4) significantly:
> >
> >   - Improve newer AMD processor support (Family 0Fh Revision F
> > and later). - Adjust offset if DiodeOffet is set and valid.  Note
> > it is experimental but it seems to give us more realistic
> > temperatures.  Newer Linux driver blindly adds 21C for Family 0Fh
> > desktop processors, however. - Always populate dev.cpu and
> > dev.amdtemp sysctl trees regardless of probe order for
> > consistency.  Previously, dev.cpu.N.temperature was not populated
> > if amdtemp was loaded later than ACPI CPU driver and temperatures
> > were not accessible from dev.amdtemp.N.sensor0 tree for Family
> > 10h/11h processors. - Read the CPUID from PCI register instead of
> > CPUID instruction to prevent possible revision mismatches on
> > multi-socket system.
> >   - Change macros and variables to make them closer to AMD
> > documents. - Fix style(9) nits and improve comments.
>
> It no longer appears to work for me.  The old version reported:
>
> dev.amdtemp.0.%desc: AMD K8 Thermal Sensors
> dev.amdtemp.0.%driver: amdtemp
> dev.amdtemp.0.%parent: hostb9
> dev.amdtemp.0.sensor0.core0: 38.0C
> dev.amdtemp.0.sensor0.core1: 45.0C
> dev.amdtemp.0.sensor1.core0: 38.0C
> dev.amdtemp.0.sensor1.core1: 45.0C
> dev.cpu.0.temperature: 38.0C
> dev.cpu.1.temperature: 38.0C
>
> but none of those sysctl nodes are now present.
>
> CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ (2400.10-MHz
> K8-class CPU)
>Origin = "AuthenticAMD"  Id = 0x20f32  Stepping = 2
>
> Features=0x178bfbffR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
> Features2=0x1
>AMD Features=0xe2500800
>AMD Features2=0x3
> ACPI APIC Table: 

Arg...  This is a Socket 939, Revision E processor and Revision C/D/E 
seems to have different DiodeOffset encoding.  Please try the 
attached patch until I fix it properly.

Sorry for the inconvenience.

Jung-uk Kim
--- sys/dev/amdtemp/amdtemp.c
+++ sys/dev/amdtemp/amdtemp.c
@@ -185,13 +185,6 @@ amdtemp_probe(device_t dev)
break;
case 0x10:
case 0x11:
-   /*
-* DiodeOffset must be non-zero if thermal diode is supported.
-*/
-   temp = pci_read_config(dev, AMDTEMP_THERMTP_STAT, 4);
-   temp = (temp >> 8) & 0x7f;
-   if (temp == 0)
-   return (ENXIO);
break;
default:
return (ENXIO);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Re: svn commit: r197102 - head/sys/dev/amdtemp

2009-09-13 Thread Kris Kennaway

Jung-uk Kim wrote:

Author: jkim
Date: Fri Sep 11 21:47:44 2009
New Revision: 197102
URL: http://svn.freebsd.org/changeset/base/197102

Log:
  Improve amdtemp(4) significantly:
  
  - Improve newer AMD processor support (Family 0Fh Revision F and later).

  - Adjust offset if DiodeOffet is set and valid.  Note it is experimental
  but it seems to give us more realistic temperatures.  Newer Linux driver
  blindly adds 21C for Family 0Fh desktop processors, however.
  - Always populate dev.cpu and dev.amdtemp sysctl trees regardless of probe
  order for consistency.  Previously, dev.cpu.N.temperature was not populated
  if amdtemp was loaded later than ACPI CPU driver and temperatures were not
  accessible from dev.amdtemp.N.sensor0 tree for Family 10h/11h processors.
  - Read the CPUID from PCI register instead of CPUID instruction to prevent
  possible revision mismatches on multi-socket system.
  - Change macros and variables to make them closer to AMD documents.
  - Fix style(9) nits and improve comments.


It no longer appears to work for me.  The old version reported:

dev.amdtemp.0.%desc: AMD K8 Thermal Sensors
dev.amdtemp.0.%driver: amdtemp
dev.amdtemp.0.%parent: hostb9
dev.amdtemp.0.sensor0.core0: 38.0C
dev.amdtemp.0.sensor0.core1: 45.0C
dev.amdtemp.0.sensor1.core0: 38.0C
dev.amdtemp.0.sensor1.core1: 45.0C
dev.cpu.0.temperature: 38.0C
dev.cpu.1.temperature: 38.0C

but none of those sysctl nodes are now present.

CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+ (2400.10-MHz 
K8-class CPU)

  Origin = "AuthenticAMD"  Id = 0x20f32  Stepping = 2

Features=0x178bfbff
  Features2=0x1
  AMD Features=0xe2500800
  AMD Features2=0x3
ACPI APIC Table: 

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"