diff options
| author | Jeff Garzik <jeff@garzik.org> | 2006-05-15 11:26:53 -0400 |
|---|---|---|
| committer | Jeff Garzik <jeff@garzik.org> | 2006-05-15 11:26:53 -0400 |
| commit | efa6e7e9d40fe01406d889a5bed62f2e0da49bff (patch) | |
| tree | 7f856e4c4264a2e51768610f4b883ef023152f27 /include/linux/libata.h | |
| parent | 5006ecc2d5073d4e52f54381fd0fee1575d4ce22 (diff) | |
| parent | aee10a03eb3e240bfd1a6f91e06ce82df47c5c58 (diff) | |
Merge branch 'for-jeff' of git://htj.dyndns.org/libata-tj into tejun-merge
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 273 |
1 files changed, 191 insertions, 82 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index d35b1e3bb7e0..fcdd798bb086 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -108,7 +108,9 @@ 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 */ |
| 113 | ATA_MAX_BUS = 2, | 115 | ATA_MAX_BUS = 2, |
| 114 | ATA_DEF_BUSY_WAIT = 10000, | 116 | ATA_DEF_BUSY_WAIT = 10000, |
| @@ -122,6 +124,8 @@ enum { | |||
| 122 | /* struct ata_device stuff */ | 124 | /* struct ata_device stuff */ |
| 123 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ | 125 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ |
| 124 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ | 126 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ |
| 127 | ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */ | ||
| 128 | ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */ | ||
| 125 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, | 129 | ATA_DFLAG_CFG_MASK = (1 << 8) - 1, |
| 126 | 130 | ||
| 127 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ | 131 | ATA_DFLAG_PIO = (1 << 8), /* device currently in PIO mode */ |
| @@ -145,14 +149,19 @@ enum { | |||
| 145 | ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ | 149 | ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ |
| 146 | ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ | 150 | ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ |
| 147 | ATA_FLAG_IRQ_MASK = (1 << 9), /* Mask IRQ in PIO xfers */ | 151 | ATA_FLAG_IRQ_MASK = (1 << 9), /* Mask IRQ in PIO xfers */ |
| 152 | ATA_FLAG_PIO_POLLING = (1 << 10), /* use polling PIO if LLD | ||
| 153 | * doesn't handle PIO interrupts */ | ||
| 154 | ATA_FLAG_NCQ = (1 << 11), /* host supports NCQ */ | ||
| 148 | 155 | ||
| 149 | ATA_FLAG_NOINTR = (1 << 16), /* FIXME: Remove this once | 156 | ATA_FLAG_DEBUGMSG = (1 << 14), |
| 150 | * proper HSM is in place. */ | 157 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* flush port task */ |
| 151 | ATA_FLAG_DEBUGMSG = (1 << 17), | ||
| 152 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */ | ||
| 153 | 158 | ||
| 154 | ATA_FLAG_DISABLED = (1 << 19), /* port is disabled, ignore it */ | 159 | ATA_FLAG_EH_PENDING = (1 << 16), /* EH pending */ |
| 155 | ATA_FLAG_SUSPENDED = (1 << 20), /* port is suspended */ | 160 | ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */ |
| 161 | ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */ | ||
| 162 | |||
| 163 | ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */ | ||
| 164 | ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */ | ||
| 156 | 165 | ||
| 157 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ | 166 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ |
| 158 | 167 | ||
| @@ -162,17 +171,18 @@ enum { | |||
| 162 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | 171 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ |
| 163 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 172 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
| 164 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ | 173 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
| 165 | ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */ | 174 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ |
| 175 | |||
| 176 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ | ||
| 177 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ | ||
| 178 | ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */ | ||
| 166 | 179 | ||
| 167 | /* host set flags */ | 180 | /* host set flags */ |
| 168 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ | 181 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ |
| 169 | 182 | ||
| 170 | /* various lengths of time */ | 183 | /* various lengths of time */ |
| 171 | ATA_TMOUT_PIO = 30 * HZ, | ||
| 172 | ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ | 184 | ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ |
| 173 | ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ | 185 | ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ |
| 174 | ATA_TMOUT_CDB = 30 * HZ, | ||
| 175 | ATA_TMOUT_CDB_QUICK = 5 * HZ, | ||
| 176 | ATA_TMOUT_INTERNAL = 30 * HZ, | 186 | ATA_TMOUT_INTERNAL = 30 * HZ, |
| 177 | ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, | 187 | ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, |
| 178 | 188 | ||
| @@ -216,19 +226,39 @@ enum { | |||
| 216 | ATA_PORT_PRIMARY = (1 << 0), | 226 | ATA_PORT_PRIMARY = (1 << 0), |
| 217 | ATA_PORT_SECONDARY = (1 << 1), | 227 | ATA_PORT_SECONDARY = (1 << 1), |
| 218 | 228 | ||
| 229 | /* ering size */ | ||
| 230 | ATA_ERING_SIZE = 32, | ||
| 231 | |||
| 232 | /* desc_len for ata_eh_info and context */ | ||
| 233 | ATA_EH_DESC_LEN = 80, | ||
| 234 | |||
| 235 | /* reset / recovery action types */ | ||
| 236 | ATA_EH_REVALIDATE = (1 << 0), | ||
| 237 | ATA_EH_SOFTRESET = (1 << 1), | ||
| 238 | ATA_EH_HARDRESET = (1 << 2), | ||
| 239 | |||
| 240 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | ||
| 241 | |||
| 242 | /* ata_eh_info->flags */ | ||
| 243 | ATA_EHI_DID_RESET = (1 << 0), /* already reset this port */ | ||
| 244 | |||
| 245 | /* max repeat if error condition is still set after ->error_handler */ | ||
| 246 | ATA_EH_MAX_REPEAT = 5, | ||
| 247 | |||
| 219 | /* how hard are we gonna try to probe/recover devices */ | 248 | /* how hard are we gonna try to probe/recover devices */ |
| 220 | ATA_PROBE_MAX_TRIES = 3, | 249 | ATA_PROBE_MAX_TRIES = 3, |
| 250 | ATA_EH_RESET_TRIES = 3, | ||
| 251 | ATA_EH_DEV_TRIES = 3, | ||
| 221 | }; | 252 | }; |
| 222 | 253 | ||
| 223 | enum hsm_task_states { | 254 | enum hsm_task_states { |
| 224 | HSM_ST_UNKNOWN, | 255 | HSM_ST_UNKNOWN, /* state unknown */ |
| 225 | HSM_ST_IDLE, | 256 | HSM_ST_IDLE, /* no command on going */ |
| 226 | HSM_ST_POLL, | 257 | HSM_ST, /* (waiting the device to) transfer data */ |
| 227 | HSM_ST_TMOUT, | 258 | HSM_ST_LAST, /* (waiting the device to) complete command */ |
| 228 | HSM_ST, | 259 | HSM_ST_ERR, /* error */ |
| 229 | HSM_ST_LAST, | 260 | HSM_ST_FIRST, /* (waiting the device to) |
| 230 | HSM_ST_LAST_POLL, | 261 | write CDB or first data block */ |
| 231 | HSM_ST_ERR, | ||
| 232 | }; | 262 | }; |
| 233 | 263 | ||
| 234 | enum ata_completion_errors { | 264 | enum ata_completion_errors { |
| @@ -343,7 +373,7 @@ struct ata_queued_cmd { | |||
| 343 | struct scatterlist *__sg; | 373 | struct scatterlist *__sg; |
| 344 | 374 | ||
| 345 | unsigned int err_mask; | 375 | unsigned int err_mask; |
| 346 | 376 | struct ata_taskfile result_tf; | |
| 347 | ata_qc_cb_t complete_fn; | 377 | ata_qc_cb_t complete_fn; |
| 348 | 378 | ||
| 349 | void *private_data; | 379 | void *private_data; |
| @@ -355,12 +385,24 @@ struct ata_host_stats { | |||
| 355 | unsigned long rw_reqbuf; | 385 | unsigned long rw_reqbuf; |
| 356 | }; | 386 | }; |
| 357 | 387 | ||
| 388 | struct ata_ering_entry { | ||
| 389 | int is_io; | ||
| 390 | unsigned int err_mask; | ||
| 391 | u64 timestamp; | ||
| 392 | }; | ||
| 393 | |||
| 394 | struct ata_ering { | ||
| 395 | int cursor; | ||
| 396 | struct ata_ering_entry ring[ATA_ERING_SIZE]; | ||
| 397 | }; | ||
| 398 | |||
| 358 | struct ata_device { | 399 | struct ata_device { |
| 400 | struct ata_port *ap; | ||
| 359 | u64 n_sectors; /* size of device, if ATA */ | 401 | u64 n_sectors; /* size of device, if ATA */ |
| 360 | unsigned long flags; /* ATA_DFLAG_xxx */ | 402 | unsigned long flags; /* ATA_DFLAG_xxx */ |
| 361 | unsigned int class; /* ATA_DEV_xxx */ | 403 | unsigned int class; /* ATA_DEV_xxx */ |
| 362 | unsigned int devno; /* 0 or 1 */ | 404 | unsigned int devno; /* 0 or 1 */ |
| 363 | u16 *id; /* IDENTIFY xxx DEVICE data */ | 405 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ |
| 364 | u8 pio_mode; | 406 | u8 pio_mode; |
| 365 | u8 dma_mode; | 407 | u8 dma_mode; |
| 366 | u8 xfer_mode; | 408 | u8 xfer_mode; |
| @@ -380,6 +422,24 @@ struct ata_device { | |||
| 380 | u16 cylinders; /* Number of cylinders */ | 422 | u16 cylinders; /* Number of cylinders */ |
| 381 | u16 heads; /* Number of heads */ | 423 | u16 heads; /* Number of heads */ |
| 382 | u16 sectors; /* Number of sectors per track */ | 424 | u16 sectors; /* Number of sectors per track */ |
| 425 | |||
| 426 | /* error history */ | ||
| 427 | struct ata_ering ering; | ||
| 428 | }; | ||
| 429 | |||
| 430 | struct ata_eh_info { | ||
| 431 | struct ata_device *dev; /* offending device */ | ||
| 432 | u32 serror; /* SError from LLDD */ | ||
| 433 | unsigned int err_mask; /* port-wide err_mask */ | ||
| 434 | unsigned int action; /* ATA_EH_* action mask */ | ||
| 435 | unsigned int flags; /* ATA_EHI_* flags */ | ||
| 436 | char desc[ATA_EH_DESC_LEN]; | ||
| 437 | int desc_len; | ||
| 438 | }; | ||
| 439 | |||
| 440 | struct ata_eh_context { | ||
| 441 | struct ata_eh_info i; | ||
| 442 | int tries[ATA_MAX_DEVICES]; | ||
| 383 | }; | 443 | }; |
| 384 | 444 | ||
| 385 | struct ata_port { | 445 | struct ata_port { |
| @@ -406,11 +466,19 @@ struct ata_port { | |||
| 406 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 466 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
| 407 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | 467 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ |
| 408 | 468 | ||
| 469 | /* record runtime error info, protected by host_set lock */ | ||
| 470 | struct ata_eh_info eh_info; | ||
| 471 | /* EH context owned by EH */ | ||
| 472 | struct ata_eh_context eh_context; | ||
| 473 | |||
| 409 | struct ata_device device[ATA_MAX_DEVICES]; | 474 | struct ata_device device[ATA_MAX_DEVICES]; |
| 410 | 475 | ||
| 411 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; | 476 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; |
| 412 | unsigned long qactive; | 477 | unsigned long qc_allocated; |
| 478 | unsigned int qc_active; | ||
| 479 | |||
| 413 | unsigned int active_tag; | 480 | unsigned int active_tag; |
| 481 | u32 sactive; | ||
| 414 | 482 | ||
| 415 | struct ata_host_stats stats; | 483 | struct ata_host_stats stats; |
| 416 | struct ata_host_set *host_set; | 484 | struct ata_host_set *host_set; |
| @@ -419,12 +487,13 @@ struct ata_port { | |||
| 419 | struct work_struct port_task; | 487 | struct work_struct port_task; |
| 420 | 488 | ||
| 421 | unsigned int hsm_task_state; | 489 | unsigned int hsm_task_state; |
| 422 | unsigned long pio_task_timeout; | ||
| 423 | 490 | ||
| 424 | u32 msg_enable; | 491 | u32 msg_enable; |
| 425 | struct list_head eh_done_q; | 492 | struct list_head eh_done_q; |
| 426 | 493 | ||
| 427 | void *private_data; | 494 | void *private_data; |
| 495 | |||
| 496 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | ||
| 428 | }; | 497 | }; |
| 429 | 498 | ||
| 430 | struct ata_port_operations { | 499 | struct ata_port_operations { |
| @@ -458,7 +527,15 @@ struct ata_port_operations { | |||
| 458 | void (*qc_prep) (struct ata_queued_cmd *qc); | 527 | void (*qc_prep) (struct ata_queued_cmd *qc); |
| 459 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | 528 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
| 460 | 529 | ||
| 461 | void (*eng_timeout) (struct ata_port *ap); | 530 | /* Error handlers. ->error_handler overrides ->eng_timeout and |
| 531 | * indicates that new-style EH is in place. | ||
| 532 | */ | ||
| 533 | void (*eng_timeout) (struct ata_port *ap); /* obsolete */ | ||
| 534 | |||
| 535 | void (*freeze) (struct ata_port *ap); | ||
| 536 | void (*thaw) (struct ata_port *ap); | ||
| 537 | void (*error_handler) (struct ata_port *ap); | ||
| 538 | void (*post_internal_cmd) (struct ata_queued_cmd *qc); | ||
| 462 | 539 | ||
| 463 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 540 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
| 464 | void (*irq_clear) (struct ata_port *); | 541 | void (*irq_clear) (struct ata_port *); |
| @@ -504,7 +581,7 @@ extern void ata_port_probe(struct ata_port *); | |||
| 504 | extern void __sata_phy_reset(struct ata_port *ap); | 581 | extern void __sata_phy_reset(struct ata_port *ap); |
| 505 | extern void sata_phy_reset(struct ata_port *ap); | 582 | extern void sata_phy_reset(struct ata_port *ap); |
| 506 | extern void ata_bus_reset(struct ata_port *ap); | 583 | extern void ata_bus_reset(struct ata_port *ap); |
| 507 | extern int ata_set_sata_spd(struct ata_port *ap); | 584 | extern int sata_set_spd(struct ata_port *ap); |
| 508 | extern int ata_drive_probe_reset(struct ata_port *ap, | 585 | extern int ata_drive_probe_reset(struct ata_port *ap, |
| 509 | ata_probeinit_fn_t probeinit, | 586 | ata_probeinit_fn_t probeinit, |
| 510 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 587 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, |
| @@ -513,8 +590,7 @@ extern void ata_std_probeinit(struct ata_port *ap); | |||
| 513 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); | 590 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
| 514 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); | 591 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
| 515 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 592 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
| 516 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 593 | extern int ata_dev_revalidate(struct ata_device *dev, int post_reset); |
| 517 | int post_reset); | ||
| 518 | extern void ata_port_disable(struct ata_port *); | 594 | extern void ata_port_disable(struct ata_port *); |
| 519 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 595 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
| 520 | #ifdef CONFIG_PCI | 596 | #ifdef CONFIG_PCI |
| @@ -530,14 +606,18 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
| 530 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 606 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
| 531 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 607 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
| 532 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 608 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
| 533 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 534 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 535 | extern int ata_scsi_release(struct Scsi_Host *host); | 609 | extern int ata_scsi_release(struct Scsi_Host *host); |
| 536 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 610 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
| 611 | extern int sata_scr_valid(struct ata_port *ap); | ||
| 612 | extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); | ||
| 613 | extern int sata_scr_write(struct ata_port *ap, int reg, u32 val); | ||
| 614 | extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); | ||
| 615 | extern int ata_port_online(struct ata_port *ap); | ||
| 616 | extern int ata_port_offline(struct ata_port *ap); | ||
| 537 | extern int ata_scsi_device_resume(struct scsi_device *); | 617 | extern int ata_scsi_device_resume(struct scsi_device *); |
| 538 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 618 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
| 539 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 619 | extern int ata_device_resume(struct ata_device *); |
| 540 | extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state); | 620 | extern int ata_device_suspend(struct ata_device *, pm_message_t state); |
| 541 | extern int ata_ratelimit(void); | 621 | extern int ata_ratelimit(void); |
| 542 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 622 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
| 543 | unsigned long timeout_pat, | 623 | unsigned long timeout_pat, |
| @@ -582,16 +662,26 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); | |||
| 582 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 662 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
| 583 | extern u8 ata_bmdma_status(struct ata_port *ap); | 663 | extern u8 ata_bmdma_status(struct ata_port *ap); |
| 584 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 664 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
| 585 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 665 | extern void ata_bmdma_freeze(struct ata_port *ap); |
| 586 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 666 | extern void ata_bmdma_thaw(struct ata_port *ap); |
| 587 | struct scsi_cmnd *cmd, | 667 | extern void ata_bmdma_drive_eh(struct ata_port *ap, |
| 668 | ata_reset_fn_t softreset, | ||
| 669 | ata_reset_fn_t hardreset, | ||
| 670 | ata_postreset_fn_t postreset); | ||
| 671 | extern void ata_bmdma_error_handler(struct ata_port *ap); | ||
| 672 | extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); | ||
| 673 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | ||
| 674 | extern int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active, | ||
| 675 | void (*finish_qc)(struct ata_queued_cmd *)); | ||
| 676 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | ||
| 588 | void (*done)(struct scsi_cmnd *)); | 677 | void (*done)(struct scsi_cmnd *)); |
| 589 | extern int ata_std_bios_param(struct scsi_device *sdev, | 678 | extern int ata_std_bios_param(struct scsi_device *sdev, |
| 590 | struct block_device *bdev, | 679 | struct block_device *bdev, |
| 591 | sector_t capacity, int geom[]); | 680 | sector_t capacity, int geom[]); |
| 592 | extern int ata_scsi_slave_config(struct scsi_device *sdev); | 681 | extern int ata_scsi_slave_config(struct scsi_device *sdev); |
| 593 | extern struct ata_device *ata_dev_pair(struct ata_port *ap, | 682 | extern int ata_scsi_change_queue_depth(struct scsi_device *sdev, |
| 594 | struct ata_device *adev); | 683 | int queue_depth); |
| 684 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); | ||
| 595 | 685 | ||
| 596 | /* | 686 | /* |
| 597 | * Timing helpers | 687 | * Timing helpers |
| @@ -641,10 +731,46 @@ extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_ | |||
| 641 | * EH | 731 | * EH |
| 642 | */ | 732 | */ |
| 643 | extern void ata_eng_timeout(struct ata_port *ap); | 733 | extern void ata_eng_timeout(struct ata_port *ap); |
| 734 | |||
| 735 | extern void ata_port_schedule_eh(struct ata_port *ap); | ||
| 736 | extern int ata_port_abort(struct ata_port *ap); | ||
| 737 | extern int ata_port_freeze(struct ata_port *ap); | ||
| 738 | |||
| 739 | extern void ata_eh_freeze_port(struct ata_port *ap); | ||
| 740 | extern void ata_eh_thaw_port(struct ata_port *ap); | ||
| 741 | |||
| 644 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | 742 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); |
| 645 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | 743 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); |
| 646 | 744 | ||
| 745 | extern void ata_do_eh(struct ata_port *ap, ata_reset_fn_t softreset, | ||
| 746 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset); | ||
| 747 | |||
| 748 | /* | ||
| 749 | * printk helpers | ||
| 750 | */ | ||
| 751 | #define ata_port_printk(ap, lv, fmt, args...) \ | ||
| 752 | printk(lv"ata%u: "fmt, (ap)->id , ##args) | ||
| 753 | |||
| 754 | #define ata_dev_printk(dev, lv, fmt, args...) \ | ||
| 755 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) | ||
| 756 | |||
| 757 | /* | ||
| 758 | * ata_eh_info helpers | ||
| 759 | */ | ||
| 760 | #define ata_ehi_push_desc(ehi, fmt, args...) do { \ | ||
| 761 | (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \ | ||
| 762 | ATA_EH_DESC_LEN - (ehi)->desc_len, \ | ||
| 763 | fmt , ##args); \ | ||
| 764 | } while (0) | ||
| 765 | |||
| 766 | #define ata_ehi_clear_desc(ehi) do { \ | ||
| 767 | (ehi)->desc[0] = '\0'; \ | ||
| 768 | (ehi)->desc_len = 0; \ | ||
| 769 | } while (0) | ||
| 647 | 770 | ||
| 771 | /* | ||
| 772 | * qc helpers | ||
| 773 | */ | ||
| 648 | static inline int | 774 | static inline int |
| 649 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 775 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
| 650 | { | 776 | { |
| @@ -687,6 +813,11 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
| 687 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 813 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| 688 | } | 814 | } |
| 689 | 815 | ||
| 816 | static inline unsigned int ata_tag_internal(unsigned int tag) | ||
| 817 | { | ||
| 818 | return tag == ATA_MAX_QUEUE - 1; | ||
| 819 | } | ||
| 820 | |||
| 690 | static inline unsigned int ata_class_enabled(unsigned int class) | 821 | static inline unsigned int ata_class_enabled(unsigned int class) |
| 691 | { | 822 | { |
| 692 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 823 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
| @@ -795,20 +926,35 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | |||
| 795 | qc->tf.ctl |= ATA_NIEN; | 926 | qc->tf.ctl |= ATA_NIEN; |
| 796 | } | 927 | } |
| 797 | 928 | ||
| 798 | static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, | 929 | static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, |
| 799 | unsigned int tag) | 930 | unsigned int tag) |
| 800 | { | 931 | { |
| 801 | if (likely(ata_tag_valid(tag))) | 932 | if (likely(ata_tag_valid(tag))) |
| 802 | return &ap->qcmd[tag]; | 933 | return &ap->qcmd[tag]; |
| 803 | return NULL; | 934 | return NULL; |
| 804 | } | 935 | } |
| 805 | 936 | ||
| 806 | static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device) | 937 | static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap, |
| 938 | unsigned int tag) | ||
| 939 | { | ||
| 940 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
| 941 | |||
| 942 | if (unlikely(!qc) || !ap->ops->error_handler) | ||
| 943 | return qc; | ||
| 944 | |||
| 945 | if ((qc->flags & (ATA_QCFLAG_ACTIVE | | ||
| 946 | ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE) | ||
| 947 | return qc; | ||
| 948 | |||
| 949 | return NULL; | ||
| 950 | } | ||
| 951 | |||
| 952 | static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | ||
| 807 | { | 953 | { |
| 808 | memset(tf, 0, sizeof(*tf)); | 954 | memset(tf, 0, sizeof(*tf)); |
| 809 | 955 | ||
| 810 | tf->ctl = ap->ctl; | 956 | tf->ctl = dev->ap->ctl; |
| 811 | if (device == 0) | 957 | if (dev->devno == 0) |
| 812 | tf->device = ATA_DEVICE_OBS; | 958 | tf->device = ATA_DEVICE_OBS; |
| 813 | else | 959 | else |
| 814 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 960 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
| @@ -823,26 +969,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
| 823 | qc->nbytes = qc->curbytes = 0; | 969 | qc->nbytes = qc->curbytes = 0; |
| 824 | qc->err_mask = 0; | 970 | qc->err_mask = 0; |
| 825 | 971 | ||
| 826 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | 972 | ata_tf_init(qc->dev, &qc->tf); |
| 827 | } | ||
| 828 | 973 | ||
| 829 | /** | 974 | /* init result_tf such that it indicates normal completion */ |
| 830 | * ata_qc_complete - Complete an active ATA command | 975 | qc->result_tf.command = ATA_DRDY; |
| 831 | * @qc: Command to complete | 976 | qc->result_tf.feature = 0; |
| 832 | * @err_mask: ATA Status register contents | ||
| 833 | * | ||
| 834 | * Indicate to the mid and upper layers that an ATA | ||
| 835 | * command has completed, with either an ok or not-ok status. | ||
| 836 | * | ||
| 837 | * LOCKING: | ||
| 838 | * spin_lock_irqsave(host_set lock) | ||
| 839 | */ | ||
| 840 | static inline void ata_qc_complete(struct ata_queued_cmd *qc) | ||
| 841 | { | ||
| 842 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
| 843 | return; | ||
| 844 | |||
| 845 | __ata_qc_complete(qc); | ||
| 846 | } | 977 | } |
| 847 | 978 | ||
| 848 | /** | 979 | /** |
| @@ -921,28 +1052,6 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
| 921 | return status; | 1052 | return status; |
| 922 | } | 1053 | } |
| 923 | 1054 | ||
| 924 | static inline u32 scr_read(struct ata_port *ap, unsigned int reg) | ||
| 925 | { | ||
| 926 | return ap->ops->scr_read(ap, reg); | ||
| 927 | } | ||
| 928 | |||
| 929 | static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val) | ||
| 930 | { | ||
| 931 | ap->ops->scr_write(ap, reg, val); | ||
| 932 | } | ||
| 933 | |||
| 934 | static inline void scr_write_flush(struct ata_port *ap, unsigned int reg, | ||
| 935 | u32 val) | ||
| 936 | { | ||
| 937 | ap->ops->scr_write(ap, reg, val); | ||
| 938 | (void) ap->ops->scr_read(ap, reg); | ||
| 939 | } | ||
| 940 | |||
| 941 | static inline unsigned int sata_dev_present(struct ata_port *ap) | ||
| 942 | { | ||
| 943 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; | ||
| 944 | } | ||
| 945 | |||
| 946 | static inline int ata_try_flush_cache(const struct ata_device *dev) | 1055 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
| 947 | { | 1056 | { |
| 948 | return ata_id_wcache_enabled(dev->id) || | 1057 | return ata_id_wcache_enabled(dev->id) || |
