{"payload":{"allShortcutsEnabled":false,"fileTree":{"Documentation/usb":{"items":[{"name":"CREDITS","path":"Documentation/usb/CREDITS","contentType":"file"},{"name":"URB.txt","path":"Documentation/usb/URB.txt","contentType":"file"},{"name":"acm.txt","path":"Documentation/usb/acm.txt","contentType":"file"},{"name":"anchors.txt","path":"Documentation/usb/anchors.txt","contentType":"file"},{"name":"authorization.txt","path":"Documentation/usb/authorization.txt","contentType":"file"},{"name":"callbacks.txt","path":"Documentation/usb/callbacks.txt","contentType":"file"},{"name":"dma.txt","path":"Documentation/usb/dma.txt","contentType":"file"},{"name":"ehci.txt","path":"Documentation/usb/ehci.txt","contentType":"file"},{"name":"error-codes.txt","path":"Documentation/usb/error-codes.txt","contentType":"file"},{"name":"gadget_printer.txt","path":"Documentation/usb/gadget_printer.txt","contentType":"file"},{"name":"gadget_serial.txt","path":"Documentation/usb/gadget_serial.txt","contentType":"file"},{"name":"hiddev.txt","path":"Documentation/usb/hiddev.txt","contentType":"file"},{"name":"hotplug.txt","path":"Documentation/usb/hotplug.txt","contentType":"file"},{"name":"iuu_phoenix.txt","path":"Documentation/usb/iuu_phoenix.txt","contentType":"file"},{"name":"linux.inf","path":"Documentation/usb/linux.inf","contentType":"file"},{"name":"mtouchusb.txt","path":"Documentation/usb/mtouchusb.txt","contentType":"file"},{"name":"ohci.txt","path":"Documentation/usb/ohci.txt","contentType":"file"},{"name":"persist.txt","path":"Documentation/usb/persist.txt","contentType":"file"},{"name":"power-management.txt","path":"Documentation/usb/power-management.txt","contentType":"file"},{"name":"proc_usb_info.txt","path":"Documentation/usb/proc_usb_info.txt","contentType":"file"},{"name":"rio.txt","path":"Documentation/usb/rio.txt","contentType":"file"},{"name":"usb-help.txt","path":"Documentation/usb/usb-help.txt","contentType":"file"},{"name":"usb-serial.txt","path":"Documentation/usb/usb-serial.txt","contentType":"file"},{"name":"usbmon.txt","path":"Documentation/usb/usbmon.txt","contentType":"file"}],"totalCount":24},"Documentation":{"items":[{"name":"ABI","path":"Documentation/ABI","contentType":"directory"},{"name":"DocBook","path":"Documentation/DocBook","contentType":"directory"},{"name":"PCI","path":"Documentation/PCI","contentType":"directory"},{"name":"RCU","path":"Documentation/RCU","contentType":"directory"},{"name":"accounting","path":"Documentation/accounting","contentType":"directory"},{"name":"acpi","path":"Documentation/acpi","contentType":"directory"},{"name":"aoe","path":"Documentation/aoe","contentType":"directory"},{"name":"arm","path":"Documentation/arm","contentType":"directory"},{"name":"auxdisplay","path":"Documentation/auxdisplay","contentType":"directory"},{"name":"blackfin","path":"Documentation/blackfin","contentType":"directory"},{"name":"block","path":"Documentation/block","contentType":"directory"},{"name":"cdrom","path":"Documentation/cdrom","contentType":"directory"},{"name":"connector","path":"Documentation/connector","contentType":"directory"},{"name":"console","path":"Documentation/console","contentType":"directory"},{"name":"controllers","path":"Documentation/controllers","contentType":"directory"},{"name":"cpu-freq","path":"Documentation/cpu-freq","contentType":"directory"},{"name":"cpuidle","path":"Documentation/cpuidle","contentType":"directory"},{"name":"cris","path":"Documentation/cris","contentType":"directory"},{"name":"crypto","path":"Documentation/crypto","contentType":"directory"},{"name":"device-mapper","path":"Documentation/device-mapper","contentType":"directory"},{"name":"driver-model","path":"Documentation/driver-model","contentType":"directory"},{"name":"dvb","path":"Documentation/dvb","contentType":"directory"},{"name":"early-userspace","path":"Documentation/early-userspace","contentType":"directory"},{"name":"fault-injection","path":"Documentation/fault-injection","contentType":"directory"},{"name":"fb","path":"Documentation/fb","contentType":"directory"},{"name":"filesystems","path":"Documentation/filesystems","contentType":"directory"},{"name":"firmware_class","path":"Documentation/firmware_class","contentType":"directory"},{"name":"frv","path":"Documentation/frv","contentType":"directory"},{"name":"hwmon","path":"Documentation/hwmon","contentType":"directory"},{"name":"i2c","path":"Documentation/i2c","contentType":"directory"},{"name":"i2o","path":"Documentation/i2o","contentType":"directory"},{"name":"ia64","path":"Documentation/ia64","contentType":"directory"},{"name":"ide","path":"Documentation/ide","contentType":"directory"},{"name":"infiniband","path":"Documentation/infiniband","contentType":"directory"},{"name":"input","path":"Documentation/input","contentType":"directory"},{"name":"ioctl","path":"Documentation/ioctl","contentType":"directory"},{"name":"isdn","path":"Documentation/isdn","contentType":"directory"},{"name":"ja_JP","path":"Documentation/ja_JP","contentType":"directory"},{"name":"kbuild","path":"Documentation/kbuild","contentType":"directory"},{"name":"kdump","path":"Documentation/kdump","contentType":"directory"},{"name":"ko_KR","path":"Documentation/ko_KR","contentType":"directory"},{"name":"laptops","path":"Documentation/laptops","contentType":"directory"},{"name":"lguest","path":"Documentation/lguest","contentType":"directory"},{"name":"m68k","path":"Documentation/m68k","contentType":"directory"},{"name":"make","path":"Documentation/make","contentType":"directory"},{"name":"mips","path":"Documentation/mips","contentType":"directory"},{"name":"mn10300","path":"Documentation/mn10300","contentType":"directory"},{"name":"namespaces","path":"Documentation/namespaces","contentType":"directory"},{"name":"netlabel","path":"Documentation/netlabel","contentType":"directory"},{"name":"networking","path":"Documentation/networking","contentType":"directory"},{"name":"parisc","path":"Documentation/parisc","contentType":"directory"},{"name":"pcmcia","path":"Documentation/pcmcia","contentType":"directory"},{"name":"power","path":"Documentation/power","contentType":"directory"},{"name":"powerpc","path":"Documentation/powerpc","contentType":"directory"},{"name":"prctl","path":"Documentation/prctl","contentType":"directory"},{"name":"s390","path":"Documentation/s390","contentType":"directory"},{"name":"scheduler","path":"Documentation/scheduler","contentType":"directory"},{"name":"scsi","path":"Documentation/scsi","contentType":"directory"},{"name":"serial","path":"Documentation/serial","contentType":"directory"},{"name":"sh","path":"Documentation/sh","contentType":"directory"},{"name":"sound","path":"Documentation/sound","contentType":"directory"},{"name":"sparc","path":"Documentation/sparc","contentType":"directory"},{"name":"spi","path":"Documentation/spi","contentType":"directory"},{"name":"sysctl","path":"Documentation/sysctl","contentType":"directory"},{"name":"telephony","path":"Documentation/telephony","contentType":"directory"},{"name":"thermal","path":"Documentation/thermal","contentType":"directory"},{"name":"timers","path":"Documentation/timers","contentType":"directory"},{"name":"tracers","path":"Documentation/tracers","contentType":"directory"},{"name":"uml","path":"Documentation/uml","contentType":"directory"},{"name":"usb","path":"Documentation/usb","contentType":"directory"},{"name":"video4linux","path":"Documentation/video4linux","contentType":"directory"},{"name":"vm","path":"Documentation/vm","contentType":"directory"},{"name":"w1","path":"Documentation/w1","contentType":"directory"},{"name":"watchdog","path":"Documentation/watchdog","contentType":"directory"},{"name":"x86","path":"Documentation/x86","contentType":"directory"},{"name":"zh_CN","path":"Documentation/zh_CN","contentType":"directory"},{"name":"00-INDEX","path":"Documentation/00-INDEX","contentType":"file"},{"name":"BUG-HUNTING","path":"Documentation/BUG-HUNTING","contentType":"file"},{"name":"Changes","path":"Documentation/Changes","contentType":"file"},{"name":"CodingStyle","path":"Documentation/CodingStyle","contentType":"file"},{"name":"DMA-API.txt","path":"Documentation/DMA-API.txt","contentType":"file"},{"name":"DMA-ISA-LPC.txt","path":"Documentation/DMA-ISA-LPC.txt","contentType":"file"},{"name":"DMA-attributes.txt","path":"Documentation/DMA-attributes.txt","contentType":"file"},{"name":"DMA-mapping.txt","path":"Documentation/DMA-mapping.txt","contentType":"file"},{"name":"HOWTO","path":"Documentation/HOWTO","contentType":"file"},{"name":"IO-mapping.txt","path":"Documentation/IO-mapping.txt","contentType":"file"},{"name":"IPMI.txt","path":"Documentation/IPMI.txt","contentType":"file"},{"name":"IRQ-affinity.txt","path":"Documentation/IRQ-affinity.txt","contentType":"file"},{"name":"IRQ.txt","path":"Documentation/IRQ.txt","contentType":"file"},{"name":"Intel-IOMMU.txt","path":"Documentation/Intel-IOMMU.txt","contentType":"file"},{"name":"MSI-HOWTO.txt","path":"Documentation/MSI-HOWTO.txt","contentType":"file"},{"name":"Makefile","path":"Documentation/Makefile","contentType":"file"},{"name":"ManagementStyle","path":"Documentation/ManagementStyle","contentType":"file"},{"name":"README.DAC960","path":"Documentation/README.DAC960","contentType":"file"},{"name":"README.cycladesZ","path":"Documentation/README.cycladesZ","contentType":"file"},{"name":"SAK.txt","path":"Documentation/SAK.txt","contentType":"file"},{"name":"SM501.txt","path":"Documentation/SM501.txt","contentType":"file"},{"name":"SecurityBugs","path":"Documentation/SecurityBugs","contentType":"file"},{"name":"Smack.txt","path":"Documentation/Smack.txt","contentType":"file"},{"name":"SubmitChecklist","path":"Documentation/SubmitChecklist","contentType":"file"},{"name":"SubmittingDrivers","path":"Documentation/SubmittingDrivers","contentType":"file"},{"name":"SubmittingPatches","path":"Documentation/SubmittingPatches","contentType":"file"},{"name":"VGA-softcursor.txt","path":"Documentation/VGA-softcursor.txt","contentType":"file"},{"name":"applying-patches.txt","path":"Documentation/applying-patches.txt","contentType":"file"},{"name":"atomic_ops.txt","path":"Documentation/atomic_ops.txt","contentType":"file"},{"name":"basic_profiling.txt","path":"Documentation/basic_profiling.txt","contentType":"file"},{"name":"binfmt_misc.txt","path":"Documentation/binfmt_misc.txt","contentType":"file"},{"name":"braille-console.txt","path":"Documentation/braille-console.txt","contentType":"file"},{"name":"bt8xxgpio.txt","path":"Documentation/bt8xxgpio.txt","contentType":"file"},{"name":"cachetlb.txt","path":"Documentation/cachetlb.txt","contentType":"file"},{"name":"cciss.txt","path":"Documentation/cciss.txt","contentType":"file"},{"name":"cgroups.txt","path":"Documentation/cgroups.txt","contentType":"file"},{"name":"computone.txt","path":"Documentation/computone.txt","contentType":"file"},{"name":"cpqarray.txt","path":"Documentation/cpqarray.txt","contentType":"file"},{"name":"cpu-hotplug.txt","path":"Documentation/cpu-hotplug.txt","contentType":"file"},{"name":"cpu-load.txt","path":"Documentation/cpu-load.txt","contentType":"file"},{"name":"cpusets.txt","path":"Documentation/cpusets.txt","contentType":"file"},{"name":"cputopology.txt","path":"Documentation/cputopology.txt","contentType":"file"},{"name":"dcdbas.txt","path":"Documentation/dcdbas.txt","contentType":"file"},{"name":"debugging-modules.txt","path":"Documentation/debugging-modules.txt","contentType":"file"},{"name":"debugging-via-ohci1394.txt","path":"Documentation/debugging-via-ohci1394.txt","contentType":"file"},{"name":"dell_rbu.txt","path":"Documentation/dell_rbu.txt","contentType":"file"},{"name":"devices.txt","path":"Documentation/devices.txt","contentType":"file"},{"name":"digiepca.txt","path":"Documentation/digiepca.txt","contentType":"file"},{"name":"dontdiff","path":"Documentation/dontdiff","contentType":"file"},{"name":"edac.txt","path":"Documentation/edac.txt","contentType":"file"},{"name":"eisa.txt","path":"Documentation/eisa.txt","contentType":"file"},{"name":"email-clients.txt","path":"Documentation/email-clients.txt","contentType":"file"},{"name":"exception.txt","path":"Documentation/exception.txt","contentType":"file"},{"name":"feature-removal-schedule.txt","path":"Documentation/feature-removal-schedule.txt","contentType":"file"},{"name":"floppy.txt","path":"Documentation/floppy.txt","contentType":"file"},{"name":"ftrace.txt","path":"Documentation/ftrace.txt","contentType":"file"},{"name":"gpio.txt","path":"Documentation/gpio.txt","contentType":"file"},{"name":"hayes-esp.txt","path":"Documentation/hayes-esp.txt","contentType":"file"},{"name":"highuid.txt","path":"Documentation/highuid.txt","contentType":"file"},{"name":"hpet.txt","path":"Documentation/hpet.txt","contentType":"file"},{"name":"hw_random.txt","path":"Documentation/hw_random.txt","contentType":"file"},{"name":"initrd.txt","path":"Documentation/initrd.txt","contentType":"file"},{"name":"io_ordering.txt","path":"Documentation/io_ordering.txt","contentType":"file"},{"name":"ioctl-number.txt","path":"Documentation/ioctl-number.txt","contentType":"file"},{"name":"iostats.txt","path":"Documentation/iostats.txt","contentType":"file"},{"name":"irqflags-tracing.txt","path":"Documentation/irqflags-tracing.txt","contentType":"file"},{"name":"isapnp.txt","path":"Documentation/isapnp.txt","contentType":"file"},{"name":"java.txt","path":"Documentation/java.txt","contentType":"file"},{"name":"kernel-doc-nano-HOWTO.txt","path":"Documentation/kernel-doc-nano-HOWTO.txt","contentType":"file"},{"name":"kernel-docs.txt","path":"Documentation/kernel-docs.txt","contentType":"file"},{"name":"kernel-parameters.txt","path":"Documentation/kernel-parameters.txt","contentType":"file"},{"name":"keys-request-key.txt","path":"Documentation/keys-request-key.txt","contentType":"file"},{"name":"keys.txt","path":"Documentation/keys.txt","contentType":"file"},{"name":"kobject.txt","path":"Documentation/kobject.txt","contentType":"file"},{"name":"kprobes.txt","path":"Documentation/kprobes.txt","contentType":"file"},{"name":"kref.txt","path":"Documentation/kref.txt","contentType":"file"},{"name":"ldm.txt","path":"Documentation/ldm.txt","contentType":"file"},{"name":"leds-class.txt","path":"Documentation/leds-class.txt","contentType":"file"},{"name":"local_ops.txt","path":"Documentation/local_ops.txt","contentType":"file"},{"name":"lockdep-design.txt","path":"Documentation/lockdep-design.txt","contentType":"file"},{"name":"lockstat.txt","path":"Documentation/lockstat.txt","contentType":"file"},{"name":"logo.gif","path":"Documentation/logo.gif","contentType":"file"},{"name":"logo.txt","path":"Documentation/logo.txt","contentType":"file"},{"name":"magic-number.txt","path":"Documentation/magic-number.txt","contentType":"file"},{"name":"markers.txt","path":"Documentation/markers.txt","contentType":"file"},{"name":"mca.txt","path":"Documentation/mca.txt","contentType":"file"},{"name":"md.txt","path":"Documentation/md.txt","contentType":"file"},{"name":"memory-barriers.txt","path":"Documentation/memory-barriers.txt","contentType":"file"},{"name":"memory-hotplug.txt","path":"Documentation/memory-hotplug.txt","contentType":"file"},{"name":"memory.txt","path":"Documentation/memory.txt","contentType":"file"},{"name":"mono.txt","path":"Documentation/mono.txt","contentType":"file"},{"name":"moxa-smartio","path":"Documentation/moxa-smartio","contentType":"file"},{"name":"mtrr.txt","path":"Documentation/mtrr.txt","contentType":"file"},{"name":"mutex-design.txt","path":"Documentation/mutex-design.txt","contentType":"file"},{"name":"nbd.txt","path":"Documentation/nbd.txt","contentType":"file"},{"name":"nmi_watchdog.txt","path":"Documentation/nmi_watchdog.txt","contentType":"file"},{"name":"nommu-mmap.txt","path":"Documentation/nommu-mmap.txt","contentType":"file"},{"name":"numastat.txt","path":"Documentation/numastat.txt","contentType":"file"},{"name":"oops-tracing.txt","path":"Documentation/oops-tracing.txt","contentType":"file"},{"name":"paride.txt","path":"Documentation/paride.txt","contentType":"file"},{"name":"parport-lowlevel.txt","path":"Documentation/parport-lowlevel.txt","contentType":"file"},{"name":"parport.txt","path":"Documentation/parport.txt","contentType":"file"},{"name":"pi-futex.txt","path":"Documentation/pi-futex.txt","contentType":"file"},{"name":"pnp.txt","path":"Documentation/pnp.txt","contentType":"file"},{"name":"preempt-locking.txt","path":"Documentation/preempt-locking.txt","contentType":"file"},{"name":"prio_tree.txt","path":"Documentation/prio_tree.txt","contentType":"file"},{"name":"ramdisk.txt","path":"Documentation/ramdisk.txt","contentType":"file"},{"name":"rbtree.txt","path":"Documentation/rbtree.txt","contentType":"file"},{"name":"rfkill.txt","path":"Documentation/rfkill.txt","contentType":"file"},{"name":"riscom8.txt","path":"Documentation/riscom8.txt","contentType":"file"},{"name":"robust-futex-ABI.txt","path":"Documentation/robust-futex-ABI.txt","contentType":"file"},{"name":"robust-futexes.txt","path":"Documentation/robust-futexes.txt","contentType":"file"},{"name":"rocket.txt","path":"Documentation/rocket.txt","contentType":"file"},{"name":"rt-mutex-design.txt","path":"Documentation/rt-mutex-design.txt","contentType":"file"},{"name":"rt-mutex.txt","path":"Documentation/rt-mutex.txt","contentType":"file"},{"name":"rtc.txt","path":"Documentation/rtc.txt","contentType":"file"},{"name":"serial-console.txt","path":"Documentation/serial-console.txt","contentType":"file"},{"name":"sgi-ioc4.txt","path":"Documentation/sgi-ioc4.txt","contentType":"file"},{"name":"sgi-visws.txt","path":"Documentation/sgi-visws.txt","contentType":"file"},{"name":"sparse.txt","path":"Documentation/sparse.txt","contentType":"file"},{"name":"specialix.txt","path":"Documentation/specialix.txt","contentType":"file"},{"name":"spinlocks.txt","path":"Documentation/spinlocks.txt","contentType":"file"},{"name":"stable_api_nonsense.txt","path":"Documentation/stable_api_nonsense.txt","contentType":"file"},{"name":"stable_kernel_rules.txt","path":"Documentation/stable_kernel_rules.txt","contentType":"file"},{"name":"stallion.txt","path":"Documentation/stallion.txt","contentType":"file"},{"name":"svga.txt","path":"Documentation/svga.txt","contentType":"file"},{"name":"sx.txt","path":"Documentation/sx.txt","contentType":"file"},{"name":"sysfs-rules.txt","path":"Documentation/sysfs-rules.txt","contentType":"file"},{"name":"sysrq.txt","path":"Documentation/sysrq.txt","contentType":"file"},{"name":"tty.txt","path":"Documentation/tty.txt","contentType":"file"},{"name":"unaligned-memory-access.txt","path":"Documentation/unaligned-memory-access.txt","contentType":"file"},{"name":"unicode.txt","path":"Documentation/unicode.txt","contentType":"file"},{"name":"unshare.txt","path":"Documentation/unshare.txt","contentType":"file"},{"name":"video-output.txt","path":"Documentation/video-output.txt","contentType":"file"},{"name":"volatile-considered-harmful.txt","path":"Documentation/volatile-considered-harmful.txt","contentType":"file"},{"name":"voyager.txt","path":"Documentation/voyager.txt","contentType":"file"},{"name":"zorro.txt","path":"Documentation/zorro.txt","contentType":"file"}],"totalCount":213},"":{"items":[{"name":"Documentation","path":"Documentation","contentType":"directory"},{"name":"arch","path":"arch","contentType":"directory"},{"name":"block","path":"block","contentType":"directory"},{"name":"crypto","path":"crypto","contentType":"directory"},{"name":"drivers","path":"drivers","contentType":"directory"},{"name":"firmware","path":"firmware","contentType":"directory"},{"name":"fs","path":"fs","contentType":"directory"},{"name":"include","path":"include","contentType":"directory"},{"name":"init","path":"init","contentType":"directory"},{"name":"ipc","path":"ipc","contentType":"directory"},{"name":"kernel","path":"kernel","contentType":"directory"},{"name":"lib","path":"lib","contentType":"directory"},{"name":"mm","path":"mm","contentType":"directory"},{"name":"net","path":"net","contentType":"directory"},{"name":"samples","path":"samples","contentType":"directory"},{"name":"scripts","path":"scripts","contentType":"directory"},{"name":"security","path":"security","contentType":"directory"},{"name":"sound","path":"sound","contentType":"directory"},{"name":"usr","path":"usr","contentType":"directory"},{"name":"virt","path":"virt","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".mailmap","path":".mailmap","contentType":"file"},{"name":"COPYING","path":"COPYING","contentType":"file"},{"name":"CREDITS","path":"CREDITS","contentType":"file"},{"name":"Kbuild","path":"Kbuild","contentType":"file"},{"name":"MAINTAINERS","path":"MAINTAINERS","contentType":"file"},{"name":"Makefile","path":"Makefile","contentType":"file"},{"name":"README","path":"README","contentType":"file"},{"name":"REPORTING-BUGS","path":"REPORTING-BUGS","contentType":"file"}],"totalCount":29}},"fileTreeProcessingTime":31.263500999999998,"foldersToFetch":[],"repo":{"id":2325298,"defaultBranch":"master","name":"linux","ownerLogin":"torvalds","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2011-09-04T22:48:12.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/1024025?v=4","public":true,"private":false,"isOrgOwned":false},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"v2.6.27","listCacheKey":"v0:1710104938.0","canEdit":false,"refType":"tag","currentOid":"3fa8749e584b55f1180411ab1b51117190bac1e5"},"path":"Documentation/usb/dma.txt","currentUser":null,"blob":{"rawLines":["In Linux 2.5 kernels (and later), USB device drivers have additional control","over how DMA may be used to perform I/O operations. The APIs are detailed","in the kernel usb programming guide (kerneldoc, from the source code).","","","API OVERVIEW","","The big picture is that USB drivers can continue to ignore most DMA issues,","though they still must provide DMA-ready buffers (see DMA-mapping.txt).","That's how they've worked through the 2.4 (and earlier) kernels.","","OR: they can now be DMA-aware.","","- New calls enable DMA-aware drivers, letting them allocate dma buffers and"," manage dma mappings for existing dma-ready buffers (see below).","","- URBs have an additional \"transfer_dma\" field, as well as a transfer_flags"," bit saying if it's valid. (Control requests also have \"setup_dma\" and a"," corresponding transfer_flags bit.)","","- \"usbcore\" will map those DMA addresses, if a DMA-aware driver didn't do"," it first and set URB_NO_TRANSFER_DMA_MAP or URB_NO_SETUP_DMA_MAP. HCDs"," don't manage dma mappings for URBs.","","- There's a new \"generic DMA API\", parts of which are usable by USB device"," drivers. Never use dma_set_mask() on any USB interface or device; that"," would potentially break all devices sharing that bus.","","","ELIMINATING COPIES","","It's good to avoid making CPUs copy data needlessly. The costs can add up,","and effects like cache-trashing can impose subtle penalties.","","- If you're doing lots of small data transfers from the same buffer all"," the time, that can really burn up resources on systems which use an"," IOMMU to manage the DMA mappings. It can cost MUCH more to set up and"," tear down the IOMMU mappings with each request than perform the I/O!",""," For those specific cases, USB has primitives to allocate less expensive"," memory. They work like kmalloc and kfree versions that give you the right"," kind of addresses to store in urb->transfer_buffer and urb->transfer_dma."," You'd also set URB_NO_TRANSFER_DMA_MAP in urb->transfer_flags:","","\tvoid *usb_buffer_alloc (struct usb_device *dev, size_t size,","\t\tint mem_flags, dma_addr_t *dma);","","\tvoid usb_buffer_free (struct usb_device *dev, size_t size,","\t\tvoid *addr, dma_addr_t dma);",""," Most drivers should *NOT* be using these primitives; they don't need"," to use this type of memory (\"dma-coherent\"), and memory returned from"," kmalloc() will work just fine.",""," For control transfers you can use the buffer primitives or not for each"," of the transfer buffer and setup buffer independently. Set the flag bits"," URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP to indicate which"," buffers you have prepared. For non-control transfers URB_NO_SETUP_DMA_MAP"," is ignored.",""," The memory buffer returned is \"dma-coherent\"; sometimes you might need to"," force a consistent memory access ordering by using memory barriers. It's"," not using a streaming DMA mapping, so it's good for small transfers on"," systems where the I/O would otherwise thrash an IOMMU mapping. (See"," Documentation/DMA-mapping.txt for definitions of \"coherent\" and \"streaming\""," DMA mappings.)",""," Asking for 1/Nth of a page (as well as asking for N pages) is reasonably"," space-efficient.",""," On most systems the memory returned will be uncached, because the"," semantics of dma-coherent memory require either bypassing CPU caches"," or using cache hardware with bus-snooping support. While x86 hardware"," has such bus-snooping, many other systems use software to flush cache"," lines to prevent DMA conflicts.","","- Devices on some EHCI controllers could handle DMA to/from high memory.",""," Unfortunately, the current Linux DMA infrastructure doesn't have a sane"," way to expose these capabilities ... and in any case, HIGHMEM is mostly a"," design wart specific to x86_32. So your best bet is to ensure you never"," pass a highmem buffer into a USB driver. That's easy; it's the default"," behavior. Just don't override it; e.g. with NETIF_F_HIGHDMA.",""," This may force your callers to do some bounce buffering, copying from"," high memory to \"normal\" DMA memory. If you can come up with a good way"," to fix this issue (for x86_32 machines with over 1 GByte of memory),"," feel free to submit patches.","","","WORKING WITH EXISTING BUFFERS","","Existing buffers aren't usable for DMA without first being mapped into the","DMA address space of the device. However, most buffers passed to your","driver can safely be used with such DMA mapping. (See the first section","of DMA-mapping.txt, titled \"What memory is DMA-able?\")","","- When you're using scatterlists, you can map everything at once. On some"," systems, this kicks in an IOMMU and turns the scatterlists into single"," DMA transactions:","","\tint usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,","\t\tstruct scatterlist *sg, int nents);","","\tvoid usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,","\t\tstruct scatterlist *sg, int n_hw_ents);","","\tvoid usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,","\t\tstruct scatterlist *sg, int n_hw_ents);",""," It's probably easier to use the new usb_sg_*() calls, which do the DMA"," mapping and apply other tweaks to make scatterlist i/o be fast.","","- Some drivers may prefer to work with the model that they're mapping large"," buffers, synchronizing their safe re-use. (If there's no re-use, then let"," usbcore do the map/unmap.) Large periodic transfers make good examples"," here, since it's cheaper to just synchronize the buffer than to unmap it"," each time an urb completes and then re-map it on during resubmission.",""," These calls all work with initialized urbs: urb->dev, urb->pipe,"," urb->transfer_buffer, and urb->transfer_buffer_length must all be"," valid when these calls are used (urb->setup_packet must be valid too"," if urb is a control request):","","\tstruct urb *usb_buffer_map (struct urb *urb);","","\tvoid usb_buffer_dmasync (struct urb *urb);","","\tvoid usb_buffer_unmap (struct urb *urb);",""," The calls manage urb->transfer_dma for you, and set URB_NO_TRANSFER_DMA_MAP"," so that usbcore won't map or unmap the buffer. The same goes for"," urb->setup_dma and URB_NO_SETUP_DMA_MAP for control requests.","","Note that several of those interfaces are currently commented out, since","they don't have current users. See the source code. Other than the dmasync","calls (where the underlying DMA primitives have changed), most of them can","easily be commented back in if you want to use them."],"stylingDirectives":[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]],"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/torvalds/linux/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"dma.txt","displayUrl":"https://github.com/torvalds/linux/blob/v2.6.27/Documentation/usb/dma.txt?raw=true","headerInfo":{"blobSize":"6.15 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":null,"isGitLfs":false,"onBranch":false,"shortPath":"e8b50b7","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Ftorvalds%2Flinux%2Fblob%2Fv2.6.27%2FDocumentation%2Fusb%2Fdma.txt","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"138","truncatedSloc":"100"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Text","languageID":372,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/torvalds/linux/blob/v2.6.27/Documentation/usb/dma.txt","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/torvalds/linux/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/torvalds/linux/raw/v2.6.27/Documentation/usb/dma.txt","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":true,"symbols":[]}},"copilotInfo":null,"copilotAccessAllowed":false,"csrf_tokens":{"/torvalds/linux/branches":{"post":"9ZGcZzgbMocaOGPrPU_7Za2gzUAYAteqFaPN_u1zR_LVTvnpLZiUA1VScISr9XEjVhL-cIEx4mKfbye9wdMvqw"},"/repos/preferences":{"post":"a6Oh3MwIAx9ouub9C1VmVzO39pvnpOn1Nm4xYRcuPd8h9HaS4zmCH5P7MZcV1M7yq4MnSZTcLH8x1ta5-UKmyw"}}},"title":"linux/Documentation/usb/dma.txt at v2.6.27 ยท torvalds/linux"}