---
name: "usb_buffer_map_sg"
section: "9"
platform: "linux"
package: "linux-manual-4.9"
version: "4.9.228-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/usb_buffer_map_sg"
---

# usb\_buffer\_map\_sg(9)

create scatterlist DMA mapping(s) for an endpoint

## NAME

usb\_buffer\_map\_sg - create scatterlist DMA mapping(s) for an endpoint

## SYNOPSIS

**int usb\_buffer\_map\_sg(const struct usb\_device \*** *dev***, int** *is\_in***, struct scatterlist \*** *sg***, int** *nents***);**

## ARGUMENTS

*dev*

device to which the scatterlist will be mapped

*is\_in*

mapping transfer direction

*sg*

the scatterlist to map

*nents*

the number of entries in the scatterlist

## RETURN

Either \< 0 (indicating no buffers could be mapped), or the number of DMA mapping array entries in the scatterlist.

## NOTE

The caller is responsible for placing the resulting DMA addresses from the scatterlist into URB transfer buffer pointers, and for setting the URB\_NO\_TRANSFER\_DMA\_MAP transfer flag in each of those URBs.

Top I/O rates come from queuing URBs, instead of waiting for each one to complete before starting the next I/O. This is particularly easy to do with scatterlists. Just allocate and submit one URB for each DMA mapping entry returned, stopping on the first error or when all succeed. Better yet, use the usb\_sg\_\*() calls, which do that (and more) for you.

This call would normally be used when translating scatterlist requests, rather than **usb\_buffer\_map**, since on some hardware (with IOMMUs) it may be able to coalesce mappings for improved I/O efficiency.

Reverse the effect of this call with **usb\_buffer\_unmap\_sg**.

## COPYRIGHT
