Re: piixpm(4) on ATI SBx00

2020-01-30 Thread Karel Gardas



On 1/22/20 5:25 AM, Ted Unangst wrote:

Karel Gardas wrote:


On 1/21/20 2:33 AM, Claudio Jeker wrote:

Please test this since I can't test this properly at the moment.




Sorry for delay with testing. Used today current to update and dmesg and 
diff of last fix and current dmesg are attached. Looks nice. Besides 
this it looks like someone also plays with acpi related output but 
nothing to complain about.


Thanks!

OpenBSD 6.6-current (GENERIC.MP) #624: Wed Jan 29 09:11:58 MST 2020
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4009230336 (3823MB)
avail mem = 3875233792 (3695MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0x9f000 (69 entries)
bios0: vendor American Megatrends Inc. version "1701" date 09/08/2010
bios0: ASUSTeK Computer INC. M4A88TD-M EVO
acpi0 at bios0: ACPI 3.0
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB SRAT HPET SSDT
acpi0: wakeup devices PCE2(S4) PCE3(S4) PCE5(S4) PCE6(S4) PCE7(S4) PCE9(S4) 
PCEA(S4) SBAZ(S4) P0PC(S4) GEC_(S4) UHC1(S4) UHC2(S4) USB3(S4) UHC4(S4) 
USB5(S4) UHC6(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) II X2 265 Processor, 3315.15 MHz, 10-06-03
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu0: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu0: AMD erratum 721 detected and fixed
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 200MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Athlon(tm) II X2 265 Processor, 3314.79 MHz, 10-06-03
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu1: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu1: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu1: AMD erratum 721 detected and fixed
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 21, 24 pins
acpimcfg0 at acpi0
acpimcfg0: addr 0xe000, bus 0-255
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P0P1)
acpiprt2 at acpi0: bus -1 (PCE2)
acpiprt3 at acpi0: bus -1 (PCE3)
acpiprt4 at acpi0: bus -1 (PCE5)
acpiprt5 at acpi0: bus 2 (PCE6)
acpiprt6 at acpi0: bus 3 (PCE7)
acpiprt7 at acpi0: bus 4 (PCE9)
acpiprt8 at acpi0: bus 5 (PCEA)
acpiprt9 at acpi0: bus 6 (P0PC)
acpiec0 at acpi0
acpicpu0 at acpi0: C1(@1 halt!), PSS
acpicpu1 at acpi0: C1(@1 halt!), PSS
acpipci0 at acpi0 PCI0: 0x 0x0011 0x0001
extent `acpipci0 pcibus' (0x0 - 0xff), flags=0
extent `acpipci0 pciio' (0x0 - 0x), flags=0
 0xcf8 - 0xcff
 0x1 - 0x
extent `acpipci0 pcimem' (0x0 - 0x), flags=0
 0x0 - 0x9
 0xc - 0xc
 0xe - 0xcfff
 0xe000 - 0xefff
 0xfec0 - 0x
acpicmos0 at acpi0
aibs0 at acpi0 RTMP RVLT RFAN GGRP GITM SITM
acpibtn0 at acpi0: PWRB
"PNP0C14" at acpi0 not configured
cpu0: 3315 MHz: speeds: 3300 2600 1900 800 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD RS880 Host" rev 0x00
ppb0 at pci0 dev 1 function 0 vendor "Asustek", unknown product 0x9602 rev 0x00
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 5 function 0 "ATI Radeon HD 4250" rev 0x00
drm0 at radeondrm0
radeondrm0: apic 2 int 18
azalia0 at pci1 dev 5 function 1 "ATI Radeon HD 4200 HD Audio" rev 0x00: msi
azalia0: no supported codecs
ppb1 at pci0 dev 6 function 0 "AMD RS780 PCIE" rev 0x00: msi
pci2 at ppb1 bus 2
xhci0 at pci2 dev 0 function 0 "NEC xHCI" rev 0x03: msi, xHCI 0.96
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "NEC xHCI root hub" rev 3.00/1.00 
addr 1
ppb2 at pci0 dev 7 function 0 "AMD RS780 PCIE" rev 0x00: msi
pci3 at ppb2 bus 3
vendor "VIA", unknown product 0x3403 (class serial bus subclass Firewire, rev 
0x01) at pci3 dev 0 function 0 not configured
ppb3 at pci0 dev 9 function 0 "AMD RS780 PCIE" rev 0x00: msi
pci4 at ppb3 bus 4
pciide0 at pci4 dev 0 function 0 "VIA VT6415 IDE" rev 0x00: ATA133, channel 0 
wired to native-PCI, channel 1 wired to native-PCI
pciide0: using apic 2 int 17 for native-PCI interrupt

Re: piixpm(4) on ATI SBx00

2020-01-21 Thread Ted Unangst
Karel Gardas wrote:
> 
> 
> On 1/21/20 2:33 AM, Claudio Jeker wrote:
> > Please test this since I can't test this properly at the moment. 
> 
> Would like to, but all hunks fail on today current:

it's been committed.



Re: piixpm(4) on ATI SBx00

2020-01-21 Thread Karel Gardas




On 1/21/20 2:33 AM, Claudio Jeker wrote:
Please test this since I can't test this properly at the moment. 


Would like to, but all hunks fail on today current:

solo$ patch < /tmp/piixpm.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--
|Index: piixpm.c
|===
|RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
|retrieving revision 1.41
|diff -u -p -r1.41 piixpm.c
|--- piixpm.c   9 Jan 2020 14:35:19 -   1.41
|+++ piixpm.c   21 Jan 2020 01:23:21 -
--
Patching file piixpm.c using Plan A...
Hunk #1 failed at 158.
Hunk #2 failed at 175.
Hunk #3 failed at 189.
Hunk #4 failed at 206.
Hunk #5 failed at 218.
5 out of 5 hunks failed--saving rejects to piixpm.c.rej
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--
|Index: piixreg.h
|===
|RCS file: /cvs/src/sys/dev/pci/piixreg.h,v
|retrieving revision 1.5
|diff -u -p -r1.5 piixreg.h
|--- piixreg.h  16 Dec 2019 21:39:40 -  1.5
|+++ piixreg.h  21 Jan 2020 01:22:49 -
--
Patching file piixreg.h using Plan A...
Hunk #1 failed at 70.
1 out of 1 hunks failed--saving rejects to piixreg.h.rej
Hmm...  Ignoring the trailing garbage.
done



Re: piixpm(4) on ATI SBx00

2020-01-20 Thread Claudio Jeker
On Tue, Jan 07, 2020 at 12:44:59PM +0100, Claudio Jeker wrote:
> On Tue, Jan 07, 2020 at 09:27:50AM +0100, Claudio Jeker wrote:
> > In -current I added support for the additional I2C busses on piixpm(4)
> > now I noticed that on my old AMD system the I2C bus seems to either
> > connect all those 4 busses together (or there is a bug in the driver).
> 
> Looks like this is indeed a problem with the driver.
> 
> With the following diff I now get:
> piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x41: polling
> iic0 at piixpm0
> sdtemp0 at iic0 addr 0x18: stts2002
> sdtemp1 at iic0 addr 0x19: stts2002
> sdtemp2 at iic0 addr 0x1a: stts2002
> sdtemp3 at iic0 addr 0x1b: stts2002
> spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem2 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem3 at iic0 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> iic1 at piixpm0   
>   piixpm0: exec: op 1, addr 0x18, cmdlen 1, len 0, flags 0x08: timeout, 
> status 0x1
> 
> iic2 at piixpm0
> iic3 at piixpm0
> 
> Not sure what is up with the timeout on iic @ addr 0x18. If that is seen
> on more systems it may be better to only use the primary bus on SB800
> devices that don't support SB800_PMREG_SMB0SEL.
> 
> Please test and report back.

Picking this up again. Since the second bus causes read timeouts and the
docu mentions that this bus is used for fan and temp control I think it is
better to just not attach the extra busses on these old AMD chipsets.
The additional SB800 busses will only be used if SB800_PMREG_SMB0SELEN
tells us that SMB0SELEN is enabled.

While looking at this I also investigated a bit more into the
PCI_PRODUCT_AMD_HUDSON2_SMB issues. So PCI ID 1022:780b are used by AMD
Bolton and Family 16h model 30h-3fh. AMD Bolton still needs the old layout
while the family 16h chips use the FCH register layout. So merge the if
statements a bit so that AMD Bolton uses the old code path and Family 16h
uses the new. 

Last but not least I was informed that we reversed the meaning of
SB800_SMB_HOSTC_SMI (if SB800_SMB_HOSTC bit 1 is set then use IRQ else
SMI). This is visible in the dmesg line of piixpm.

Please test this since I can't test this properly at the moment.
Works for me on
piixpm0 at pci0 dev 20 function 0 "AMD FCH SMBus" rev 0x61: SMI 

-- 
:wq Claudio

Index: piixpm.c
===
RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
retrieving revision 1.41
diff -u -p -r1.41 piixpm.c
--- piixpm.c9 Jan 2020 14:35:19 -   1.41
+++ piixpm.c21 Jan 2020 01:23:21 -
@@ -158,8 +158,13 @@ piixpm_attach(struct device *parent, str
return;
}
 
+   /*
+* AMD Bolton matches PCI_PRODUCT_AMD_HUDSON2_SMB but
+* uses old register layout. Therefor check PCI_REVISION.
+*/
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD &&
-   (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_HUDSON2_SMB ||
+   ((PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_HUDSON2_SMB &&
+   PCI_REVISION(pa->pa_class) >= 0x1f) ||
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_KERNCZ_SMB)) {
bus_space_write_1(sc->sc_iot, ioh, 0,
AMDFCH41_PM_DECODE_EN);
@@ -170,6 +175,9 @@ piixpm_attach(struct device *parent, str
AMDFCH41_PM_DECODE_EN + 1);
val = bus_space_read_1(sc->sc_iot, ioh, 1) << 8;
base = val;
+
+   sc->sc_is_fch = 1;
+   numbusses = 2;
} else {
/* Read "SmBus0En" */
bus_space_write_1(sc->sc_iot, ioh, 0,
@@ -181,6 +189,14 @@ piixpm_attach(struct device *parent, str
val |= (bus_space_read_1(sc->sc_iot, ioh, 1) << 8);
smb0en = val & SB800_SMB0EN_EN;
base = val & SB800_SMB0EN_BASE_MASK;
+
+   bus_space_write_1(sc->sc_iot, ioh, 0,
+   SB800_PMREG_SMB0SELEN);
+   val = bus_space_read_1(sc->sc_iot, ioh, 1);
+   if (val & SB800_SMB0SELEN_EN) {
+   sc->sc_is_sb800 = 1;
+   numbusses = 4;
+   }
}
 
if (smb0en == 0) {
@@ -190,17 +206,6 @@ piixpm_attach(struct device *parent, str
}
 
sc->sc_sb800_ioh = ioh;
-   if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD &&
-   PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_KERNCZ_SMB) ||
-   (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD &&
-

Re: piixpm(4) on ATI SBx00

2020-01-07 Thread Matthieu Herrb
On Tue, Jan 07, 2020 at 12:44:59PM +0100, Claudio Jeker wrote:
> On Tue, Jan 07, 2020 at 09:27:50AM +0100, Claudio Jeker wrote:
> > In -current I added support for the additional I2C busses on piixpm(4)
> > now I noticed that on my old AMD system the I2C bus seems to either
> > connect all those 4 busses together (or there is a bug in the driver).
> 
> Looks like this is indeed a problem with the driver.
> 
> With the following diff I now get:
> piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x41: polling
> iic0 at piixpm0
> sdtemp0 at iic0 addr 0x18: stts2002
> sdtemp1 at iic0 addr 0x19: stts2002
> sdtemp2 at iic0 addr 0x1a: stts2002
> sdtemp3 at iic0 addr 0x1b: stts2002
> spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem2 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> spdmem3 at iic0 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
> iic1 at piixpm0   
>   piixpm0: exec: op 1, addr 0x18, cmdlen 1, len 0, flags 0x08: timeout, 
> status 0x1
> 
> iic2 at piixpm0
> iic3 at piixpm0
> 
> Not sure what is up with the timeout on iic @ addr 0x18. If that is seen
> on more systems it may be better to only use the primary bus on SB800
> devices that don't support SB800_PMREG_SMB0SEL.
> 
> Please test and report back.

Hi,

My old Athlon X2 based machine is still working. No visible change in
dmesg()

OpenBSD 6.6-current (GENERIC.MP) #19: Tue Jan  7 23:30:37 CET 2020
matth...@cortez.herrb.net:/usr/obj/GENERIC.MP
real mem = 4008247296 (3822MB)
avail mem = 3874312192 (3694MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xfbdd0 (54 entries)
bios0: vendor American Megatrends Inc. version "V1.0" date 02/20/2009
bios0: MICRO-STAR INTERNATIONAL CO.,LTD MS-7576
acpi0 at bios0: ACPI 1.0
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB HPET
acpi0: wakeup devices PCE2(S4) PCE3(S4) PCE4(S4) PCE5(S4) PCE6(S4) PCE7(S4) 
PCE9(S4) PCEA(S4) PCEB(S4) PCEC(S4) SBAZ(S4) PS2K(S1) P0PC(S4) UHC1(S4) 
UHC2(S4) UHC3(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) X2 250 Processor, 3000.65 MHz, 10-06-02
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu0: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu0: AMD erratum 721 detected and fixed
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 200MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Athlon(tm) X2 250 Processor, 3000.15 MHz, 10-06-02
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu1: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu1: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu1: AMD erratum 721 detected and fixed
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 21, 24 pins
acpimcfg0 at acpi0
acpimcfg0: addr 0xe000, bus 0-255
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P0P1)
acpiprt2 at acpi0: bus -1 (PCE2)
acpiprt3 at acpi0: bus -1 (PCE3)
acpiprt4 at acpi0: bus -1 (PCE4)
acpiprt5 at acpi0: bus 2 (PCE5)
acpiprt6 at acpi0: bus 3 (PCE6)
acpiprt7 at acpi0: bus -1 (PCE7)
acpiprt8 at acpi0: bus -1 (PCE9)
acpiprt9 at acpi0: bus -1 (PCEA)
acpiprt10 at acpi0: bus -1 (PCEB)
acpiprt11 at acpi0: bus -1 (PCEC)
acpiprt12 at acpi0: bus 4 (P0PC)
acpicpu0 at acpi0: C1(@1 halt!)
acpicpu1 at acpi0: C1(@1 halt!)
acpipci0 at acpi0 PCI0: _OSC failed
acpicmos0 at acpi0
acpibtn0 at acpi0: PWRB
"PNP0C14" at acpi0 not configured
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD RS780 Host" rev 0x00
ppb0 at pci0 dev 1 function 0 "AMD RS780 PCIE" rev 0x00
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 5 function 0 "ATI Radeon HD 3300" rev 0x00
drm0 at radeondrm0
radeondrm0: apic 2 int 18
ppb1 at pci0 dev 5 function 0 "AMD RS780 PCIE" rev 0x00: msi
pci2 at ppb1 bus 2
re0 at pci2 dev 0 function 0 "Realtek 8168" rev 0x03: RTL8168D/8111D (0x2800), 
msi, addres

Re: piixpm(4) on ATI SBx00

2020-01-07 Thread Karel Gardas

Current and patched current dmesg diff below and both dmesgs attached.

 real mem = 4009230336 (3823MB)
-avail mem = 3875258368 (3695MB)
+avail mem = 3875254272 (3695MB)
 mpath0 at root
 scsibus0 at mpath0: 256 targets
 mainbus0 at root
@@ -108,20 +108,9 @@
 spdmem0 at iic0 addr 0x50: 2GB DDR3 SDRAM ECC PC3-10600 with thermal 
sensor
 spdmem1 at iic0 addr 0x51: 2GB DDR3 SDRAM ECC PC3-10600 with thermal 
sensor

 iic1 at piixpm0
-sdtemp1 at iic1 addr 0x18: mcp98243
-sdtemp2 at iic1 addr 0x19: mcp98243
-spdmem2 at iic1 addr 0x50: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
-spdmem3 at iic1 addr 0x51: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
+piixpm0: exec: op 1, addr 0x18, cmdlen 1, len 0, flags 0x08: timeout, 
status 0x1

 iic2 at piixpm0
-sdtemp3 at iic2 addr 0x18: mcp98243
-sdtemp4 at iic2 addr 0x19: mcp98243
-spdmem4 at iic2 addr 0x50: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
-spdmem5 at iic2 addr 0x51: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
 iic3 at piixpm0
-sdtemp5 at iic3 addr 0x18: mcp98243
-sdtemp6 at iic3 addr 0x19: mcp98243
-spdmem6 at iic3 addr 0x50: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
-spdmem7 at iic3 addr 0x51: 2GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
 azalia1 at pci0 dev 20 function 2 "ATI SBx00 HD Audio" rev 0x40: apic 
2 int 16

 azalia1: codecs: Realtek/0x0892
 audio0 at azalia1

On 1/7/20 12:44 PM, Claudio Jeker wrote:

On Tue, Jan 07, 2020 at 09:27:50AM +0100, Claudio Jeker wrote:

In -current I added support for the additional I2C busses on piixpm(4)
now I noticed that on my old AMD system the I2C bus seems to either
connect all those 4 busses together (or there is a bug in the driver).

Looks like this is indeed a problem with the driver.

With the following diff I now get:
piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x41: polling
iic0 at piixpm0
sdtemp0 at iic0 addr 0x18: stts2002
sdtemp1 at iic0 addr 0x19: stts2002
sdtemp2 at iic0 addr 0x1a: stts2002
sdtemp3 at iic0 addr 0x1b: stts2002
spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem2 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem3 at iic0 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
iic1 at piixpm0 
piixpm0: exec: op 1, addr 0x18, cmdlen 1, len 0, flags 0x08: timeout, status 0x1

iic2 at piixpm0
iic3 at piixpm0

Not sure what is up with the timeout on iic @ addr 0x18. If that is seen
on more systems it may be better to only use the primary bus on SB800
devices that don't support SB800_PMREG_SMB0SEL.

Please test and report back.


OpenBSD 6.6-current (GENERIC.MP) #584: Sat Jan  4 14:08:54 MST 2020
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4009230336 (3823MB)
avail mem = 3875258368 (3695MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0x9f000 (69 entries)
bios0: vendor American Megatrends Inc. version "1701" date 09/08/2010
bios0: ASUSTeK Computer INC. M4A88TD-M EVO
acpi0 at bios0: ACPI 3.0
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB SRAT HPET SSDT
acpi0: wakeup devices PCE2(S4) PCE3(S4) PCE5(S4) PCE6(S4) PCE7(S4) PCE9(S4) 
PCEA(S4) SBAZ(S4) P0PC(S4) GEC_(S4) UHC1(S4) UHC2(S4) USB3(S4) UHC4(S4) 
USB5(S4) UHC6(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Athlon(tm) II X2 265 Processor, 3315.20 MHz, 10-06-03
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu0: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu0: AMD erratum 721 detected and fixed
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 200MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Athlon(tm) II X2 265 Processor, 3314.80 MHz, 10-06-03
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,MWAIT,CX16,POPCNT,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,3DNOW2,3DNOW,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,ITSC
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB 64b/line 
16-way L2 cache
cpu1: ITLB 32 4KB entries fully associative, 16 4MB entries fully associative
cpu1: DTLB 48 4KB entries fully associative, 48 4MB entries fully associative
cpu1: AMD erratum 721 detec

Re: piixpm(4) on ATI SBx00

2020-01-07 Thread Claudio Jeker
On Tue, Jan 07, 2020 at 09:27:50AM +0100, Claudio Jeker wrote:
> In -current I added support for the additional I2C busses on piixpm(4)
> now I noticed that on my old AMD system the I2C bus seems to either
> connect all those 4 busses together (or there is a bug in the driver).

Looks like this is indeed a problem with the driver.

With the following diff I now get:
piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x41: polling
iic0 at piixpm0
sdtemp0 at iic0 addr 0x18: stts2002
sdtemp1 at iic0 addr 0x19: stts2002
sdtemp2 at iic0 addr 0x1a: stts2002
sdtemp3 at iic0 addr 0x1b: stts2002
spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem2 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem3 at iic0 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
iic1 at piixpm0 
piixpm0: exec: op 1, addr 0x18, cmdlen 1, len 0, flags 0x08: timeout, status 0x1

iic2 at piixpm0
iic3 at piixpm0

Not sure what is up with the timeout on iic @ addr 0x18. If that is seen
on more systems it may be better to only use the primary bus on SB800
devices that don't support SB800_PMREG_SMB0SEL.

Please test and report back.
-- 
:wq Claudio

Index: piixpm.c
===
RCS file: /cvs/src/sys/dev/pci/piixpm.c,v
retrieving revision 1.40
diff -u -p -r1.40 piixpm.c
--- piixpm.c16 Dec 2019 21:39:40 -  1.40
+++ piixpm.c7 Jan 2020 11:19:09 -
@@ -60,6 +60,7 @@ struct piixpm_softc {
int sc_poll;
int sc_is_sb800;
int sc_is_fch;
+   int sc_sb800_selen;
 
struct piixpm_smbus sc_busses[4];
struct i2c_controller   sc_i2c_tag[4];
@@ -181,6 +182,12 @@ piixpm_attach(struct device *parent, str
val |= (bus_space_read_1(sc->sc_iot, ioh, 1) << 8);
smb0en = val & SB800_SMB0EN_EN;
base = val & SB800_SMB0EN_BASE_MASK;
+
+   bus_space_write_1(sc->sc_iot, ioh, 0,
+   SB800_PMREG_SMB0SELEN);
+   val = bus_space_read_1(sc->sc_iot, ioh, 1);
+   if (val & SB800_SMB0SELEN_EN)
+   sc->sc_sb800_selen = 1;
}
 
if (smb0en == 0) {
@@ -296,11 +303,20 @@ piixpm_i2c_acquire_bus(void *cookie, int
AMDFCH41_PM_PORT_INDEX);
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1,
smbus->sb_bus << 3);
-   } else if (sc->sc_is_sb800) {
+   } else if (sc->sc_is_sb800 && sc->sc_sb800_selen) {
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 0,
SB800_PMREG_SMB0SEL);
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1,
smbus->sb_bus << 1);
+   } else if (sc->sc_is_sb800) {
+   uint8_t val;
+
+   bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 0,
+   SB800_PMREG_SMB0EN);
+   val = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh, 1) &
+   ~SB800_SMB0EN_PORT_MASK;
+   val |= smbus->sb_bus << 1;
+   bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1, val);
}
 
return (0);
@@ -317,11 +333,20 @@ piixpm_i2c_release_bus(void *cookie, int
AMDFCH41_PM_PORT_INDEX);
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1,
0);
-   } else if (sc->sc_is_sb800) {
+   } else if (sc->sc_is_sb800 && sc->sc_sb800_selen) {
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 0,
SB800_PMREG_SMB0SEL);
bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1,
0);
+   } else if (sc->sc_is_sb800) {
+   uint8_t val;
+
+   bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 0,
+   SB800_PMREG_SMB0EN);
+   val = bus_space_read_1(sc->sc_iot, sc->sc_sb800_ioh, 1) &
+   ~SB800_SMB0EN_PORT_MASK;
+   val |= 0;
+   bus_space_write_1(sc->sc_iot, sc->sc_sb800_ioh, 1, val);
}
 
if (cold || sc->sc_poll || (flags & I2C_F_POLL))
Index: piixreg.h
===
RCS file: /cvs/src/sys/dev/pci/piixreg.h,v
retrieving revision 1.5
diff -u -p -r1.5 piixreg.h
--- piixreg.h   16 Dec 2019 21:39:40 -  1.5
+++ piixreg.h   7 Jan 2020 11:12:29 -
@@ -70,8 +70,11 @@
 #define SB800_PMREG_SIZE   2   /* index/data pair */
 #define SB800_PMREG_SMB0EN 0x2c/* 16-bit register */
 #define SB800_PMREG_SMB0SEL0x2e/* bus selection */
+#define SB800_PMREG_SMB0SELEN  0x2f/* bus selection enab

piixpm(4) on ATI SBx00

2020-01-07 Thread Claudio Jeker
In -current I added support for the additional I2C busses on piixpm(4)
now I noticed that on my old AMD system the I2C bus seems to either connect all
those 4 busses together (or there is a bug in the driver).

I would like to know if people with ATI SBx00 SMBus chips see the same
effect as I do. Here the bit from my dmesg:

piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x41: polling
iic0 at piixpm0
sdtemp0 at iic0 addr 0x18: stts2002
sdtemp1 at iic0 addr 0x19: stts2002
sdtemp2 at iic0 addr 0x1a: stts2002
sdtemp3 at iic0 addr 0x1b: stts2002
spdmem0 at iic0 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem1 at iic0 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem2 at iic0 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem3 at iic0 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
iic1 at piixpm0
sdtemp4 at iic1 addr 0x18: stts2002
sdtemp5 at iic1 addr 0x19: stts2002
sdtemp6 at iic1 addr 0x1a: stts2002
sdtemp7 at iic1 addr 0x1b: stts2002
spdmem4 at iic1 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem5 at iic1 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem6 at iic1 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem7 at iic1 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
iic2 at piixpm0
sdtemp8 at iic2 addr 0x18: stts2002
sdtemp9 at iic2 addr 0x19: stts2002
sdtemp10 at iic2 addr 0x1a: stts2002
sdtemp11 at iic2 addr 0x1b: stts2002
spdmem8 at iic2 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem9 at iic2 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem10 at iic2 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem11 at iic2 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
iic3 at piixpm0
sdtemp12 at iic3 addr 0x18: stts2002
sdtemp13 at iic3 addr 0x19: stts2002
sdtemp14 at iic3 addr 0x1a: stts2002
sdtemp15 at iic3 addr 0x1b: stts2002
spdmem12 at iic3 addr 0x50: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem13 at iic3 addr 0x51: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem14 at iic3 addr 0x52: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor
spdmem15 at iic3 addr 0x53: 4GB DDR3 SDRAM ECC PC3-10600 with thermal sensor

-- 
:wq Claudio