Crash plugging in a USB device with XHCI activated.

2014-04-03 Thread Remco
I tried XHCI and found it unusable in my case as it immediately crashes the 
system when plugging in an USB device.

This mail has three sections with information gathered from dmesgs that 
survived reboot:

1) plugging in an USB device appear to crash the USB stack as well as the 
console.

2) in single user mode, plugging in an USB device appear to crash just the USB 
stack.

3) addition of printfs revealing xfer pointer becoming 0xdeafbeaddeafbead.


1) Startup is in xdm, goto virtual console with Alt-F2.
Plugin USB device (USB-to-serial in this case), resulting in:


OpenBSD 5.5-current (GENERIC.MP) #13: Wed Mar 26 10:39:35 CET 2014
re...@ws0001.home.lan:/mnt/remco/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4277010432 (4078MB)
avail mem = 4154404864 (3961MB)
warning: no entropy supplied by boot loader
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xf0100 (38 entries)
bios0: vendor Award Software International, Inc. version F12 date 06/19/2009
bios0: Gigabyte Technology Co., Ltd. P35-DS3P
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP HPET MCFG APIC SSDT
acpi0: wakeup devices PEX0(S5) PEX1(S5) PEX2(S5) PEX3(S5) PEX4(S5) PEX5(S5) 
HUB0(S5) UAR1(S1) USB0(S1) USB1(S1) USB2(S1) USB3(S1) US31(S1) USB4(S1) USB5
(S1) USBE(S1) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimcfg0 at acpi0 addr 0xf000, bus 0-63
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz, 2400.31 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,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 266MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.0.0, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz, 2400.00 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,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,NXE,LONG,LAHF,PERF
cpu1: 4MB 64b/line 16-way L2 cache
cpu1: smt 0, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 2
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (PEX0)
acpiprt2 at acpi0: bus 3 (PEX1)
acpiprt3 at acpi0: bus -1 (PEX2)
acpiprt4 at acpi0: bus -1 (PEX3)
acpiprt5 at acpi0: bus 4 (PEX4)
acpiprt6 at acpi0: bus 5 (PEX5)
acpiprt7 at acpi0: bus 6 (HUB0)
acpicpu0 at acpi0: FVS, 2400, 1600 MHz
acpicpu1 at acpi0: FVS, 2400, 1600 MHz
acpibtn0 at acpi0: PWRB
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 Intel 82G33 Host rev 0x02
ppb0 at pci0 dev 1 function 0 Intel 82G33 PCIE rev 0x02: msi
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 0 function 0 ATI Radeon Mobility HD 5430 rev 0x00
drm0 at radeondrm0
radeondrm0: msi
azalia0 at pci1 dev 0 function 1 ATI Radeon HD 5470 Audio rev 0x00: msi
azalia0: no supported codecs
uhci0 at pci0 dev 26 function 0 Intel 82801I USB rev 0x02: apic 2 int 16
uhci1 at pci0 dev 26 function 1 Intel 82801I USB rev 0x02: apic 2 int 21
uhci2 at pci0 dev 26 function 2 Intel 82801I USB rev 0x02: apic 2 int 18
ehci0 at pci0 dev 26 function 7 Intel 82801I USB rev 0x02: apic 2 int 18
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 Intel EHCI root hub rev 2.00/1.00 addr 1
azalia1 at pci0 dev 27 function 0 Intel 82801I HD Audio rev 0x02: msi
azalia1: codecs: Realtek ALC885
audio0 at azalia1
ppb1 at pci0 dev 28 function 0 Intel 82801I PCIE rev 0x02: msi
pci2 at ppb1 bus 2
ppb2 at pci0 dev 28 function 1 Intel 82801I PCIE rev 0x02: msi
pci3 at ppb2 bus 3
xhci0 at pci3 dev 0 function 0 NEC xHCI rev 0x04: apic 2 int 17
usb1 at xhci0: USB revision 3.0
uhub1 at usb1 NEC XHCI root hub rev 3.00/1.00 addr 1
ppb3 at pci0 dev 28 function 4 Intel 82801I PCIE rev 0x02: msi
pci4 at ppb3 bus 4
jmb0 at pci4 dev 0 function 0 JMicron JMB363 IDE/SATA rev 0x02
ahci0 at jmb0: apic 2 int 16, AHCI 1.0
scsibus0 at ahci0: 32 targets
jmb1 at pci4 dev 0 function 1 JMicron JMB363 IDE/SATA rev 0x02
pciide0 at jmb1: DMA, channel 0 wired to native-PCI, channel 1 wired to 
native-PCI
pciide0: using apic 2 int 17 for native-PCI interrupt
atapiscsi0 at pciide0 channel 0 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0: _NEC, DVD_RW ND-4571A, 1-02 ATAPI 5/cdrom 
removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
pciide0: channel 1 disabled (no drives)
ppb4 at pci0 dev 28 function 5 Intel 82801I PCIE rev 0x02: msi
pci5 at ppb4 bus 5
re0 at pci5 dev 0 function 0 Realtek 8168 rev 0x01: RTL8168 2 (0x3800), msi, 
address 00:1a:4d:52:9b:be
rgephy0 at re0 phy 7: RTL8169S/8110S PHY, rev. 2
uhci3 at pci0 dev 29 function 0 Intel 82801I USB rev 0x02: apic 2 int 23
uhci4 at 

Re: Samsung900X3F: wrong acpitz temperature, acpibat0 not detecting battery

2014-04-03 Thread Remi Locherer
Hi Paul

On Wed, Apr 02, 2014 at 06:22:35PM +0300, Paul Irofti wrote:
 Hi Remi,
 
 thank you for the detailed report and for your patience.
 
 I was wondering if you could test the following diff and let me know
 what happens.

I applied this patch to a freshly checked out source tree on April 2
and tested a few boot sequences:

#1
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032101.txt
acpitz0 ok, battery sensors partly
zzz: imediate shutdown after resume: acpitz0  144

#2
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032104.txt
immediate shutdown, acpitz0  144

#3
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032136.txt
acpitz0 ok, battery sensors partly
zzz: imediate shutdown after resume: acpitz0  144

#4
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032138.txt
immediate shutdown, acpitz0  144

#5
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032140.txt
immediate shutdown, acpitz0  144

#6
https://relo.ch/dmesg-samsung900X3F/dmesg-samsung900X3F-201404032147.txt
acpitz0 ok, battery sensors partly, keyboard illumination on
zzz: imediate shutdown after resume: acpitz0  144, 
 keyboard illumination stays off during and after resume


Thank you for having a look into this!
Remi

 
 Thanks,
 Paul
 
 Index: dev/acpi/acpiec.c
 ===
 RCS file: /cvs/src/sys/dev/acpi/acpiec.c,v
 retrieving revision 1.48
 diff -u -p -r1.48 acpiec.c
 --- dev/acpi/acpiec.c 2 Jul 2013 18:37:47 -   1.48
 +++ dev/acpi/acpiec.c 2 Apr 2014 15:21:00 -
 @@ -34,6 +34,7 @@
  
  int  acpiec_match(struct device *, void *, void *);
  void acpiec_attach(struct device *, struct device *, void *);
 +int  acpiec_activate(struct device *, int);
  
  u_int8_t acpiec_status(struct acpiec_softc *);
  u_int8_t acpiec_read_data(struct acpiec_softc *);
 @@ -54,6 +55,7 @@ int acpiec_getregister(const u_int8_t *
  
  void acpiec_wait(struct acpiec_softc *, u_int8_t, u_int8_t);
  void acpiec_sci_event(struct acpiec_softc *);
 +void acpiec_clear_events(struct acpiec_softc *);
  
  void acpiec_get_events(struct acpiec_softc *);
  
 @@ -82,7 +84,8 @@ voidacpiec_unlock(struct acpiec_softc 
  int  acpiec_reg(struct acpiec_softc *);
  
  struct cfattach acpiec_ca = {
 - sizeof(struct acpiec_softc), acpiec_match, acpiec_attach
 + sizeof(struct acpiec_softc), acpiec_match, acpiec_attach,
 + NULL, acpiec_activate
  };
  
  struct cfdriver acpiec_cd = {
 @@ -296,6 +299,8 @@ acpiec_attach(struct device *parent, str
   acpi_set_gpehandler(sc-sc_acpi, sc-sc_gpe, acpiec_gpehandler,
   sc, 1);
  #endif
 +
 + /* acpiec_clear_events(sc); */
   
   if (aml_evalname(sc-sc_acpi, sc-sc_devnode, _GLK, 0, NULL, res))
   sc-sc_glk = 0;
 @@ -307,6 +312,20 @@ acpiec_attach(struct device *parent, str
   printf(\n);
  }
  
 +int
 +acpiec_activate(struct device *self, int act)
 +{
 + struct acpiec_softc *sc = (struct acpiec_softc *)self;
 +
 +
 + switch (act) {
 + case DVACT_RESUME:
 + acpiec_clear_events(sc);
 + break;
 + }
 + return (0);
 +}
 +
  void
  acpiec_get_events(struct acpiec_softc *sc)
  {
 @@ -552,4 +571,19 @@ acpiec_unlock(struct acpiec_softc *sc)
   }
  
   sc-sc_ecbusy = 0;
 +}
 +
 +void
 +acpiec_clear_events(struct acpiec_softc *sc)
 +{
 + int i;
 +
 + for (i = 0; i  100; i++) {
 + /*acpiec_write_cmd(sc, EC_CMD_QR);*/
 + bus_space_write_1(sc-sc_cmd_bt, sc-sc_cmd_bh, 0, EC_CMD_QR);
 + sc-sc_gotsci = 0;
 + if ((acpiec_status(sc)  EC_STAT_SCI_EVT) != EC_STAT_SCI_EVT) {
 + break;
 + }
 + }
  }



Re: Crash plugging in a USB device with XHCI activated.

2014-04-03 Thread Martin Pieuchot
On 03/04/14(Thu) 18:09, Remco wrote:
 I tried XHCI and found it unusable in my case as it immediately crashes the 
 system when plugging in an USB device.

xhci(4) is not enabled for a reason, the stack is not ready, this is not
an issue.