Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Apr 2003 12:38:52 -0500
From:      Anish Mistry <mistry.7@osu.edu>
To:        freebsd-current@freebsd.org
Subject:   USB Ohci Suspend/Resume
Message-ID:  <200304051238.52084.mistry.7@osu.edu>

next in thread | raw e-mail | index | archive | help

--Boundary-00=_sSxj+tsz7Vihhss
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,
	I've been working on some usb suspend/resume code for my laptop since the USB 
ports stop working after a resume.  After a lot of trial and error I finally 
got it to "work" sorta.  Behavior with my code:
1) If I remove any type of device, suspend the laptop and then resume any usb 
device that I plug in will start working correctly, etc.
attach -> detach -> suspend -> resume -> attach  (OK)
2) When I leave a device plugged in and remove it while it is suspended, then 
resume it, the laptop will resume properly, but when I plug the device back 
it will show a detaching message then panic.
attach -> suspend -> detach -> resume -> attach  (Panic)
3) If I leave the device plugged in then suspend and resume with the device 
plugged in it will panic.
attach -> suspend -> resume -> (Panic)
4) If I suspend the laptop, plug in the device, and then resume, then it's ok.
suspend -> attach -> resume -> (Ok)

Now for the weird part, at least for me.   Panics for numbers (2) and (3) only 
happen with certain classes of devices (ums,ukbd), but with devices like 
(uhid,umass,uscanner,ugen) there was no panic and the devices reattached just 
fine.  These were the only type of devices that I was able to test, so the 
lists probably includes other device types.

If anyone has any suggestions it would be appreciated.  This is my first 
attempt at any kernel code.

Attached is my dmesg, and usb code patch. 

Thanks,

This is where it panics:
ohci_device_intr_close

This GDB was configured as "i386-undermydesk-freebsd"...
panic: page fault
panic messages:
---
Fatal trap 12: page fault while in kernel mode
fault virtual address   = 0x10
fault code              = supervisor write, page not present
instruction pointer     = 0x8:0xc266605f
stack pointer           = 0x10:0xcd357be4
frame pointer           = 0x10:0xcd357c00
code segment            = base 0x0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, def32 1, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 337 (usb0)
trap number             = 12
panic: page fault

syncing disks, buffers remaining... 1414 1414 1413 1413 1413 1413 1413 1413 
1413                        1413 1413 1413 1413 1413 1413 
wakeup from sleeping state (slept 00:00:09)
ata0: resetting devices ..
done
ata1: resetting devices ..
done
1413 1413 1413 1413 1413 1413 1413 
giving up on 1326 buffers
Uptime: 1m39s
Dumping 239 MB
ata0: resetting devices ..
done
 16 32 48 64 80 96 112 128 144 160 176 192 208 224
---
Reading symbols from 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/                       
acpi/acpi.ko.debug...done.
pi/acpi.ko.debug
Reading symbols from 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/                       
usb/usb.ko.debug...done.
Loaded symbols for 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/us                       
b/usb.ko.debug
Reading symbols from 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/                       
linux/linux.ko.debug...done.
Loaded symbols for 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/li                       
nux/linux.ko.debug
Reading symbols from 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/                       
ums/ums.ko.debug...done.
Loaded symbols for 
/usr/obj/usr/src/sys/LITTLEGUY/modules/usr/src/sys/modules/um                       
s/ums.ko.debug
#0  doadump () at /usr/src/sys/kern/kern_shutdown.c:239
239             dumping++;
(kgdb) bt
#0  doadump () at /usr/src/sys/kern/kern_shutdown.c:239
#1  0xc01e5a98 in boot (howto=256) at /usr/src/sys/kern/kern_shutdown.c:371
#2  0xc01e5d43 in panic () at /usr/src/sys/kern/kern_shutdown.c:542
#3  0xc02fa7e2 in trap_fatal (frame=0xcd357ba4, eva=0)
    at /usr/src/sys/i386/i386/trap.c:843
#4  0xc02fa4c2 in trap_pfault (frame=0xcd357ba4, usermode=0, eva=16)
    at /usr/src/sys/i386/i386/trap.c:757
#5  0xc02fa03d in trap (frame=
      {tf_fs = 24, tf_es = 16, tf_ds = 16, tf_edi = 4, tf_esi = -1033428992, 
tf_                       ebp = -852132864, tf_isp = -852132912, tf_ebx = 
-1033431168, tf_edx = 0, tf_ecx                        = -1033444956, tf_eax 
= -1033429216, tf_trapno = 12, tf_err = 2, tf_eip = -10334                       
78049, tf_cs = 8, tf_eflags = 66118, tf_esp = -1033351552, tf_ss = 
-852132872})
    at /usr/src/sys/i386/i386/trap.c:444
#6  0xc02eaa08 in calltrap () at {standard input}:96
#7  0xc265c148 in usbd_close_pipe (pipe=0xc2671780)
    at /usr/src/sys/dev/usb/usbdi.c:272
#8  0xc26b3c4d in ums_disable (priv=0xc2671780)
    at /usr/src/sys/dev/usb/ums.c:582
#9  0xc26b36d2 in ums_detach (self=0x0) at /usr/src/sys/dev/usb/ums.c:371
#10 0xc01f9d57 in device_detach (dev=0xc2672000) at device_if.h:48
#11 0xc01f90ef in device_delete_child (dev=0x0, child=0xc28390a0)
    at /usr/src/sys/kern/subr_bus.c:976
#12 0xc265be93 in usb_disconnect_port (up=0x4, parent=0x0)
---Type <return> to continue, or q <return> to quit--- 
    at /usr/src/sys/dev/usb/usb_subr.c:1364
#13 0xc265919e in uhub_explore (dev=0xc262e100)
    at /usr/src/sys/dev/usb/uhub.c:428
#14 0xc2659f65 in usb_discover (v=0xc242c1a0) at 
/usr/src/sys/dev/usb/usb.c:702
#15 0xc2659958 in usb_event_thread (arg=0xc242c1a0)
    at /usr/src/sys/dev/usb/usb.c:399
#16 0xc01d3912 in fork_exit (callout=0xc26598f0 <usb_event_thread>, arg=0x0, 
    frame=0x0) at /usr/src/sys/kern/kern_fork.c:791
(kgdb) 


-- 
Anish Mistry
--Boundary-00=_sSxj+tsz7Vihhss
Content-Type: text/plain;
  charset="us-ascii";
  name="dmesg.littleguy"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="dmesg.littleguy"

Copyright (c) 1992-2003 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT #5: Thu Apr  3 17:07:28 EST 2003
    root@littleguy.resnet.ohio-state.edu:/usr/obj/usr/src/sys/LITTLEGUY
Preloaded elf kernel "/boot/kernel/kernel" at 0xc046b000.
Preloaded elf module "/boot/kernel/acpi.ko" at 0xc046b0a8.
Timecounter "i8254"  frequency 1193182 Hz
Timecounter "TSC"  frequency 859336263 Hz
CPU: Transmeta(tm) Crusoe(tm) Processor TM5800 (859.34-MHz 586-class CPU)
  Origin = "GenuineTMx86"  Id = 0x543
real memory  = 251527168 (239 MB)
avail memory = 239439872 (228 MB)
Allocating major#253 to "net"
Allocating major#252 to "g_ctl"
Allocating major#251 to "pci"
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: <FUJ    PAULING2> on motherboard
    ACPI-0625: *** Info: GPE Block0 defined as GPE0 to GPE63
pcibios: BIOS version 2.10
Using $PIR table, 9 entries at 0xc00fdf30
acpi0: power button is handled as a fixed feature programming model.
Timecounter "ACPI-safe"  frequency 3579545 Hz
acpi_timer0: <24-bit timer at 3.579545MHz> port 0xff08-0xff0b on acpi0
acpi_cpu0: <CPU> port 0x530-0x537 on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pci0: <memory, RAM> at device 0.1 (no driver attached)
pci0: <memory, RAM> at device 0.2 (no driver attached)
pci0: <serial bus, USB> at device 2.0 (no driver attached)
pcm0: <Acer Labs M5451> port 0x1000-0x10ff mem 0xfc005000-0xfc005fff irq 9 at device 4.0 on pci0
pcm0: <SigmaTel STAC9756/57 AC97 Codec>
alpm0: <AcerLabs M15x3 Power Management Unit> at device 6.0 on pci0
alpm0: Could not allocate Bus space
device_probe_and_attach: alpm0 attach returned 6
isab0: <PCI-ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
pci0: <bridge, PCI-CardBus> at device 12.0 (no driver attached)
atapci0: <AcerLabs Aladdin UDMA66 controller> port 0x1800-0x180f at device 15.0 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
rl0: <RealTek 8139 10/100BaseTX> port 0x8000-0x80ff mem 0xfc007800-0xfc0078ff irq 9 at device 16.0 on pci0
rl0: Realtek 8139B detected. Warning, this may be unstable in autoselect mode
rl0: Ethernet address: 00:e0:00:ae:45:08
miibus0: <MII bus> on rl0
rlphy0: <RealTek internal media interface> on miibus0
rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
pci0: <serial bus, FireWire> at device 19.0 (no driver attached)
pci0: <display, VGA> at device 20.0 (no driver attached)
acpi_button0: <Power Button> on acpi0
acpi_acad0: <AC adapter> on acpi0
acpi_cmbat0: <Control method Battery> on acpi0
acpi_cmbat1: <Control method Battery> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model Generic PS/2 mouse, device ID 0
acpi_ec0: <embedded controller> port 0x66,0x62 on acpi0
orm0: <Option ROMs> at iomem 0xd0000-0xd0fff,0xc0000-0xcffff on isa0
pmtimer0 on isa0
fdc0: ready for input in output
fdc0: cmd 3 failed at out byte 1 of 3
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
Timecounters tick every 10.000 msec
acpi_cpu: throttling enabled, 8 steps (100% to 12.5%), currently 100.0%
Allocating major#250 to "devstat"
ad0: 19077MB <TOSHIBA MK2018GAP> [38760/16/63] at ata0-master UDMA66
acd0: CD-RW <TOSHIBA DVD-ROM SD-R2212> at ata1-master PIO4
Mounting root from ufs:/dev/ad0s2a
warning: KLD '/boot/kernel/usb.ko' is newer than the linker.hints file
alpm0: <AcerLabs M15x3 Power Management Unit> at device 6.0 on pci0
alpm0: Could not allocate Bus space
device_probe_and_attach: alpm0 attach returned 6
ohci0: <AcerLabs M5237 (Aladdin-V) USB controller> mem 0xfc004000-0xfc004fff irq 11 at device 2.0 on pci0
usb0: OHCI version 1.0, legacy support
usb0: <AcerLabs M5237 (Aladdin-V) USB controller> on ohci0
usb0: USB revision 1.0
uhub0: AcerLabs OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
alpm0: <AcerLabs M15x3 Power Management Unit> at device 6.0 on pci0
alpm0: Could not allocate Bus space
device_probe_and_attach: alpm0 attach returned 6

--Boundary-00=_sSxj+tsz7Vihhss--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304051238.52084.mistry.7>