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
> <BUSY>
> 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
    [email protected]:/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 0xfee00000: 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 0xfec00000, version 21, 24 pins
acpimcfg0 at acpi0
acpimcfg0: addr 0xe0000000, 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, address 00:24:21:20:da:c2
rgephy0 at re0 phy 7: RTL8169S/8110S/8211 PHY, rev. 2
ppb2 at pci0 dev 6 function 0 "AMD RS780 PCIE" rev 0x00: msi
pci3 at ppb2 bus 3
vendor "VIA", unknown product 0x3403 (class serial bus subclass Firewire, rev 
0x00) at pci3 dev 0 function 0 not configured
ahci0 at pci0 dev 17 function 0 "ATI SBx00 SATA" rev 0x00: apic 2 int 22, AHCI 
1.1
ahci0: port 1: 3.0Gb/s
ahci0: port 3: 3.0Gb/s
ahci0: port 4: 1.5Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 1 lun 0: <ATA, ST3320613AS, CC2H> naa.5000c50013fa5bd1
sd0: 305245MB, 512 bytes/sector, 625142448 sectors
sd1 at scsibus1 targ 3 lun 0: <ATA, ST3320613AS, CC2H> naa.5000c50013fa5682
sd1: 305245MB, 512 bytes/sector, 625142448 sectors
cd0 at scsibus1 targ 4 lun 0: <Optiarc, DVD RW AD-7200S, 1.0A> removable
ohci0 at pci0 dev 18 function 0 "ATI SB700 USB" rev 0x00: apic 2 int 16, 
version 1.0, legacy support
ohci1 at pci0 dev 18 function 1 "ATI SB700 USB" rev 0x00: apic 2 int 16, 
version 1.0, legacy support
ehci0 at pci0 dev 18 function 2 "ATI SB700 USB2" rev 0x00: apic 2 int 17
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "ATI EHCI root hub" rev 2.00/1.00 
addr 1
ohci2 at pci0 dev 19 function 0 "ATI SB700 USB" rev 0x00: apic 2 int 18, 
version 1.0, legacy support
ohci3 at pci0 dev 19 function 1 "ATI SB700 USB" rev 0x00: apic 2 int 18, 
version 1.0, legacy support
ehci1 at pci0 dev 19 function 2 "ATI SB700 USB2" rev 0x00: apic 2 int 19
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 configuration 1 interface 0 "ATI EHCI root hub" rev 2.00/1.00 
addr 1
piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x3c: SMI
iic0 at piixpm0
iic0: addr 0x28 01=20 02=00 03=00 04=20 05=00 06=00 07=83 3e=03 41=20 42=00 
43=00 44=20 45=00 46=00 47=83 81=20 82=00 83=00 84=20 85=00 86=00 87=83 c1=20 
c2=00 c3=00 c4=20 c5=00 c6=00 c7=83 words 00=ff20 01=2000 02=0000 03=00ff 
04=20ff 05=00ff 06=00ff 07=ffff
spdmem0 at iic0 addr 0x50: 2GB DDR3 SDRAM PC3-10600
spdmem1 at iic0 addr 0x51: 2GB DDR3 SDRAM PC3-10600
pciide0 at pci0 dev 20 function 1 "ATI SB700 IDE" rev 0x00: DMA, channel 0 
configured to compatibility, channel 1 configured to compatibility
azalia0 at pci0 dev 20 function 2 "ATI SBx00 HD Audio" rev 0x00: apic 2 int 16
azalia0: codecs: Realtek/0x0889
audio0 at azalia0
pcib0 at pci0 dev 20 function 3 "ATI SB700 ISA" rev 0x00
ppb3 at pci0 dev 20 function 4 "ATI SB600 PCI" rev 0x00
pci4 at ppb3 bus 4
ohci4 at pci0 dev 20 function 5 "ATI SB700 USB" rev 0x00: apic 2 int 18, 
version 1.0, legacy support
pchb1 at pci0 dev 24 function 0 "AMD 10h HyperTransport" rev 0x00
pchb2 at pci0 dev 24 function 1 "AMD 10h Address Map" rev 0x00
pchb3 at pci0 dev 24 function 2 "AMD 10h DRAM Cfg" rev 0x00
km0 at pci0 dev 24 function 3 "AMD 10h Misc Cfg" rev 0x00
pchb4 at pci0 dev 24 function 4 "AMD 10h Link Cfg" rev 0x00
usb2 at ohci0: USB revision 1.0
uhub2 at usb2 configuration 1 interface 0 "ATI OHCI root hub" rev 1.00/1.00 
addr 1
usb3 at ohci1: USB revision 1.0
uhub3 at usb3 configuration 1 interface 0 "ATI OHCI root hub" rev 1.00/1.00 
addr 1
usb4 at ohci2: USB revision 1.0
uhub4 at usb4 configuration 1 interface 0 "ATI OHCI root hub" rev 1.00/1.00 
addr 1
usb5 at ohci3: USB revision 1.0
uhub5 at usb5 configuration 1 interface 0 "ATI OHCI root hub" rev 1.00/1.00 
addr 1
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: probed fifo depth: 15 bytes
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
usb6 at ohci4: USB revision 1.0
uhub6 at usb6 configuration 1 interface 0 "ATI OHCI root hub" rev 1.00/1.00 
addr 1
vmm0 at mainbus0: SVM/RVI
uhidev0 at uhub2 port 3 configuration 1 interface 0 "Logitech USB-PS/2 Optical 
Mouse" rev 2.00/11.10 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (7a7c285317b14d00.a) swap on sd0b dump on sd0b
initializing kernel modesetting (RS780 0x1002:0x9614 0x1462:0x7576 0x00).
radeondrm0: 1280x1024, 32bpp
wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0
wsdisplay0: screen 1-5 added (std, vt100 emulation)

> -- 
> :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.c  16 Dec 2019 21:39:40 -0000      1.40
> +++ piixpm.c  7 Jan 2020 11:19:09 -0000
> @@ -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 -0000      1.5
> +++ piixreg.h 7 Jan 2020 11:12:29 -0000
> @@ -70,8 +70,11 @@
>  #define SB800_PMREG_SIZE     2       /* index/data pair */
>  #define SB800_PMREG_SMB0EN   0x2c    /* 16-bit register */
>  #define SB800_PMREG_SMB0SEL  0x2e    /* bus selection */
> +#define SB800_PMREG_SMB0SELEN        0x2f    /* bus selection enable */
>  #define SB800_SMB0EN_EN              0x0001
>  #define SB800_SMB0EN_BASE_MASK       0xffe0
> +#define SB800_SMB0EN_PORT_MASK       0x06
> +#define SB800_SMB0SELEN_EN   0x01
>  
>  #define SB800_SMB_HOSTC      0x10            /* I2C bus configuration */
>  #define SB800_SMB_HOSTC_SMI  (1 << 0)        /* SMI */

-- 
Matthieu Herrb

Reply via email to