Op maandag 20-02-2012 om 13:17 uur [tijdzone -0500], schreef Kevin O'Connor: > Hi Nils, > > I put together a patch to modify the way the OHCI controller does pipe > free'ing. This is a preliminary patch (similar batch free'ing should > be done for the other controllers as well). However, it might help > with the USB issues you've been having. > > -Kevin > > > commit fa43976172295d3bad9209374bd68469c10ec918 > Author: Kevin O'Connor <[email protected]> > Date: Mon Feb 20 12:54:49 2012 -0500 > > Batch free USB pipes on OHCI controllers. > > Instead of unregistering each control "endpoint descriptor" after it > is used, keep them around for later users. Free all unused > descriptors in one batch at the end of initialization. This should > slightly optimize boot time, and it requires less overall interaction > with the controller. > > This also makes the descriptor free code more compliant with the spec. > The descriptor lists will only be modified after the list processing > has been disabled on the controller. > > Signed-off-by: Kevin O'Connor <[email protected]> > > diff --git a/src/usb-ohci.c b/src/usb-ohci.c > index 9107db2..7a437ad 100644 > --- a/src/usb-ohci.c > +++ b/src/usb-ohci.c > @@ -19,6 +19,14 @@ struct usb_ohci_s { > struct ohci_regs *regs; > }; > > +struct ohci_pipe { > + struct ohci_ed ed; > + struct usb_pipe pipe; > + void *data; > + int count; > + struct ohci_td *tds; > +}; > + > > /**************************************************************** > * Root hub > @@ -109,6 +117,56 @@ check_ohci_ports(struct usb_ohci_s *cntl) > * Setup > ****************************************************************/ > > +// Wait for next USB frame to start - for ensuring safe memory release. > +static void > +ohci_waittick(struct usb_ohci_s *cntl) > +{ > + barrier(); > + struct ohci_hcca *hcca = (void*)cntl->regs->hcca; > + u32 startframe = hcca->frame_no; > + u64 end = calc_future_tsc(1000 * 5); > + for (;;) { > + if (hcca->frame_no != startframe) > + break; > + if (check_tsc(end)) { > + warn_timeout(); > + return; > + } > + yield(); > + } > +} > + > +static void > +ohci_free_pipes(struct usb_ohci_s *cntl) > +{ > + dprintf(7, "ohci_free_pipes %p\n", cntl); > + > + u32 creg = readl(&cntl->regs->control); > + if (creg & (OHCI_CTRL_CLE|OHCI_CTRL_BLE)) { > + writel(&cntl->regs->control, creg & ~(OHCI_CTRL_CLE|OHCI_CTRL_BLE)); > + ohci_waittick(cntl); > + } > + > + u32 *pos = &cntl->regs->ed_controlhead; > + for (;;) { > + struct ohci_ed *next = (void*)*pos; > + if (!next) > + break; > + struct ohci_pipe *pipe = container_of(next, struct ohci_pipe, ed); > + if (pipe->pipe.cntl != &cntl->usb) { > + *pos = next->hwNextED; > + free(pipe); > + } else { > + pos = &next->hwNextED; > + } > + } > + > + writel(&cntl->regs->ed_controlcurrent, 0); > + writel(&cntl->regs->ed_bulkcurrent, 0); > + writel(&cntl->regs->control, creg); > + cntl->usb.freelist = NULL; > +} > + > static int > start_ohci(struct usb_ohci_s *cntl, struct ohci_hcca *hcca) > { > @@ -192,6 +250,7 @@ configure_ohci(void *data) > > int count = check_ohci_ports(cntl); > free_pipe(cntl->usb.defaultpipe); > + ohci_free_pipes(cntl); > if (! count) > goto err; > return; > @@ -260,74 +319,13 @@ wait_ed(struct ohci_ed *ed) > } > } > > -// Wait for next USB frame to start - for ensuring safe memory release. > -static void > -ohci_waittick(struct usb_ohci_s *cntl) > -{ > - barrier(); > - struct ohci_hcca *hcca = (void*)cntl->regs->hcca; > - u32 startframe = hcca->frame_no; > - u64 end = calc_future_tsc(1000 * 5); > - for (;;) { > - if (hcca->frame_no != startframe) > - break; > - if (check_tsc(end)) { > - warn_timeout(); > - return; > - } > - yield(); > - } > -} > - > -static void > -signal_freelist(struct usb_ohci_s *cntl) > -{ > - u32 v = readl(&cntl->regs->control); > - if (v & OHCI_CTRL_CLE) { > - writel(&cntl->regs->control, v & ~(OHCI_CTRL_CLE|OHCI_CTRL_BLE)); > - ohci_waittick(cntl); > - writel(&cntl->regs->ed_controlcurrent, 0); > - writel(&cntl->regs->ed_bulkcurrent, 0); > - writel(&cntl->regs->control, v); > - } else { > - ohci_waittick(cntl); > - } > -} > - > -struct ohci_pipe { > - struct ohci_ed ed; > - struct usb_pipe pipe; > - void *data; > - int count; > - struct ohci_td *tds; > -}; > - > void > -ohci_free_pipe(struct usb_pipe *p) > +ohci_free_pipe(struct usb_pipe *pipe) > { > - if (! CONFIG_USB_OHCI) > - return; > - dprintf(7, "ohci_free_pipe %p\n", p); > - struct ohci_pipe *pipe = container_of(p, struct ohci_pipe, pipe); > - struct usb_ohci_s *cntl = container_of( > - pipe->pipe.cntl, struct usb_ohci_s, usb); > - > - u32 *pos = &cntl->regs->ed_controlhead; > - for (;;) { > - struct ohci_ed *next = (void*)*pos; > - if (!next) { > - // Not found?! Exit without freeing. > - warn_internalerror(); > - return; > - } > - if (next == &pipe->ed) { > - *pos = next->hwNextED; > - signal_freelist(cntl); > - free(pipe); > - return; > - } > - pos = &next->hwNextED; > - } > + // Add to controller's free list. > + struct usb_s *cntl = pipe->cntl; > + pipe->freenext = cntl->freelist; > + cntl->freelist = pipe; > } > > struct usb_pipe * > @@ -339,7 +337,17 @@ ohci_alloc_control_pipe(struct usb_pipe *dummy) > dummy->cntl, struct usb_ohci_s, usb); > dprintf(7, "ohci_alloc_control_pipe %p\n", &cntl->usb); > > - // Allocate a queue head. > + if (cntl->usb.freelist) { > + // Use previously allocated queue head. > + struct ohci_pipe *pipe = container_of(cntl->usb.freelist > + , struct ohci_pipe, pipe); > + cntl->usb.freelist = pipe->pipe.freenext; > + > + memcpy(&pipe->pipe, dummy, sizeof(pipe->pipe)); > + return &pipe->pipe; > + } > + > + // Allocate a new queue head. > struct ohci_pipe *pipe = malloc_tmphigh(sizeof(*pipe)); > if (!pipe) { > warn_noalloc(); > diff --git a/src/usb.h b/src/usb.h > index 8b2af40..cc32eb7 100644 > --- a/src/usb.h > +++ b/src/usb.h > @@ -6,7 +6,10 @@ > > // Information on a USB end point. > struct usb_pipe { > - struct usb_s *cntl; > + union { > + struct usb_s *cntl; > + struct usb_pipe *freenext; > + }; > u64 path; > u8 type; > u8 ep; > @@ -20,6 +23,7 @@ struct usb_pipe { > // Common information for usb controllers. > struct usb_s { > struct usb_pipe *defaultpipe; > + struct usb_pipe *freelist; > struct mutex_s resetlock; > struct pci_device *pci; > int busid; Thanks for the patch. I tested this patch and the keyboard gets initialized now. The keyboard doesn't seem to react on keystroke yet tough and i still get a timeout error.(another bug?)
Thanks, Nils.
Start bios (version pre-1.6.4-20120221_194416-Debian) Find memory size Attempting to find coreboot table Found coreboot table forwarder. Now attempting to find coreboot memory map Add to e820 map: 00000000 00001000 2 Add to e820 map: 00001000 0009f000 1 Add to e820 map: 000c0000 1f710000 1 Add to e820 map: 1f7d0000 00010000 2 Add to e820 map: 00000000 00004000 1 Found mainboard Wyse s50 Found CBFS header at 0xfffffd30 Add to e820 map: 000a0000 00050000 -1 Add to e820 map: 000f0000 00010000 2 Ram Size=0x1f7d0000 (0x0000000000000000 high) malloc setup Add to e820 map: 1f7c0000 00010000 2 pmm_malloc zone=0x000f3870 handle=ffffffff size=34972 align=10 ret=0x1f7b7640 (detail=0x1f7bfee0) Relocating init from 0x000eafe0 to 0x1f7b7640 (size 34972) malloc fixup reloc init ivt init bda Add to e820 map: 0009fc00 00000400 2 init pic init timer tsc calibrate start=1144522701 end=1145149823 diff=627122 CPU Mhz=365 math cp init PCI probe Searching CBFS for prefix etc/extra-pci-roots Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b7570 (detail=0x1f7b75e0) PCI device 00:01.0 (vd=100b:0028 c=0600) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b74d0 (detail=0x1f7b7540) PCI device 00:01.1 (vd=100b:0030 c=0300) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b7430 (detail=0x1f7b74a0) PCI device 00:0e.0 (vd=10ec:8139 c=0200) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b7390 (detail=0x1f7b7400) PCI device 00:0f.0 (vd=1022:2090 c=0601) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b72f0 (detail=0x1f7b7360) PCI device 00:0f.2 (vd=1022:209a c=0101) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b7250 (detail=0x1f7b72c0) PCI device 00:0f.3 (vd=1022:2093 c=0401) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b71b0 (detail=0x1f7b7220) PCI device 00:0f.4 (vd=1022:2094 c=0c03) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=112 align=10 ret=0x1f7b7110 (detail=0x1f7b7180) PCI device 00:0f.5 (vd=1022:2095 c=0c03) Found 8 PCI devices (max PCI bus is 00) Searching CBFS for prefix bootorder Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file No apic - only the main cpu is present. init bios32 init PMM init PNPBIOS table init keyboard init mouse Relocating coreboot bios tables pmm_malloc zone=0x1f7bfec8 handle=ffffffff size=80 align=10 ret=0x000fdb10 (detail=0x1f7b70e0) Copying PIR from 0x1f7d0400 to 0x000fdb10 pmm_malloc zone=0x1f7bfec8 handle=ffffffff size=31 align=10 ret=0x000fdaf0 (detail=0x1f7b70b0) Copying SMBIOS entry point from 0x1f7d1400 to 0x000fdaf0 Scan for VGA option rom Searching CBFS for prefix etc/optionroms-checksum Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Searching CBFS for prefix etc/s3-resume-vga-init Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Searching CBFS for prefix etc/screen-and-debug Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to init PCI bdf 00:01.1 (vd 100b:0030) Searching CBFS for prefix pci100b,0030.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:01.1 Option rom sizing returned 0 0 Searching CBFS for prefix vgaroms/ Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file init usb pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=28 align=10 ret=0x1f7b7060 (detail=0x1f7b7080) OHCI init on dev 00:0f.4 (regs=0xfe00e000) pmm_malloc zone=0x1f7bfec4 handle=ffffffff size=256 align=100 ret=0x1f7cff00 (detail=0x1f7b7030) pmm_malloc zone=0x1f7bfec4 handle=ffffffff size=16 align=10 ret=0x1f7cfef0 (detail=0x1f7b7000) set_address 0x1f7b7060 ohci_alloc_control_pipe 0x1f7b7060 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6fa0 (detail=0x1f7b6fd0) ohci_control 0x1f7b6fb0 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6f40 (detail=0x1f7b6f70) pmm_free 0x1f7b6f40 (detail=0x1f7b6f70) ohci_alloc_control_pipe 0x1f7b7060 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6f40 (detail=0x1f7b6f70) config_usb: 0x1f7b6f50 ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6ee0 (detail=0x1f7b6f10) pmm_free 0x1f7b6ee0 (detail=0x1f7b6f10) device rev=0110 cls=00 sub=00 proto=00 size=08 ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6ee0 (detail=0x1f7b6f10) pmm_free 0x1f7b6ee0 (detail=0x1f7b6f10) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=59 align=10 ret=0x1f7b6ed0 (detail=0x1f7b6f10) ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6e70 (detail=0x1f7b6ea0) pmm_free 0x1f7b6e70 (detail=0x1f7b6ea0) ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6e70 (detail=0x1f7b6ea0) pmm_free 0x1f7b6e70 (detail=0x1f7b6ea0) usb_hid_init 0x1f7b6f50 ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6e70 (detail=0x1f7b6ea0) pmm_free 0x1f7b6e70 (detail=0x1f7b6ea0) ohci_control 0x1f7b6f50 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=48 align=10 ret=0x1f7b6e70 (detail=0x1f7b6ea0) pmm_free 0x1f7b6e70 (detail=0x1f7b6ea0) ohci_alloc_intr_pipe 0x1f7b7060 3 ebda moved from 9fc00 to 9f800 pmm_malloc zone=0x1f7bfec0 handle=ffffffff size=48 align=10 ret=0x0009ffd0 (detail=0x1f7b6ea0) pmm_malloc zone=0x1f7bfec0 handle=ffffffff size=240 align=10 ret=0x0009fee0 (detail=0x1f7b6e70) pmm_malloc zone=0x1f7bfec0 handle=ffffffff size=120 align=10 ret=0x0009fe60 (detail=0x1f7b6e40) USB keyboard initialized pmm_free 0x1f7b6ed0 (detail=0x1f7b6f10) ohci_free_pipes 0x1f7b7060 WARNING - Timeout at ohci_waittick:132! pmm_free 0x1f7b6f40 (detail=0x1f7b6f70) pmm_free 0x1f7b6fa0 (detail=0x1f7b6fd0) init serial Found 1 serial ports init hard drives pmm_malloc zone=0x1f7bfec8 handle=ffffffff size=16 align=10 ret=0x000fdae0 (detail=0x1f7b6fd0) ATA controller 1 at 1f0/3f4/1ca0 (irq 14 dev 7a) powerup iobase=1f0 st=50 powerup iobase=1f0 st=50 ata_detect ata0-0: sc=55 sn=aa dh=a0 ata_reset drive=0x00006e90 ata_reset exit status=50 send_cmd : read error (status=51 err=04) pmm_malloc zone=0x1f7bfec8 handle=ffffffff size=40 align=10 ret=0x000fdab0 (detail=0x1f7b6fa0) pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=80 align=10 ret=0x1f7b6f20 (detail=0x1f7b6f70) ata0-0: ST9100823A ATA-6 Hard-Disk (93 GiBytes) Searching bootorder for: /pci@i0cf8/*@f,2/drive@0/disk@0 pmm_malloc zone=0x1f7bfed0 handle=ffffffff size=20 align=10 ret=0x1f7b6ed0 (detail=0x1f7b6ef0) Registering bootable: ata0-0: ST9100823A ATA-6 Hard-Disk (93 GiBytes) (type:2 prio:103 data:fdab0) ata_detect resetresult=604d pmm_malloc zone=0x1f7bfec8 handle=ffffffff size=16 align=10 ret=0x000fdaa0 (detail=0x1f7b6e10) ATA controller 2 at 170/374/1ca8 (irq 15 dev 7a) powerup IDE floating powerup IDE floating ata_detect ata1-0: sc=ff sn=ff dh=ff powerup IDE floating powerup IDE floating ata_detect ata1-1: sc=ff sn=ff dh=ff init ahci Searching CBFS for prefix img/ Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Scan for option roms Attempting to init PCI bdf 00:01.0 (vd 100b:0028) Searching CBFS for prefix pci100b,0028.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:01.0 Option rom sizing returned 0 0 Attempting to init PCI bdf 00:0e.0 (vd 10ec:8139) Searching CBFS for prefix pci10ec,8139.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:0e.0 Option rom sizing returned 0 0 Attempting to init PCI bdf 00:0f.0 (vd 1022:2090) Searching CBFS for prefix pci1022,2090.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:0f.0 Option rom sizing returned 0 0 Attempting to init PCI bdf 00:0f.3 (vd 1022:2093) Searching CBFS for prefix pci1022,2093.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:0f.3 Option rom sizing returned 0 0 Attempting to init PCI bdf 00:0f.4 (vd 1022:2094) Searching CBFS for prefix pci1022,2094.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:0f.4 Option rom sizing returned 0 0 Attempting to init PCI bdf 00:0f.5 (vd 1022:2095) Searching CBFS for prefix pci1022,2095.rom Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file Attempting to map option rom on dev 00:0f.5 Option rom sizing returned 0 0 Searching CBFS for prefix genroms/ Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Found CBFS file enter handle_16: a=00000100 b=00000000 c=00000000 d=00000000 ds=0000 es=0000 ss=0000 si=00000000 di=00000000 bp=00000000 sp=00006e78 cs=f000 ip=ffec f=0202 Press F12 for boot menu. Searching CBFS for prefix etc/boot-menu-wait Found CBFS file fallback/romstage Found CBFS file fallback/coreboot_ram Found CBFS file fallback/payload Found CBFS file vsa Found CBFS file config Found CBFS file etc/boot-menu-wait Copying data 8@0xfff24a78 to 8@0x00006f10 enter handle_16:
_______________________________________________ SeaBIOS mailing list [email protected] http://www.seabios.org/mailman/listinfo/seabios
