aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/ata.h34
-rw-r--r--include/linux/libata.h466
-rw-r--r--include/linux/pci_ids.h9
-rw-r--r--include/scsi/scsi_cmnd.h1
-rw-r--r--include/scsi/scsi_host.h1
5 files changed, 384 insertions, 127 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 312a2c0c64e6..c494e1c0531e 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -97,6 +97,9 @@ enum {
97 ATA_DRQ = (1 << 3), /* data request i/o */ 97 ATA_DRQ = (1 << 3), /* data request i/o */
98 ATA_ERR = (1 << 0), /* have an error */ 98 ATA_ERR = (1 << 0), /* have an error */
99 ATA_SRST = (1 << 2), /* software reset */ 99 ATA_SRST = (1 << 2), /* software reset */
100 ATA_ICRC = (1 << 7), /* interface CRC error */
101 ATA_UNC = (1 << 6), /* uncorrectable media error */
102 ATA_IDNF = (1 << 4), /* ID not found */
100 ATA_ABORTED = (1 << 2), /* command aborted */ 103 ATA_ABORTED = (1 << 2), /* command aborted */
101 104
102 /* ATA command block registers */ 105 /* ATA command block registers */
@@ -130,6 +133,8 @@ enum {
130 ATA_CMD_WRITE = 0xCA, 133 ATA_CMD_WRITE = 0xCA,
131 ATA_CMD_WRITE_EXT = 0x35, 134 ATA_CMD_WRITE_EXT = 0x35,
132 ATA_CMD_WRITE_FUA_EXT = 0x3D, 135 ATA_CMD_WRITE_FUA_EXT = 0x3D,
136 ATA_CMD_FPDMA_READ = 0x60,
137 ATA_CMD_FPDMA_WRITE = 0x61,
133 ATA_CMD_PIO_READ = 0x20, 138 ATA_CMD_PIO_READ = 0x20,
134 ATA_CMD_PIO_READ_EXT = 0x24, 139 ATA_CMD_PIO_READ_EXT = 0x24,
135 ATA_CMD_PIO_WRITE = 0x30, 140 ATA_CMD_PIO_WRITE = 0x30,
@@ -148,6 +153,10 @@ enum {
148 ATA_CMD_INIT_DEV_PARAMS = 0x91, 153 ATA_CMD_INIT_DEV_PARAMS = 0x91,
149 ATA_CMD_READ_NATIVE_MAX = 0xF8, 154 ATA_CMD_READ_NATIVE_MAX = 0xF8,
150 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, 155 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
156 ATA_CMD_READ_LOG_EXT = 0x2f,
157
158 /* READ_LOG_EXT pages */
159 ATA_LOG_SATA_NCQ = 0x10,
151 160
152 /* SETFEATURES stuff */ 161 /* SETFEATURES stuff */
153 SETFEATURES_XFER = 0x03, 162 SETFEATURES_XFER = 0x03,
@@ -192,6 +201,16 @@ enum {
192 SCR_ACTIVE = 3, 201 SCR_ACTIVE = 3,
193 SCR_NOTIFICATION = 4, 202 SCR_NOTIFICATION = 4,
194 203
204 /* SError bits */
205 SERR_DATA_RECOVERED = (1 << 0), /* recovered data error */
206 SERR_COMM_RECOVERED = (1 << 1), /* recovered comm failure */
207 SERR_DATA = (1 << 8), /* unrecovered data error */
208 SERR_PERSISTENT = (1 << 9), /* persistent data/comm error */
209 SERR_PROTOCOL = (1 << 10), /* protocol violation */
210 SERR_INTERNAL = (1 << 11), /* host internal error */
211 SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */
212 SERR_DEV_XCHG = (1 << 26), /* device exchanged */
213
195 /* struct ata_taskfile flags */ 214 /* struct ata_taskfile flags */
196 ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ 215 ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */
197 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ 216 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
@@ -199,6 +218,7 @@ enum {
199 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ 218 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */
200 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ 219 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
201 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ 220 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
221 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
202}; 222};
203 223
204enum ata_tf_protocols { 224enum ata_tf_protocols {
@@ -207,6 +227,7 @@ enum ata_tf_protocols {
207 ATA_PROT_NODATA, /* no data */ 227 ATA_PROT_NODATA, /* no data */
208 ATA_PROT_PIO, /* PIO single sector */ 228 ATA_PROT_PIO, /* PIO single sector */
209 ATA_PROT_DMA, /* DMA */ 229 ATA_PROT_DMA, /* DMA */
230 ATA_PROT_NCQ, /* NCQ */
210 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ 231 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
211 ATA_PROT_ATAPI_NODATA, /* packet command, no data */ 232 ATA_PROT_ATAPI_NODATA, /* packet command, no data */
212 ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */ 233 ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */
@@ -262,6 +283,8 @@ struct ata_taskfile {
262#define ata_id_has_pm(id) ((id)[82] & (1 << 3)) 283#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
263#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 284#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
264#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 285#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
286#define ata_id_has_ncq(id) ((id)[76] & (1 << 8))
287#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1)
265#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 288#define ata_id_removeable(id) ((id)[0] & (1 << 7))
266#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0)) 289#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0))
267#define ata_id_u32(id,n) \ 290#define ata_id_u32(id,n) \
@@ -272,6 +295,8 @@ struct ata_taskfile {
272 ((u64) (id)[(n) + 1] << 16) | \ 295 ((u64) (id)[(n) + 1] << 16) | \
273 ((u64) (id)[(n) + 0]) ) 296 ((u64) (id)[(n) + 0]) )
274 297
298#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20)
299
275static inline unsigned int ata_id_major_version(const u16 *id) 300static inline unsigned int ata_id_major_version(const u16 *id)
276{ 301{
277 unsigned int mver; 302 unsigned int mver;
@@ -311,6 +336,15 @@ static inline int is_atapi_taskfile(const struct ata_taskfile *tf)
311 (tf->protocol == ATA_PROT_ATAPI_DMA); 336 (tf->protocol == ATA_PROT_ATAPI_DMA);
312} 337}
313 338
339static inline int is_multi_taskfile(struct ata_taskfile *tf)
340{
341 return (tf->command == ATA_CMD_READ_MULTI) ||
342 (tf->command == ATA_CMD_WRITE_MULTI) ||
343 (tf->command == ATA_CMD_READ_MULTI_EXT) ||
344 (tf->command == ATA_CMD_WRITE_MULTI_EXT) ||
345 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
346}
347
314static inline int ata_ok(u8 status) 348static inline int ata_ok(u8 status)
315{ 349{
316 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) 350 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
diff --git a/include/linux/libata.h b/include/linux/libata.h
index b80d2e7fa6d2..39e6b77de1a9 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -33,6 +33,7 @@
33#include <asm/io.h> 33#include <asm/io.h>
34#include <linux/ata.h> 34#include <linux/ata.h>
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36#include <scsi/scsi_host.h>
36 37
37/* 38/*
38 * compile-time options: to be removed as soon as all the drivers are 39 * compile-time options: to be removed as soon as all the drivers are
@@ -44,7 +45,6 @@
44#undef ATA_NDEBUG /* define to disable quick runtime checks */ 45#undef ATA_NDEBUG /* define to disable quick runtime checks */
45#undef ATA_ENABLE_PATA /* define to enable PATA support in some 46#undef ATA_ENABLE_PATA /* define to enable PATA support in some
46 * low-level drivers */ 47 * low-level drivers */
47#undef ATAPI_ENABLE_DMADIR /* enables ATAPI DMADIR bridge support */
48 48
49 49
50/* note: prints function name for you */ 50/* note: prints function name for you */
@@ -108,8 +108,11 @@ enum {
108 LIBATA_MAX_PRD = ATA_MAX_PRD / 2, 108 LIBATA_MAX_PRD = ATA_MAX_PRD / 2,
109 ATA_MAX_PORTS = 8, 109 ATA_MAX_PORTS = 8,
110 ATA_DEF_QUEUE = 1, 110 ATA_DEF_QUEUE = 1,
111 ATA_MAX_QUEUE = 1, 111 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
112 ATA_MAX_QUEUE = 32,
113 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
112 ATA_MAX_SECTORS = 200, /* FIXME */ 114 ATA_MAX_SECTORS = 200, /* FIXME */
115 ATA_MAX_SECTORS_LBA48 = 65535,
113 ATA_MAX_BUS = 2, 116 ATA_MAX_BUS = 2,
114 ATA_DEF_BUSY_WAIT = 10000, 117 ATA_DEF_BUSY_WAIT = 10000,
115 ATA_SHORT_PAUSE = (HZ >> 6) + 1, 118 ATA_SHORT_PAUSE = (HZ >> 6) + 1,
@@ -120,9 +123,17 @@ enum {
120 ATA_SHT_USE_CLUSTERING = 1, 123 ATA_SHT_USE_CLUSTERING = 1,
121 124
122 /* struct ata_device stuff */ 125 /* struct ata_device stuff */
123 ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ 126 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */
124 ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ 127 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */
125 ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */ 128 ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */
129 ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */
130 ATA_DFLAG_CFG_MASK = (1 << 8) - 1,
131
132 ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */
133 ATA_DFLAG_INIT_MASK = (1 << 16) - 1,
134
135 ATA_DFLAG_DETACH = (1 << 16),
136 ATA_DFLAG_DETACHED = (1 << 17),
126 137
127 ATA_DEV_UNKNOWN = 0, /* unknown device */ 138 ATA_DEV_UNKNOWN = 0, /* unknown device */
128 ATA_DEV_ATA = 1, /* ATA device */ 139 ATA_DEV_ATA = 1, /* ATA device */
@@ -132,43 +143,57 @@ enum {
132 ATA_DEV_NONE = 5, /* no device */ 143 ATA_DEV_NONE = 5, /* no device */
133 144
134 /* struct ata_port flags */ 145 /* struct ata_port flags */
135 ATA_FLAG_SLAVE_POSS = (1 << 1), /* host supports slave dev */ 146 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
136 /* (doesn't imply presence) */ 147 /* (doesn't imply presence) */
137 ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ 148 ATA_FLAG_SATA = (1 << 1),
138 ATA_FLAG_SATA = (1 << 3), 149 ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */
139 ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ 150 ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */
140 ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ 151 ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
141 ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ 152 ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */
142 ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ 153 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
143 ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ 154 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
144 ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once 155 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */
145 * proper HSM is in place. */ 156 ATA_FLAG_PIO_POLLING = (1 << 9), /* use polling PIO if LLD
146 ATA_FLAG_DEBUGMSG = (1 << 10), 157 * doesn't handle PIO interrupts */
147 ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */ 158 ATA_FLAG_NCQ = (1 << 10), /* host supports NCQ */
148 159 ATA_FLAG_HRST_TO_RESUME = (1 << 11), /* hardreset to resume phy */
149 ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */ 160 ATA_FLAG_SKIP_D2H_BSY = (1 << 12), /* can't wait for the first D2H
150 161 * Register FIS clearing BSY */
151 ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ 162
152 ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ 163 ATA_FLAG_DEBUGMSG = (1 << 13),
153 164 ATA_FLAG_FLUSH_PORT_TASK = (1 << 14), /* flush port task */
154 ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */ 165
155 ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ 166 ATA_FLAG_EH_PENDING = (1 << 15), /* EH pending */
156 167 ATA_FLAG_EH_IN_PROGRESS = (1 << 16), /* EH in progress */
157 ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ 168 ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */
158 ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ 169 ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */
159 ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ 170 ATA_FLAG_LOADING = (1 << 19), /* boot/loading probe */
171 ATA_FLAG_UNLOADING = (1 << 20), /* module is unloading */
172 ATA_FLAG_SCSI_HOTPLUG = (1 << 21), /* SCSI hotplug scheduled */
173
174 ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */
175 ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */
176
177 /* bits 24:31 of ap->flags are reserved for LLDD specific flags */
178
179 /* struct ata_queued_cmd flags */
180 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
181 ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */
182 ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */
160 ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, 183 ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
161 ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ 184 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */
185 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */
186
187 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */
188 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */
189 ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */
162 190
163 /* host set flags */ 191 /* host set flags */
164 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ 192 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */
165 193
166 /* various lengths of time */ 194 /* various lengths of time */
167 ATA_TMOUT_PIO = 30 * HZ,
168 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 195 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */
169 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ 196 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */
170 ATA_TMOUT_CDB = 30 * HZ,
171 ATA_TMOUT_CDB_QUICK = 5 * HZ,
172 ATA_TMOUT_INTERNAL = 30 * HZ, 197 ATA_TMOUT_INTERNAL = 30 * HZ,
173 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, 198 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,
174 199
@@ -207,21 +232,55 @@ enum {
207 /* size of buffer to pad xfers ending on unaligned boundaries */ 232 /* size of buffer to pad xfers ending on unaligned boundaries */
208 ATA_DMA_PAD_SZ = 4, 233 ATA_DMA_PAD_SZ = 4,
209 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, 234 ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
210 235
211 /* Masks for port functions */ 236 /* masks for port functions */
212 ATA_PORT_PRIMARY = (1 << 0), 237 ATA_PORT_PRIMARY = (1 << 0),
213 ATA_PORT_SECONDARY = (1 << 1), 238 ATA_PORT_SECONDARY = (1 << 1),
239
240 /* ering size */
241 ATA_ERING_SIZE = 32,
242
243 /* desc_len for ata_eh_info and context */
244 ATA_EH_DESC_LEN = 80,
245
246 /* reset / recovery action types */
247 ATA_EH_REVALIDATE = (1 << 0),
248 ATA_EH_SOFTRESET = (1 << 1),
249 ATA_EH_HARDRESET = (1 << 2),
250
251 ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET,
252
253 /* ata_eh_info->flags */
254 ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */
255
256 ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */
257
258 /* max repeat if error condition is still set after ->error_handler */
259 ATA_EH_MAX_REPEAT = 5,
260
261 /* how hard are we gonna try to probe/recover devices */
262 ATA_PROBE_MAX_TRIES = 3,
263 ATA_EH_RESET_TRIES = 3,
264 ATA_EH_DEV_TRIES = 3,
265
266 /* Drive spinup time (time from power-on to the first D2H FIS)
267 * in msecs - 8s currently. Failing to get ready in this time
268 * isn't critical. It will result in reset failure for
269 * controllers which can't wait for the first D2H FIS. libata
270 * will retry, so it just has to be long enough to spin up
271 * most devices.
272 */
273 ATA_SPINUP_WAIT = 8000,
214}; 274};
215 275
216enum hsm_task_states { 276enum hsm_task_states {
217 HSM_ST_UNKNOWN, 277 HSM_ST_UNKNOWN, /* state unknown */
218 HSM_ST_IDLE, 278 HSM_ST_IDLE, /* no command on going */
219 HSM_ST_POLL, 279 HSM_ST, /* (waiting the device to) transfer data */
220 HSM_ST_TMOUT, 280 HSM_ST_LAST, /* (waiting the device to) complete command */
221 HSM_ST, 281 HSM_ST_ERR, /* error */
222 HSM_ST_LAST, 282 HSM_ST_FIRST, /* (waiting the device to)
223 HSM_ST_LAST_POLL, 283 write CDB or first data block */
224 HSM_ST_ERR,
225}; 284};
226 285
227enum ata_completion_errors { 286enum ata_completion_errors {
@@ -244,9 +303,9 @@ struct ata_queued_cmd;
244 303
245/* typedefs */ 304/* typedefs */
246typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); 305typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
247typedef void (*ata_probeinit_fn_t)(struct ata_port *); 306typedef int (*ata_prereset_fn_t)(struct ata_port *ap);
248typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); 307typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes);
249typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); 308typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes);
250 309
251struct ata_ioports { 310struct ata_ioports {
252 unsigned long cmd_addr; 311 unsigned long cmd_addr;
@@ -336,7 +395,7 @@ struct ata_queued_cmd {
336 struct scatterlist *__sg; 395 struct scatterlist *__sg;
337 396
338 unsigned int err_mask; 397 unsigned int err_mask;
339 398 struct ata_taskfile result_tf;
340 ata_qc_cb_t complete_fn; 399 ata_qc_cb_t complete_fn;
341 400
342 void *private_data; 401 void *private_data;
@@ -348,12 +407,26 @@ struct ata_host_stats {
348 unsigned long rw_reqbuf; 407 unsigned long rw_reqbuf;
349}; 408};
350 409
410struct ata_ering_entry {
411 int is_io;
412 unsigned int err_mask;
413 u64 timestamp;
414};
415
416struct ata_ering {
417 int cursor;
418 struct ata_ering_entry ring[ATA_ERING_SIZE];
419};
420
351struct ata_device { 421struct ata_device {
352 u64 n_sectors; /* size of device, if ATA */ 422 struct ata_port *ap;
423 unsigned int devno; /* 0 or 1 */
353 unsigned long flags; /* ATA_DFLAG_xxx */ 424 unsigned long flags; /* ATA_DFLAG_xxx */
425 struct scsi_device *sdev; /* attached SCSI device */
426 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
427 u64 n_sectors; /* size of device, if ATA */
354 unsigned int class; /* ATA_DEV_xxx */ 428 unsigned int class; /* ATA_DEV_xxx */
355 unsigned int devno; /* 0 or 1 */ 429 u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
356 u16 *id; /* IDENTIFY xxx DEVICE data */
357 u8 pio_mode; 430 u8 pio_mode;
358 u8 dma_mode; 431 u8 dma_mode;
359 u8 xfer_mode; 432 u8 xfer_mode;
@@ -373,6 +446,35 @@ struct ata_device {
373 u16 cylinders; /* Number of cylinders */ 446 u16 cylinders; /* Number of cylinders */
374 u16 heads; /* Number of heads */ 447 u16 heads; /* Number of heads */
375 u16 sectors; /* Number of sectors per track */ 448 u16 sectors; /* Number of sectors per track */
449
450 /* error history */
451 struct ata_ering ering;
452};
453
454/* Offset into struct ata_device. Fields above it are maintained
455 * acress device init. Fields below are zeroed.
456 */
457#define ATA_DEVICE_CLEAR_OFFSET offsetof(struct ata_device, n_sectors)
458
459struct ata_eh_info {
460 struct ata_device *dev; /* offending device */
461 u32 serror; /* SError from LLDD */
462 unsigned int err_mask; /* port-wide err_mask */
463 unsigned int action; /* ATA_EH_* action mask */
464 unsigned int flags; /* ATA_EHI_* flags */
465
466 unsigned long hotplug_timestamp;
467 unsigned int probe_mask;
468
469 char desc[ATA_EH_DESC_LEN];
470 int desc_len;
471};
472
473struct ata_eh_context {
474 struct ata_eh_info i;
475 int tries[ATA_MAX_DEVICES];
476 unsigned int classes[ATA_MAX_DEVICES];
477 unsigned int did_probe_mask;
376}; 478};
377 479
378struct ata_port { 480struct ata_port {
@@ -397,26 +499,39 @@ struct ata_port {
397 unsigned int mwdma_mask; 499 unsigned int mwdma_mask;
398 unsigned int udma_mask; 500 unsigned int udma_mask;
399 unsigned int cbl; /* cable type; ATA_CBL_xxx */ 501 unsigned int cbl; /* cable type; ATA_CBL_xxx */
502 unsigned int hw_sata_spd_limit;
503 unsigned int sata_spd_limit; /* SATA PHY speed limit */
504
505 /* record runtime error info, protected by host_set lock */
506 struct ata_eh_info eh_info;
507 /* EH context owned by EH */
508 struct ata_eh_context eh_context;
400 509
401 struct ata_device device[ATA_MAX_DEVICES]; 510 struct ata_device device[ATA_MAX_DEVICES];
402 511
403 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; 512 struct ata_queued_cmd qcmd[ATA_MAX_QUEUE];
404 unsigned long qactive; 513 unsigned long qc_allocated;
514 unsigned int qc_active;
515
405 unsigned int active_tag; 516 unsigned int active_tag;
517 u32 sactive;
406 518
407 struct ata_host_stats stats; 519 struct ata_host_stats stats;
408 struct ata_host_set *host_set; 520 struct ata_host_set *host_set;
409 struct device *dev; 521 struct device *dev;
410 522
411 struct work_struct port_task; 523 struct work_struct port_task;
524 struct work_struct hotplug_task;
412 525
413 unsigned int hsm_task_state; 526 unsigned int hsm_task_state;
414 unsigned long pio_task_timeout;
415 527
416 u32 msg_enable; 528 u32 msg_enable;
417 struct list_head eh_done_q; 529 struct list_head eh_done_q;
530 wait_queue_head_t eh_wait_q;
418 531
419 void *private_data; 532 void *private_data;
533
534 u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */
420}; 535};
421 536
422struct ata_port_operations { 537struct ata_port_operations {
@@ -438,7 +553,6 @@ struct ata_port_operations {
438 553
439 void (*phy_reset) (struct ata_port *ap); /* obsolete */ 554 void (*phy_reset) (struct ata_port *ap); /* obsolete */
440 void (*set_mode) (struct ata_port *ap); 555 void (*set_mode) (struct ata_port *ap);
441 int (*probe_reset) (struct ata_port *ap, unsigned int *classes);
442 556
443 void (*post_set_mode) (struct ata_port *ap); 557 void (*post_set_mode) (struct ata_port *ap);
444 558
@@ -447,10 +561,20 @@ struct ata_port_operations {
447 void (*bmdma_setup) (struct ata_queued_cmd *qc); 561 void (*bmdma_setup) (struct ata_queued_cmd *qc);
448 void (*bmdma_start) (struct ata_queued_cmd *qc); 562 void (*bmdma_start) (struct ata_queued_cmd *qc);
449 563
564 void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int);
565
450 void (*qc_prep) (struct ata_queued_cmd *qc); 566 void (*qc_prep) (struct ata_queued_cmd *qc);
451 unsigned int (*qc_issue) (struct ata_queued_cmd *qc); 567 unsigned int (*qc_issue) (struct ata_queued_cmd *qc);
452 568
453 void (*eng_timeout) (struct ata_port *ap); 569 /* Error handlers. ->error_handler overrides ->eng_timeout and
570 * indicates that new-style EH is in place.
571 */
572 void (*eng_timeout) (struct ata_port *ap); /* obsolete */
573
574 void (*freeze) (struct ata_port *ap);
575 void (*thaw) (struct ata_port *ap);
576 void (*error_handler) (struct ata_port *ap);
577 void (*post_internal_cmd) (struct ata_queued_cmd *qc);
454 578
455 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); 579 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *);
456 void (*irq_clear) (struct ata_port *); 580 void (*irq_clear) (struct ata_port *);
@@ -492,22 +616,22 @@ struct ata_timing {
492 616
493#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) 617#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin)
494 618
619extern const unsigned long sata_deb_timing_boot[];
620extern const unsigned long sata_deb_timing_eh[];
621extern const unsigned long sata_deb_timing_before_fsrst[];
622
495extern void ata_port_probe(struct ata_port *); 623extern void ata_port_probe(struct ata_port *);
496extern void __sata_phy_reset(struct ata_port *ap); 624extern void __sata_phy_reset(struct ata_port *ap);
497extern void sata_phy_reset(struct ata_port *ap); 625extern void sata_phy_reset(struct ata_port *ap);
498extern void ata_bus_reset(struct ata_port *ap); 626extern void ata_bus_reset(struct ata_port *ap);
499extern int ata_drive_probe_reset(struct ata_port *ap, 627extern int sata_set_spd(struct ata_port *ap);
500 ata_probeinit_fn_t probeinit, 628extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param);
501 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 629extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param);
502 ata_postreset_fn_t postreset, unsigned int *classes); 630extern int ata_std_prereset(struct ata_port *ap);
503extern void ata_std_probeinit(struct ata_port *ap); 631extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes);
504extern int ata_std_softreset(struct ata_port *ap, int verbose, 632extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class);
505 unsigned int *classes);
506extern int sata_std_hardreset(struct ata_port *ap, int verbose,
507 unsigned int *class);
508extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); 633extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
509extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, 634extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
510 int post_reset);
511extern void ata_port_disable(struct ata_port *); 635extern void ata_port_disable(struct ata_port *);
512extern void ata_std_ports(struct ata_ioports *ioaddr); 636extern void ata_std_ports(struct ata_ioports *ioaddr);
513#ifdef CONFIG_PCI 637#ifdef CONFIG_PCI
@@ -519,24 +643,32 @@ extern int ata_pci_device_resume(struct pci_dev *pdev);
519extern int ata_pci_clear_simplex(struct pci_dev *pdev); 643extern int ata_pci_clear_simplex(struct pci_dev *pdev);
520#endif /* CONFIG_PCI */ 644#endif /* CONFIG_PCI */
521extern int ata_device_add(const struct ata_probe_ent *ent); 645extern int ata_device_add(const struct ata_probe_ent *ent);
646extern void ata_port_detach(struct ata_port *ap);
522extern void ata_host_set_remove(struct ata_host_set *host_set); 647extern void ata_host_set_remove(struct ata_host_set *host_set);
523extern int ata_scsi_detect(struct scsi_host_template *sht); 648extern int ata_scsi_detect(struct scsi_host_template *sht);
524extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); 649extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
525extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); 650extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *));
526extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
527extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
528extern int ata_scsi_release(struct Scsi_Host *host); 651extern int ata_scsi_release(struct Scsi_Host *host);
529extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); 652extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
653extern int sata_scr_valid(struct ata_port *ap);
654extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val);
655extern int sata_scr_write(struct ata_port *ap, int reg, u32 val);
656extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val);
657extern int ata_port_online(struct ata_port *ap);
658extern int ata_port_offline(struct ata_port *ap);
530extern int ata_scsi_device_resume(struct scsi_device *); 659extern int ata_scsi_device_resume(struct scsi_device *);
531extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); 660extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state);
532extern int ata_device_resume(struct ata_port *, struct ata_device *); 661extern int ata_device_resume(struct ata_device *);
533extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state); 662extern int ata_device_suspend(struct ata_device *, pm_message_t state);
534extern int ata_ratelimit(void); 663extern int ata_ratelimit(void);
535extern unsigned int ata_busy_sleep(struct ata_port *ap, 664extern unsigned int ata_busy_sleep(struct ata_port *ap,
536 unsigned long timeout_pat, 665 unsigned long timeout_pat,
537 unsigned long timeout); 666 unsigned long timeout);
538extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), 667extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *),
539 void *data, unsigned long delay); 668 void *data, unsigned long delay);
669extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
670 unsigned long interval_msec,
671 unsigned long timeout_msec);
540 672
541/* 673/*
542 * Default driver ops implementations 674 * Default driver ops implementations
@@ -550,11 +682,16 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device);
550extern u8 ata_check_status(struct ata_port *ap); 682extern u8 ata_check_status(struct ata_port *ap);
551extern u8 ata_altstatus(struct ata_port *ap); 683extern u8 ata_altstatus(struct ata_port *ap);
552extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); 684extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf);
553extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes);
554extern int ata_port_start (struct ata_port *ap); 685extern int ata_port_start (struct ata_port *ap);
555extern void ata_port_stop (struct ata_port *ap); 686extern void ata_port_stop (struct ata_port *ap);
556extern void ata_host_stop (struct ata_host_set *host_set); 687extern void ata_host_stop (struct ata_host_set *host_set);
557extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); 688extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
689extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf,
690 unsigned int buflen, int write_data);
691extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf,
692 unsigned int buflen, int write_data);
693extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf,
694 unsigned int buflen, int write_data);
558extern void ata_qc_prep(struct ata_queued_cmd *qc); 695extern void ata_qc_prep(struct ata_queued_cmd *qc);
559extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 696extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
560extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 697extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
@@ -572,17 +709,29 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc);
572extern void ata_bmdma_stop(struct ata_queued_cmd *qc); 709extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
573extern u8 ata_bmdma_status(struct ata_port *ap); 710extern u8 ata_bmdma_status(struct ata_port *ap);
574extern void ata_bmdma_irq_clear(struct ata_port *ap); 711extern void ata_bmdma_irq_clear(struct ata_port *ap);
575extern void __ata_qc_complete(struct ata_queued_cmd *qc); 712extern void ata_bmdma_freeze(struct ata_port *ap);
576extern void ata_eng_timeout(struct ata_port *ap); 713extern void ata_bmdma_thaw(struct ata_port *ap);
577extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, 714extern void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
578 struct scsi_cmnd *cmd, 715 ata_reset_fn_t softreset,
716 ata_reset_fn_t hardreset,
717 ata_postreset_fn_t postreset);
718extern void ata_bmdma_error_handler(struct ata_port *ap);
719extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc);
720extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
721 u8 status, int in_wq);
722extern void ata_qc_complete(struct ata_queued_cmd *qc);
723extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active,
724 void (*finish_qc)(struct ata_queued_cmd *));
725extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
579 void (*done)(struct scsi_cmnd *)); 726 void (*done)(struct scsi_cmnd *));
580extern int ata_std_bios_param(struct scsi_device *sdev, 727extern int ata_std_bios_param(struct scsi_device *sdev,
581 struct block_device *bdev, 728 struct block_device *bdev,
582 sector_t capacity, int geom[]); 729 sector_t capacity, int geom[]);
583extern int ata_scsi_slave_config(struct scsi_device *sdev); 730extern int ata_scsi_slave_config(struct scsi_device *sdev);
584extern struct ata_device *ata_dev_pair(struct ata_port *ap, 731extern void ata_scsi_slave_destroy(struct scsi_device *sdev);
585 struct ata_device *adev); 732extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
733 int queue_depth);
734extern struct ata_device *ata_dev_pair(struct ata_device *adev);
586 735
587/* 736/*
588 * Timing helpers 737 * Timing helpers
@@ -628,7 +777,64 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit
628extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); 777extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
629#endif /* CONFIG_PCI */ 778#endif /* CONFIG_PCI */
630 779
780/*
781 * EH
782 */
783extern void ata_eng_timeout(struct ata_port *ap);
784
785extern void ata_port_schedule_eh(struct ata_port *ap);
786extern int ata_port_abort(struct ata_port *ap);
787extern int ata_port_freeze(struct ata_port *ap);
788
789extern void ata_eh_freeze_port(struct ata_port *ap);
790extern void ata_eh_thaw_port(struct ata_port *ap);
791
792extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
793extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
794
795extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
796 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
797 ata_postreset_fn_t postreset);
798
799/*
800 * printk helpers
801 */
802#define ata_port_printk(ap, lv, fmt, args...) \
803 printk(lv"ata%u: "fmt, (ap)->id , ##args)
804
805#define ata_dev_printk(dev, lv, fmt, args...) \
806 printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args)
807
808/*
809 * ata_eh_info helpers
810 */
811#define ata_ehi_push_desc(ehi, fmt, args...) do { \
812 (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \
813 ATA_EH_DESC_LEN - (ehi)->desc_len, \
814 fmt , ##args); \
815} while (0)
816
817#define ata_ehi_clear_desc(ehi) do { \
818 (ehi)->desc[0] = '\0'; \
819 (ehi)->desc_len = 0; \
820} while (0)
821
822static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi)
823{
824 if (ehi->flags & ATA_EHI_HOTPLUGGED)
825 return;
826
827 ehi->flags |= ATA_EHI_HOTPLUGGED;
828 ehi->hotplug_timestamp = jiffies;
631 829
830 ehi->err_mask |= AC_ERR_ATA_BUS;
831 ehi->action |= ATA_EH_SOFTRESET;
832 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
833}
834
835/*
836 * qc helpers
837 */
632static inline int 838static inline int
633ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) 839ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc)
634{ 840{
@@ -671,14 +877,39 @@ static inline unsigned int ata_tag_valid(unsigned int tag)
671 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 877 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
672} 878}
673 879
674static inline unsigned int ata_class_present(unsigned int class) 880static inline unsigned int ata_tag_internal(unsigned int tag)
881{
882 return tag == ATA_MAX_QUEUE - 1;
883}
884
885static inline unsigned int ata_class_enabled(unsigned int class)
675{ 886{
676 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; 887 return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI;
677} 888}
678 889
679static inline unsigned int ata_dev_present(const struct ata_device *dev) 890static inline unsigned int ata_class_disabled(unsigned int class)
680{ 891{
681 return ata_class_present(dev->class); 892 return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP;
893}
894
895static inline unsigned int ata_class_absent(unsigned int class)
896{
897 return !ata_class_enabled(class) && !ata_class_disabled(class);
898}
899
900static inline unsigned int ata_dev_enabled(const struct ata_device *dev)
901{
902 return ata_class_enabled(dev->class);
903}
904
905static inline unsigned int ata_dev_disabled(const struct ata_device *dev)
906{
907 return ata_class_disabled(dev->class);
908}
909
910static inline unsigned int ata_dev_absent(const struct ata_device *dev)
911{
912 return ata_class_absent(dev->class);
682} 913}
683 914
684static inline u8 ata_chk_status(struct ata_port *ap) 915static inline u8 ata_chk_status(struct ata_port *ap)
@@ -759,20 +990,35 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
759 qc->tf.ctl |= ATA_NIEN; 990 qc->tf.ctl |= ATA_NIEN;
760} 991}
761 992
762static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, 993static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap,
763 unsigned int tag) 994 unsigned int tag)
764{ 995{
765 if (likely(ata_tag_valid(tag))) 996 if (likely(ata_tag_valid(tag)))
766 return &ap->qcmd[tag]; 997 return &ap->qcmd[tag];
767 return NULL; 998 return NULL;
768} 999}
769 1000
770static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device) 1001static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap,
1002 unsigned int tag)
1003{
1004 struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag);
1005
1006 if (unlikely(!qc) || !ap->ops->error_handler)
1007 return qc;
1008
1009 if ((qc->flags & (ATA_QCFLAG_ACTIVE |
1010 ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE)
1011 return qc;
1012
1013 return NULL;
1014}
1015
1016static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
771{ 1017{
772 memset(tf, 0, sizeof(*tf)); 1018 memset(tf, 0, sizeof(*tf));
773 1019
774 tf->ctl = ap->ctl; 1020 tf->ctl = dev->ap->ctl;
775 if (device == 0) 1021 if (dev->devno == 0)
776 tf->device = ATA_DEVICE_OBS; 1022 tf->device = ATA_DEVICE_OBS;
777 else 1023 else
778 tf->device = ATA_DEVICE_OBS | ATA_DEV1; 1024 tf->device = ATA_DEVICE_OBS | ATA_DEV1;
@@ -787,26 +1033,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
787 qc->nbytes = qc->curbytes = 0; 1033 qc->nbytes = qc->curbytes = 0;
788 qc->err_mask = 0; 1034 qc->err_mask = 0;
789 1035
790 ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); 1036 ata_tf_init(qc->dev, &qc->tf);
791}
792
793/**
794 * ata_qc_complete - Complete an active ATA command
795 * @qc: Command to complete
796 * @err_mask: ATA Status register contents
797 *
798 * Indicate to the mid and upper layers that an ATA
799 * command has completed, with either an ok or not-ok status.
800 *
801 * LOCKING:
802 * spin_lock_irqsave(host_set lock)
803 */
804static inline void ata_qc_complete(struct ata_queued_cmd *qc)
805{
806 if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED))
807 return;
808 1037
809 __ata_qc_complete(qc); 1038 /* init result_tf such that it indicates normal completion */
1039 qc->result_tf.command = ATA_DRDY;
1040 qc->result_tf.feature = 0;
810} 1041}
811 1042
812/** 1043/**
@@ -885,28 +1116,6 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq)
885 return status; 1116 return status;
886} 1117}
887 1118
888static inline u32 scr_read(struct ata_port *ap, unsigned int reg)
889{
890 return ap->ops->scr_read(ap, reg);
891}
892
893static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val)
894{
895 ap->ops->scr_write(ap, reg, val);
896}
897
898static inline void scr_write_flush(struct ata_port *ap, unsigned int reg,
899 u32 val)
900{
901 ap->ops->scr_write(ap, reg, val);
902 (void) ap->ops->scr_read(ap, reg);
903}
904
905static inline unsigned int sata_dev_present(struct ata_port *ap)
906{
907 return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0;
908}
909
910static inline int ata_try_flush_cache(const struct ata_device *dev) 1119static inline int ata_try_flush_cache(const struct ata_device *dev)
911{ 1120{
912 return ata_id_wcache_enabled(dev->id) || 1121 return ata_id_wcache_enabled(dev->id) ||
@@ -916,7 +1125,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
916 1125
917static inline unsigned int ac_err_mask(u8 status) 1126static inline unsigned int ac_err_mask(u8 status)
918{ 1127{
919 if (status & ATA_BUSY) 1128 if (status & (ATA_BUSY | ATA_DRQ))
920 return AC_ERR_HSM; 1129 return AC_ERR_HSM;
921 if (status & (ATA_ERR | ATA_DF)) 1130 if (status & (ATA_ERR | ATA_DF))
922 return AC_ERR_DEV; 1131 return AC_ERR_DEV;
@@ -944,4 +1153,9 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
944 dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); 1153 dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma);
945} 1154}
946 1155
1156static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1157{
1158 return (struct ata_port *) &host->hostdata[0];
1159}
1160
947#endif /* __LINUX_LIBATA_H__ */ 1161#endif /* __LINUX_LIBATA_H__ */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 590dc6dca315..55dc8ac3f020 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1182,6 +1182,10 @@
1182#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E 1182#define PCI_DEVICE_ID_NVIDIA_QUADRO_FX_1100 0x034E
1183#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372 1183#define PCI_DEVICE_ID_NVIDIA_NVENET_14 0x0372
1184#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373 1184#define PCI_DEVICE_ID_NVIDIA_NVENET_15 0x0373
1185#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA 0x03E7
1186#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE 0x03EC
1187#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2 0x03F6
1188#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3 0x03F7
1185 1189
1186#define PCI_VENDOR_ID_IMS 0x10e0 1190#define PCI_VENDOR_ID_IMS 0x10e0
1187#define PCI_DEVICE_ID_IMS_TT128 0x9128 1191#define PCI_DEVICE_ID_IMS_TT128 0x9128
@@ -1235,6 +1239,7 @@
1235#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 1239#define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259
1236#define PCI_DEVICE_ID_VIA_3269_0 0x0269 1240#define PCI_DEVICE_ID_VIA_3269_0 0x0269
1237#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 1241#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282
1242#define PCI_DEVICE_ID_VIA_3296_0 0x0296
1238#define PCI_DEVICE_ID_VIA_8363_0 0x0305 1243#define PCI_DEVICE_ID_VIA_8363_0 0x0305
1239#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314 1244#define PCI_DEVICE_ID_VIA_P4M800CE 0x0314
1240#define PCI_DEVICE_ID_VIA_8371_0 0x0391 1245#define PCI_DEVICE_ID_VIA_8371_0 0x0391
@@ -1242,6 +1247,7 @@
1242#define PCI_DEVICE_ID_VIA_82C561 0x0561 1247#define PCI_DEVICE_ID_VIA_82C561 0x0561
1243#define PCI_DEVICE_ID_VIA_82C586_1 0x0571 1248#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
1244#define PCI_DEVICE_ID_VIA_82C576 0x0576 1249#define PCI_DEVICE_ID_VIA_82C576 0x0576
1250#define PCI_DEVICE_ID_VIA_SATA_EIDE 0x0581
1245#define PCI_DEVICE_ID_VIA_82C586_0 0x0586 1251#define PCI_DEVICE_ID_VIA_82C586_0 0x0586
1246#define PCI_DEVICE_ID_VIA_82C596 0x0596 1252#define PCI_DEVICE_ID_VIA_82C596 0x0596
1247#define PCI_DEVICE_ID_VIA_82C597_0 0x0597 1253#define PCI_DEVICE_ID_VIA_82C597_0 0x0597
@@ -1282,10 +1288,11 @@
1282#define PCI_DEVICE_ID_VIA_8783_0 0x3208 1288#define PCI_DEVICE_ID_VIA_8783_0 0x3208
1283#define PCI_DEVICE_ID_VIA_8237 0x3227 1289#define PCI_DEVICE_ID_VIA_8237 0x3227
1284#define PCI_DEVICE_ID_VIA_8251 0x3287 1290#define PCI_DEVICE_ID_VIA_8251 0x3287
1285#define PCI_DEVICE_ID_VIA_3296_0 0x0296 1291#define PCI_DEVICE_ID_VIA_8237A 0x3337
1286#define PCI_DEVICE_ID_VIA_8231 0x8231 1292#define PCI_DEVICE_ID_VIA_8231 0x8231
1287#define PCI_DEVICE_ID_VIA_8231_4 0x8235 1293#define PCI_DEVICE_ID_VIA_8231_4 0x8235
1288#define PCI_DEVICE_ID_VIA_8365_1 0x8305 1294#define PCI_DEVICE_ID_VIA_8365_1 0x8305
1295#define PCI_DEVICE_ID_VIA_CX700 0x8324
1289#define PCI_DEVICE_ID_VIA_8371_1 0x8391 1296#define PCI_DEVICE_ID_VIA_8371_1 0x8391
1290#define PCI_DEVICE_ID_VIA_82C598_1 0x8598 1297#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
1291#define PCI_DEVICE_ID_VIA_838X_1 0xB188 1298#define PCI_DEVICE_ID_VIA_838X_1 0xB188
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 1ace1b9fe537..88c6c4da6c05 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -151,5 +151,6 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
151extern void scsi_put_command(struct scsi_cmnd *); 151extern void scsi_put_command(struct scsi_cmnd *);
152extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); 152extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
153extern void scsi_finish_command(struct scsi_cmnd *cmd); 153extern void scsi_finish_command(struct scsi_cmnd *cmd);
154extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
154 155
155#endif /* _SCSI_SCSI_CMND_H */ 156#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index de6ce541a046..a42efd6e4be8 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -472,6 +472,7 @@ struct Scsi_Host {
472 */ 472 */
473 unsigned int host_busy; /* commands actually active on low-level */ 473 unsigned int host_busy; /* commands actually active on low-level */
474 unsigned int host_failed; /* commands that failed. */ 474 unsigned int host_failed; /* commands that failed. */
475 unsigned int host_eh_scheduled; /* EH scheduled without command */
475 476
476 unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */ 477 unsigned short host_no; /* Used for IOCTL_GET_IDLUN, /proc/scsi et al. */
477 int resetting; /* if set, it means that last_reset is a valid value */ 478 int resetting; /* if set, it means that last_reset is a valid value */