On Mon, Apr 09, 2018 at 11:51:19PM +0200, Peter J. Philipp wrote:
> Hi,
> 
> I inherited a computer which I want to make a sleeping backup computer.  The
> idea is that it sleeps during the day and then I wake it with arp -W and it
> receives backups and then it goes back to sleep, but I'm running into 
> problems.
> 
> First with a snapshot kernel when I wake the box I get this, and the system
> is inoperable (due to the ahci not coming ready, 3rd line from top, sorry
> about the flash on my camera, I had one shot and I didn't want to repeat the
> moment). The screenshot is here:
> 
> http://centroid.eu/private/ahci-problem.jpg
> 
> Then I added a longer timeout on ahci and it at least put the wake state into
> a stable state, here is my patch but it's far from perfect:

I have expanded on the patch a little bit, it can guarantee a resume from 
suspend exactly once, after that the box won't suspend anymore, but is 
otherwise useable.  Here the new patch.  After my signature follows a dmesg
with exactly one suspend to ram (S3) and a wake on lan to bring it back.


Index: ic/ahci.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/ahci.c,v
retrieving revision 1.32
diff -u -p -u -r1.32 ahci.c
--- ic/ahci.c   21 Aug 2017 21:43:46 -0000      1.32
+++ ic/ahci.c   10 Apr 2018 16:34:06 -0000
@@ -1488,6 +1488,17 @@ ahci_port_portreset_finish(struct ahci_p
        int                             rc, s, retries = 0;
 
        s = splbio();
+
+       /*
+        * if we have a quirky AHCI hardware, reset it immediately
+        * instead of trying something and having to reset anyhow
+        */
+       if ((ap->ap_sc->sc_flags & AHCI_F_QUIRKAROUND)) {
+               ahci_port_comreset(ap);
+               ahci_port_portreset_wait(ap);
+               retries = 1;
+       }
+
 retry:
        if (ahci_port_portreset_poll(ap)) {
                rc = ENODEV;
@@ -2756,7 +2767,11 @@ ahci_pwait_eq(struct ahci_port *ap, bus_
        for (i = 0; i < n * 1000; i++) {
                if ((ahci_pread(ap, r) & mask) == target)
                        return (0);
-               delay(1000);
+               
+               if ((ap->ap_sc->sc_flags & AHCI_F_QUIRKAROUND))
+                       delay(5000);
+               else
+                       delay(1000);
        }
 
        return (1);
Index: ic/ahcivar.h
===================================================================
RCS file: /cvs/src/sys/dev/ic/ahcivar.h,v
retrieving revision 1.10
diff -u -p -u -r1.10 ahcivar.h
--- ic/ahcivar.h        21 Aug 2017 21:43:46 -0000      1.10
+++ ic/ahcivar.h        10 Apr 2018 16:34:06 -0000
@@ -124,6 +124,7 @@ struct ahci_softc {
 #define AHCI_F_IPMS_PROBE              (1<<1)  /* IPMS on failed PMP probe */
 #define AHCI_F_NO_PMP                  (1<<2)  /* ignore PMP capability */
 #define AHCI_F_NO_MSI                  (1<<3)  /* disable MSI */
+#define AHCI_F_QUIRKAROUND             (1<<4)  /* Intel 6 HD for now */
 
        u_int                   sc_ncmds;
 
Index: pci/ahci_pci.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/ahci_pci.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 ahci_pci.c
--- pci/ahci_pci.c      3 Jan 2018 20:10:40 -0000       1.14
+++ pci/ahci_pci.c      10 Apr 2018 16:34:06 -0000
@@ -275,6 +275,9 @@ ahci_intel_attach(struct ahci_softc *sc,
 {
        sc->sc_flags |= AHCI_F_NO_PMP;
 
+       if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_6SERIES_AHCI_1)
+               sc->sc_flags |= AHCI_F_QUIRKAROUND;
+
        return (0);
 }
 


Thanks, maybe you have some ideas how to make this work better?

Regards,
-peter


OpenBSD 6.3-current (GENERIC.MP) #7: Tue Apr 10 18:33:01 CEST 2018
    p...@theta.centroid.eu:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4259340288 (4062MB)
avail mem = 4123140096 (3932MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.6 @ 0xeafb0 (100 entries)
bios0: vendor American Megatrends Inc. version "E7728MLN.208" date 08/15/2011
bios0: MEDIONPC MS-7728
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP APIC SSDT MCFG SLIC HPET
acpi0: wakeup devices BR20(S3) EUSB(S3) USBE(S3) PEX0(S4) RTL_(S1) PEX1(S4) 
PEX2(S4) PEX3(S4) PEX4(S4) PEX5(S4) PEX6(S4) PEX7(S4) P0P1(S4) P0P2(S3) 
P0P3(S3) P0P4(S3) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz, 3293.02 MHz
cpu0: 
FPU,VME,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,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,DEADLINE,XSAVE,AVX,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,SENSOR,ARAT,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz, 3292.53 MHz
cpu1: 
FPU,VME,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,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,DEADLINE,XSAVE,AVX,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,SENSOR,ARAT,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz, 3292.53 MHz
cpu2: 
FPU,VME,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,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,DEADLINE,XSAVE,AVX,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,SENSOR,ARAT,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz, 3292.53 MHz
cpu3: 
FPU,VME,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,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT,DEADLINE,XSAVE,AVX,NXE,RDTSCP,LONG,LAHF,PERF,ITSC,IBRS,IBPB,STIBP,SENSOR,ARAT,MELTDOWN
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 0 pa 0xfec00000, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (PEX0)
acpiprt2 at acpi0: bus -1 (PEX1)
acpiprt3 at acpi0: bus -1 (PEX2)
acpiprt4 at acpi0: bus -1 (PEX3)
acpiprt5 at acpi0: bus 3 (PEX4)
acpiprt6 at acpi0: bus 4 (PEX5)
acpiprt7 at acpi0: bus -1 (PEX6)
acpiprt8 at acpi0: bus -1 (PEX7)
acpiprt9 at acpi0: bus 1 (P0P1)
acpiprt10 at acpi0: bus -1 (P0P2)
acpiprt11 at acpi0: bus -1 (P0P3)
acpiprt12 at acpi0: bus -1 (P0P4)
acpicpu0 at acpi0: C3(350@104 mwait.3@0x20), C1(1000@1 halt), PSS
acpicpu1 at acpi0: C3(350@104 mwait.3@0x20), C1(1000@1 halt), PSS
acpicpu2 at acpi0: C3(350@104 mwait.3@0x20), C1(1000@1 halt), PSS
acpicpu3 at acpi0: C3(350@104 mwait.3@0x20), C1(1000@1 halt), PSS
acpicmos0 at acpi0
"INT3F0D" at acpi0 not configured
acpibtn0 at acpi0: PWRB
cpu0: Enhanced SpeedStep 3293 MHz: speeds: 3300, 3100, 2900, 2700, 2500, 2300, 
2100, 1900, 1700, 1600 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Core 2G Host" rev 0x09
ppb0 at pci0 dev 1 function 0 "Intel Core 2G PCIE" rev 0x09: msi
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 0 function 0 "ATI Radeon HD 6450" rev 0x00
drm0 at radeondrm0
radeondrm0: msi
azalia0 at pci1 dev 0 function 1 "ATI Radeon HD 6400 Audio" rev 0x00: msi
azalia0: no supported codecs
"Intel 6 Series MEI" rev 0x04 at pci0 dev 22 function 0 not configured
ehci0 at pci0 dev 26 function 0 "Intel 6 Series USB" rev 0x05: apic 0 int 16
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
azalia1 at pci0 dev 27 function 0 "Intel 6 Series HD Audio" rev 0x05: msi
azalia1: codecs: Realtek/0x0887
audio0 at azalia1
ppb1 at pci0 dev 28 function 0 "Intel 6 Series PCIE" rev 0xb5: msi
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 4 "Intel 6 Series PCIE" rev 0xb5: msi
pci3 at ppb2 bus 3
xhci0 at pci3 dev 0 function 0 "ASMedia ASM1042 xHCI" rev 0x00: msi
usb1 at xhci0: USB revision 3.0
uhub1 at usb1 configuration 1 interface 0 "ASMedia xHCI root hub" rev 3.00/1.00 
addr 1
ppb3 at pci0 dev 28 function 5 "Intel 6 Series PCIE" rev 0xb5: msi
pci4 at ppb3 bus 4
re0 at pci4 dev 0 function 0 "Realtek 8168" rev 0x06: RTL8168E/8111E-VL 
(0x2c80), msi, address 8c:89:a5:68:9c:a7
rgephy0 at re0 phy 7: RTL8169S/8110S/8211 PHY, rev. 5
ehci1 at pci0 dev 29 function 0 "Intel 6 Series USB" rev 0x05: apic 0 int 23
usb2 at ehci1: USB revision 2.0
uhub2 at usb2 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
pcib0 at pci0 dev 31 function 0 "Intel H61 LPC" rev 0x05
ahci0 at pci0 dev 31 function 2 "Intel 6 Series AHCI" rev 0x05: msi, GHC 
0x80000000<AE> AHCI 1.3
ahci0: capabilities 
0xe720ff63<S64A,NCQ,SSNTF,SALP,SAL,SCLO,PMD,SSC,PSC,EMS,SXS>, 4 ports, 32 cmds, 
gen 2 (3.0Gb/s)
ahci0: extended capabilities 0x4<APST>
ahci0: ports implemented: 0x00000033
ahci0.0: port reset
ahci0.1: port reset
ahci0.4: port reset
ahci0.5: port reset
ahci0: detected device on port 0; 0
ahci0.0: port 0: 3.0Gb/s
ahci0: detected device on port 1; 0
ahci0.1: port 1: 1.5Gb/s
ahci0: no device detected on port 4
ahci0: no device detected on port 5
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, WDC WD10EARS-00Y, 80.0> SCSI3 0/direct 
fixed naa.50014ee2b0b82bea
sd0: 953869MB, 512 bytes/sector, 1953525168 sectors
ahci0.1: errored slot 1, TFD: 2051<ERR>, SERR: 0, DIAG: 0
ahci0.1: errored slot 3, TFD: 2051<ERR>, SERR: 0, DIAG: 0
cd0 at scsibus1 targ 1 lun 0: <TSSTcorp, CDDVDW SH-S223C, me03> ATAPI 5/cdrom 
removable
ichiic0 at pci0 dev 31 function 3 "Intel 6 Series SMBus" rev 0x05: apic 0 int 18
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 2GB DDR3 SDRAM PC3-10600
spdmem1 at iic0 addr 0x52: 2GB DDR3 SDRAM PC3-10600
isa0 at pcib0
isadma0 at isa0
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
vmm0 at mainbus0: VMX/EPT
uhub3 at uhub0 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 
2.00/0.00 addr 2
uhub4 at uhub3 port 2 configuration 1 interface 0 "Macally Macally iKey" rev 
1.10/0.01 addr 3
uhidev0 at uhub4 port 1 configuration 1 interface 0 "Macally Macally iKey" rev 
1.10/0.01 addr 4
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd1 at ukbd0 mux 1
uhub5 at uhub2 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 
2.00/0.00 addr 2
umass0 at uhub5 port 5 configuration 1 interface 0 "Generic Mass Storage 
Device" rev 2.00/1.00 addr 3
umass0: using SCSI over Bulk-Only
scsibus2 at umass0: 2 targets, initiator 0
sd1 at scsibus2 targ 1 lun 0: <Multiple, Card Reader, 1.00> SCSI0 0/direct 
removable serial.058f6366058F63666433
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
root on sd0a (8783bc3bd26c2187.a) swap on sd0b dump on sd0b
reading hibernate signature block location: 8843311
wrong magic number in hibernate signature: 0
radeondrm0: 1920x1080, 32bpp
wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0
wskbd1: connecting to wsdisplay0
wsdisplay0: screen 1-5 added (std, vt100 emulation)
WARNING !(rw_status(&mode_config->mutex) == 0x0001UL) && 
!drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
/usr/src/sys/dev/pci/drm/drm_crtc.h:1577
WARNING !(rw_status(&mode_config->mutex) == 0x0001UL) && 
!drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
/usr/src/sys/dev/pci/drm/drm_crtc.h:1577
wskbd1: disconnecting from wsdisplay0
wskbd1 detached
ukbd0 detached
uhidev0 detached
uhub4 detached
uhub3 detached
uhub0 detached
uhub1 detached
sd1 detached
scsibus2 detached
umass0 detached
uhub5 detached
uhub2 detached
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
uhub1 at usb1 configuration 1 interface 0 "ASMedia xHCI root hub" rev 3.00/1.00 
addr 1
uhub2 at usb2 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
ahci0.0: port reset
ahci0: detected device on port 0
ahci0.1: port reset
ahci0: detected device on port 1
WARNING !(rw_status(&mode_config->mutex) == 0x0001UL) && 
!drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
/usr/src/sys/dev/pci/drm/drm_crtc.h:1577
WARNING !(rw_status(&mode_config->mutex) == 0x0001UL) && 
!drm_modeset_is_locked(&mode_config->connection_mutex) failed at 
/usr/src/sys/dev/pci/drm/drm_crtc.h:1577
uhub3 at uhub0 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 
2.00/0.00 addr 2
uhub4 at uhub3 port 2 configuration 1 interface 0 "Macally Macally iKey" rev 
1.10/0.01 addr 3
uhidev0 at uhub4 port 1 configuration 1 interface 0 "Macally Macally iKey" rev 
1.10/0.01 addr 4
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd1 at ukbd0 mux 1
wskbd1: connecting to wsdisplay0
uhub5 at uhub2 port 1 configuration 1 interface 0 "Intel Rate Matching Hub" rev 
2.00/0.00 addr 2
umass0 at uhub5 port 5 configuration 1 interface 0 "Generic Mass Storage 
Device" rev 2.00/1.00 addr 3
umass0: using SCSI over Bulk-Only
scsibus2 at umass0: 2 targets, initiator 0
sd1 at scsibus2 targ 1 lun 0: <Multiple, Card Reader, 1.00> SCSI0 0/direct 
removable serial.058f6366058F63666433

Reply via email to