old-www/HOWTO/SCSI-Generic-HOWTO/dmmio.html

202 lines
3.3 KiB
HTML

<HTML
><HEAD
><TITLE
>Direct and Mmap-ed IO</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="The Linux SCSI Generic (sg) HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="SCSI_IOCTL_SEND_COMMAND"
HREF="scsi_snd_cmd.html"><LINK
REL="NEXT"
TITLE="Direct IO"
HREF="dio.html"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>The Linux SCSI Generic (sg) HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="scsi_snd_cmd.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="dio.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="DMMIO">Chapter 9. Direct and Mmap-ed IO</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
>9.1. <A
HREF="dio.html"
>Direct IO</A
></DT
><DT
>9.2. <A
HREF="mmapio.html"
>Mmap-ed IO</A
></DT
></DL
></DIV
><P
>The normal action of the sg driver for a read operation (from a device)
is to request the lower level (adapter) driver to DMA
<A
NAME="AEN693"
HREF="#FTN.AEN693"
>[1]</A
>
data into kernel buffers that the sg driver manages. The sg driver will
then copy the contents of its buffers into the user space. [This sequence
is reversed for a write operation (towards a device)]. While this double
handling of data is obviously inefficient it does decouple some hardware
issues from user applications. For these and historical reasons the
"double-buffered" IO remains the default for the sg driver.</P
><P
>Both "direct" and "mmap-ed" IO are techniques that permit the data
to be DMA-ed directly from the lower level (adapter) driver into
the user application (vice versa for write operations). Both techniques
result in faster speed, smaller latencies and lower CPU utilization
but come at the expense of complexity (as always). For example the Linux
kernel must not attempt to swap out pages in a user application that a
SCSI adapter is busy DMA-ing data into.</P
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN693"
HREF="dmmio.html#AEN693"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>Older SCSI adapters and some pseudo adapter drivers don't have DMA
capability in which case the CPU is used to copy the data.</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="scsi_snd_cmd.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="dio.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SCSI_IOCTL_SEND_COMMAND</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Direct IO</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>