<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
	"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>

<book id="libataDevGuide">
 <bookinfo>
  <title>libATA Developer's Guide</title>
  
  <authorgroup>
   <author>
    <firstname>Jeff</firstname>
    <surname>Garzik</surname>
   </author>
  </authorgroup>

  <copyright>
   <year>2003-2005</year>
   <holder>Jeff Garzik</holder>
  </copyright>

  <legalnotice>
   <para>
   The contents of this file are subject to the Open
   Software License version 1.1 that can be found at
   <ulink url="http://www.opensource.org/licenses/osl-1.1.txt">http://www.opensource.org/licenses/osl-1.1.txt</ulink> and is included herein
   by reference.
   </para>

   <para>
   Alternatively, the contents of this file may be used under the terms
   of the GNU General Public License version 2 (the "GPL") as distributed
   in the kernel source COPYING file, in which case the provisions of
   the GPL are applicable instead of the above.  If you wish to allow
   the use of your version of this file only under the terms of the
   GPL and not to allow others to use your version of this file under
   the OSL, indicate your decision by deleting the provisions above and
   replace them with the notice and other provisions required by the GPL.
   If you do not delete the provisions above, a recipient may use your
   version of this file under either the OSL or the GPL.
   </para>

  </legalnotice>
 </bookinfo>

<toc></toc>

  <chapter id="libataIntroduction">
     <title>Introduction</title>
  <para>
  libATA is a library used inside the Linux kernel to support ATA host
  controllers and devices.  libATA provides an ATA driver API, class
  transports for ATA and ATAPI devices, and SCSI&lt;-&gt;ATA translation
  for ATA devices according to the T10 SAT specification.
  </para>
  <para>
  This Guide documents the libATA driver API, library functions, library
  internals, and a couple sample ATA low-level drivers.
  </para>
  </chapter>

  <chapter id="libataDriverApi">
     <title>libata Driver API</title>
     <para>
     struct ata_port_operations is defined for every low-level libata
     hardware driver, and it controls how the low-level driver
     interfaces with the ATA and SCSI layers.
     </para>
     <para>
     FIS-based drivers will hook into the system with ->qc_prep() and
     ->qc_issue() high-level hooks.  Hardware which behaves in a manner
     similar to PCI IDE hardware may utilize several generic helpers,
     defining at a bare minimum the bus I/O addresses of the ATA shadow
     register blocks.
     </para>
     <sect1>
        <title>struct ata_port_operations</title>

	<sect2><title>Disable ATA port</title>
	<programlisting>
void (*port_disable) (struct ata_port *);
	</programlisting>

	<para>
	Called from ata_bus_probe() and ata_bus_reset() error paths,
	as well as when unregistering from the SCSI module (rmmod, hot
	unplug).
	This function should do whatever needs to be done to take the
	port out of use.  In most cases, ata_port_disable() can be used
	as this hook.
	</para>
	<para>
	Called from ata_bus_probe() on a failed probe.
	Called from ata_bus_reset() on a failed bus reset.
	Called from ata_scsi_release().
	</para>

	</sect2>

	<sect2><title>Post-IDENTIFY device configuration</title>
	<programlisting>
void (*dev_config) (struct ata_port *, struct ata_device *);
	</programlisting>

	<para>
	Called after IDENTIFY [PACKET] DEVICE is issued to each device
	found.  Typically used to apply device-specific fixups prior to
	issue of SET FEATURES - XFER MODE, and prior to operation.
	</para>
	<para>
	Called by ata_device_add() after ata_dev_identify() determines
	a device is present.
	</para>
	<para>
	This entry may be specified as NULL in ata_port_operations.
	</para>

	</sect2>

	<sect2><title>Set PIO/DMA mode</title>
	<programlisting>
void (*set_piomode) (struct ata_port *, struct ata_device *);
void (*set_dmamode) (struct ata_port *, struct ata_device *);
void (*post_set_mode) (struct ata_port *);
unsigned int (*mode_filter) (struct ata_port *, struct ata_device *, unsigned int);
	</programlisting>

	<para>
	Hooks called prior to the issue of SET FEATURES - XFER MODE
	command.  The optional ->mode_filter() hook is called when libata
	has built a mask of the possible modes. This is passed to the 
	->mode_filter() function which should return a mask of valid modes
	after filtering those unsuitable due to hardware limits. It is not
	valid to use this interface to add modes.
	</para>
	<para>
	dev->pio_mode and dev->dma_mode are guaranteed to be valid when
	->set_piomode() and when ->set_dmamode() is called. The timings for
	any other drive sharing the cable will also be valid at this point.
	That is the library records the decisions for the modes of each
	drive on a channel before it attempts to set any of them.
	</para>
	<para>
	->post_set_mode() is
	called unconditionally, after the SET FEATURES - XFER MODE
	command completes successfully.
	</para>

	<para>
	->set_piomode() is always called (if present), but
	->set_dma_mode() is only called if DMA is possible.
	</para>

	</sect2>

	<sect2><title>Taskfile read/write</title>
	<programlisting>
void (*tf_load) (struct ata_port *ap, struct ata_taskfile *tf);
void (*tf_read) (struct ata_port *ap, struct ata_taskfile *tf);
	</programlisting>

	<para>
	->tf_load() is called to load the given taskfile into hardware
	registers / DMA buffers.  ->tf_read() is called to read the
	hardware registers / DMA buffers, to obtain the current set of
	taskfile register values.
	Most drivers for taskfile-based hardware (PIO or MMIO) use
	ata_tf_load() and ata_tf_read() for these hooks.
	</para>

	</sect2>

	<sect2><title>ATA command execute</title>
	<programlisting>
void (*exec_command)(struct ata_port *ap, struct ata_taskfile *tf);
	</programlisting>

	<para>
	causes an ATA command, previously loaded with
	->tf_load(), to be initiated in hardware.
	Most drivers for taskfile-based hardware use ata_exec_command()
	for this hook.
	</para>

	</sect2>

	<sect2><title>Per-cmd ATAPI DMA capabilities filter</title>
	<programlisting>
int (*check_atapi_dma) (struct ata_queued_cmd *qc);
	</programlisting>

	<para>
Allow low-level driver to filter ATA PACKET commands, returning a status
indicating whether or not it is OK to use DMA for the supplied PACKET
command.
	</para>
	<para>
	This hook may be specified as NULL, in which case libata will
	assume that atapi dma can be supported.
	</para>

	</sect2>

	<sect2><title>Read specific ATA shadow registers</title>
	<programlisting>
u8   (*check_status)(struct ata_port *ap);
u8   (*check_altstatus)(struct ata_port *ap);
u8   (*check_err)(struct ata_port *ap);
	</programlisting>

	<para>
	Reads the Status/AltStatus/Error ATA shadow register from
	hardware.  On some hardware, reading the Status register has
	the side effect of clearing the interrupt condition.
	Most drivers for taskfile-based hardware use
	ata_check_status() for this hook.
	</para>
	<para>
	Note that because this is called from ata_device_add(), at
	least a dummy function that clears device interrupts must be
	provided for all drivers, even if the controller doesn't
	actually have a taskfile status register.
	</para>

	</sect2>

	<sect2><title>Select ATA device on bus</title>
	<programlisting>
void (*dev_select)(struct ata_port *ap, unsigned int device);
	</programlisting>

	<para>
	Issues the low-level hardware command(s) that causes one of N
	hardware devices to be considered 'selected' (active and
	available for use) on the ATA bus.  This generally has no
	meaning on FIS-based devices.
	</para>
	<para>
	Most drivers for taskfile-based hardware use
	ata_std_dev_select() for this hook.  Controllers which do not
	support second drives on a port (such as SATA contollers) will
	use ata_noop_dev_select().
	</para>

	</sect2>

	<sect2><title>Private tuning method</title>
	<programlisting>
void (*set_mode) (struct ata_port *ap);
	</programlisting>

	<para>
	By default libata performs drive and controller tuning in
	accordance with the ATA timing rules and also applies blacklists
	and cable limits. Some controllers need special handling and have
	custom tuning rules, typically raid controllers that use ATA
	commands but do not actually do drive timing.
	</para>

	<warning>
	<para>
	This hook should not be used to replace the standard controller
	tuning logic when a controller has quirks. Replacing the default
	tuning logic in that case would bypass handling for drive and
	bridge quirks that may be important to data reliability. If a
	controller needs to filter the mode selection it should use the
	mode_filter hook instead.
	</para>
	</warning>

	</sect2>

	<sect2><title>Reset ATA bus</title>
	<programlisting>
void (*phy_reset) (struct ata_port *ap);
	</programlisting>

	<para>
	The very first step in the probe phase.  Actions vary depending
	on the bus type, typically.  After waking up the device and probing
	for device presence (PATA and SATA), typically a soft reset
	(SRST) will be performed.  Drivers typically use the helper
	functions ata_bus_reset() or sata_phy_reset() for this hook.
	Many SATA drivers use sata_phy_reset() or call it from within
	their own phy_reset() functions.
	</para>

	</sect2>

	<sect2><title>Control PCI IDE BMDMA engine</title>
	<programlisting>
void (*bmdma_setup) (struct ata_queued_cmd *qc);
void (*bmdma_start) (struct ata_queued_cmd *qc);
void (*bmdma_stop) (struct ata_port *ap);
u8   (*bmdma_status) (struct ata_port *ap);
	</programlisting>

	<para>
When setting up an IDE BMDMA transaction, these hooks arm
(->bmdma_setup), fire (->bmdma_start), and halt (->bmdma_stop)
the hardware's DMA engine.  ->bmdma_status is used to read the standard
PCI IDE DMA Status register.
	</para>

	<para>
These hooks are typically either no-ops, or simply not implemented, in
FIS-based drivers.
	</para>
	<para>
Most legacy IDE drivers use ata_bmdma_setup() for the bmdma_setup()
hook.  ata_bmdma_setup() will write the pointer to the PRD table to
the IDE PRD Table Address register, enable DMA in the DMA Command
register, and call exec_command() to begin the transfer.
	</para>
	<para>
Most legacy IDE drivers use ata_bmdma_start() for the bmdma_start()
hook.  ata_bmdma_start() will write the ATA_DMA_START flag to the DMA
Command register.
	</para>
	<para>
Many legacy IDE drivers use ata_bmdma_stop() for the bmdma_stop()
hook.  ata_bmdma_stop() clears the ATA_DMA_START flag in the DMA
command register.
	</para>
	<para>
Many legacy IDE drivers use ata_bmdma_status() as the bmdma_status() hook.
	</para>

	</sect2>

	<sect2><title>High-level taskfile hooks</title>
	<programlisting>
void (*qc_prep) (struct ata_queued_cmd *qc);
int (*qc_issue) (struct ata_queued_cmd *qc);
	</programlisting>

	<para>
	Higher-level hooks, these two hooks can potentially supercede
	several of the above taskfile/DMA engine hooks.  ->qc_prep is
	called after the buffers have been DMA-mapped, and is typically
	used to populate the hardware's DMA scatter-gather table.
	Most drivers use the standard ata_qc_prep() helper function, but
	more advanced drivers roll their own.
	</para>
	<para>
	->qc_issue is used to make a command active, once the hardware
	and S/G tables have been prepared.  IDE BMDMA drivers use the
	helper function ata_qc_issue_prot() for taskfile protocol-based
	dispatch.  More advanced drivers implement their own ->qc_issue.
	</para>
	<para>
	ata_qc_issue_prot() calls ->tf_load(), ->bmdma_setup(), and
	->bmdma_start() as necessary to initiate a transfer.
	</para>

	</sect2>

	<sect2><title>Timeout (error) handling</title>
	<programlisting>
void (*eng_timeout) (struct ata_port *ap);
	</programlisting>

	<para>
This is a high level error handling function, called from the
error handling thread, when a command times out.  Most newer
hardware will implement its own error handling code here.  IDE BMDMA
drivers may use the helper function ata_eng_timeout().
	</para>

	</sect2>

	<sect2><title>Hardware interrupt handling</title>
	<programlisting>
irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
void (*irq_clear) (struct ata_port *);
	</programlisting>

	<para>
	->irq_handler is the interrupt handling routine registered with
	the system, by libata.  ->irq_clear is called during probe just
	before the interrupt handler is registered, to be sure hardware
	is quiet.
	</para>
	<para>
	The second argument, dev_instance, should be cast to a pointer
	to struct ata_host_set.
	</para>
	<para>
	Most legacy IDE drivers use ata_interrupt() for the
	irq_handler hook, which scans all ports in the host_set,
	determines which queued command was active (if any), and calls
	ata_host_intr(ap,qc).
	</para>
	<para>
	Most legacy IDE drivers use ata_bmdma_irq_clear() for the
	irq_clear() hook, which simply clears the interrupt and error
	flags in the DMA status register.
	</para>

	</sect2>

	<sect2><title>SATA phy read/write</title>
	<programlisting>
u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg);
void (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
                   u32 val);
	</programlisting>

	<para>
	Read and write standard SATA phy registers.  Currently only used
	if ->phy_reset hook called the sata_phy_reset() helper function.
	sc_reg is one of SCR_STATUS, SCR_CONTROL, SCR_ERROR, or SCR_ACTIVE.
	</para>

	</sect2>

	<sect2><title>Init and shutdown</title>
	<programlisting>
int (*port_start) (struct ata_port *ap);
void (*port_stop) (struct ata_port *ap);
void (*host_stop) (struct ata_host_set *host_set);
	</programlisting>

	<para>
	->port_start() is called just after the data structures for each
	port are initialized.  Typically this is used to alloc per-port
	DMA buffers / tables / rings, enable DMA engines, and similar
	tasks.  Some drivers also use this entry point as a chance to
	allocate driver-private memory for ap->private_data.
	</para>
	<para>
	Many drivers use ata_port_start() as this hook or call
	it from their own port_start() hooks.  ata_port_start()
	allocates space for a legacy IDE PRD table and returns.
	</para>
	<para>
	->port_stop() is called after ->host_stop().  It's sole function
	is to release DMA/memory resources, now that they are no longer
	actively being used.  Many drivers also free driver-private
	data from port at this time.
	</para>
	<para>
	Many drivers use ata_port_stop() as this hook, which frees the
	PRD table.
	</para>
	<para>
	->host_stop() is called after all ->port_stop() calls
have completed.  The hook must finalize hardware shutdown, release DMA
and other resources, etc.
	This hook may be specified as NULL, in which case it is not called.
	</para>

	</sect2>

     </sect1>
  </chapter>

  <chapter id="libataEH">
        <title>Error handling</title>

	<para>
	This chapter describes how errors are handled under libata.
	Readers are advised to read SCSI EH
	(Documentation/scsi/scsi_eh.txt) and ATA exceptions doc first.
	</para>

	<sect1><title>Origins of commands</title>
	<para>
	In libata, a command is represented with struct ata_queued_cmd
	or qc.  qc's are preallocated during port initialization and
	repetitively used for command executions.  Currently only one
	qc is allocated per port but yet-to-be-merged NCQ branch
	allocates one for each tag and maps each qc to NCQ tag 1-to-1.
	</para>
	<para>
	libata commands can originate from two sources - libata itself
	and SCSI midlayer.  libata internal commands are used for
	initialization and error handling.  All normal blk requests
	and commands for SCSI emulation are passed as SCSI commands
	through queuecommand callback of SCSI host template.
	</para>
	</sect1>

	<sect1><title>How commands are issued</title>

	<variablelist>

	<varlistentry><term>Internal commands</term>
	<listitem>
	<para>
	First, qc is allocated and initialized using
	ata_qc_new_init().  Although ata_qc_new_init() doesn't
	implement any wait or retry mechanism when qc is not
	available, internal commands are currently issued only during
	initialization and error recovery, so no other command is
	active and allocation is guaranteed to succeed.
	</para>
	<para>
	Once allocated qc's taskfile is initialized for the command to
	be executed.  qc currently has two mechanisms to notify
	completion.  One is via qc->complete_fn() callback and the
	other is completion qc->waiting.  qc->complete_fn() callback
	is the asynchronous path used by normal SCSI translated
	commands and qc->waiting is the synchronous (issuer sleeps in
	process context) path used by internal commands.
	</para>
	<para>
	Once initialization is complete, host_set lock is acquired
	and the qc is issued.
	</para>
	</listitem>
	</varlistentry>

	<varlistentry><term>SCSI commands</term>
	<listitem>
	<para>
	All libata drivers use ata_scsi_queuecmd() as
	hostt->queuecommand callback.  scmds can either be simulated
	or translated.  No qc is involved in processing a simulated
	scmd.  The result is computed right away and the scmd is
	completed.
	</para>
	<para>
	For a translated scmd, ata_qc_new_init() is invoked to
	allocate a qc and the scmd is translated into the qc.  SCSI
	midlayer's completion notification function pointer is stored
	into qc->scsidone.
	</para>
	<para>
	qc->complete_fn() callback is used for completion
	notification.  ATA commands use ata_scsi_qc_complete() while
	ATAPI commands use atapi_qc_complete().  Both functions end up
	calling qc->scsidone to notify upper layer when the qc is
	finished.  After translation is completed, the qc is issued
	with ata_qc_issue().
	</para>
	<para>
	Note that SCSI midlayer invokes hostt->queuecommand while
	holding host_set lock, so all above occur while holding
	host_set lock.
	</para>
	</listitem>
	</varlistentry>

	</variablelist>
	</sect1>

	<sect1><title>How commands are processed</title>
	<para>
	Depending on which protocol and which controller are used,
	commands are processed differently.  For the purpose of
	discussion, a controller which uses taskfile interface and all
	standard callbacks is assumed.
	</para>
	<para>
	Currently 6 ATA command protocols are used.  They can be
	sorted into the following four categories according to how
	they are processed.
	</para>

	<variablelist>
	   <varlistentry><term>ATA NO DATA or DMA</term>
	   <listitem>
	   <para>
	   ATA_PROT_NODATA and ATA_PROT_DMA fall into this category.
	   These types of commands don't require any software
	   intervention once issued.  Device will raise interrupt on
	   completion.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>ATA PIO</term>
	   <listitem>
	   <para>
	   ATA_PROT_PIO is in this category.  libata currently
	   implements PIO with polling.  ATA_NIEN bit is set to turn
	   off interrupt and pio_task on ata_wq performs polling and
	   IO.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>ATAPI NODATA or DMA</term>
	   <listitem>
	   <para>
	   ATA_PROT_ATAPI_NODATA and ATA_PROT_ATAPI_DMA are in this
	   category.  packet_task is used to poll BSY bit after
	   issuing PACKET command.  Once BSY is turned off by the
	   device, packet_task transfers CDB and hands off processing
	   to interrupt handler.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>ATAPI PIO</term>
	   <listitem>
	   <para>
	   ATA_PROT_ATAPI is in this category.  ATA_NIEN bit is set
	   and, as in ATAPI NODATA or DMA, packet_task submits cdb.
	   However, after submitting cdb, further processing (data
	   transfer) is handed off to pio_task.
	   </para>
	   </listitem>
	   </varlistentry>
	</variablelist>
        </sect1>

	<sect1><title>How commands are completed</title>
	<para>
	Once issued, all qc's are either completed with
	ata_qc_complete() or time out.  For commands which are handled
	by interrupts, ata_host_intr() invokes ata_qc_complete(), and,
	for PIO tasks, pio_task invokes ata_qc_complete().  In error
	cases, packet_task may also complete commands.
	</para>
	<para>
	ata_qc_complete() does the following.
	</para>

	<orderedlist>

	<listitem>
	<para>
	DMA memory is unmapped.
	</para>
	</listitem>

	<listitem>
	<para>
	ATA_QCFLAG_ACTIVE is clared from qc->flags.
	</para>
	</listitem>

	<listitem>
	<para>
	qc->complete_fn() callback is invoked.  If the return value of
	the callback is not zero.  Completion is short circuited and
	ata_qc_complete() returns.
	</para>
	</listitem>

	<listitem>
	<para>
	__ata_qc_complete() is called, which does
	   <orderedlist>

	   <listitem>
	   <para>
	   qc->flags is cleared to zero.
	   </para>
	   </listitem>

	   <listitem>
	   <para>
	   ap->active_tag and qc->tag are poisoned.
	   </para>
	   </listitem>

	   <listitem>
	   <para>
	   qc->waiting is claread &amp; completed (in that order).
	   </para>
	   </listitem>

	   <listitem>
	   <para>
	   qc is deallocated by clearing appropriate bit in ap->qactive.
	   </para>
	   </listitem>

	   </orderedlist>
	</para>
	</listitem>

	</orderedlist>

	<para>
	So, it basically notifies upper layer and deallocates qc.  One
	exception is short-circuit path in #3 which is used by
	atapi_qc_complete().
	</para>
	<para>
	For all non-ATAPI commands, whether it fails or not, almost
	the same code path is taken and very little error handling
	takes place.  A qc is completed with success status if it
	succeeded, with failed status otherwise.
	</para>
	<para>
	However, failed ATAPI commands require more handling as
	REQUEST SENSE is needed to acquire sense data.  If an ATAPI
	command fails, ata_qc_complete() is invoked with error status,
	which in turn invokes atapi_qc_complete() via
	qc->complete_fn() callback.
	</para>
	<para>
	This makes atapi_qc_complete() set scmd->result to
	SAM_STAT_CHECK_CONDITION, complete the scmd and return 1.  As
	the sense data is empty but scmd->result is CHECK CONDITION,
	SCSI midlayer will invoke EH for the scmd, and returning 1
	makes ata_qc_complete() to return without deallocating the qc.
	This leads us to ata_scsi_error() with partially completed qc.
	</para>

	</sect1>

	<sect1><title>ata_scsi_error()</title>
	<para>
	ata_scsi_error() is the current transportt->eh_strategy_handler()
	for libata.  As discussed above, this will be entered in two
	cases - timeout and ATAPI error completion.  This function
	calls low level libata driver's eng_timeout() callback, the
	standard callback for which is ata_eng_timeout().  It checks
	if a qc is active and calls ata_qc_timeout() on the qc if so.
	Actual error handling occurs in ata_qc_timeout().
	</para>
	<para>
	If EH is invoked for timeout, ata_qc_timeout() stops BMDMA and
	completes the qc.  Note that as we're currently in EH, we
	cannot call scsi_done.  As described in SCSI EH doc, a
	recovered scmd should be either retried with
	scsi_queue_insert() or finished with scsi_finish_command().
	Here, we override qc->scsidone with scsi_finish_command() and
	calls ata_qc_complete().
	</para>
	<para>
	If EH is invoked due to a failed ATAPI qc, the qc here is
	completed but not deallocated.  The purpose of this
	half-completion is to use the qc as place holder to make EH
	code reach this place.  This is a bit hackish, but it works.
	</para>
	<para>
	Once control reaches here, the qc is deallocated by invoking
	__ata_qc_complete() explicitly.  Then, internal qc for REQUEST
	SENSE is issued.  Once sense data is acquired, scmd is
	finished by directly invoking scsi_finish_command() on the
	scmd.  Note that as we already have completed and deallocated
	the qc which was associated with the scmd, we don't need
	to/cannot call ata_qc_complete() again.
	</para>

	</sect1>

	<sect1><title>Problems with the current EH</title>

	<itemizedlist>

	<listitem>
	<para>
	Error representation is too crude.  Currently any and all
	error conditions are represented with ATA STATUS and ERROR
	registers.  Errors which aren't ATA device errors are treated
	as ATA device errors by setting ATA_ERR bit.  Better error
	descriptor which can properly represent ATA and other
	errors/exceptions is needed.
	</para>
	</listitem>

	<listitem>
	<para>
	When handling timeouts, no action is taken to make device
	forget about the timed out command and ready for new commands.
	</para>
	</listitem>

	<listitem>
	<para>
	EH handling via ata_scsi_error() is not properly protected
	from usual command processing.  On EH entrance, the device is
	not in quiescent state.  Timed out commands may succeed or
	fail any time.  pio_task and atapi_task may still be running.
	</para>
	</listitem>

	<listitem>
	<para>
	Too weak error recovery.  Devices / controllers causing HSM
	mismatch errors and other errors quite often require reset to
	return to known state.  Also, advanced error handling is
	necessary to support features like NCQ and hotplug.
	</para>
	</listitem>

	<listitem>
	<para>
	ATA errors are directly handled in the interrupt handler and
	PIO errors in pio_task.  This is problematic for advanced
	error handling for the following reasons.
	</para>
	<para>
	First, advanced error handling often requires context and
	internal qc execution.
	</para>
	<para>
	Second, even a simple failure (say, CRC error) needs
	information gathering and could trigger complex error handling
	(say, resetting &amp; reconfiguring).  Having multiple code
	paths to gather information, enter EH and trigger actions
	makes life painful.
	</para>
	<para>
	Third, scattered EH code makes implementing low level drivers
	difficult.  Low level drivers override libata callbacks.  If
	EH is scattered over several places, each affected callbacks
	should perform its part of error handling.  This can be error
	prone and painful.
	</para>
	</listitem>

	</itemizedlist>
	</sect1>
  </chapter>

  <chapter id="libataExt">
     <title>libata Library</title>
<!-- drivers/scsi/libata-core.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-tf-to-fis">ata_tf_to_fis</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_tf_to_fis</refname>
 <refpurpose>
   Convert ATA taskfile to SATA FIS structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_tf_to_fis </function></funcdef>
   <paramdef>const struct ata_taskfile * <parameter>tf</parameter></paramdef>
   <paramdef>u8 * <parameter>fis</parameter></paramdef>
   <paramdef>u8 <parameter>pmp</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     Taskfile to convert
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fis</parameter></term>
   <listitem>
    <para>
     Buffer into which data will output
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pmp</parameter></term>
   <listitem>
    <para>
     Port multiplier port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Converts a standard ATA taskfile to a Serial ATA
   FIS structure (Register - Host to Device).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-tf-from-fis">ata_tf_from_fis</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_tf_from_fis</refname>
 <refpurpose>
      Convert SATA FIS to ATA taskfile
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_tf_from_fis </function></funcdef>
   <paramdef>const u8 * <parameter>fis</parameter></paramdef>
   <paramdef>struct ata_taskfile * <parameter>tf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>fis</parameter></term>
   <listitem>
    <para>
     Buffer from which data will be input
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     Taskfile to output
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Converts a serial ATA FIS structure to a standard ATA taskfile.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-classify">ata_dev_classify</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_classify</refname>
 <refpurpose>
      determine device type based on ATA-spec signature
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_dev_classify </function></funcdef>
   <paramdef>const struct ata_taskfile * <parameter>tf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     ATA taskfile register set for device to be identified
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Determine from taskfile register contents whether a device is
   ATA or ATAPI, as per <quote>Signature and persistence</quote> section
   of ATA/PI spec (volume 1, sect 5.14).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Device type, <constant>ATA_DEV_ATA</constant>, <constant>ATA_DEV_ATAPI</constant>, or <constant>ATA_DEV_UNKNOWN</constant>
   the event of failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-id-string">ata_id_string</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_id_string</refname>
 <refpurpose>
      Convert IDENTIFY DEVICE page into string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_id_string </function></funcdef>
   <paramdef>const u16 * <parameter>id</parameter></paramdef>
   <paramdef>unsigned char * <parameter>s</parameter></paramdef>
   <paramdef>unsigned int <parameter>ofs</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     IDENTIFY DEVICE results we will examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     string into which data is output
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ofs</parameter></term>
   <listitem>
    <para>
     offset into identify device page
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     length of string to return. must be an even number.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The strings in the IDENTIFY DEVICE page are broken up into
   16-bit chunks.  Run through the string, and output each
   8-bit chunk linearly, regardless of platform.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-id-c-string">ata_id_c_string</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_id_c_string</refname>
 <refpurpose>
      Convert IDENTIFY DEVICE page into C string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_id_c_string </function></funcdef>
   <paramdef>const u16 * <parameter>id</parameter></paramdef>
   <paramdef>unsigned char * <parameter>s</parameter></paramdef>
   <paramdef>unsigned int <parameter>ofs</parameter></paramdef>
   <paramdef>unsigned int <parameter>len</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     IDENTIFY DEVICE results we will examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>s</parameter></term>
   <listitem>
    <para>
     string into which data is output
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ofs</parameter></term>
   <listitem>
    <para>
     offset into identify device page
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>len</parameter></term>
   <listitem>
    <para>
     length of string to return. must be an odd number.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function is identical to ata_id_string except that it
   trims trailing spaces and terminates the resulting string with
   null.  <parameter>len</parameter> must be actual maximum length (even number) + 1.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-noop-dev-select">ata_noop_dev_select</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_noop_dev_select</refname>
 <refpurpose>
      Select device 0/1 on ATA bus
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_noop_dev_select </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to manipulate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     ATA device (numbered from zero) to select
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function performs no actual function.
   </para><para>

   May be used as the <function>dev_select</function> entry in ata_port_operations.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-dev-select">ata_std_dev_select</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_dev_select</refname>
 <refpurpose>
      Select device 0/1 on ATA bus
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_std_dev_select </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to manipulate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     ATA device (numbered from zero) to select
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Use the method defined in the ATA specification to
   make either device 0, or device 1, active on the
   ATA channel.  Works with both PIO and MMIO.
   </para><para>

   May be used as the <function>dev_select</function> entry in ata_port_operations.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-queue-task">ata_port_queue_task</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_queue_task</refname>
 <refpurpose>
      Queue port_task
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_port_queue_task </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>void (*<parameter>fn</parameter>)
     <funcparams>void *</funcparams></paramdef>
   <paramdef>void * <parameter>data</parameter></paramdef>
   <paramdef>unsigned long <parameter>delay</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     The ata_port to queue port_task for
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>fn</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>data</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>delay</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Schedule <parameter>fn</parameter>(<parameter>data</parameter>) for execution after <parameter>delay</parameter> jiffies using
   port_task.  There is one port_task per port and it's the
   user(low level driver)'s responsibility to make sure that only
   one task is active at any given time.
   </para><para>

   libata core layer takes care of synchronization between
   port_task and EH.  <function>ata_port_queue_task</function> may be ignored for EH
   synchronization.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-need-iordy">ata_pio_need_iordy</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_need_iordy</refname>
 <refpurpose>
     	check if iordy needed
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_pio_need_iordy </function></funcdef>
   <paramdef>const struct ata_device * <parameter>adev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>adev</parameter></term>
   <listitem>
    <para>
     ATA device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Check if the current speed of the device requires IORDY. Used
   by various controllers for chip configuration.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-probe">ata_port_probe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_probe</refname>
 <refpurpose>
      Mark port as enabled
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_port_probe </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port for which we indicate enablement
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Modify <parameter>ap</parameter> data structure such that the system
   thinks that the entire port is enabled.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   host_set lock, or some other form of
   serialization.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API---sata-phy-reset">__sata_phy_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>__sata_phy_reset</refname>
 <refpurpose>
      Wake/reset a low-level SATA PHY
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__sata_phy_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     SATA port associated with target SATA PHY.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function issues commands to standard SATA Sxxx
   PHY registers, to wake up the phy (and device), and
   clear any reset condition.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sata-phy-reset">sata_phy_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sata_phy_reset</refname>
 <refpurpose>
      Reset SATA bus.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>sata_phy_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     SATA port associated with target SATA PHY.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function resets the SATA bus, and then probes
   the bus for devices.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-pair">ata_dev_pair</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_pair</refname>
 <refpurpose>
     	return other device on cable
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_device * <function>ata_dev_pair </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>adev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>adev</parameter></term>
   <listitem>
    <para>
     device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Obtain the other device on the same cable, or if none is
   present NULL is returned
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-disable">ata_port_disable</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_disable</refname>
 <refpurpose>
      Disable port.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_port_disable </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to be disabled.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Modify <parameter>ap</parameter> data structure such that the system
   thinks that the entire port is disabled, and should
   never attempt to probe or communicate with devices
   on this port.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   host_set lock, or some other form of
   serialization.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-busy-sleep">ata_busy_sleep</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_busy_sleep</refname>
 <refpurpose>
      sleep until BSY clears, or timeout
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_busy_sleep </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned long <parameter>tmout_pat</parameter></paramdef>
   <paramdef>unsigned long <parameter>tmout</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port containing status register to be polled
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tmout_pat</parameter></term>
   <listitem>
    <para>
     impatience timeout
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tmout</parameter></term>
   <listitem>
    <para>
     overall timeout
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Sleep until ATA Status register bit BSY clears,
   or a timeout occurs.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-bus-reset">ata_bus_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_bus_reset</refname>
 <refpurpose>
      reset host port and associated ATA channel
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_bus_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to reset
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is typically the first time we actually start issuing
   commands to the ATA channel.  We wait for BSY to clear, then
   issue EXECUTE DEVICE DIAGNOSTIC command, polling for its
   result.  Determine what devices, if any, are on the channel
   by looking at the device 0/1 error register.  Look at the signature
   stored in each device's taskfile registers, to determine if
   the device is ATA or ATAPI.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
   Obtains host_set lock.
</para>
</refsect1>
<refsect1>
<title>SIDE EFFECTS</title>
<para>
   Sets ATA_FLAG_PORT_DISABLED if bus reset fails.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-probeinit">ata_std_probeinit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_probeinit</refname>
 <refpurpose>
      initialize probing
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_std_probeinit </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to be probed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   <parameter>ap</parameter> is about to be probed.  Initialize it.  This function is
   to be used as standard callback for <function>ata_drive_probe_reset</function>.
   </para><para>

   NOTE!!! Do not use this function as probeinit if a low level
   driver implements only hardreset.  Just pass NULL as probeinit
   in that case.  Using this function is probably okay but doing
   so makes reset sequence different from the original
   -&gt;phy_reset implementation and Jeff nervous.  :-P
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-softreset">ata_std_softreset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_softreset</refname>
 <refpurpose>
      reset host port via ATA SRST
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_std_softreset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>int <parameter>verbose</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>verbose</parameter></term>
   <listitem>
    <para>
     fail verbosely
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     resulting classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Reset host port using ATA SRST.  This function is to be used
   as standard callback for ata_drive_*<function>_reset</function> functions.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -errno otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sata-std-hardreset">sata_std_hardreset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sata_std_hardreset</refname>
 <refpurpose>
      reset host port via SATA phy reset
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>sata_std_hardreset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>int <parameter>verbose</parameter></paramdef>
   <paramdef>unsigned int * <parameter>class</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>verbose</parameter></term>
   <listitem>
    <para>
     fail verbosely
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>class</parameter></term>
   <listitem>
    <para>
     resulting class of attached device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   SATA phy-reset host port using DET bits of SControl register.
   This function is to be used as standard callback for
   ata_drive_*<function>_reset</function>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -errno otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-postreset">ata_std_postreset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_postreset</refname>
 <refpurpose>
      standard postreset callback
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_std_postreset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     the target ata_port
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function is invoked after a successful reset.  Note that
   the device might have been reset more than once using
   different reset methods before postreset is invoked.
   </para><para>

   This function is to be used as standard callback for
   ata_drive_*<function>_reset</function>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-probe-reset">ata_std_probe_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_probe_reset</refname>
 <refpurpose>
      standard probe reset method
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_std_probe_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     prot to perform probe-reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     resulting classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   The stock off-the-shelf -&gt;probe_reset method.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -errno otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-drive-probe-reset">ata_drive_probe_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_drive_probe_reset</refname>
 <refpurpose>
      Perform probe reset with given methods
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_drive_probe_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>ata_probeinit_fn_t <parameter>probeinit</parameter></paramdef>
   <paramdef>ata_reset_fn_t <parameter>softreset</parameter></paramdef>
   <paramdef>ata_reset_fn_t <parameter>hardreset</parameter></paramdef>
   <paramdef>ata_postreset_fn_t <parameter>postreset</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>probeinit</parameter></term>
   <listitem>
    <para>
     probeinit method (can be NULL)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>softreset</parameter></term>
   <listitem>
    <para>
     softreset method (can be NULL)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>hardreset</parameter></term>
   <listitem>
    <para>
     hardreset method (can be NULL)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>postreset</parameter></term>
   <listitem>
    <para>
     postreset method (can be NULL)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     resulting classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Reset the specified port and classify attached devices using
   given methods.  This function prefers softreset but tries all
   possible reset sequences to reset and classify devices.  This
   function is intended to be used for constructing -&gt;probe_reset
   callback by low level drivers.
   </para><para>

   Reset methods should follow the following rules.
   </para><para>

   - Return 0 on sucess, -errno on failure.
   - If classification is supported, fill classes[] with
   recognized class codes.
   - If classification is not supported, leave classes[] alone.
   - If verbose is non-zero, print error message on failure;
   otherwise, shut up.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -EINVAL if no reset method is avaliable, -ENODEV
   if classification fails, and any error code from reset
   methods.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-revalidate">ata_dev_revalidate</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_revalidate</refname>
 <refpurpose>
      Revalidate ATA device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_dev_revalidate </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>int <parameter>post_reset</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port on which the device to revalidate resides
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     device to revalidate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>post_reset</parameter></term>
   <listitem>
    <para>
     is this revalidation after reset?
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Re-read IDENTIFY page and make sure <parameter>dev</parameter> is still attached to
   the port.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, negative errno otherwise
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-prep">ata_qc_prep</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_prep</refname>
 <refpurpose>
      Prepare taskfile for submission
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_qc_prep </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Metadata associated with taskfile to be prepared
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Prepare ATA taskfile for submission.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-sg-init-one">ata_sg_init_one</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_sg_init_one</refname>
 <refpurpose>
      Associate command with memory buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_sg_init_one </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>void * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to be associated
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     Memory buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Length of memory buffer, in bytes.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Initialize the data-related elements of queued_cmd <parameter>qc</parameter>
   to point to a single memory buffer, <parameter>buf</parameter> of byte length <parameter>buflen</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-sg-init">ata_sg_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_sg_init</refname>
 <refpurpose>
      Associate command with scatter-gather table.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_sg_init </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>struct scatterlist * <parameter>sg</parameter></paramdef>
   <paramdef>unsigned int <parameter>n_elem</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to be associated
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sg</parameter></term>
   <listitem>
    <para>
     Scatter-gather table.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>n_elem</parameter></term>
   <listitem>
    <para>
     Number of elements in s/g table.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Initialize the data-related elements of queued_cmd <parameter>qc</parameter>
   to point to a scatter-gather table <parameter>sg</parameter>, containing <parameter>n_elem</parameter>
   elements.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-eng-timeout">ata_eng_timeout</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_eng_timeout</refname>
 <refpurpose>
      Handle timeout of queued command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_eng_timeout </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port on which timed-out command is active
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Some part of the kernel (currently, only the SCSI layer)
   has noticed that the active command on port <parameter>ap</parameter> has not
   completed after a specified length of time.  Handle this
   condition by disabling DMA (if necessary) and completing
   transactions, with error if necessary.
   </para><para>

   This also handles the case of the <quote>lost interrupt</quote>, where
   for some reason (possibly hardware bug, possibly driver bug)
   an interrupt was not delivered to the driver, even though the
   transaction completed successfully.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from SCSI layer (none, can sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-issue-prot">ata_qc_issue_prot</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_issue_prot</refname>
 <refpurpose>
      issue taskfile to device in proto-dependent manner
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_qc_issue_prot </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     command to issue to device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Using various libata functions and hooks, this function
   starts an ATA command.  ATA commands are grouped into
   classes called <quote>protocols</quote>, and issuing each type of protocol
   is slightly different.
   </para><para>

   May be used as the <function>qc_issue</function> entry in ata_port_operations.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, AC_ERR_* mask on failure
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-host-intr">ata_host_intr</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_host_intr</refname>
 <refpurpose>
      Handle host interrupt for given (port, task)
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_host_intr </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port on which interrupt arrived (possibly...)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Taskfile currently active in engine
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Handle host interrupt for given queued command.  Currently,
   only DMA interrupts are handled.  All other commands are
   handled via polling with interrupts disabled (nIEN bit).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   One if interrupt was handled, zero if not (shared irq).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-interrupt">ata_interrupt</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_interrupt</refname>
 <refpurpose>
      Default ATA host interrupt handler
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>irqreturn_t <function>ata_interrupt </function></funcdef>
   <paramdef>int <parameter>irq</parameter></paramdef>
   <paramdef>void * <parameter>dev_instance</parameter></paramdef>
   <paramdef>struct pt_regs * <parameter>regs</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>irq</parameter></term>
   <listitem>
    <para>
     irq line (unused)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev_instance</parameter></term>
   <listitem>
    <para>
     pointer to our ata_host_set information structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>regs</parameter></term>
   <listitem>
    <para>
     unused
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Default interrupt handler for PCI IDE devices.  Calls
   <function>ata_host_intr</function> for each port that is not disabled.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Obtains host_set lock during operation.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   IRQ_NONE or IRQ_HANDLED.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-device-resume">ata_device_resume</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_device_resume</refname>
 <refpurpose>
      wakeup a previously suspended devices
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_device_resume </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port the device is connected to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     the device to resume
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Kick the drive back into action, by sending it an idle immediate
   command and making sure its transfer mode matches between drive
   and host.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-device-suspend">ata_device_suspend</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_device_suspend</refname>
 <refpurpose>
      prepare a device for suspend
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_device_suspend </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>pm_message_t <parameter>state</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port the device is connected to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     the device to suspend
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>state</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Flush the cache on the drive, if appropriate, then issue a
   standbynow command.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-start">ata_port_start</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_start</refname>
 <refpurpose>
      Set port up for dma.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_port_start </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to initialize
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Called just after data structures for each port are
   initialized.  Allocates space for PRD table.
   </para><para>

   May be used as the <function>port_start</function> entry in ata_port_operations.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-stop">ata_port_stop</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_stop</refname>
 <refpurpose>
      Undo <function>ata_port_start</function>
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_port_stop </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to shut down
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Frees the PRD table.
   </para><para>

   May be used as the <function>port_stop</function> entry in ata_port_operations.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-device-add">ata_device_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_device_add</refname>
 <refpurpose>
      Register hardware device with ATA and SCSI layers
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_device_add </function></funcdef>
   <paramdef>const struct ata_probe_ent * <parameter>ent</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ent</parameter></term>
   <listitem>
    <para>
     Probe information describing hardware device to be registered
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function processes the information provided in the probe
   information struct <parameter>ent</parameter>, allocates the necessary ATA and SCSI
   host information structures, initializes them, and registers
   everything with requisite kernel subsystems.
   </para><para>

   This function requests irqs, probes the ATA bus, and probes
   the SCSI bus.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Number of ports registered.  Zero on error (no ports registered).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-host-set-remove">ata_host_set_remove</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_host_set_remove</refname>
 <refpurpose>
      PCI layer callback for device removal
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_host_set_remove </function></funcdef>
   <paramdef>struct ata_host_set * <parameter>host_set</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>host_set</parameter></term>
   <listitem>
    <para>
     ATA host set that was removed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unregister all objects associated with this host set. Free those
   objects.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from calling layer (may sleep).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-release">ata_scsi_release</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_release</refname>
 <refpurpose>
      SCSI layer callback hook for host unload
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_scsi_release </function></funcdef>
   <paramdef>struct Scsi_Host * <parameter>host</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>host</parameter></term>
   <listitem>
    <para>
     libata host to be unloaded
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Performs all duties necessary to shut down a libata port...
   Kill port kthread, disable port, and release resources.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from SCSI layer.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   One.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-ports">ata_std_ports</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_ports</refname>
 <refpurpose>
      initialize ioaddr with standard port offsets.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_std_ports </function></funcdef>
   <paramdef>struct ata_ioports * <parameter>ioaddr</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ioaddr</parameter></term>
   <listitem>
    <para>
     IO address structure to be initialized
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Utility function which initializes data_addr, error_addr,
   feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr,
   device_addr, status_addr, and command_addr to standard offsets
   relative to cmd_addr.
   </para><para>

   Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pci-remove-one">ata_pci_remove_one</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pci_remove_one</refname>
 <refpurpose>
      PCI layer callback for device removal
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_pci_remove_one </function></funcdef>
   <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pdev</parameter></term>
   <listitem>
    <para>
     PCI device that was removed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   PCI layer indicates to libata via this hook that
   hot-unplug or module unload event has occurred.
   Handle this by unregistering all objects associated
   with this PCI device.  Free those objects.  Then finally
   release PCI resources and disable device.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from PCI layer (may sleep).
</para>
</refsect1>
</refentry>

  </chapter>

  <chapter id="libataInt">
     <title>libata Core Internals</title>
<!-- drivers/scsi/libata-core.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-rwcmd-protocol">ata_rwcmd_protocol</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_rwcmd_protocol</refname>
 <refpurpose>
   set taskfile r/w commands and protocol
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_rwcmd_protocol </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     command to examine and configure
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Examine the device configuration and tf-&gt;flags to calculate
   the proper read/write commands and protocol to use.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pack-xfermask">ata_pack_xfermask</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pack_xfermask</refname>
 <refpurpose>
      Pack pio, mwdma and udma masks into xfer_mask
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_pack_xfermask </function></funcdef>
   <paramdef>unsigned int <parameter>pio_mask</parameter></paramdef>
   <paramdef>unsigned int <parameter>mwdma_mask</parameter></paramdef>
   <paramdef>unsigned int <parameter>udma_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pio_mask</parameter></term>
   <listitem>
    <para>
     pio_mask
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mwdma_mask</parameter></term>
   <listitem>
    <para>
     mwdma_mask
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>udma_mask</parameter></term>
   <listitem>
    <para>
     udma_mask
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Pack <parameter>pio_mask</parameter>, <parameter>mwdma_mask</parameter> and <parameter>udma_mask</parameter> into a single
   unsigned int xfer_mask.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Packed xfer_mask.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-unpack-xfermask">ata_unpack_xfermask</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_unpack_xfermask</refname>
 <refpurpose>
      Unpack xfer_mask into pio, mwdma and udma masks
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_unpack_xfermask </function></funcdef>
   <paramdef>unsigned int <parameter>xfer_mask</parameter></paramdef>
   <paramdef>unsigned int * <parameter>pio_mask</parameter></paramdef>
   <paramdef>unsigned int * <parameter>mwdma_mask</parameter></paramdef>
   <paramdef>unsigned int * <parameter>udma_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>xfer_mask</parameter></term>
   <listitem>
    <para>
     xfer_mask to unpack
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>pio_mask</parameter></term>
   <listitem>
    <para>
     resulting pio_mask
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>mwdma_mask</parameter></term>
   <listitem>
    <para>
     resulting mwdma_mask
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>udma_mask</parameter></term>
   <listitem>
    <para>
     resulting udma_mask
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unpack <parameter>xfer_mask</parameter> into <parameter>pio_mask</parameter>, <parameter>mwdma_mask</parameter> and <parameter>udma_mask</parameter>.
   Any NULL distination masks will be ignored.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-xfer-mask2mode">ata_xfer_mask2mode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_xfer_mask2mode</refname>
 <refpurpose>
      Find matching XFER_* for the given xfer_mask
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>u8 <function>ata_xfer_mask2mode </function></funcdef>
   <paramdef>unsigned int <parameter>xfer_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>xfer_mask</parameter></term>
   <listitem>
    <para>
     xfer_mask of interest
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return matching XFER_* value for <parameter>xfer_mask</parameter>.  Only the highest
   bit of <parameter>xfer_mask</parameter> is considered.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Matching XFER_* value, 0 if no match found.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-xfer-mode2mask">ata_xfer_mode2mask</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_xfer_mode2mask</refname>
 <refpurpose>
      Find matching xfer_mask for XFER_*
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_xfer_mode2mask </function></funcdef>
   <paramdef>u8 <parameter>xfer_mode</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>xfer_mode</parameter></term>
   <listitem>
    <para>
     XFER_* of interest
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return matching xfer_mask for <parameter>xfer_mode</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Matching xfer_mask, 0 if no match found.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-xfer-mode2shift">ata_xfer_mode2shift</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_xfer_mode2shift</refname>
 <refpurpose>
      Find matching xfer_shift for XFER_*
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_xfer_mode2shift </function></funcdef>
   <paramdef>unsigned int <parameter>xfer_mode</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>xfer_mode</parameter></term>
   <listitem>
    <para>
     XFER_* of interest
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Return matching xfer_shift for <parameter>xfer_mode</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Matching xfer_shift, -1 if no match found.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-mode-string">ata_mode_string</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_mode_string</refname>
 <refpurpose>
      convert xfer_mask to string
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>const char * <function>ata_mode_string </function></funcdef>
   <paramdef>unsigned int <parameter>xfer_mask</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>xfer_mask</parameter></term>
   <listitem>
    <para>
     mask of bits supported; only highest bit counts.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Determine string which represents the highest speed
   (highest bit in <parameter>modemask</parameter>).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Constant C string representing highest speed listed in
   <parameter>mode_mask</parameter>, or the constant C string <quote>&lt;n/a&gt;</quote>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-devchk">ata_pio_devchk</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_devchk</refname>
 <refpurpose>
      PATA device presence detection
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_pio_devchk </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     Device to examine (starting at zero)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This technique was originally described in
   Hale Landis's ATADRVR (www.ata-atapi.com), and
   later found its way into the ATA/ATAPI spec.
   </para><para>

   Write a pattern to the ATA shadow registers,
   and if a device is present, it will respond by
   correctly storing and echoing back the
   ATA shadow register contents.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-mmio-devchk">ata_mmio_devchk</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_mmio_devchk</refname>
 <refpurpose>
      PATA device presence detection
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_mmio_devchk </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     Device to examine (starting at zero)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This technique was originally described in
   Hale Landis's ATADRVR (www.ata-atapi.com), and
   later found its way into the ATA/ATAPI spec.
   </para><para>

   Write a pattern to the ATA shadow registers,
   and if a device is present, it will respond by
   correctly storing and echoing back the
   ATA shadow register contents.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-devchk">ata_devchk</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_devchk</refname>
 <refpurpose>
      PATA device presence detection
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_devchk </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     Device to examine (starting at zero)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Dispatch ATA device presence detection, depending
   on whether we are using PIO or MMIO to talk to the
   ATA shadow registers.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-try-classify">ata_dev_try_classify</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_try_classify</refname>
 <refpurpose>
      Parse returned ATA device signature
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_dev_try_classify </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
   <paramdef>u8 * <parameter>r_err</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to examine
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     Device to examine (starting at zero)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>r_err</parameter></term>
   <listitem>
    <para>
     Value of error register on completion
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   After an event -- SRST, E.D.D., or SATA COMRESET -- occurs,
   an ATA/ATAPI-defined set of values is placed in the ATA
   shadow registers, indicating the results of device detection
   and diagnostics.
   </para><para>

   Select the ATA device, and read the values from the ATA shadow
   registers.  Then parse according to the Error register value,
   and the spec-defined values examined by <function>ata_dev_classify</function>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Device type - <constant>ATA_DEV_ATA</constant>, <constant>ATA_DEV_ATAPI</constant> or <constant>ATA_DEV_NONE</constant>.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-select">ata_dev_select</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_select</refname>
 <refpurpose>
      Select device 0/1 on ATA bus
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_dev_select </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>device</parameter></paramdef>
   <paramdef>unsigned int <parameter>wait</parameter></paramdef>
   <paramdef>unsigned int <parameter>can_sleep</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA channel to manipulate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>device</parameter></term>
   <listitem>
    <para>
     ATA device (numbered from zero) to select
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>wait</parameter></term>
   <listitem>
    <para>
     non-zero to wait for Status register BSY bit to clear
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>can_sleep</parameter></term>
   <listitem>
    <para>
     non-zero if context allows sleeping
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Use the method defined in the ATA specification to
   make either device 0, or device 1, active on the
   ATA channel.
   </para><para>

   This is a high-level version of <function>ata_std_dev_select</function>,
   which additionally provides the services of inserting
   the proper pauses and status polling, where needed.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dump-id">ata_dump_id</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dump_id</refname>
 <refpurpose>
      IDENTIFY DEVICE info debugging output
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_dump_id </function></funcdef>
   <paramdef>const u16 * <parameter>id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     IDENTIFY DEVICE page to dump
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Dump selected 16-bit words from the given IDENTIFY DEVICE
   page.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-id-xfermask">ata_id_xfermask</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_id_xfermask</refname>
 <refpurpose>
      Compute xfermask from the given IDENTIFY data
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_id_xfermask </function></funcdef>
   <paramdef>const u16 * <parameter>id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     IDENTIFY data to compute xfer mask from
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Compute the xfermask for this device. This is not as trivial
   as it seems if we must consider early devices correctly.
</para>
</refsect1>
<refsect1>
<title>FIXME</title>
<para>
   pre IDE drive timing (do we care ?).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Computed xfermask
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-port-flush-task">ata_port_flush_task</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_port_flush_task</refname>
 <refpurpose>
      Flush port_task
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_port_flush_task </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     The ata_port to flush port_task for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   After this function completes, port_task is guranteed not to
   be running or scheduled.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-exec-internal">ata_exec_internal</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_exec_internal</refname>
 <refpurpose>
      execute libata internal command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned <function>ata_exec_internal </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>struct ata_taskfile * <parameter>tf</parameter></paramdef>
   <paramdef>int <parameter>dma_dir</parameter></paramdef>
   <paramdef>void * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to which the command is sent
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device to which the command is sent
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     Taskfile registers for the command and the result
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dma_dir</parameter></term>
   <listitem>
    <para>
     Data tranfer direction of the command
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     Data buffer of the command
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Length of data buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Executes libata internal command with timeout.  <parameter>tf</parameter> contains
   command on entry and result on return.  Timeout and error
   conditions are reported via return value.  No recovery action
   is taken after a command times out.  It's caller's duty to
   clean up after timeout.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.  Should be called with kernel context, might sleep.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-read-id">ata_dev_read_id</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_read_id</refname>
 <refpurpose>
      Read ID data from the specified device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_dev_read_id </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>unsigned int * <parameter>p_class</parameter></paramdef>
   <paramdef>int <parameter>post_reset</parameter></paramdef>
   <paramdef>u16 ** <parameter>p_id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port on which target device resides
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     target device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>p_class</parameter></term>
   <listitem>
    <para>
     pointer to class of the target device (may be changed)
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>post_reset</parameter></term>
   <listitem>
    <para>
     is this read ID post-reset?
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>p_id</parameter></term>
   <listitem>
    <para>
     read IDENTIFY page (newly allocated)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Read ID data from the specified device.  ATA_CMD_ID_ATA is
   performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI
   devices.  This function also issues ATA_CMD_INIT_DEV_PARAMS
   for pre-ATA4 drives.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -errno otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-configure">ata_dev_configure</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_configure</refname>
 <refpurpose>
      Configure the specified ATA/ATAPI device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_dev_configure </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>int <parameter>print_info</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port on which target device resides
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Target device to configure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>print_info</parameter></term>
   <listitem>
    <para>
     Enable device info printout
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Configure <parameter>dev</parameter> according to <parameter>dev</parameter>-&gt;id.  Generic and low-level
   driver specific fixups are also applied.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, -errno otherwise
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-bus-probe">ata_bus_probe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_bus_probe</refname>
 <refpurpose>
      Reset and probe ATA bus
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_bus_probe </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Bus to probe
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Master ATA bus probing function.  Initiates a hardware-dependent
   bus reset, then attempts to identify any devices found on
   the bus.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sata-print-link-status">sata_print_link_status</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sata_print_link_status</refname>
 <refpurpose>
      Print SATA link status
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>sata_print_link_status </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     SATA port to printk link status about
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This function prints link speed and status of a SATA link.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-set-mode">ata_set_mode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_set_mode</refname>
 <refpurpose>
      Program timings and issue SET FEATURES - XFER
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_set_mode </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port on which timings will be programmed
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Set ATA device disk transfer mode (PIO3, UDMA6, etc.).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-tf-to-host">ata_tf_to_host</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_tf_to_host</refname>
 <refpurpose>
      issue ATA taskfile to host controller
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_tf_to_host </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>const struct ata_taskfile * <parameter>tf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to which command is being issued
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     ATA taskfile register set
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Issues ATA taskfile register set to ATA host controller,
   with proper synchronization with interrupt handler and
   other threads.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-same-device">ata_dev_same_device</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_same_device</refname>
 <refpurpose>
      Determine whether new ID matches configured device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_dev_same_device </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>unsigned int <parameter>new_class</parameter></paramdef>
   <paramdef>const u16 * <parameter>new_id</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port on which the device to compare against resides
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     device to compare against
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new_class</parameter></term>
   <listitem>
    <para>
     class of the new device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>new_id</parameter></term>
   <listitem>
    <para>
     IDENTIFY page of the new device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Compare <parameter>new_class</parameter> and <parameter>new_id</parameter> against <parameter>dev</parameter> and determine
   whether <parameter>dev</parameter> is the device indicated by <parameter>new_class</parameter> and
   <parameter>new_id</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   1 if <parameter>dev</parameter> matches <parameter>new_class</parameter> and <parameter>new_id</parameter>, 0 otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-xfermask">ata_dev_xfermask</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_xfermask</refname>
 <refpurpose>
      Compute supported xfermask of the given device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_dev_xfermask </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port on which the device to compute xfermask for resides
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device to compute xfermask for
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Compute supported xfermask of <parameter>dev</parameter> and store it in
   dev-&gt;*_mask.  This function is responsible for applying all
   known limits including host controller limits, device
   blacklist, etc...
</para>
</refsect1>
<refsect1>
<title>FIXME</title>
<para>
   The current implementation limits all transfer modes to
   the fastest of the lowested device on the port.  This is not
   required on most controllers.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-set-xfermode">ata_dev_set_xfermode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_set_xfermode</refname>
 <refpurpose>
      Issue SET FEATURES - XFER MODE command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_dev_set_xfermode </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port associated with device <parameter>dev</parameter>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device to which command will be sent
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Issue SET FEATURES - XFER MODE command to device <parameter>dev</parameter>
   on port <parameter>ap</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, AC_ERR_* mask otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dev-init-params">ata_dev_init_params</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dev_init_params</refname>
 <refpurpose>
      Issue INIT DEV PARAMS command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_dev_init_params </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>u16 <parameter>heads</parameter></paramdef>
   <paramdef>u16 <parameter>sectors</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port associated with device <parameter>dev</parameter>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device to which command will be sent
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>heads</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sectors</parameter></term>
   <listitem>
    <para>
     -- undescribed --
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 on success, AC_ERR_* mask otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-sg-clean">ata_sg_clean</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_sg_clean</refname>
 <refpurpose>
      Unmap DMA memory associated with command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_sg_clean </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command containing DMA memory to be released
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unmap all mapped DMA memory associated with this command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-fill-sg">ata_fill_sg</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_fill_sg</refname>
 <refpurpose>
      Fill PCI IDE PRD table
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_fill_sg </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Metadata associated with taskfile to be transferred
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Fill PCI IDE PRD (scatter-gather) table with segments
   associated with the current disk command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-check-atapi-dma">ata_check_atapi_dma</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_check_atapi_dma</refname>
 <refpurpose>
      Check whether ATAPI DMA can be supported
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_check_atapi_dma </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Metadata associated with taskfile to check
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Allow low-level driver to filter ATA PACKET commands, returning
   a status indicating whether or not it is OK to use DMA for the
   supplied PACKET command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   0 when ATAPI DMA can be used
   nonzero otherwise
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-sg-setup-one">ata_sg_setup_one</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_sg_setup_one</refname>
 <refpurpose>
      DMA-map the memory buffer associated with a command.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_sg_setup_one </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command with memory buffer to be mapped.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   DMA-map the memory buffer associated with queued_cmd <parameter>qc</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, negative on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-sg-setup">ata_sg_setup</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_sg_setup</refname>
 <refpurpose>
      DMA-map the scatter-gather table associated with a command.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_sg_setup </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command with scatter-gather table to be mapped.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   DMA-map the scatter-gather table associated with queued_cmd <parameter>qc</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, negative on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-poll-qc-complete">ata_poll_qc_complete</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_poll_qc_complete</refname>
 <refpurpose>
      turn irq back on and finish qc
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_poll_qc_complete </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to complete
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.  (grabs host lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-poll">ata_pio_poll</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_poll</refname>
 <refpurpose>
      poll using PIO, depending on current state
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned long <function>ata_pio_poll </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     the target ata_port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.  (executing in kernel thread context)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   timeout value to use
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-complete">ata_pio_complete</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_complete</refname>
 <refpurpose>
      check if drive is busy or idle
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_pio_complete </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     the target ata_port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.  (executing in kernel thread context)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Non-zero if qc completed, zero otherwise.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-swap-buf-le16">swap_buf_le16</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>swap_buf_le16</refname>
 <refpurpose>
      swap halves of 16-bit words in place
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>swap_buf_le16 </function></funcdef>
   <paramdef>u16 * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buf_words</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
      Buffer to swap
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf_words</parameter></term>
   <listitem>
    <para>
      Number of 16-bit words in buffer.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Swap halves of 16-bit words if needed to convert from
   little-endian byte order to native cpu byte order, or
   vice-versa.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-mmio-data-xfer">ata_mmio_data_xfer</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_mmio_data_xfer</refname>
 <refpurpose>
      Transfer data by MMIO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_mmio_data_xfer </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>int <parameter>write_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to read/write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     data buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     buffer length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>write_data</parameter></term>
   <listitem>
    <para>
     read/write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer data from/to the device data register by MMIO.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-data-xfer">ata_pio_data_xfer</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_data_xfer</refname>
 <refpurpose>
      Transfer data by PIO
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_pio_data_xfer </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>int <parameter>write_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to read/write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     data buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     buffer length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>write_data</parameter></term>
   <listitem>
    <para>
     read/write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer data from/to the device data register by PIO.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-data-xfer">ata_data_xfer</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_data_xfer</refname>
 <refpurpose>
      Transfer data from/to the data register.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_data_xfer </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned char * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
   <paramdef>int <parameter>do_write</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port to read/write
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     data buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     buffer length
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>do_write</parameter></term>
   <listitem>
    <para>
     read/write
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer data from/to the device data register.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-sector">ata_pio_sector</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_sector</refname>
 <refpurpose>
      Transfer ATA_SECT_SIZE (512 bytes) of data.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_pio_sector </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command on going
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer ATA_SECT_SIZE of data from/to the ATA device.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API---atapi-pio-bytes">__atapi_pio_bytes</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>__atapi_pio_bytes</refname>
 <refpurpose>
      Transfer data from/to the ATAPI device.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>__atapi_pio_bytes </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>unsigned int <parameter>bytes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command on going
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bytes</parameter></term>
   <listitem>
    <para>
     number of bytes
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer Transfer data from/to the ATAPI device.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atapi-pio-bytes">atapi_pio_bytes</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atapi_pio_bytes</refname>
 <refpurpose>
      Transfer data from/to the ATAPI device.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atapi_pio_bytes </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command on going
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Transfer Transfer data from/to the ATAPI device.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-pio-block">ata_pio_block</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_pio_block</refname>
 <refpurpose>
      start PIO on a block
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_pio_block </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     the target ata_port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.  (executing in kernel thread context)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atapi-packet-task">atapi_packet_task</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atapi_packet_task</refname>
 <refpurpose>
      Write CDB bytes to hardware
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>atapi_packet_task </function></funcdef>
   <paramdef>void * <parameter>_data</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>_data</parameter></term>
   <listitem>
    <para>
     Port to which ATAPI device is attached.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   When device has indicated its readiness to accept
   a CDB, this function is called.  Send the CDB.
   If DMA is to be performed, exit immediately.
   Otherwise, we are in polling mode, so poll
   status under operation succeeds or fails.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Kernel thread context (may sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-timeout">ata_qc_timeout</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_timeout</refname>
 <refpurpose>
      Handle timeout of queued command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_qc_timeout </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command that timed out
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Some part of the kernel (currently, only the SCSI layer)
   has noticed that the active command on port <parameter>ap</parameter> has not
   completed after a specified length of time.  Handle this
   condition by disabling DMA (if necessary) and completing
   transactions, with error if necessary.
   </para><para>

   This also handles the case of the <quote>lost interrupt</quote>, where
   for some reason (possibly hardware bug, possibly driver bug)
   an interrupt was not delivered to the driver, even though the
   transaction completed successfully.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from SCSI layer (none, can sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-new">ata_qc_new</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_new</refname>
 <refpurpose>
      Request an available ATA command, for queueing
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_queued_cmd * <function>ata_qc_new </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port associated with device <parameter>dev</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-new-init">ata_qc_new_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_new_init</refname>
 <refpurpose>
      Request an available ATA command, and initialize it
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_queued_cmd * <function>ata_qc_new_init </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port associated with device <parameter>dev</parameter>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device from whom we request an available command structure
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-free">ata_qc_free</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_free</refname>
 <refpurpose>
      free unused ata_queued_cmd
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_qc_free </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to complete
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Designed to free unused ata_queued_cmd object
   in case something prevents using it.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-qc-issue">ata_qc_issue</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_qc_issue</refname>
 <refpurpose>
      issue taskfile to device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_qc_issue </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     command to issue to device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Prepare an ATA command to submission to device.
   This includes mapping the data into a DMA-able
   area, filling in the S/G table, and finally
   writing the taskfile to hardware, starting the command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-host-remove">ata_host_remove</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_host_remove</refname>
 <refpurpose>
      Unregister SCSI host structure with upper layers
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_host_remove </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int <parameter>do_unregister</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to unregister
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>do_unregister</parameter></term>
   <listitem>
    <para>
     1 if we fully unregister, 0 to just stop the port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-host-init">ata_host_init</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_host_init</refname>
 <refpurpose>
      Initialize an ata_port structure
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_host_init </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct Scsi_Host * <parameter>host</parameter></paramdef>
   <paramdef>struct ata_host_set * <parameter>host_set</parameter></paramdef>
   <paramdef>const struct ata_probe_ent * <parameter>ent</parameter></paramdef>
   <paramdef>unsigned int <parameter>port_no</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Structure to initialize
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>host</parameter></term>
   <listitem>
    <para>
     associated SCSI mid-layer structure
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>host_set</parameter></term>
   <listitem>
    <para>
     Collection of hosts to which <parameter>ap</parameter> belongs
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ent</parameter></term>
   <listitem>
    <para>
     Probe information provided by low-level driver
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>port_no</parameter></term>
   <listitem>
    <para>
     Port number associated with this ata_port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Initialize a new ata_port structure, and its associated
   scsi_host.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from caller.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-host-add">ata_host_add</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_host_add</refname>
 <refpurpose>
      Attach low-level ATA driver to system
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_port * <function>ata_host_add </function></funcdef>
   <paramdef>const struct ata_probe_ent * <parameter>ent</parameter></paramdef>
   <paramdef>struct ata_host_set * <parameter>host_set</parameter></paramdef>
   <paramdef>unsigned int <parameter>port_no</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ent</parameter></term>
   <listitem>
    <para>
     Information provided by low-level driver
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>host_set</parameter></term>
   <listitem>
    <para>
     Collections of ports to which we add
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>port_no</parameter></term>
   <listitem>
    <para>
     Port number associated with this host
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Attach low-level ATA driver to system.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   PCI/etc. bus probe sem.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   New ata_port on success, for NULL on error.
</para>
</refsect1>
</refentry>

  </chapter>

  <chapter id="libataScsiInt">
     <title>libata SCSI translation/emulation</title>
<!-- drivers/scsi/libata-scsi.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-std-bios-param">ata_std_bios_param</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_std_bios_param</refname>
 <refpurpose>
   generic bios head/sector/cylinder calculator used by sd.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_std_bios_param </function></funcdef>
   <paramdef>struct scsi_device * <parameter>sdev</parameter></paramdef>
   <paramdef>struct block_device * <parameter>bdev</parameter></paramdef>
   <paramdef>sector_t <parameter>capacity</parameter></paramdef>
   <paramdef>int <parameter>geom[]</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>sdev</parameter></term>
   <listitem>
    <para>
     SCSI device for which BIOS geometry is to be determined
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>bdev</parameter></term>
   <listitem>
    <para>
     block device associated with <parameter>sdev</parameter>
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>capacity</parameter></term>
   <listitem>
    <para>
     capacity of SCSI device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>geom[]</parameter></term>
   <listitem>
    <para>
     location to which geometry will be output
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Generic bios head/sector/cylinder calculator
   used by sd. Most BIOSes nowadays expect a XXX/255/16  (CHS)
   mapping. Some situations may arise where the disk is not
   bootable if this is not used.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Defined by the SCSI layer.  We don't really care.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-slave-config">ata_scsi_slave_config</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_slave_config</refname>
 <refpurpose>
      Set SCSI device attributes
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_scsi_slave_config </function></funcdef>
   <paramdef>struct scsi_device * <parameter>sdev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>sdev</parameter></term>
   <listitem>
    <para>
     SCSI device to examine
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   This is called before we actually start reading
   and writing to the device, to configure certain
   SCSI mid-layer behaviors.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Defined by SCSI layer.  We don't really care.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-eh-qc-complete">ata_eh_qc_complete</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_eh_qc_complete</refname>
 <refpurpose>
      Complete an active ATA command from EH
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_eh_qc_complete </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to complete
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Indicate to the mid and upper layers that an ATA command has
   completed.  To be used from EH.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-eh-qc-retry">ata_eh_qc_retry</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_eh_qc_retry</refname>
 <refpurpose>
      Tell midlayer to retry an ATA command after EH
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_eh_qc_retry </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command to retry
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Indicate to the mid and upper layers that an ATA command
   should be retried.  To be used from EH.
   </para><para>

   SCSI midlayer limits the number of retries to scmd-&gt;allowed.
   This function might need to adjust scmd-&gt;retries for commands
   which get retried due to unrelated NCQ failures.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-queuecmd">ata_scsi_queuecmd</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_queuecmd</refname>
 <refpurpose>
      Issue SCSI cdb to libata-managed device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_scsi_queuecmd </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>void (*<parameter>done</parameter>)
     <funcparams>struct scsi_cmnd *</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command to be sent
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>done</parameter></term>
   <listitem>
    <para>
     Completion function, called when command is complete
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   In some cases, this function translates SCSI commands into
   ATA taskfiles, and queues the taskfiles to be sent to
   hardware.  In other cases, this function simulates a
   SCSI device by evaluating and responding to certain
   SCSI commands.  This creates the overall effect of
   ATA and ATAPI devices appearing as SCSI devices.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Releases scsi-layer-held lock, and obtains host_set lock.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-simulate">ata_scsi_simulate</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_simulate</refname>
 <refpurpose>
      simulate SCSI command on ATA device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_simulate </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>void (*<parameter>done</parameter>)
     <funcparams>struct scsi_cmnd *</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     port the device is connected to
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     the target device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command being sent to device.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>done</parameter></term>
   <listitem>
    <para>
     SCSI command completion function.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Interprets and directly executes a select list of SCSI commands
   that can be handled internally.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<!-- drivers/scsi/libata-scsi.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-cmd-ioctl">ata_cmd_ioctl</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_cmd_ioctl</refname>
 <refpurpose>
   Handler for HDIO_DRIVE_CMD ioctl
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_cmd_ioctl </function></funcdef>
   <paramdef>struct scsi_device * <parameter>scsidev</parameter></paramdef>
   <paramdef>void __user * <parameter>arg</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>scsidev</parameter></term>
   <listitem>
    <para>
     Device to which we are issuing command
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>arg</parameter></term>
   <listitem>
    <para>
     User provided data for issuing command
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Defined by the SCSI layer.  We don't really care.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, negative errno on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-task-ioctl">ata_task_ioctl</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_task_ioctl</refname>
 <refpurpose>
      Handler for HDIO_DRIVE_TASK ioctl
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>ata_task_ioctl </function></funcdef>
   <paramdef>struct scsi_device * <parameter>scsidev</parameter></paramdef>
   <paramdef>void __user * <parameter>arg</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>scsidev</parameter></term>
   <listitem>
    <para>
     Device to which we are issuing command
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>arg</parameter></term>
   <listitem>
    <para>
     User provided data for issuing command
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Defined by the SCSI layer.  We don't really care.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, negative errno on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-qc-new">ata_scsi_qc_new</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_qc_new</refname>
 <refpurpose>
      acquire new ata_queued_cmd reference
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_queued_cmd * <function>ata_scsi_qc_new </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>void (*<parameter>done</parameter>)
     <funcparams>struct scsi_cmnd *</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA port to which the new command is attached
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     ATA device to which the new command is attached
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command that originated this ATA command
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>done</parameter></term>
   <listitem>
    <para>
     SCSI command completion function
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Obtain a reference to an unused ata_queued_cmd structure,
   which is the basic libata structure representing a single
   ATA command sent to the hardware.
   </para><para>

   If a command was available, fill in the SCSI-specific
   portions of the structure with information on the
   current command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Command allocated, or <constant>NULL</constant> if none available.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-dump-status">ata_dump_status</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_dump_status</refname>
 <refpurpose>
      user friendly display of error info
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_dump_status </function></funcdef>
   <paramdef>unsigned <parameter>id</parameter></paramdef>
   <paramdef>struct ata_taskfile * <parameter>tf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     id of the port in question
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>tf</parameter></term>
   <listitem>
    <para>
     ptr to filled out taskfile
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Decode and dump the ATA error/status registers for the user so
   that they have some idea what really happened at the non
   make-believe layer.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   inherited from caller
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-to-sense-error">ata_to_sense_error</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_to_sense_error</refname>
 <refpurpose>
      convert ATA error to SCSI error
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_to_sense_error </function></funcdef>
   <paramdef>unsigned <parameter>id</parameter></paramdef>
   <paramdef>u8 <parameter>drv_stat</parameter></paramdef>
   <paramdef>u8 <parameter>drv_err</parameter></paramdef>
   <paramdef>u8 * <parameter>sk</parameter></paramdef>
   <paramdef>u8 * <parameter>asc</parameter></paramdef>
   <paramdef>u8 * <parameter>ascq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     ATA device number
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>drv_stat</parameter></term>
   <listitem>
    <para>
     value contained in ATA status register
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>drv_err</parameter></term>
   <listitem>
    <para>
     value contained in ATA error register
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sk</parameter></term>
   <listitem>
    <para>
     the sense key we'll fill out
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>asc</parameter></term>
   <listitem>
    <para>
     the additional sense code we'll fill out
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ascq</parameter></term>
   <listitem>
    <para>
     the additional sense code qualifier we'll fill out
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Converts an ATA error into a SCSI error.  Fill out pointers to
   SK, ASC, and ASCQ bytes for later use in fixed or descriptor
   format sense blocks.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-gen-fixed-sense">ata_gen_fixed_sense</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_gen_fixed_sense</refname>
 <refpurpose>
      generate a SCSI fixed sense block
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_gen_fixed_sense </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Command that we are erroring out
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Leverage <function>ata_to_sense_error</function> to give us the codes.  Fit our
   LBA in here if there's room.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   inherited from caller
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-timed-out">ata_scsi_timed_out</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_timed_out</refname>
 <refpurpose>
      SCSI layer time out callback
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>enum scsi_eh_timer_return <function>ata_scsi_timed_out </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     timed out SCSI command
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Handles SCSI layer timeout.  We race with normal completion of
   the qc for <parameter>cmd</parameter>.  If the qc is already gone, we lose and let
   the scsi command finish (EH_HANDLED).  Otherwise, the qc has
   timed out and EH should be invoked.  Prevent <function>ata_qc_complete</function>
   from finishing it by setting EH_SCHEDULED and return
   EH_NOT_HANDLED.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Called from timer context
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   EH_HANDLED or EH_NOT_HANDLED
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-error">ata_scsi_error</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_error</refname>
 <refpurpose>
      SCSI layer error handler callback
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_error </function></funcdef>
   <paramdef>struct Scsi_Host * <parameter>host</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>host</parameter></term>
   <listitem>
    <para>
     SCSI host on which error occurred
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Handles SCSI-layer-thrown error events.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from SCSI layer (none, can sleep)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-start-stop-xlat">ata_scsi_start_stop_xlat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_start_stop_xlat</refname>
 <refpurpose>
      Translate SCSI START STOP UNIT command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_start_stop_xlat </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Storage for translated ATA taskfile
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Sets up an ATA taskfile to issue STANDBY (to stop) or READ VERIFY
   (to start). Perhaps these commands should be preceded by
   CHECK POWER MODE to see what power mode the device is already in.
   [See SAT revision 5 at www.t10.org]
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-flush-xlat">ata_scsi_flush_xlat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_flush_xlat</refname>
 <refpurpose>
      Translate SCSI SYNCHRONIZE CACHE command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_flush_xlat </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Storage for translated ATA taskfile
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate (ignored)
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Sets up an ATA taskfile to issue FLUSH CACHE or
   FLUSH CACHE EXT.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-scsi-6-lba-len">scsi_6_lba_len</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>scsi_6_lba_len</refname>
 <refpurpose>
      Get LBA and transfer length
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>scsi_6_lba_len </function></funcdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
   <paramdef>u64 * <parameter>plba</parameter></paramdef>
   <paramdef>u32 * <parameter>plen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plba</parameter></term>
   <listitem>
    <para>
     the LBA
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plen</parameter></term>
   <listitem>
    <para>
     the transfer length
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calculate LBA and transfer length for 6-byte commands.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-scsi-10-lba-len">scsi_10_lba_len</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>scsi_10_lba_len</refname>
 <refpurpose>
      Get LBA and transfer length
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>scsi_10_lba_len </function></funcdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
   <paramdef>u64 * <parameter>plba</parameter></paramdef>
   <paramdef>u32 * <parameter>plen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plba</parameter></term>
   <listitem>
    <para>
     the LBA
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plen</parameter></term>
   <listitem>
    <para>
     the transfer length
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calculate LBA and transfer length for 10-byte commands.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-scsi-16-lba-len">scsi_16_lba_len</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>scsi_16_lba_len</refname>
 <refpurpose>
      Get LBA and transfer length
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>scsi_16_lba_len </function></funcdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
   <paramdef>u64 * <parameter>plba</parameter></paramdef>
   <paramdef>u32 * <parameter>plen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plba</parameter></term>
   <listitem>
    <para>
     the LBA
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>plen</parameter></term>
   <listitem>
    <para>
     the transfer length
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Calculate LBA and transfer length for 16-byte commands.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-verify-xlat">ata_scsi_verify_xlat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_verify_xlat</refname>
 <refpurpose>
      Translate SCSI VERIFY command into an ATA one
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_verify_xlat </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Storage for translated ATA taskfile
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Converts SCSI VERIFY command to an ATA READ VERIFY command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-rw-xlat">ata_scsi_rw_xlat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_rw_xlat</refname>
 <refpurpose>
      Translate SCSI r/w command into an ATA one
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_rw_xlat </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     Storage for translated ATA taskfile
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to translate
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Converts any of six SCSI read/write commands into the
   ATA counterpart, including starting sector (LBA),
   sector count, and taking into account the device's LBA48
   support.
   </para><para>

   Commands <constant>READ_6</constant>, <constant>READ_10</constant>, <constant>READ_16</constant>, <constant>WRITE_6</constant>, <constant>WRITE_10</constant>, and
   <constant>WRITE_16</constant> are currently supported.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on error.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-translate">ata_scsi_translate</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_translate</refname>
 <refpurpose>
      Translate then issue SCSI command to ATA device
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_translate </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>void (*<parameter>done</parameter>)
     <funcparams>struct scsi_cmnd *</funcparams></paramdef>
   <paramdef>ata_xlat_func_t <parameter>xlat_func</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA port to which the command is addressed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     ATA device to which the command is addressed
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command to execute
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>done</parameter></term>
   <listitem>
    <para>
     SCSI command completion function
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>xlat_func</parameter></term>
   <listitem>
    <para>
     Actor which translates <parameter>cmd</parameter> to an ATA taskfile
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Our -&gt;<function>queuecommand</function> function has decided that the SCSI
   command issued can be directly translated into an ATA
   command, rather than handled internally.
   </para><para>

   This function sets up an ata_queued_cmd structure for the
   SCSI command, and sends that ata_queued_cmd to the hardware.
   </para><para>

   The xlat_func argument (actor) returns 0 if ready to execute
   ATA command, else 1 to finish translation. If 1 is returned
   then cmd-&gt;result (and possibly cmd-&gt;sense_buffer) are assumed
   to be set reflecting an error condition or clean (early)
   termination.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-rbuf-get">ata_scsi_rbuf_get</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_rbuf_get</refname>
 <refpurpose>
      Map response buffer.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_rbuf_get </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>u8 ** <parameter>buf_out</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command containing buffer to be mapped.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf_out</parameter></term>
   <listitem>
    <para>
     Pointer to mapped area.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Maps buffer contained within SCSI command <parameter>cmd</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Length of response buffer.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-rbuf-put">ata_scsi_rbuf_put</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_rbuf_put</refname>
 <refpurpose>
      Unmap response buffer.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_rbuf_put </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>u8 * <parameter>buf</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command containing buffer to be unmapped.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     buffer to unmap
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Unmaps response buffer contained within <parameter>cmd</parameter>.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-rbuf-fill">ata_scsi_rbuf_fill</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_rbuf_fill</refname>
 <refpurpose>
      wrapper for SCSI command simulators
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_rbuf_fill </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>unsigned int (*<parameter>actor</parameter>)
     <funcparams>struct ata_scsi_args *args, 			     		   u8 *rbuf, unsigned int buflen</funcparams></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>actor</parameter></term>
   <listitem>
    <para>
     Callback hook for desired SCSI command simulator
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Takes care of the hard work of simulating a SCSI command...
   Mapping the response buffer, calling the command's handler,
   and handling the handler's return value.  This return value
   indicates whether the handler wishes the SCSI command to be
   completed successfully (0), or not (in which case cmd-&gt;result
   and sense buffer are assumed to be set).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-inq-std">ata_scsiop_inq_std</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_inq_std</refname>
 <refpurpose>
      Simulate INQUIRY command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_inq_std </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns standard device identification data associated
   with non-VPD INQUIRY command output.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-inq-00">ata_scsiop_inq_00</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_inq_00</refname>
 <refpurpose>
      Simulate INQUIRY VPD page 0, list of pages
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_inq_00 </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns list of inquiry VPD pages available.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-inq-80">ata_scsiop_inq_80</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_inq_80</refname>
 <refpurpose>
      Simulate INQUIRY VPD page 80, device serial number
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_inq_80 </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Returns ATA device serial number.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-inq-83">ata_scsiop_inq_83</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_inq_83</refname>
 <refpurpose>
      Simulate INQUIRY VPD page 83, device identity
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_inq_83 </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Yields two logical unit device identification designators</title>
<para>
   - vendor specific ASCII containing the ATA serial number
   - SAT defined <quote>t10 vendor id based</quote> containing ASCII vendor
   name (<quote>ATA     </quote>), model and serial numbers.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-noop">ata_scsiop_noop</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_noop</refname>
 <refpurpose>
      Command handler that simply returns success.
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_noop </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   No operation.  Simply returns success to caller, to indicate
   that the caller should successfully complete this SCSI command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-msense-push">ata_msense_push</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_msense_push</refname>
 <refpurpose>
      Push data onto MODE SENSE data output buffer
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_msense_push </function></funcdef>
   <paramdef>u8 ** <parameter>ptr_io</parameter></paramdef>
   <paramdef>const u8 * <parameter>last</parameter></paramdef>
   <paramdef>const u8 * <parameter>buf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr_io</parameter></term>
   <listitem>
    <para>
     (input/output) Location to store more output data
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>last</parameter></term>
   <listitem>
    <para>
     End of output data buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buf</parameter></term>
   <listitem>
    <para>
     Pointer to BLOB being added to output buffer
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Length of BLOB
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Store MODE SENSE data on an output buffer.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-msense-caching">ata_msense_caching</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_msense_caching</refname>
 <refpurpose>
      Simulate MODE SENSE caching info page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_msense_caching </function></funcdef>
   <paramdef>u16 * <parameter>id</parameter></paramdef>
   <paramdef>u8 ** <parameter>ptr_io</parameter></paramdef>
   <paramdef>const u8 * <parameter>last</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>id</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ptr_io</parameter></term>
   <listitem>
    <para>
     (input/output) Location to store more output data
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>last</parameter></term>
   <listitem>
    <para>
     End of output data buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Generate a caching info page, which conditionally indicates
   write caching to the SCSI layer, depending on device
   capabilities.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-msense-ctl-mode">ata_msense_ctl_mode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_msense_ctl_mode</refname>
 <refpurpose>
      Simulate MODE SENSE control mode page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_msense_ctl_mode </function></funcdef>
   <paramdef>u8 ** <parameter>ptr_io</parameter></paramdef>
   <paramdef>const u8 * <parameter>last</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr_io</parameter></term>
   <listitem>
    <para>
     (input/output) Location to store more output data
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>last</parameter></term>
   <listitem>
    <para>
     End of output data buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Generate a generic MODE SENSE control mode page.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-msense-rw-recovery">ata_msense_rw_recovery</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_msense_rw_recovery</refname>
 <refpurpose>
      Simulate MODE SENSE r/w error recovery page
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_msense_rw_recovery </function></funcdef>
   <paramdef>u8 ** <parameter>ptr_io</parameter></paramdef>
   <paramdef>const u8 * <parameter>last</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ptr_io</parameter></term>
   <listitem>
    <para>
     (input/output) Location to store more output data
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>last</parameter></term>
   <listitem>
    <para>
     End of output data buffer
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Generate a generic MODE SENSE r/w error recovery page.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-mode-sense">ata_scsiop_mode_sense</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_mode_sense</refname>
 <refpurpose>
      Simulate MODE SENSE 6, 10 commands
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_mode_sense </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Simulate MODE SENSE commands. Assume this is invoked for direct
   access devices (e.g. disks) only. There should be no block
   descriptor for other device types.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-read-cap">ata_scsiop_read_cap</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_read_cap</refname>
 <refpurpose>
      Simulate READ CAPACITY[ 16] commands
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_read_cap </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Simulate READ CAPACITY commands.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsiop-report-luns">ata_scsiop_report_luns</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsiop_report_luns</refname>
 <refpurpose>
      Simulate REPORT LUNS command
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsiop_report_luns </function></funcdef>
   <paramdef>struct ata_scsi_args * <parameter>args</parameter></paramdef>
   <paramdef>u8 * <parameter>rbuf</parameter></paramdef>
   <paramdef>unsigned int <parameter>buflen</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>args</parameter></term>
   <listitem>
    <para>
     device IDENTIFY data / SCSI command of interest.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>rbuf</parameter></term>
   <listitem>
    <para>
     Response buffer, to which simulated SCSI cmd output is sent.
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>buflen</parameter></term>
   <listitem>
    <para>
     Response buffer length.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Simulate REPORT LUNS command.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-set-sense">ata_scsi_set_sense</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_set_sense</refname>
 <refpurpose>
      Set SCSI sense data and status
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_set_sense </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>u8 <parameter>sk</parameter></paramdef>
   <paramdef>u8 <parameter>asc</parameter></paramdef>
   <paramdef>u8 <parameter>ascq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI request to be handled
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>sk</parameter></term>
   <listitem>
    <para>
     SCSI-defined sense key
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>asc</parameter></term>
   <listitem>
    <para>
     SCSI-defined additional sense code
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ascq</parameter></term>
   <listitem>
    <para>
     SCSI-defined additional sense code qualifier
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Helper function that builds a valid fixed format, current
   response code and the given sense key (sk), additional sense
   code (asc) and additional sense code qualifier (ascq) with
   a SCSI command status of <constant>SAM_STAT_CHECK_CONDITION</constant> and
</para>
</refsect1>
<refsect1>
<title>DRIVER_SENSE set in the upper bits of scsi_cmnd</title>
<para>
   :result .
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Not required
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-badcmd">ata_scsi_badcmd</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_badcmd</refname>
 <refpurpose>
      End a SCSI request with an error
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_badcmd </function></funcdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
   <paramdef>void (*<parameter>done</parameter>)
     <funcparams>struct scsi_cmnd *</funcparams></paramdef>
   <paramdef>u8 <parameter>asc</parameter></paramdef>
   <paramdef>u8 <parameter>ascq</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI request to be handled
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>done</parameter></term>
   <listitem>
    <para>
     SCSI command completion function
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>asc</parameter></term>
   <listitem>
    <para>
     SCSI-defined additional sense code
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ascq</parameter></term>
   <listitem>
    <para>
     SCSI-defined additional sense code qualifier
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Helper function that completes a SCSI command with
   <constant>SAM_STAT_CHECK_CONDITION</constant>, with a sense key <constant>ILLEGAL_REQUEST</constant>
   and the specified additional sense codes.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-atapi-xlat">atapi_xlat</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>atapi_xlat</refname>
 <refpurpose>
      Initialize PACKET taskfile
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>atapi_xlat </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     command structure to be initialized
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI CDB associated with this PACKET command
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-find-dev">ata_scsi_find_dev</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_find_dev</refname>
 <refpurpose>
      lookup ata_device from scsi_cmnd
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>struct ata_device * <function>ata_scsi_find_dev </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>const struct scsi_device * <parameter>scsidev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA port to which the device is attached
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsidev</parameter></term>
   <listitem>
    <para>
     SCSI device from which we derive the ATA device
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Given various information provided in struct scsi_cmnd,
   map that onto an ATA bus, and using that mapping
   determine which ata_device is associated with the
   SCSI command to be sent.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   spin_lock_irqsave(host_set lock)
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Associated ATA device, or <constant>NULL</constant> if not found.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-pass-thru">ata_scsi_pass_thru</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_pass_thru</refname>
 <refpurpose>
      convert ATA pass-thru CDB to taskfile
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>ata_scsi_pass_thru </function></funcdef>
   <paramdef>struct ata_queued_cmd * <parameter>qc</parameter></paramdef>
   <paramdef>const u8 * <parameter>scsicmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>qc</parameter></term>
   <listitem>
    <para>
     command structure to be initialized
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>scsicmd</parameter></term>
   <listitem>
    <para>
     SCSI command to convert
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Handles either 12 or 16-byte versions of the CDB.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, non-zero on failure.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-get-xlat-func">ata_get_xlat_func</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_get_xlat_func</refname>
 <refpurpose>
      check if SCSI to ATA translation is possible
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>ata_xlat_func_t <function>ata_get_xlat_func </function></funcdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
   <paramdef>u8 <parameter>cmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     ATA device
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command opcode to consider
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Look up the SCSI command given, and determine whether the
   SCSI command is to be translated or simulated.
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Pointer to translation function if possible, <constant>NULL</constant> if not.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-ata-scsi-dump-cdb">ata_scsi_dump_cdb</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>ata_scsi_dump_cdb</refname>
 <refpurpose>
      dump SCSI command contents to dmesg
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>ata_scsi_dump_cdb </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct scsi_cmnd * <parameter>cmd</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     ATA port to which the command was being sent
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>cmd</parameter></term>
   <listitem>
    <para>
     SCSI command to dump
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Prints the contents of a SCSI command via <function>printk</function>.
</para>
</refsect1>
</refentry>

  </chapter>

  <chapter id="ataExceptions">
     <title>ATA errors &amp; exceptions</title>

  <para>
  This chapter tries to identify what error/exception conditions exist
  for ATA/ATAPI devices and describe how they should be handled in
  implementation-neutral way.
  </para>

  <para>
  The term 'error' is used to describe conditions where either an
  explicit error condition is reported from device or a command has
  timed out.
  </para>

  <para>
  The term 'exception' is either used to describe exceptional
  conditions which are not errors (say, power or hotplug events), or
  to describe both errors and non-error exceptional conditions.  Where
  explicit distinction between error and exception is necessary, the
  term 'non-error exception' is used.
  </para>

  <sect1 id="excat">
     <title>Exception categories</title>
     <para>
     Exceptions are described primarily with respect to legacy
     taskfile + bus master IDE interface.  If a controller provides
     other better mechanism for error reporting, mapping those into
     categories described below shouldn't be difficult.
     </para>

     <para>
     In the following sections, two recovery actions - reset and
     reconfiguring transport - are mentioned.  These are described
     further in <xref linkend="exrec"/>.
     </para>

     <sect2 id="excatHSMviolation">
        <title>HSM violation</title>
        <para>
        This error is indicated when STATUS value doesn't match HSM
        requirement during issuing or excution any ATA/ATAPI command.
        </para>

	<itemizedlist>
	<title>Examples</title>

        <listitem>
	<para>
	ATA_STATUS doesn't contain !BSY &amp;&amp; DRDY &amp;&amp; !DRQ while trying
	to issue a command.
        </para>
	</listitem>

        <listitem>
	<para>
	!BSY &amp;&amp; !DRQ during PIO data transfer.
        </para>
	</listitem>

        <listitem>
	<para>
	DRQ on command completion.
        </para>
	</listitem>

        <listitem>
	<para>
	!BSY &amp;&amp; ERR after CDB tranfer starts but before the
        last byte of CDB is transferred.  ATA/ATAPI standard states
        that &quot;The device shall not terminate the PACKET command
        with an error before the last byte of the command packet has
        been written&quot; in the error outputs description of PACKET
        command and the state diagram doesn't include such
        transitions.
	</para>
	</listitem>

	</itemizedlist>

	<para>
	In these cases, HSM is violated and not much information
	regarding the error can be acquired from STATUS or ERROR
	register.  IOW, this error can be anything - driver bug,
	faulty device, controller and/or cable.
	</para>

	<para>
	As HSM is violated, reset is necessary to restore known state.
	Reconfiguring transport for lower speed might be helpful too
	as transmission errors sometimes cause this kind of errors.
	</para>
     </sect2>
     
     <sect2 id="excatDevErr">
        <title>ATA/ATAPI device error (non-NCQ / non-CHECK CONDITION)</title>

	<para>
	These are errors detected and reported by ATA/ATAPI devices
	indicating device problems.  For this type of errors, STATUS
	and ERROR register values are valid and describe error
	condition.  Note that some of ATA bus errors are detected by
	ATA/ATAPI devices and reported using the same mechanism as
	device errors.  Those cases are described later in this
	section.
	</para>

	<para>
	For ATA commands, this type of errors are indicated by !BSY
	&amp;&amp; ERR during command execution and on completion.
	</para>

	<para>For ATAPI commands,</para>

	<itemizedlist>

	<listitem>
	<para>
	!BSY &amp;&amp; ERR &amp;&amp; ABRT right after issuing PACKET
	indicates that PACKET command is not supported and falls in
	this category.
	</para>
	</listitem>

	<listitem>
	<para>
	!BSY &amp;&amp; ERR(==CHK) &amp;&amp; !ABRT after the last
	byte of CDB is transferred indicates CHECK CONDITION and
	doesn't fall in this category.
	</para>
	</listitem>

	<listitem>
	<para>
	!BSY &amp;&amp; ERR(==CHK) &amp;&amp; ABRT after the last byte
        of CDB is transferred *probably* indicates CHECK CONDITION and
        doesn't fall in this category.
	</para>
	</listitem>

	</itemizedlist>

	<para>
	Of errors detected as above, the followings are not ATA/ATAPI
	device errors but ATA bus errors and should be handled
	according to <xref linkend="excatATAbusErr"/>.
	</para>

	<variablelist>

	   <varlistentry>
	   <term>CRC error during data transfer</term>
	   <listitem>
	   <para>
	   This is indicated by ICRC bit in the ERROR register and
	   means that corruption occurred during data transfer.  Upto
	   ATA/ATAPI-7, the standard specifies that this bit is only
	   applicable to UDMA transfers but ATA/ATAPI-8 draft revision
	   1f says that the bit may be applicable to multiword DMA and
	   PIO.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry>
	   <term>ABRT error during data transfer or on completion</term>
	   <listitem>
	   <para>
	   Upto ATA/ATAPI-7, the standard specifies that ABRT could be
	   set on ICRC errors and on cases where a device is not able
	   to complete a command.  Combined with the fact that MWDMA
	   and PIO transfer errors aren't allowed to use ICRC bit upto
	   ATA/ATAPI-7, it seems to imply that ABRT bit alone could
	   indicate tranfer errors.
	   </para>
	   <para>
	   However, ATA/ATAPI-8 draft revision 1f removes the part
	   that ICRC errors can turn on ABRT.  So, this is kind of
	   gray area.  Some heuristics are needed here.
	   </para>
	   </listitem>
	   </varlistentry>

	</variablelist>

	<para>
	ATA/ATAPI device errors can be further categorized as follows.
	</para>

	<variablelist>

	   <varlistentry>
	   <term>Media errors</term>
	   <listitem>
	   <para>
	   This is indicated by UNC bit in the ERROR register.  ATA
	   devices reports UNC error only after certain number of
	   retries cannot recover the data, so there's nothing much
	   else to do other than notifying upper layer.
	   </para>
	   <para>
	   READ and WRITE commands report CHS or LBA of the first
	   failed sector but ATA/ATAPI standard specifies that the
	   amount of transferred data on error completion is
	   indeterminate, so we cannot assume that sectors preceding
	   the failed sector have been transferred and thus cannot
	   complete those sectors successfully as SCSI does.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry>
	   <term>Media changed / media change requested error</term>
	   <listitem>
	   <para>
	   &lt;&lt;TODO: fill here&gt;&gt;
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>Address error</term>
	   <listitem>
	   <para>
	   This is indicated by IDNF bit in the ERROR register.
	   Report to upper layer.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>Other errors</term>
	   <listitem>
	   <para>
	   This can be invalid command or parameter indicated by ABRT
	   ERROR bit or some other error condition.  Note that ABRT
	   bit can indicate a lot of things including ICRC and Address
	   errors.  Heuristics needed.
	   </para>
	   </listitem>
	   </varlistentry>

	</variablelist>

	<para>
	Depending on commands, not all STATUS/ERROR bits are
	applicable.  These non-applicable bits are marked with
	&quot;na&quot; in the output descriptions but upto ATA/ATAPI-7
	no definition of &quot;na&quot; can be found.  However,
	ATA/ATAPI-8 draft revision 1f describes &quot;N/A&quot; as
	follows.
	</para>

	<blockquote>
	<variablelist>
	   <varlistentry><term>3.2.3.3a N/A</term>
	   <listitem>
	   <para>
	   A keyword the indicates a field has no defined value in
	   this standard and should not be checked by the host or
	   device. N/A fields should be cleared to zero.
	   </para>
	   </listitem>
	   </varlistentry>
	</variablelist>
	</blockquote>

	<para>
	So, it seems reasonable to assume that &quot;na&quot; bits are
	cleared to zero by devices and thus need no explicit masking.
	</para>

     </sect2>

     <sect2 id="excatATAPIcc">
        <title>ATAPI device CHECK CONDITION</title>

	<para>
	ATAPI device CHECK CONDITION error is indicated by set CHK bit
	(ERR bit) in the STATUS register after the last byte of CDB is
	transferred for a PACKET command.  For this kind of errors,
	sense data should be acquired to gather information regarding
	the errors.  REQUEST SENSE packet command should be used to
	acquire sense data.
	</para>

	<para>
	Once sense data is acquired, this type of errors can be
	handled similary to other SCSI errors.  Note that sense data
	may indicate ATA bus error (e.g. Sense Key 04h HARDWARE ERROR
	&amp;&amp; ASC/ASCQ 47h/00h SCSI PARITY ERROR).  In such
	cases, the error should be considered as an ATA bus error and
	handled according to <xref linkend="excatATAbusErr"/>.
	</para>

     </sect2>

     <sect2 id="excatNCQerr">
        <title>ATA device error (NCQ)</title>

	<para>
	NCQ command error is indicated by cleared BSY and set ERR bit
	during NCQ command phase (one or more NCQ commands
	outstanding).  Although STATUS and ERROR registers will
	contain valid values describing the error, READ LOG EXT is
	required to clear the error condition, determine which command
	has failed and acquire more information.
	</para>

	<para>
	READ LOG EXT Log Page 10h reports which tag has failed and
	taskfile register values describing the error.  With this
	information the failed command can be handled as a normal ATA
	command error as in <xref linkend="excatDevErr"/> and all
	other in-flight commands must be retried.  Note that this
	retry should not be counted - it's likely that commands
	retried this way would have completed normally if it were not
	for the failed command.
	</para>

	<para>
	Note that ATA bus errors can be reported as ATA device NCQ
	errors.  This should be handled as described in <xref
	linkend="excatATAbusErr"/>.
	</para>

	<para>
	If READ LOG EXT Log Page 10h fails or reports NQ, we're
	thoroughly screwed.  This condition should be treated
	according to <xref linkend="excatHSMviolation"/>.
	</para>

     </sect2>

     <sect2 id="excatATAbusErr">
        <title>ATA bus error</title>

	<para>
	ATA bus error means that data corruption occurred during
	transmission over ATA bus (SATA or PATA).  This type of errors
	can be indicated by
	</para>

	<itemizedlist>

	<listitem>
	<para>
	ICRC or ABRT error as described in <xref linkend="excatDevErr"/>.
	</para>
	</listitem>

	<listitem>
	<para>
	Controller-specific error completion with error information
	indicating transmission error.
	</para>
	</listitem>

	<listitem>
	<para>
	On some controllers, command timeout.  In this case, there may
	be a mechanism to determine that the timeout is due to
	transmission error.
	</para>
	</listitem>

	<listitem>
	<para>
	Unknown/random errors, timeouts and all sorts of weirdities.
	</para>
	</listitem>

	</itemizedlist>

	<para>
	As described above, transmission errors can cause wide variety
	of symptoms ranging from device ICRC error to random device
	lockup, and, for many cases, there is no way to tell if an
	error condition is due to transmission error or not;
	therefore, it's necessary to employ some kind of heuristic
	when dealing with errors and timeouts.  For example,
	encountering repetitive ABRT errors for known supported
	command is likely to indicate ATA bus error.
	</para>

	<para>
	Once it's determined that ATA bus errors have possibly
	occurred, lowering ATA bus transmission speed is one of
	actions which may alleviate the problem.  See <xref
	linkend="exrecReconf"/> for more information.
	</para>

     </sect2>

     <sect2 id="excatPCIbusErr">
        <title>PCI bus error</title>

	<para>
	Data corruption or other failures during transmission over PCI
	(or other system bus).  For standard BMDMA, this is indicated
	by Error bit in the BMDMA Status register.  This type of
	errors must be logged as it indicates something is very wrong
	with the system.  Resetting host controller is recommended.
	</para>

     </sect2>

     <sect2 id="excatLateCompletion">
        <title>Late completion</title>

	<para>
	This occurs when timeout occurs and the timeout handler finds
	out that the timed out command has completed successfully or
	with error.  This is usually caused by lost interrupts.  This
	type of errors must be logged.  Resetting host controller is
	recommended.
	</para>

     </sect2>

     <sect2 id="excatUnknown">
        <title>Unknown error (timeout)</title>

	<para>
	This is when timeout occurs and the command is still
	processing or the host and device are in unknown state.  When
	this occurs, HSM could be in any valid or invalid state.  To
	bring the device to known state and make it forget about the
	timed out command, resetting is necessary.  The timed out
	command may be retried.
	</para>

	<para>
	Timeouts can also be caused by transmission errors.  Refer to
	<xref linkend="excatATAbusErr"/> for more details.
	</para>

     </sect2>

     <sect2 id="excatHoplugPM">
        <title>Hotplug and power management exceptions</title>

	<para>
	&lt;&lt;TODO: fill here&gt;&gt;
	</para>

     </sect2>

  </sect1>

  <sect1 id="exrec">
     <title>EH recovery actions</title>

     <para>
     This section discusses several important recovery actions.
     </para>

     <sect2 id="exrecClr">
        <title>Clearing error condition</title>

	<para>
	Many controllers require its error registers to be cleared by
	error handler.  Different controllers may have different
	requirements.
	</para>

	<para>
	For SATA, it's strongly recommended to clear at least SError
	register during error handling.
	</para>
     </sect2>

     <sect2 id="exrecRst">
        <title>Reset</title>

	<para>
	During EH, resetting is necessary in the following cases.
	</para>

	<itemizedlist>

	<listitem>
	<para>
	HSM is in unknown or invalid state
	</para>
	</listitem>

	<listitem>
	<para>
	HBA is in unknown or invalid state
	</para>
	</listitem>

	<listitem>
	<para>
	EH needs to make HBA/device forget about in-flight commands
	</para>
	</listitem>

	<listitem>
	<para>
	HBA/device behaves weirdly
	</para>
	</listitem>

	</itemizedlist>

	<para>
	Resetting during EH might be a good idea regardless of error
	condition to improve EH robustness.  Whether to reset both or
	either one of HBA and device depends on situation but the
	following scheme is recommended.
	</para>

	<itemizedlist>

	<listitem>
	<para>
	When it's known that HBA is in ready state but ATA/ATAPI
	device in in unknown state, reset only device.
	</para>
	</listitem>

	<listitem>
	<para>
	If HBA is in unknown state, reset both HBA and device.
	</para>
	</listitem>

	</itemizedlist>

	<para>
	HBA resetting is implementation specific.  For a controller
	complying to taskfile/BMDMA PCI IDE, stopping active DMA
	transaction may be sufficient iff BMDMA state is the only HBA
	context.  But even mostly taskfile/BMDMA PCI IDE complying
	controllers may have implementation specific requirements and
	mechanism to reset themselves.  This must be addressed by
	specific drivers.
	</para>

	<para>
	OTOH, ATA/ATAPI standard describes in detail ways to reset
	ATA/ATAPI devices.
	</para>

	<variablelist>

	   <varlistentry><term>PATA hardware reset</term>
	   <listitem>
	   <para>
	   This is hardware initiated device reset signalled with
	   asserted PATA RESET- signal.  There is no standard way to
	   initiate hardware reset from software although some
	   hardware provides registers that allow driver to directly
	   tweak the RESET- signal.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>Software reset</term>
	   <listitem>
	   <para>
	   This is achieved by turning CONTROL SRST bit on for at
	   least 5us.  Both PATA and SATA support it but, in case of
	   SATA, this may require controller-specific support as the
	   second Register FIS to clear SRST should be transmitted
	   while BSY bit is still set.  Note that on PATA, this resets
	   both master and slave devices on a channel.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>EXECUTE DEVICE DIAGNOSTIC command</term>
	   <listitem>
	   <para>
	   Although ATA/ATAPI standard doesn't describe exactly, EDD
	   implies some level of resetting, possibly similar level
	   with software reset.  Host-side EDD protocol can be handled
	   with normal command processing and most SATA controllers
	   should be able to handle EDD's just like other commands.
	   As in software reset, EDD affects both devices on a PATA
	   bus.
	   </para>
	   <para>
	   Although EDD does reset devices, this doesn't suit error
	   handling as EDD cannot be issued while BSY is set and it's
	   unclear how it will act when device is in unknown/weird
	   state.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>ATAPI DEVICE RESET command</term>
	   <listitem>
	   <para>
	   This is very similar to software reset except that reset
	   can be restricted to the selected device without affecting
	   the other device sharing the cable.
	   </para>
	   </listitem>
	   </varlistentry>

	   <varlistentry><term>SATA phy reset</term>
	   <listitem>
	   <para>
	   This is the preferred way of resetting a SATA device.  In
	   effect, it's identical to PATA hardware reset.  Note that
	   this can be done with the standard SCR Control register.
	   As such, it's usually easier to implement than software
	   reset.
	   </para>
	   </listitem>
	   </varlistentry>

	</variablelist>

	<para>
	One more thing to consider when resetting devices is that
	resetting clears certain configuration parameters and they
	need to be set to their previous or newly adjusted values
	after reset.
	</para>

	<para>
	Parameters affected are.
	</para>

	<itemizedlist>

	<listitem>
	<para>
	CHS set up with INITIALIZE DEVICE PARAMETERS (seldomly used)
	</para>
	</listitem>

	<listitem>
	<para>
	Parameters set with SET FEATURES including transfer mode setting
	</para>
	</listitem>

	<listitem>
	<para>
	Block count set with SET MULTIPLE MODE
	</para>
	</listitem>

	<listitem>
	<para>
	Other parameters (SET MAX, MEDIA LOCK...)
	</para>
	</listitem>

	</itemizedlist>

	<para>
	ATA/ATAPI standard specifies that some parameters must be
	maintained across hardware or software reset, but doesn't
	strictly specify all of them.  Always reconfiguring needed
	parameters after reset is required for robustness.  Note that
	this also applies when resuming from deep sleep (power-off).
	</para>

	<para>
	Also, ATA/ATAPI standard requires that IDENTIFY DEVICE /
	IDENTIFY PACKET DEVICE is issued after any configuration
	parameter is updated or a hardware reset and the result used
	for further operation.  OS driver is required to implement
	revalidation mechanism to support this.
	</para>

     </sect2>

     <sect2 id="exrecReconf">
        <title>Reconfigure transport</title>

	<para>
	For both PATA and SATA, a lot of corners are cut for cheap
	connectors, cables or controllers and it's quite common to see
	high transmission error rate.  This can be mitigated by
	lowering transmission speed.
	</para>

	<para>
	The following is a possible scheme Jeff Garzik suggested.
	</para>

	<blockquote>
	<para>
	If more than $N (3?) transmission errors happen in 15 minutes,
	</para>	
	<itemizedlist>
	<listitem>
	<para>
	if SATA, decrease SATA PHY speed.  if speed cannot be decreased,
	</para>
	</listitem>
	<listitem>
	<para>
	decrease UDMA xfer speed.  if at UDMA0, switch to PIO4,
	</para>
	</listitem>
	<listitem>
	<para>
	decrease PIO xfer speed.  if at PIO3, complain, but continue
	</para>
	</listitem>
	</itemizedlist>
	</blockquote>

     </sect2>

  </sect1>

  </chapter>

  <chapter id="PiixInt">
     <title>ata_piix Internals</title>
<!-- drivers/scsi/ata_piix.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-pata-cbl-detect">piix_pata_cbl_detect</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_pata_cbl_detect</refname>
 <refpurpose>
   Probe host controller cable detect info
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>piix_pata_cbl_detect </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port for which cable detect info is desired
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Read 80c cable indicator from ATA PCI device's PCI config
   register.  This register is normally set by firmware (BIOS).
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-pata-probeinit">piix_pata_probeinit</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_pata_probeinit</refname>
 <refpurpose>
      probeinit for PATA host controller
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>piix_pata_probeinit </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Target port
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Probeinit including cable detection.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-pata-probe-reset">piix_pata_probe_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_pata_probe_reset</refname>
 <refpurpose>
      Perform reset on PATA port and classify
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>piix_pata_probe_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     Resulting classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Reset PATA phy and classify attached devices.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-sata-probe">piix_sata_probe</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_sata_probe</refname>
 <refpurpose>
      Probe PCI device for present SATA devices
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>unsigned int <function>piix_sata_probe </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port associated with the PCI device we wish to probe
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Reads and configures SATA PCI device's PCI config register
   Port Configuration and Status (PCS) to determine port and
   device availability.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Mask of avaliable devices on the port.
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-sata-probe-reset">piix_sata_probe_reset</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_sata_probe_reset</refname>
 <refpurpose>
      Perform reset on SATA port and classify
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>piix_sata_probe_reset </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>unsigned int * <parameter>classes</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port to reset
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>classes</parameter></term>
   <listitem>
    <para>
     Resulting classes of attached devices
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Reset SATA phy and classify attached devices.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-set-piomode">piix_set_piomode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_set_piomode</refname>
 <refpurpose>
      Initialize host controller PATA PIO timings
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>piix_set_piomode </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>adev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port whose timings we are configuring
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>adev</parameter></term>
   <listitem>
    <para>
     um
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Set PIO mode for device, in host controller PCI config space.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-set-dmamode">piix_set_dmamode</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_set_dmamode</refname>
 <refpurpose>
      Initialize host controller PATA PIO timings
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>piix_set_dmamode </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>adev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port whose timings we are configuring
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>adev</parameter></term>
   <listitem>
    <para>
     um
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Set UDMA mode for device, in host controller PCI config space.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   None (inherited from caller).
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-check-450nx-errata">piix_check_450nx_errata</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_check_450nx_errata</refname>
 <refpurpose>
     	Check for problem 450NX setup
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int __devinit <function>piix_check_450nx_errata </function></funcdef>
   <paramdef>struct pci_dev * <parameter>ata_dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ata_dev</parameter></term>
   <listitem>
    <para>
     the PCI device to check
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Check for the present of 450NX errata #19 and errata #25. If
   they are found return an error code so we can turn off DMA
</para>
</refsect1>
</refentry>

<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-piix-init-one">piix_init_one</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>piix_init_one</refname>
 <refpurpose>
      Register PIIX ATA PCI device with kernel services
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>int <function>piix_init_one </function></funcdef>
   <paramdef>struct pci_dev * <parameter>pdev</parameter></paramdef>
   <paramdef>const struct pci_device_id * <parameter>ent</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>pdev</parameter></term>
   <listitem>
    <para>
     PCI device to register
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>ent</parameter></term>
   <listitem>
    <para>
     Entry in piix_pci_tbl matching with <parameter>pdev</parameter>
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   Called from kernel PCI layer.  We probe for combined mode (sigh),
   and then hand over control to libata, for it to do the rest.
</para>
</refsect1>
<refsect1>
<title>LOCKING</title>
<para>
   Inherited from PCI layer (may sleep).
</para>
</refsect1>
<refsect1>
<title>RETURNS</title>
<para>
   Zero on success, or -ERRNO value.
</para>
</refsect1>
</refentry>

  </chapter>

  <chapter id="SILInt">
     <title>sata_sil Internals</title>
<!-- drivers/scsi/sata_sil.c -->
<refentry>
<refentryinfo>
 <title>LINUX</title>
 <productname>Kernel Hackers Manual</productname>
 <date>November 2007</date>
</refentryinfo>
<refmeta>
 <refentrytitle><phrase id="API-sil-dev-config">sil_dev_config</phrase></refentrytitle>
 <manvolnum>9</manvolnum>
</refmeta>
<refnamediv>
 <refname>sil_dev_config</refname>
 <refpurpose>
   Apply device/host-specific errata fixups
 </refpurpose>
</refnamediv>
<refsynopsisdiv>
 <title>Synopsis</title>
  <funcsynopsis><funcprototype>
   <funcdef>void <function>sil_dev_config </function></funcdef>
   <paramdef>struct ata_port * <parameter>ap</parameter></paramdef>
   <paramdef>struct ata_device * <parameter>dev</parameter></paramdef>
  </funcprototype></funcsynopsis>
</refsynopsisdiv>
<refsect1>
 <title>Arguments</title>
 <variablelist>
  <varlistentry>
   <term><parameter>ap</parameter></term>
   <listitem>
    <para>
     Port containing device to be examined
    </para>
   </listitem>
  </varlistentry>
  <varlistentry>
   <term><parameter>dev</parameter></term>
   <listitem>
    <para>
     Device to be examined
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
</refsect1>
<refsect1>
<title>Description</title>
<para>
   After the IDENTIFY [PACKET] DEVICE step is complete, and a
   device is known to be present, this function is called.
   We apply two errata fixups which are specific to Silicon Image,
   a Seagate and a Maxtor fixup.
   </para><para>

   For certain Seagate devices, we must limit the maximum sectors
   to under 8K.
   </para><para>

   For certain Maxtor devices, we must not program the drive
   beyond udma5.
   </para><para>

   Both fixups are unfairly pessimistic.  As soon as I get more
   information on these errata, I will create a more exhaustive
   list, and apply the fixups to only the specific
   devices/hosts/firmwares that need it.
   </para><para>

   20040111 - Seagate drives affected by the Mod15Write bug are blacklisted
   The Maxtor quirk is in the blacklist, but I'm keeping the original
   pessimistic fix for the following reasons...
   - There seems to be less info on it, only one device gleaned off the
   Windows	driver, maybe only one is affected.  More info would be greatly
   appreciated.
   - But then again UDMA5 is hardly anything to complain about
</para>
</refsect1>
</refentry>

  </chapter>

  <chapter id="libataThanks">
     <title>Thanks</title>
  <para>
  The bulk of the ATA knowledge comes thanks to long conversations with
  Andre Hedrick (www.linux-ide.org), and long hours pondering the ATA
  and SCSI specifications.
  </para>
  <para>
  Thanks to Alan Cox for pointing out similarities 
  between SATA and SCSI, and in general for motivation to hack on
  libata.
  </para>
  <para>
  libata's device detection
  method, ata_pio_devchk, and in general all the early probing was
  based on extensive study of Hale Landis's probe/reset code in his
  ATADRVR driver (www.ata-atapi.com).
  </para>
  </chapter>

</book>
