1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>How commands are issued</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="libATA Developer's Guide"><link rel="up" href="libataEH.html" title="Chapter&#160;3.&#160;Error handling"><link rel="prev" href="libataEH.html" title="Chapter&#160;3.&#160;Error handling"><link rel="next" href="ch03s03.html" title="How commands are processed"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">How commands are issued</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="libataEH.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Error handling</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch03s03.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp1120614212"></a>How commands are issued</h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">Internal commands</span></dt><dd><p>
2	First, qc is allocated and initialized using
3	ata_qc_new_init().  Although ata_qc_new_init() doesn't
4	implement any wait or retry mechanism when qc is not
5	available, internal commands are currently issued only during
6	initialization and error recovery, so no other command is
7	active and allocation is guaranteed to succeed.
8	</p><p>
9	Once allocated qc's taskfile is initialized for the command to
10	be executed.  qc currently has two mechanisms to notify
11	completion.  One is via qc-&gt;complete_fn() callback and the
12	other is completion qc-&gt;waiting.  qc-&gt;complete_fn() callback
13	is the asynchronous path used by normal SCSI translated
14	commands and qc-&gt;waiting is the synchronous (issuer sleeps in
15	process context) path used by internal commands.
16	</p><p>
17	Once initialization is complete, host_set lock is acquired
18	and the qc is issued.
19	</p></dd><dt><span class="term">SCSI commands</span></dt><dd><p>
20	All libata drivers use ata_scsi_queuecmd() as
21	hostt-&gt;queuecommand callback.  scmds can either be simulated
22	or translated.  No qc is involved in processing a simulated
23	scmd.  The result is computed right away and the scmd is
24	completed.
25	</p><p>
26	For a translated scmd, ata_qc_new_init() is invoked to
27	allocate a qc and the scmd is translated into the qc.  SCSI
28	midlayer's completion notification function pointer is stored
29	into qc-&gt;scsidone.
30	</p><p>
31	qc-&gt;complete_fn() callback is used for completion
32	notification.  ATA commands use ata_scsi_qc_complete() while
33	ATAPI commands use atapi_qc_complete().  Both functions end up
34	calling qc-&gt;scsidone to notify upper layer when the qc is
35	finished.  After translation is completed, the qc is issued
36	with ata_qc_issue().
37	</p><p>
38	Note that SCSI midlayer invokes hostt-&gt;queuecommand while
39	holding host_set lock, so all above occur while holding
40	host_set lock.
41	</p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="libataEH.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="libataEH.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch03s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;3.&#160;Error handling&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;How commands are processed</td></tr></table></div></body></html>
42