diff options
| author | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:31:38 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:31:38 -0400 |
| commit | 4854c7b27f0975a2b629f35ea3996d2968eb7c4f (patch) | |
| tree | 4102bdb70289764a2058aff0f907b13d7cf0e0d1 /include/linux/libata.h | |
| parent | 3cbd5b32cb625f5c0f1b1476d154fac873dd49ce (diff) | |
| parent | fcc18e83e1f6fd9fa6b333735bf0fcd530655511 (diff) | |
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 473 |
1 files changed, 346 insertions, 127 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index b80d2e7fa6d2..20b1cf527c60 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,56 @@ 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 | ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, | ||
| 253 | |||
| 254 | /* ata_eh_info->flags */ | ||
| 255 | ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ | ||
| 256 | |||
| 257 | ATA_EHI_DID_RESET = (1 << 16), /* already reset this port */ | ||
| 258 | |||
| 259 | /* max repeat if error condition is still set after ->error_handler */ | ||
| 260 | ATA_EH_MAX_REPEAT = 5, | ||
| 261 | |||
| 262 | /* how hard are we gonna try to probe/recover devices */ | ||
| 263 | ATA_PROBE_MAX_TRIES = 3, | ||
| 264 | ATA_EH_RESET_TRIES = 3, | ||
| 265 | ATA_EH_DEV_TRIES = 3, | ||
| 266 | |||
| 267 | /* Drive spinup time (time from power-on to the first D2H FIS) | ||
| 268 | * in msecs - 8s currently. Failing to get ready in this time | ||
| 269 | * isn't critical. It will result in reset failure for | ||
| 270 | * controllers which can't wait for the first D2H FIS. libata | ||
| 271 | * will retry, so it just has to be long enough to spin up | ||
| 272 | * most devices. | ||
| 273 | */ | ||
| 274 | ATA_SPINUP_WAIT = 8000, | ||
| 214 | }; | 275 | }; |
| 215 | 276 | ||
| 216 | enum hsm_task_states { | 277 | enum hsm_task_states { |
| 217 | HSM_ST_UNKNOWN, | 278 | HSM_ST_UNKNOWN, /* state unknown */ |
| 218 | HSM_ST_IDLE, | 279 | HSM_ST_IDLE, /* no command on going */ |
| 219 | HSM_ST_POLL, | 280 | HSM_ST, /* (waiting the device to) transfer data */ |
| 220 | HSM_ST_TMOUT, | 281 | HSM_ST_LAST, /* (waiting the device to) complete command */ |
| 221 | HSM_ST, | 282 | HSM_ST_ERR, /* error */ |
| 222 | HSM_ST_LAST, | 283 | HSM_ST_FIRST, /* (waiting the device to) |
| 223 | HSM_ST_LAST_POLL, | 284 | write CDB or first data block */ |
| 224 | HSM_ST_ERR, | ||
| 225 | }; | 285 | }; |
| 226 | 286 | ||
| 227 | enum ata_completion_errors { | 287 | enum ata_completion_errors { |
| @@ -244,9 +304,9 @@ struct ata_queued_cmd; | |||
| 244 | 304 | ||
| 245 | /* typedefs */ | 305 | /* typedefs */ |
| 246 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 306 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
| 247 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | 307 | typedef int (*ata_prereset_fn_t)(struct ata_port *ap); |
| 248 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | 308 | typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes); |
| 249 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | 309 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); |
| 250 | 310 | ||
| 251 | struct ata_ioports { | 311 | struct ata_ioports { |
| 252 | unsigned long cmd_addr; | 312 | unsigned long cmd_addr; |
| @@ -297,7 +357,8 @@ struct ata_host_set { | |||
| 297 | unsigned long flags; | 357 | unsigned long flags; |
| 298 | int simplex_claimed; /* Keep seperate in case we | 358 | int simplex_claimed; /* Keep seperate in case we |
| 299 | ever need to do this locked */ | 359 | ever need to do this locked */ |
| 300 | struct ata_port * ports[0]; | 360 | struct ata_host_set *next; /* for legacy mode */ |
| 361 | struct ata_port *ports[0]; | ||
| 301 | }; | 362 | }; |
| 302 | 363 | ||
| 303 | struct ata_queued_cmd { | 364 | struct ata_queued_cmd { |
| @@ -336,7 +397,7 @@ struct ata_queued_cmd { | |||
| 336 | struct scatterlist *__sg; | 397 | struct scatterlist *__sg; |
| 337 | 398 | ||
| 338 | unsigned int err_mask; | 399 | unsigned int err_mask; |
| 339 | 400 | struct ata_taskfile result_tf; | |
| 340 | ata_qc_cb_t complete_fn; | 401 | ata_qc_cb_t complete_fn; |
| 341 | 402 | ||
| 342 | void *private_data; | 403 | void *private_data; |
| @@ -348,12 +409,26 @@ struct ata_host_stats { | |||
| 348 | unsigned long rw_reqbuf; | 409 | unsigned long rw_reqbuf; |
| 349 | }; | 410 | }; |
| 350 | 411 | ||
| 412 | struct ata_ering_entry { | ||
| 413 | int is_io; | ||
| 414 | unsigned int err_mask; | ||
| 415 | u64 timestamp; | ||
| 416 | }; | ||
| 417 | |||
| 418 | struct ata_ering { | ||
| 419 | int cursor; | ||
| 420 | struct ata_ering_entry ring[ATA_ERING_SIZE]; | ||
| 421 | }; | ||
| 422 | |||
| 351 | struct ata_device { | 423 | struct ata_device { |
| 352 | u64 n_sectors; /* size of device, if ATA */ | 424 | struct ata_port *ap; |
| 425 | unsigned int devno; /* 0 or 1 */ | ||
| 353 | unsigned long flags; /* ATA_DFLAG_xxx */ | 426 | unsigned long flags; /* ATA_DFLAG_xxx */ |
| 427 | struct scsi_device *sdev; /* attached SCSI device */ | ||
| 428 | /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ | ||
| 429 | u64 n_sectors; /* size of device, if ATA */ | ||
| 354 | unsigned int class; /* ATA_DEV_xxx */ | 430 | unsigned int class; /* ATA_DEV_xxx */ |
| 355 | unsigned int devno; /* 0 or 1 */ | 431 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ |
| 356 | u16 *id; /* IDENTIFY xxx DEVICE data */ | ||
| 357 | u8 pio_mode; | 432 | u8 pio_mode; |
| 358 | u8 dma_mode; | 433 | u8 dma_mode; |
| 359 | u8 xfer_mode; | 434 | u8 xfer_mode; |
| @@ -373,11 +448,42 @@ struct ata_device { | |||
| 373 | u16 cylinders; /* Number of cylinders */ | 448 | u16 cylinders; /* Number of cylinders */ |
| 374 | u16 heads; /* Number of heads */ | 449 | u16 heads; /* Number of heads */ |
| 375 | u16 sectors; /* Number of sectors per track */ | 450 | u16 sectors; /* Number of sectors per track */ |
| 451 | |||
| 452 | /* error history */ | ||
| 453 | struct ata_ering ering; | ||
| 454 | }; | ||
| 455 | |||
| 456 | /* Offset into struct ata_device. Fields above it are maintained | ||
| 457 | * acress device init. Fields below are zeroed. | ||
| 458 | */ | ||
| 459 | #define ATA_DEVICE_CLEAR_OFFSET offsetof(struct ata_device, n_sectors) | ||
| 460 | |||
| 461 | struct ata_eh_info { | ||
| 462 | struct ata_device *dev; /* offending device */ | ||
| 463 | u32 serror; /* SError from LLDD */ | ||
| 464 | unsigned int err_mask; /* port-wide err_mask */ | ||
| 465 | unsigned int action; /* ATA_EH_* action mask */ | ||
| 466 | unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */ | ||
| 467 | unsigned int flags; /* ATA_EHI_* flags */ | ||
| 468 | |||
| 469 | unsigned long hotplug_timestamp; | ||
| 470 | unsigned int probe_mask; | ||
| 471 | |||
| 472 | char desc[ATA_EH_DESC_LEN]; | ||
| 473 | int desc_len; | ||
| 474 | }; | ||
| 475 | |||
| 476 | struct ata_eh_context { | ||
| 477 | struct ata_eh_info i; | ||
| 478 | int tries[ATA_MAX_DEVICES]; | ||
| 479 | unsigned int classes[ATA_MAX_DEVICES]; | ||
| 480 | unsigned int did_probe_mask; | ||
| 376 | }; | 481 | }; |
| 377 | 482 | ||
| 378 | struct ata_port { | 483 | struct ata_port { |
| 379 | struct Scsi_Host *host; /* our co-allocated scsi host */ | 484 | struct Scsi_Host *host; /* our co-allocated scsi host */ |
| 380 | const struct ata_port_operations *ops; | 485 | const struct ata_port_operations *ops; |
| 486 | spinlock_t *lock; | ||
| 381 | unsigned long flags; /* ATA_FLAG_xxx */ | 487 | unsigned long flags; /* ATA_FLAG_xxx */ |
| 382 | unsigned int id; /* unique id req'd by scsi midlyr */ | 488 | unsigned int id; /* unique id req'd by scsi midlyr */ |
| 383 | unsigned int port_no; /* unique port #; from zero */ | 489 | unsigned int port_no; /* unique port #; from zero */ |
| @@ -397,26 +503,40 @@ struct ata_port { | |||
| 397 | unsigned int mwdma_mask; | 503 | unsigned int mwdma_mask; |
| 398 | unsigned int udma_mask; | 504 | unsigned int udma_mask; |
| 399 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 505 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
| 506 | unsigned int hw_sata_spd_limit; | ||
| 507 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | ||
| 508 | |||
| 509 | /* record runtime error info, protected by host_set lock */ | ||
| 510 | struct ata_eh_info eh_info; | ||
| 511 | /* EH context owned by EH */ | ||
| 512 | struct ata_eh_context eh_context; | ||
| 400 | 513 | ||
| 401 | struct ata_device device[ATA_MAX_DEVICES]; | 514 | struct ata_device device[ATA_MAX_DEVICES]; |
| 402 | 515 | ||
| 403 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; | 516 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; |
| 404 | unsigned long qactive; | 517 | unsigned long qc_allocated; |
| 518 | unsigned int qc_active; | ||
| 519 | |||
| 405 | unsigned int active_tag; | 520 | unsigned int active_tag; |
| 521 | u32 sactive; | ||
| 406 | 522 | ||
| 407 | struct ata_host_stats stats; | 523 | struct ata_host_stats stats; |
| 408 | struct ata_host_set *host_set; | 524 | struct ata_host_set *host_set; |
| 409 | struct device *dev; | 525 | struct device *dev; |
| 410 | 526 | ||
| 411 | struct work_struct port_task; | 527 | struct work_struct port_task; |
| 528 | struct work_struct hotplug_task; | ||
| 529 | struct work_struct scsi_rescan_task; | ||
| 412 | 530 | ||
| 413 | unsigned int hsm_task_state; | 531 | unsigned int hsm_task_state; |
| 414 | unsigned long pio_task_timeout; | ||
| 415 | 532 | ||
| 416 | u32 msg_enable; | 533 | u32 msg_enable; |
| 417 | struct list_head eh_done_q; | 534 | struct list_head eh_done_q; |
| 535 | wait_queue_head_t eh_wait_q; | ||
| 418 | 536 | ||
| 419 | void *private_data; | 537 | void *private_data; |
| 538 | |||
| 539 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | ||
| 420 | }; | 540 | }; |
| 421 | 541 | ||
| 422 | struct ata_port_operations { | 542 | struct ata_port_operations { |
| @@ -438,7 +558,6 @@ struct ata_port_operations { | |||
| 438 | 558 | ||
| 439 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ | 559 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
| 440 | void (*set_mode) (struct ata_port *ap); | 560 | void (*set_mode) (struct ata_port *ap); |
| 441 | int (*probe_reset) (struct ata_port *ap, unsigned int *classes); | ||
| 442 | 561 | ||
| 443 | void (*post_set_mode) (struct ata_port *ap); | 562 | void (*post_set_mode) (struct ata_port *ap); |
| 444 | 563 | ||
| @@ -447,10 +566,20 @@ struct ata_port_operations { | |||
| 447 | void (*bmdma_setup) (struct ata_queued_cmd *qc); | 566 | void (*bmdma_setup) (struct ata_queued_cmd *qc); |
| 448 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 567 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
| 449 | 568 | ||
| 569 | void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); | ||
| 570 | |||
| 450 | void (*qc_prep) (struct ata_queued_cmd *qc); | 571 | void (*qc_prep) (struct ata_queued_cmd *qc); |
| 451 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | 572 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
| 452 | 573 | ||
| 453 | void (*eng_timeout) (struct ata_port *ap); | 574 | /* Error handlers. ->error_handler overrides ->eng_timeout and |
| 575 | * indicates that new-style EH is in place. | ||
| 576 | */ | ||
| 577 | void (*eng_timeout) (struct ata_port *ap); /* obsolete */ | ||
| 578 | |||
| 579 | void (*freeze) (struct ata_port *ap); | ||
| 580 | void (*thaw) (struct ata_port *ap); | ||
| 581 | void (*error_handler) (struct ata_port *ap); | ||
| 582 | void (*post_internal_cmd) (struct ata_queued_cmd *qc); | ||
| 454 | 583 | ||
| 455 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 584 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
| 456 | void (*irq_clear) (struct ata_port *); | 585 | void (*irq_clear) (struct ata_port *); |
| @@ -492,22 +621,22 @@ struct ata_timing { | |||
| 492 | 621 | ||
| 493 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | 622 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) |
| 494 | 623 | ||
| 624 | extern const unsigned long sata_deb_timing_boot[]; | ||
| 625 | extern const unsigned long sata_deb_timing_eh[]; | ||
| 626 | extern const unsigned long sata_deb_timing_before_fsrst[]; | ||
| 627 | |||
| 495 | extern void ata_port_probe(struct ata_port *); | 628 | extern void ata_port_probe(struct ata_port *); |
| 496 | extern void __sata_phy_reset(struct ata_port *ap); | 629 | extern void __sata_phy_reset(struct ata_port *ap); |
| 497 | extern void sata_phy_reset(struct ata_port *ap); | 630 | extern void sata_phy_reset(struct ata_port *ap); |
| 498 | extern void ata_bus_reset(struct ata_port *ap); | 631 | extern void ata_bus_reset(struct ata_port *ap); |
| 499 | extern int ata_drive_probe_reset(struct ata_port *ap, | 632 | extern int sata_set_spd(struct ata_port *ap); |
| 500 | ata_probeinit_fn_t probeinit, | 633 | extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param); |
| 501 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 634 | extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param); |
| 502 | ata_postreset_fn_t postreset, unsigned int *classes); | 635 | extern int ata_std_prereset(struct ata_port *ap); |
| 503 | extern void ata_std_probeinit(struct ata_port *ap); | 636 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
| 504 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | 637 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
| 505 | unsigned int *classes); | ||
| 506 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
| 507 | unsigned int *class); | ||
| 508 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 638 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
| 509 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 639 | extern int ata_dev_revalidate(struct ata_device *dev, int post_reset); |
| 510 | int post_reset); | ||
| 511 | extern void ata_port_disable(struct ata_port *); | 640 | extern void ata_port_disable(struct ata_port *); |
| 512 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 641 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
| 513 | #ifdef CONFIG_PCI | 642 | #ifdef CONFIG_PCI |
| @@ -519,24 +648,32 @@ extern int ata_pci_device_resume(struct pci_dev *pdev); | |||
| 519 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); | 648 | extern int ata_pci_clear_simplex(struct pci_dev *pdev); |
| 520 | #endif /* CONFIG_PCI */ | 649 | #endif /* CONFIG_PCI */ |
| 521 | extern int ata_device_add(const struct ata_probe_ent *ent); | 650 | extern int ata_device_add(const struct ata_probe_ent *ent); |
| 651 | extern void ata_port_detach(struct ata_port *ap); | ||
| 522 | extern void ata_host_set_remove(struct ata_host_set *host_set); | 652 | extern void ata_host_set_remove(struct ata_host_set *host_set); |
| 523 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 653 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
| 524 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 654 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
| 525 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 655 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
| 526 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 527 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 528 | extern int ata_scsi_release(struct Scsi_Host *host); | 656 | extern int ata_scsi_release(struct Scsi_Host *host); |
| 529 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 657 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
| 658 | extern int sata_scr_valid(struct ata_port *ap); | ||
| 659 | extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); | ||
| 660 | extern int sata_scr_write(struct ata_port *ap, int reg, u32 val); | ||
| 661 | extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); | ||
| 662 | extern int ata_port_online(struct ata_port *ap); | ||
| 663 | extern int ata_port_offline(struct ata_port *ap); | ||
| 530 | extern int ata_scsi_device_resume(struct scsi_device *); | 664 | extern int ata_scsi_device_resume(struct scsi_device *); |
| 531 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 665 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
| 532 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 666 | extern int ata_device_resume(struct ata_device *); |
| 533 | extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state); | 667 | extern int ata_device_suspend(struct ata_device *, pm_message_t state); |
| 534 | extern int ata_ratelimit(void); | 668 | extern int ata_ratelimit(void); |
| 535 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 669 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
| 536 | unsigned long timeout_pat, | 670 | unsigned long timeout_pat, |
| 537 | unsigned long timeout); | 671 | unsigned long timeout); |
| 538 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), | 672 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), |
| 539 | void *data, unsigned long delay); | 673 | void *data, unsigned long delay); |
| 674 | extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, | ||
| 675 | unsigned long interval_msec, | ||
| 676 | unsigned long timeout_msec); | ||
| 540 | 677 | ||
| 541 | /* | 678 | /* |
| 542 | * Default driver ops implementations | 679 | * Default driver ops implementations |
| @@ -550,11 +687,16 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | |||
| 550 | extern u8 ata_check_status(struct ata_port *ap); | 687 | extern u8 ata_check_status(struct ata_port *ap); |
| 551 | extern u8 ata_altstatus(struct ata_port *ap); | 688 | extern u8 ata_altstatus(struct ata_port *ap); |
| 552 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 689 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
| 553 | extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes); | ||
| 554 | extern int ata_port_start (struct ata_port *ap); | 690 | extern int ata_port_start (struct ata_port *ap); |
| 555 | extern void ata_port_stop (struct ata_port *ap); | 691 | extern void ata_port_stop (struct ata_port *ap); |
| 556 | extern void ata_host_stop (struct ata_host_set *host_set); | 692 | extern void ata_host_stop (struct ata_host_set *host_set); |
| 557 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); | 693 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); |
| 694 | extern void ata_mmio_data_xfer(struct ata_device *adev, unsigned char *buf, | ||
| 695 | unsigned int buflen, int write_data); | ||
| 696 | extern void ata_pio_data_xfer(struct ata_device *adev, unsigned char *buf, | ||
| 697 | unsigned int buflen, int write_data); | ||
| 698 | extern void ata_pio_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, | ||
| 699 | unsigned int buflen, int write_data); | ||
| 558 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 700 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
| 559 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); | 701 | extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); |
| 560 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 702 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
| @@ -572,17 +714,29 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); | |||
| 572 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 714 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
| 573 | extern u8 ata_bmdma_status(struct ata_port *ap); | 715 | extern u8 ata_bmdma_status(struct ata_port *ap); |
| 574 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 716 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
| 575 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 717 | extern void ata_bmdma_freeze(struct ata_port *ap); |
| 576 | extern void ata_eng_timeout(struct ata_port *ap); | 718 | extern void ata_bmdma_thaw(struct ata_port *ap); |
| 577 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 719 | extern void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset, |
| 578 | struct scsi_cmnd *cmd, | 720 | ata_reset_fn_t softreset, |
| 721 | ata_reset_fn_t hardreset, | ||
| 722 | ata_postreset_fn_t postreset); | ||
| 723 | extern void ata_bmdma_error_handler(struct ata_port *ap); | ||
| 724 | extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); | ||
| 725 | extern int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
| 726 | u8 status, int in_wq); | ||
| 727 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | ||
| 728 | extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, | ||
| 729 | void (*finish_qc)(struct ata_queued_cmd *)); | ||
| 730 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | ||
| 579 | void (*done)(struct scsi_cmnd *)); | 731 | void (*done)(struct scsi_cmnd *)); |
| 580 | extern int ata_std_bios_param(struct scsi_device *sdev, | 732 | extern int ata_std_bios_param(struct scsi_device *sdev, |
| 581 | struct block_device *bdev, | 733 | struct block_device *bdev, |
| 582 | sector_t capacity, int geom[]); | 734 | sector_t capacity, int geom[]); |
| 583 | extern int ata_scsi_slave_config(struct scsi_device *sdev); | 735 | extern int ata_scsi_slave_config(struct scsi_device *sdev); |
| 584 | extern struct ata_device *ata_dev_pair(struct ata_port *ap, | 736 | extern void ata_scsi_slave_destroy(struct scsi_device *sdev); |
| 585 | struct ata_device *adev); | 737 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, |
| 738 | int queue_depth); | ||
| 739 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | ||
| 586 | 740 | ||
| 587 | /* | 741 | /* |
| 588 | * Timing helpers | 742 | * Timing helpers |
| @@ -628,7 +782,64 @@ extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bit | |||
| 628 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); | 782 | extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long); |
| 629 | #endif /* CONFIG_PCI */ | 783 | #endif /* CONFIG_PCI */ |
| 630 | 784 | ||
| 785 | /* | ||
| 786 | * EH | ||
| 787 | */ | ||
| 788 | extern void ata_eng_timeout(struct ata_port *ap); | ||
| 789 | |||
| 790 | extern void ata_port_schedule_eh(struct ata_port *ap); | ||
| 791 | extern int ata_port_abort(struct ata_port *ap); | ||
| 792 | extern int ata_port_freeze(struct ata_port *ap); | ||
| 793 | |||
| 794 | extern void ata_eh_freeze_port(struct ata_port *ap); | ||
| 795 | extern void ata_eh_thaw_port(struct ata_port *ap); | ||
| 796 | |||
| 797 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 798 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 799 | |||
| 800 | extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, | ||
| 801 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
| 802 | ata_postreset_fn_t postreset); | ||
| 803 | |||
| 804 | /* | ||
| 805 | * printk helpers | ||
| 806 | */ | ||
| 807 | #define ata_port_printk(ap, lv, fmt, args...) \ | ||
| 808 | printk(lv"ata%u: "fmt, (ap)->id , ##args) | ||
| 809 | |||
| 810 | #define ata_dev_printk(dev, lv, fmt, args...) \ | ||
| 811 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) | ||
| 812 | |||
| 813 | /* | ||
| 814 | * ata_eh_info helpers | ||
| 815 | */ | ||
| 816 | #define ata_ehi_push_desc(ehi, fmt, args...) do { \ | ||
| 817 | (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \ | ||
| 818 | ATA_EH_DESC_LEN - (ehi)->desc_len, \ | ||
| 819 | fmt , ##args); \ | ||
| 820 | } while (0) | ||
| 821 | |||
| 822 | #define ata_ehi_clear_desc(ehi) do { \ | ||
| 823 | (ehi)->desc[0] = '\0'; \ | ||
| 824 | (ehi)->desc_len = 0; \ | ||
| 825 | } while (0) | ||
| 826 | |||
| 827 | static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) | ||
| 828 | { | ||
| 829 | if (ehi->flags & ATA_EHI_HOTPLUGGED) | ||
| 830 | return; | ||
| 831 | |||
| 832 | ehi->flags |= ATA_EHI_HOTPLUGGED; | ||
| 833 | ehi->hotplug_timestamp = jiffies; | ||
| 631 | 834 | ||
| 835 | ehi->err_mask |= AC_ERR_ATA_BUS; | ||
| 836 | ehi->action |= ATA_EH_SOFTRESET; | ||
| 837 | ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; | ||
| 838 | } | ||
| 839 | |||
| 840 | /* | ||
| 841 | * qc helpers | ||
| 842 | */ | ||
| 632 | static inline int | 843 | static inline int |
| 633 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 844 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
| 634 | { | 845 | { |
| @@ -671,14 +882,39 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
| 671 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 882 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| 672 | } | 883 | } |
| 673 | 884 | ||
| 674 | static inline unsigned int ata_class_present(unsigned int class) | 885 | static inline unsigned int ata_tag_internal(unsigned int tag) |
| 886 | { | ||
| 887 | return tag == ATA_MAX_QUEUE - 1; | ||
| 888 | } | ||
| 889 | |||
| 890 | static inline unsigned int ata_class_enabled(unsigned int class) | ||
| 675 | { | 891 | { |
| 676 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 892 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
| 677 | } | 893 | } |
| 678 | 894 | ||
| 679 | static inline unsigned int ata_dev_present(const struct ata_device *dev) | 895 | static inline unsigned int ata_class_disabled(unsigned int class) |
| 680 | { | 896 | { |
| 681 | return ata_class_present(dev->class); | 897 | return class == ATA_DEV_ATA_UNSUP || class == ATA_DEV_ATAPI_UNSUP; |
| 898 | } | ||
| 899 | |||
| 900 | static inline unsigned int ata_class_absent(unsigned int class) | ||
| 901 | { | ||
| 902 | return !ata_class_enabled(class) && !ata_class_disabled(class); | ||
| 903 | } | ||
| 904 | |||
| 905 | static inline unsigned int ata_dev_enabled(const struct ata_device *dev) | ||
| 906 | { | ||
| 907 | return ata_class_enabled(dev->class); | ||
| 908 | } | ||
| 909 | |||
| 910 | static inline unsigned int ata_dev_disabled(const struct ata_device *dev) | ||
| 911 | { | ||
| 912 | return ata_class_disabled(dev->class); | ||
| 913 | } | ||
| 914 | |||
| 915 | static inline unsigned int ata_dev_absent(const struct ata_device *dev) | ||
| 916 | { | ||
| 917 | return ata_class_absent(dev->class); | ||
| 682 | } | 918 | } |
| 683 | 919 | ||
| 684 | static inline u8 ata_chk_status(struct ata_port *ap) | 920 | static inline u8 ata_chk_status(struct ata_port *ap) |
| @@ -759,20 +995,35 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | |||
| 759 | qc->tf.ctl |= ATA_NIEN; | 995 | qc->tf.ctl |= ATA_NIEN; |
| 760 | } | 996 | } |
| 761 | 997 | ||
| 762 | static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, | 998 | static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, |
| 763 | unsigned int tag) | 999 | unsigned int tag) |
| 764 | { | 1000 | { |
| 765 | if (likely(ata_tag_valid(tag))) | 1001 | if (likely(ata_tag_valid(tag))) |
| 766 | return &ap->qcmd[tag]; | 1002 | return &ap->qcmd[tag]; |
| 767 | return NULL; | 1003 | return NULL; |
| 768 | } | 1004 | } |
| 769 | 1005 | ||
| 770 | static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device) | 1006 | static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap, |
| 1007 | unsigned int tag) | ||
| 1008 | { | ||
| 1009 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
| 1010 | |||
| 1011 | if (unlikely(!qc) || !ap->ops->error_handler) | ||
| 1012 | return qc; | ||
| 1013 | |||
| 1014 | if ((qc->flags & (ATA_QCFLAG_ACTIVE | | ||
| 1015 | ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE) | ||
| 1016 | return qc; | ||
| 1017 | |||
| 1018 | return NULL; | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | ||
| 771 | { | 1022 | { |
| 772 | memset(tf, 0, sizeof(*tf)); | 1023 | memset(tf, 0, sizeof(*tf)); |
| 773 | 1024 | ||
| 774 | tf->ctl = ap->ctl; | 1025 | tf->ctl = dev->ap->ctl; |
| 775 | if (device == 0) | 1026 | if (dev->devno == 0) |
| 776 | tf->device = ATA_DEVICE_OBS; | 1027 | tf->device = ATA_DEVICE_OBS; |
| 777 | else | 1028 | else |
| 778 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 1029 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
| @@ -787,26 +1038,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
| 787 | qc->nbytes = qc->curbytes = 0; | 1038 | qc->nbytes = qc->curbytes = 0; |
| 788 | qc->err_mask = 0; | 1039 | qc->err_mask = 0; |
| 789 | 1040 | ||
| 790 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | 1041 | 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 | */ | ||
| 804 | static inline void ata_qc_complete(struct ata_queued_cmd *qc) | ||
| 805 | { | ||
| 806 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
| 807 | return; | ||
| 808 | 1042 | ||
| 809 | __ata_qc_complete(qc); | 1043 | /* init result_tf such that it indicates normal completion */ |
| 1044 | qc->result_tf.command = ATA_DRDY; | ||
| 1045 | qc->result_tf.feature = 0; | ||
| 810 | } | 1046 | } |
| 811 | 1047 | ||
| 812 | /** | 1048 | /** |
| @@ -885,28 +1121,6 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
| 885 | return status; | 1121 | return status; |
| 886 | } | 1122 | } |
| 887 | 1123 | ||
| 888 | static inline u32 scr_read(struct ata_port *ap, unsigned int reg) | ||
| 889 | { | ||
| 890 | return ap->ops->scr_read(ap, reg); | ||
| 891 | } | ||
| 892 | |||
| 893 | static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val) | ||
| 894 | { | ||
| 895 | ap->ops->scr_write(ap, reg, val); | ||
| 896 | } | ||
| 897 | |||
| 898 | static 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 | |||
| 905 | static inline unsigned int sata_dev_present(struct ata_port *ap) | ||
| 906 | { | ||
| 907 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; | ||
| 908 | } | ||
| 909 | |||
| 910 | static inline int ata_try_flush_cache(const struct ata_device *dev) | 1124 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
| 911 | { | 1125 | { |
| 912 | return ata_id_wcache_enabled(dev->id) || | 1126 | return ata_id_wcache_enabled(dev->id) || |
| @@ -916,7 +1130,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
| 916 | 1130 | ||
| 917 | static inline unsigned int ac_err_mask(u8 status) | 1131 | static inline unsigned int ac_err_mask(u8 status) |
| 918 | { | 1132 | { |
| 919 | if (status & ATA_BUSY) | 1133 | if (status & (ATA_BUSY | ATA_DRQ)) |
| 920 | return AC_ERR_HSM; | 1134 | return AC_ERR_HSM; |
| 921 | if (status & (ATA_ERR | ATA_DF)) | 1135 | if (status & (ATA_ERR | ATA_DF)) |
| 922 | return AC_ERR_DEV; | 1136 | return AC_ERR_DEV; |
| @@ -944,4 +1158,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); | 1158 | dma_free_coherent(dev, ATA_DMA_PAD_BUF_SZ, ap->pad, ap->pad_dma); |
| 945 | } | 1159 | } |
| 946 | 1160 | ||
| 1161 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | ||
| 1162 | { | ||
| 1163 | return (struct ata_port *) &host->hostdata[0]; | ||
| 1164 | } | ||
| 1165 | |||
| 947 | #endif /* __LINUX_LIBATA_H__ */ | 1166 | #endif /* __LINUX_LIBATA_H__ */ |
