Subject: CVS commit: [itohy-usb1] src/sys
To: None <source-changes@NetBSD.org>
From: ITOH Yasufumi <itohy@netbsd.org>
List: source-changes
Date: 05/22/2007 14:57:52
Module Name:	src
Committed By:	itohy
Date:		Tue May 22 14:57:51 UTC 2007

Modified Files:
	src/sys/arch/x68k/dev [itohy-usb1]: slhci_intio.c
	src/sys/conf [itohy-usb1]: files
	src/sys/dev/cardbus [itohy-usb1]: ehci_cardbus.c ohci_cardbus.c
	    uhci_cardbus.c
	src/sys/dev/ic [itohy-usb1]: sl811hs.c sl811hsvar.h
	src/sys/dev/isa [itohy-usb1]: slhci_isa.c
	src/sys/dev/pci [itohy-usb1]: ehci_pci.c ohci_pci.c uhci_pci.c
	src/sys/dev/pcmcia [itohy-usb1]: files.pcmcia
	src/sys/dev/usb [itohy-usb1]: ehci.c ehcireg.h ehcivar.h files.usb
	    if_atu.c if_aue.c if_axe.c if_cdce.c if_cue.c if_kue.c if_rum.c
	    if_udav.c if_upl.c if_ural.c if_url.c ohci.c ohcireg.h ohcivar.h
	    uaudio.c ubt.c ucom.c ugen.c uhci.c uhcireg.h uhcivar.h uhid.c
	    uhidev.c uhub.c uirda.c ulpt.c umass.c umass_scsipi.c umassvar.h
	    umidi.c urio.c usb.c usb.h usb_mem.c usb_mem.h usb_port.h
	    usb_subr.c usbdi.c usbdi.h usbdi_util.c usbdi_util.h usbdivar.h
	    uscanner.c usscanner.c ustir.c utoppy.c
Added Files:
	src/sys/dev/pcmcia [itohy-usb1]: slhci_pcmcia.c
	src/sys/dev/usb [itohy-usb1]: api.txt filelist usb_mem_nodma.c
	    usb_mem_nodma.h

Log Message:
Overhaul of USB stack, mostly DMA related

This applies to NetBSD 4.99.13 (March 1, 2007)

usbdi(9) interface is based on FreeBSD version, excluding
 - removal of portability code

Patch most NetBSD changes, excluding
 - DMA memory "reserve", since we don't need contiguous buffers any longer
 - volatiles in DMA structure, since it should not be needed
   with proper bus_dmamap_sync(9)s

DMA/non-DMA memory management overhaul
 - Move all DMA related code to usb_mem.[ch]
   (add usb_alloc_buffer_dma(), usb_free_buffer_dma(), etc.).
   XXX Should usb_mem.[ch] be renamed as usb_mem_dma.[ch] ?
 - Add corresponding non-DMA code to usb_mem_nodma.[ch] .
   Currently just use malloc(9).
 - Above files are conditionally used by config framework (added
   attributes to conf/files and dev/usb/files.usb).
 - Add diagnostic panics when resource allocation is requested
   on interrupt context.
 - Change memory allocations (that require context) from NOWAIT to WAITOK.

Allocate DMA/non-DMA buffer per host interface, not globally.
 advantage:	Buffers can be freed on detaching host interface.
		Activity of a host interface does not affect others.
 disadvantages:	It possibly consumes more memory.

API changes
 - usbd_alloc_xfer() is changed:
    old: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev);
    new: usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle dev,
		usbd_pipe_handle pipe);
 - pipe argument of usbd_setup_*xfer() are now unused
   XXX the pipe argument should be removed?
 - add mapping APIs
 - async request will be processed as a task (kernel thread context),
   and delayed to some extent
 - usbdivar.h: struct usbd_xfer: renamed a member "allocbuf" to "hcbuffer"
   (mapped/allocated/refered buffer for HCI driver)
 - usb_port.h: change usb_proc_ptr from  struct ptoc *  to struct lwp *
 - usb_port.h: add usb_sigproc_ptr for psignal(9) (struct proc *)
 - usb.h: add UE_MAXPKTSZ(ep) and UE_MAXPKTSZ_MASK macros for USB 2.0

changes to USB device drivers
 - atu, aue, axe, cdce, cue, kue, rum, udav, upl, ural, url,
   uaudio, ubt, ucom, ugen, uhidev, uirda, ulpt, umidi, urio,
   uscanner, ustir, utoppy:
    * catch up API change of usbd_alloc_xfer()
 - umass, usscanner:
    * catch up API change of usbd_alloc_xfer()
    * eliminate memory copy for large transfer

ohci
 - free resources on detach
 - add lots of bus_dmamap_sync() operations
 - simplify the code of loading std chain
 - rewrite code of looking up TD/ITD from DMA addr by using allocation chunk
 - add workaround for CMD Tech 670 and 673 chipsets
 - make sure resources are not allocated in interrupt context
 - add support for mapping buffer and mbuf

slhci
 - allocate xfer and slhci_xfer at once, and simplify relevant code
 - add slhci_detach()
 - remove second arg of slhci_attach() since it is the same as the first arg.
 - add support for "mapping" (no, it doesn't map since it doesn't do DMA)
   buffer and mbuf
 - add pcmcia frontend
 - NOT TESTED, missing hardware

ehci
 - add lots of bus_dmamap_sync() operations, possibly too many
 - make sure resources are not allocated in interrupt context
 - add support for mapping buffer and mbuf
 - done only simple test

uhci
 - add lots of bus_dmamap_sync() operations, possibly too many
 - make sure resources are not allocated in interrupt context
 - add support for mapping buffer and mbuf

To do
 - review, test, debug
 - rewrite network drivers to utilize usbd_map_buffer_mbuf()
 - rewrite uaudio(4) to eliminate memcpy
 - "pipe" argument of usbd_setup_*xfer() should eventually be removed


To generate a diff of this commit:
cvs rdiff -r1.7 -r1.7.42.1 src/sys/arch/x68k/dev/slhci_intio.c
cvs rdiff -r1.831 -r1.831.6.1 src/sys/conf/files
cvs rdiff -r1.16 -r1.16.18.1 src/sys/dev/cardbus/ehci_cardbus.c
cvs rdiff -r1.23 -r1.23.18.1 src/sys/dev/cardbus/ohci_cardbus.c
cvs rdiff -r1.5 -r1.5.18.1 src/sys/dev/cardbus/uhci_cardbus.c
cvs rdiff -r1.11 -r1.11.18.1 src/sys/dev/ic/sl811hs.c
cvs rdiff -r1.1 -r1.1.80.1 src/sys/dev/ic/sl811hsvar.h
cvs rdiff -r1.6 -r1.6.18.1 src/sys/dev/isa/slhci_isa.c
cvs rdiff -r1.27 -r1.27.14.1 src/sys/dev/pci/ehci_pci.c
cvs rdiff -r1.31 -r1.31.18.1 src/sys/dev/pci/ohci_pci.c
cvs rdiff -r1.35 -r1.35.14.1 src/sys/dev/pci/uhci_pci.c
cvs rdiff -r1.54 -r1.54.14.1 src/sys/dev/pcmcia/files.pcmcia
cvs rdiff -r0 -r1.1.2.1 src/sys/dev/pcmcia/slhci_pcmcia.c
cvs rdiff -r0 -r1.1.2.1 src/sys/dev/usb/api.txt src/sys/dev/usb/filelist \
    src/sys/dev/usb/usb_mem_nodma.c src/sys/dev/usb/usb_mem_nodma.h
cvs rdiff -r1.123 -r1.123.12.1 src/sys/dev/usb/ehci.c
cvs rdiff -r1.25 -r1.25.18.1 src/sys/dev/usb/ehcireg.h
cvs rdiff -r1.24 -r1.24.14.1 src/sys/dev/usb/ehcivar.h
cvs rdiff -r1.73 -r1.73.10.1 src/sys/dev/usb/files.usb \
    src/sys/dev/usb/usb_port.h
cvs rdiff -r1.24 -r1.24.6.1 src/sys/dev/usb/if_atu.c
cvs rdiff -r1.99 -r1.99.10.1 src/sys/dev/usb/if_aue.c
cvs rdiff -r1.17 -r1.17.10.1 src/sys/dev/usb/if_axe.c src/sys/dev/usb/ustir.c
cvs rdiff -r1.12 -r1.12.10.1 src/sys/dev/usb/if_cdce.c
cvs rdiff -r1.48 -r1.48.10.1 src/sys/dev/usb/if_cue.c
cvs rdiff -r1.58 -r1.58.10.1 src/sys/dev/usb/if_kue.c
cvs rdiff -r1.6 -r1.6.4.1 src/sys/dev/usb/if_rum.c
cvs rdiff -r1.15 -r1.15.10.1 src/sys/dev/usb/if_udav.c
cvs rdiff -r1.27 -r1.27.4.1 src/sys/dev/usb/if_upl.c
cvs rdiff -r1.18 -r1.18.10.1 src/sys/dev/usb/if_ural.c
cvs rdiff -r1.24 -r1.24.10.1 src/sys/dev/usb/if_url.c
cvs rdiff -r1.182 -r1.182.12.1 src/sys/dev/usb/ohci.c
cvs rdiff -r1.22 -r1.22.18.1 src/sys/dev/usb/ohcireg.h
cvs rdiff -r1.39 -r1.39.40.1 src/sys/dev/usb/ohcivar.h
cvs rdiff -r1.109 -r1.109.8.1 src/sys/dev/usb/uaudio.c
cvs rdiff -r1.22 -r1.22.10.1 src/sys/dev/usb/ubt.c
cvs rdiff -r1.69 -r1.69.10.1 src/sys/dev/usb/ucom.c
cvs rdiff -r1.91 -r1.91.4.1 src/sys/dev/usb/ugen.c
cvs rdiff -r1.208 -r1.208.12.1 src/sys/dev/usb/uhci.c
cvs rdiff -r1.18 -r1.18.18.1 src/sys/dev/usb/uhcireg.h
cvs rdiff -r1.40 -r1.40.40.1 src/sys/dev/usb/uhcivar.h
cvs rdiff -r1.75 -r1.75.4.1 src/sys/dev/usb/uhid.c
cvs rdiff -r1.33 -r1.33.10.1 src/sys/dev/usb/uhidev.c
cvs rdiff -r1.85 -r1.85.8.1 src/sys/dev/usb/uhub.c
cvs rdiff -r1.23 -r1.23.8.1 src/sys/dev/usb/uirda.c
cvs rdiff -r1.76 -r1.76.10.1 src/sys/dev/usb/ulpt.c
cvs rdiff -r1.123 -r1.123.10.1 src/sys/dev/usb/umass.c
cvs rdiff -r1.29 -r1.29.10.1 src/sys/dev/usb/umass_scsipi.c
cvs rdiff -r1.25 -r1.25.14.1 src/sys/dev/usb/umassvar.h
cvs rdiff -r1.29 -r1.29.8.1 src/sys/dev/usb/umidi.c
cvs rdiff -r1.26 -r1.26.10.1 src/sys/dev/usb/urio.c
cvs rdiff -r1.95 -r1.95.4.1 src/sys/dev/usb/usb.c
cvs rdiff -r1.77 -r1.77.12.1 src/sys/dev/usb/usb.h
cvs rdiff -r1.31 -r1.31.10.1 src/sys/dev/usb/usb_mem.c
cvs rdiff -r1.23 -r1.23.32.1 src/sys/dev/usb/usb_mem.h
cvs rdiff -r1.143 -r1.143.8.1 src/sys/dev/usb/usb_subr.c
cvs rdiff -r1.119 -r1.119.12.1 src/sys/dev/usb/usbdi.c
cvs rdiff -r1.72 -r1.72.10.1 src/sys/dev/usb/usbdi.h
cvs rdiff -r1.48 -r1.48.4.1 src/sys/dev/usb/usbdi_util.c
cvs rdiff -r1.36 -r1.36.12.1 src/sys/dev/usb/usbdi_util.h
cvs rdiff -r1.80 -r1.80.12.1 src/sys/dev/usb/usbdivar.h
cvs rdiff -r1.54 -r1.54.10.1 src/sys/dev/usb/uscanner.c
cvs rdiff -r1.21 -r1.21.14.1 src/sys/dev/usb/usscanner.c
cvs rdiff -r1.8 -r1.8.10.1 src/sys/dev/usb/utoppy.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.