diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ata.h | 13 | ||||
-rw-r--r-- | include/linux/libata.h | 238 | ||||
-rw-r--r-- | include/scsi/scsi_cmnd.h | 1 | ||||
-rw-r--r-- | include/scsi/scsi_eh.h | 1 | ||||
-rw-r--r-- | include/scsi/scsi_host.h | 1 |
5 files changed, 187 insertions, 67 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 206d859083ea..1cbeb434af9a 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 */ |
@@ -192,6 +195,16 @@ enum { | |||
192 | SCR_ACTIVE = 3, | 195 | SCR_ACTIVE = 3, |
193 | SCR_NOTIFICATION = 4, | 196 | SCR_NOTIFICATION = 4, |
194 | 197 | ||
198 | /* SError bits */ | ||
199 | SERR_DATA_RECOVERED = (1 << 0), /* recovered data error */ | ||
200 | SERR_COMM_RECOVERED = (1 << 1), /* recovered comm failure */ | ||
201 | SERR_DATA = (1 << 8), /* unrecovered data error */ | ||
202 | SERR_PERSISTENT = (1 << 9), /* persistent data/comm error */ | ||
203 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ | ||
204 | SERR_INTERNAL = (1 << 11), /* host internal error */ | ||
205 | SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */ | ||
206 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ | ||
207 | |||
195 | /* struct ata_taskfile flags */ | 208 | /* struct ata_taskfile flags */ |
196 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ | 209 | ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */ |
197 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ | 210 | ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */ |
diff --git a/include/linux/libata.h b/include/linux/libata.h index bf86ee474533..db17723e23fb 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 = 2, | ||
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, |
@@ -149,11 +151,15 @@ enum { | |||
149 | ATA_FLAG_PIO_POLLING = (1 << 10), /* use polling PIO if LLD | 151 | ATA_FLAG_PIO_POLLING = (1 << 10), /* use polling PIO if LLD |
150 | * doesn't handle PIO interrupts */ | 152 | * doesn't handle PIO interrupts */ |
151 | 153 | ||
152 | ATA_FLAG_DEBUGMSG = (1 << 17), | 154 | ATA_FLAG_DEBUGMSG = (1 << 14), |
153 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 18), /* flush port task */ | 155 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* flush port task */ |
154 | 156 | ||
155 | ATA_FLAG_DISABLED = (1 << 19), /* port is disabled, ignore it */ | 157 | ATA_FLAG_EH_PENDING = (1 << 16), /* EH pending */ |
156 | ATA_FLAG_SUSPENDED = (1 << 20), /* port is suspended */ | 158 | ATA_FLAG_FROZEN = (1 << 17), /* port is frozen */ |
159 | ATA_FLAG_RECOVERED = (1 << 18), /* recovery action performed */ | ||
160 | |||
161 | ATA_FLAG_DISABLED = (1 << 22), /* port is disabled, ignore it */ | ||
162 | ATA_FLAG_SUSPENDED = (1 << 23), /* port is suspended (power) */ | ||
157 | 163 | ||
158 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ | 164 | /* bits 24:31 of ap->flags are reserved for LLDD specific flags */ |
159 | 165 | ||
@@ -163,7 +169,11 @@ enum { | |||
163 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ | 169 | ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */ |
164 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 170 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
165 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ | 171 | ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ |
166 | ATA_QCFLAG_EH_SCHEDULED = (1 << 4), /* EH scheduled */ | 172 | ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ |
173 | |||
174 | ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ | ||
175 | ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ | ||
176 | ATA_QCFLAG_EH_SCHEDULED = (1 << 18), /* EH scheduled (obsolete) */ | ||
167 | 177 | ||
168 | /* host set flags */ | 178 | /* host set flags */ |
169 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ | 179 | ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host_set only */ |
@@ -214,8 +224,29 @@ enum { | |||
214 | ATA_PORT_PRIMARY = (1 << 0), | 224 | ATA_PORT_PRIMARY = (1 << 0), |
215 | ATA_PORT_SECONDARY = (1 << 1), | 225 | ATA_PORT_SECONDARY = (1 << 1), |
216 | 226 | ||
227 | /* ering size */ | ||
228 | ATA_ERING_SIZE = 32, | ||
229 | |||
230 | /* desc_len for ata_eh_info and context */ | ||
231 | ATA_EH_DESC_LEN = 80, | ||
232 | |||
233 | /* reset / recovery action types */ | ||
234 | ATA_EH_REVALIDATE = (1 << 0), | ||
235 | ATA_EH_SOFTRESET = (1 << 1), | ||
236 | ATA_EH_HARDRESET = (1 << 2), | ||
237 | |||
238 | ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, | ||
239 | |||
240 | /* ata_eh_info->flags */ | ||
241 | ATA_EHI_DID_RESET = (1 << 0), /* already reset this port */ | ||
242 | |||
243 | /* max repeat if error condition is still set after ->error_handler */ | ||
244 | ATA_EH_MAX_REPEAT = 5, | ||
245 | |||
217 | /* how hard are we gonna try to probe/recover devices */ | 246 | /* how hard are we gonna try to probe/recover devices */ |
218 | ATA_PROBE_MAX_TRIES = 3, | 247 | ATA_PROBE_MAX_TRIES = 3, |
248 | ATA_EH_RESET_TRIES = 3, | ||
249 | ATA_EH_DEV_TRIES = 3, | ||
219 | }; | 250 | }; |
220 | 251 | ||
221 | enum hsm_task_states { | 252 | enum hsm_task_states { |
@@ -340,7 +371,7 @@ struct ata_queued_cmd { | |||
340 | struct scatterlist *__sg; | 371 | struct scatterlist *__sg; |
341 | 372 | ||
342 | unsigned int err_mask; | 373 | unsigned int err_mask; |
343 | 374 | struct ata_taskfile result_tf; | |
344 | ata_qc_cb_t complete_fn; | 375 | ata_qc_cb_t complete_fn; |
345 | 376 | ||
346 | void *private_data; | 377 | void *private_data; |
@@ -352,12 +383,24 @@ struct ata_host_stats { | |||
352 | unsigned long rw_reqbuf; | 383 | unsigned long rw_reqbuf; |
353 | }; | 384 | }; |
354 | 385 | ||
386 | struct ata_ering_entry { | ||
387 | int is_io; | ||
388 | unsigned int err_mask; | ||
389 | u64 timestamp; | ||
390 | }; | ||
391 | |||
392 | struct ata_ering { | ||
393 | int cursor; | ||
394 | struct ata_ering_entry ring[ATA_ERING_SIZE]; | ||
395 | }; | ||
396 | |||
355 | struct ata_device { | 397 | struct ata_device { |
398 | struct ata_port *ap; | ||
356 | u64 n_sectors; /* size of device, if ATA */ | 399 | u64 n_sectors; /* size of device, if ATA */ |
357 | unsigned long flags; /* ATA_DFLAG_xxx */ | 400 | unsigned long flags; /* ATA_DFLAG_xxx */ |
358 | unsigned int class; /* ATA_DEV_xxx */ | 401 | unsigned int class; /* ATA_DEV_xxx */ |
359 | unsigned int devno; /* 0 or 1 */ | 402 | unsigned int devno; /* 0 or 1 */ |
360 | u16 *id; /* IDENTIFY xxx DEVICE data */ | 403 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ |
361 | u8 pio_mode; | 404 | u8 pio_mode; |
362 | u8 dma_mode; | 405 | u8 dma_mode; |
363 | u8 xfer_mode; | 406 | u8 xfer_mode; |
@@ -377,6 +420,24 @@ struct ata_device { | |||
377 | u16 cylinders; /* Number of cylinders */ | 420 | u16 cylinders; /* Number of cylinders */ |
378 | u16 heads; /* Number of heads */ | 421 | u16 heads; /* Number of heads */ |
379 | u16 sectors; /* Number of sectors per track */ | 422 | u16 sectors; /* Number of sectors per track */ |
423 | |||
424 | /* error history */ | ||
425 | struct ata_ering ering; | ||
426 | }; | ||
427 | |||
428 | struct ata_eh_info { | ||
429 | struct ata_device *dev; /* offending device */ | ||
430 | u32 serror; /* SError from LLDD */ | ||
431 | unsigned int err_mask; /* port-wide err_mask */ | ||
432 | unsigned int action; /* ATA_EH_* action mask */ | ||
433 | unsigned int flags; /* ATA_EHI_* flags */ | ||
434 | char desc[ATA_EH_DESC_LEN]; | ||
435 | int desc_len; | ||
436 | }; | ||
437 | |||
438 | struct ata_eh_context { | ||
439 | struct ata_eh_info i; | ||
440 | int tries[ATA_MAX_DEVICES]; | ||
380 | }; | 441 | }; |
381 | 442 | ||
382 | struct ata_port { | 443 | struct ata_port { |
@@ -403,6 +464,11 @@ struct ata_port { | |||
403 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 464 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
404 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ | 465 | unsigned int sata_spd_limit; /* SATA PHY speed limit */ |
405 | 466 | ||
467 | /* record runtime error info, protected by host_set lock */ | ||
468 | struct ata_eh_info eh_info; | ||
469 | /* EH context owned by EH */ | ||
470 | struct ata_eh_context eh_context; | ||
471 | |||
406 | struct ata_device device[ATA_MAX_DEVICES]; | 472 | struct ata_device device[ATA_MAX_DEVICES]; |
407 | 473 | ||
408 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; | 474 | struct ata_queued_cmd qcmd[ATA_MAX_QUEUE]; |
@@ -421,6 +487,8 @@ struct ata_port { | |||
421 | struct list_head eh_done_q; | 487 | struct list_head eh_done_q; |
422 | 488 | ||
423 | void *private_data; | 489 | void *private_data; |
490 | |||
491 | u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ | ||
424 | }; | 492 | }; |
425 | 493 | ||
426 | struct ata_port_operations { | 494 | struct ata_port_operations { |
@@ -454,7 +522,15 @@ struct ata_port_operations { | |||
454 | void (*qc_prep) (struct ata_queued_cmd *qc); | 522 | void (*qc_prep) (struct ata_queued_cmd *qc); |
455 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); | 523 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
456 | 524 | ||
457 | void (*eng_timeout) (struct ata_port *ap); | 525 | /* Error handlers. ->error_handler overrides ->eng_timeout and |
526 | * indicates that new-style EH is in place. | ||
527 | */ | ||
528 | void (*eng_timeout) (struct ata_port *ap); /* obsolete */ | ||
529 | |||
530 | void (*freeze) (struct ata_port *ap); | ||
531 | void (*thaw) (struct ata_port *ap); | ||
532 | void (*error_handler) (struct ata_port *ap); | ||
533 | void (*post_internal_cmd) (struct ata_queued_cmd *qc); | ||
458 | 534 | ||
459 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); | 535 | irqreturn_t (*irq_handler)(int, void *, struct pt_regs *); |
460 | void (*irq_clear) (struct ata_port *); | 536 | void (*irq_clear) (struct ata_port *); |
@@ -500,7 +576,7 @@ extern void ata_port_probe(struct ata_port *); | |||
500 | extern void __sata_phy_reset(struct ata_port *ap); | 576 | extern void __sata_phy_reset(struct ata_port *ap); |
501 | extern void sata_phy_reset(struct ata_port *ap); | 577 | extern void sata_phy_reset(struct ata_port *ap); |
502 | extern void ata_bus_reset(struct ata_port *ap); | 578 | extern void ata_bus_reset(struct ata_port *ap); |
503 | extern int ata_set_sata_spd(struct ata_port *ap); | 579 | extern int sata_set_spd(struct ata_port *ap); |
504 | extern int ata_drive_probe_reset(struct ata_port *ap, | 580 | extern int ata_drive_probe_reset(struct ata_port *ap, |
505 | ata_probeinit_fn_t probeinit, | 581 | ata_probeinit_fn_t probeinit, |
506 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | 582 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, |
@@ -509,8 +585,7 @@ extern void ata_std_probeinit(struct ata_port *ap); | |||
509 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); | 585 | extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); |
510 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); | 586 | extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); |
511 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | 587 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); |
512 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | 588 | extern int ata_dev_revalidate(struct ata_device *dev, int post_reset); |
513 | int post_reset); | ||
514 | extern void ata_port_disable(struct ata_port *); | 589 | extern void ata_port_disable(struct ata_port *); |
515 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 590 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
516 | #ifdef CONFIG_PCI | 591 | #ifdef CONFIG_PCI |
@@ -526,14 +601,18 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
526 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 601 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
527 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 602 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
528 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 603 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
529 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
530 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
531 | extern int ata_scsi_release(struct Scsi_Host *host); | 604 | extern int ata_scsi_release(struct Scsi_Host *host); |
532 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 605 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
606 | extern int sata_scr_valid(struct ata_port *ap); | ||
607 | extern int sata_scr_read(struct ata_port *ap, int reg, u32 *val); | ||
608 | extern int sata_scr_write(struct ata_port *ap, int reg, u32 val); | ||
609 | extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); | ||
610 | extern int ata_port_online(struct ata_port *ap); | ||
611 | extern int ata_port_offline(struct ata_port *ap); | ||
533 | extern int ata_scsi_device_resume(struct scsi_device *); | 612 | extern int ata_scsi_device_resume(struct scsi_device *); |
534 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); | 613 | extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state); |
535 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 614 | extern int ata_device_resume(struct ata_device *); |
536 | extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state); | 615 | extern int ata_device_suspend(struct ata_device *, pm_message_t state); |
537 | extern int ata_ratelimit(void); | 616 | extern int ata_ratelimit(void); |
538 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | 617 | extern unsigned int ata_busy_sleep(struct ata_port *ap, |
539 | unsigned long timeout_pat, | 618 | unsigned long timeout_pat, |
@@ -578,16 +657,22 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); | |||
578 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 657 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
579 | extern u8 ata_bmdma_status(struct ata_port *ap); | 658 | extern u8 ata_bmdma_status(struct ata_port *ap); |
580 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 659 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
581 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); | 660 | extern void ata_bmdma_freeze(struct ata_port *ap); |
582 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 661 | extern void ata_bmdma_thaw(struct ata_port *ap); |
583 | struct scsi_cmnd *cmd, | 662 | extern void ata_bmdma_drive_eh(struct ata_port *ap, |
663 | ata_reset_fn_t softreset, | ||
664 | ata_reset_fn_t hardreset, | ||
665 | ata_postreset_fn_t postreset); | ||
666 | extern void ata_bmdma_error_handler(struct ata_port *ap); | ||
667 | extern void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc); | ||
668 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | ||
669 | extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd, | ||
584 | void (*done)(struct scsi_cmnd *)); | 670 | void (*done)(struct scsi_cmnd *)); |
585 | extern int ata_std_bios_param(struct scsi_device *sdev, | 671 | extern int ata_std_bios_param(struct scsi_device *sdev, |
586 | struct block_device *bdev, | 672 | struct block_device *bdev, |
587 | sector_t capacity, int geom[]); | 673 | sector_t capacity, int geom[]); |
588 | extern int ata_scsi_slave_config(struct scsi_device *sdev); | 674 | extern int ata_scsi_slave_config(struct scsi_device *sdev); |
589 | extern struct ata_device *ata_dev_pair(struct ata_port *ap, | 675 | extern struct ata_device *ata_dev_pair(struct ata_device *adev); |
590 | struct ata_device *adev); | ||
591 | 676 | ||
592 | /* | 677 | /* |
593 | * Timing helpers | 678 | * Timing helpers |
@@ -637,10 +722,46 @@ extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_ | |||
637 | * EH | 722 | * EH |
638 | */ | 723 | */ |
639 | extern void ata_eng_timeout(struct ata_port *ap); | 724 | extern void ata_eng_timeout(struct ata_port *ap); |
725 | |||
726 | extern void ata_port_schedule_eh(struct ata_port *ap); | ||
727 | extern int ata_port_abort(struct ata_port *ap); | ||
728 | extern int ata_port_freeze(struct ata_port *ap); | ||
729 | |||
730 | extern void ata_eh_freeze_port(struct ata_port *ap); | ||
731 | extern void ata_eh_thaw_port(struct ata_port *ap); | ||
732 | |||
640 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | 733 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); |
641 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | 734 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); |
642 | 735 | ||
736 | extern void ata_do_eh(struct ata_port *ap, ata_reset_fn_t softreset, | ||
737 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset); | ||
738 | |||
739 | /* | ||
740 | * printk helpers | ||
741 | */ | ||
742 | #define ata_port_printk(ap, lv, fmt, args...) \ | ||
743 | printk(lv"ata%u: "fmt, (ap)->id , ##args) | ||
744 | |||
745 | #define ata_dev_printk(dev, lv, fmt, args...) \ | ||
746 | printk(lv"ata%u.%02u: "fmt, (dev)->ap->id, (dev)->devno , ##args) | ||
643 | 747 | ||
748 | /* | ||
749 | * ata_eh_info helpers | ||
750 | */ | ||
751 | #define ata_ehi_push_desc(ehi, fmt, args...) do { \ | ||
752 | (ehi)->desc_len += scnprintf((ehi)->desc + (ehi)->desc_len, \ | ||
753 | ATA_EH_DESC_LEN - (ehi)->desc_len, \ | ||
754 | fmt , ##args); \ | ||
755 | } while (0) | ||
756 | |||
757 | #define ata_ehi_clear_desc(ehi) do { \ | ||
758 | (ehi)->desc[0] = '\0'; \ | ||
759 | (ehi)->desc_len = 0; \ | ||
760 | } while (0) | ||
761 | |||
762 | /* | ||
763 | * qc helpers | ||
764 | */ | ||
644 | static inline int | 765 | static inline int |
645 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) | 766 | ata_sg_is_last(struct scatterlist *sg, struct ata_queued_cmd *qc) |
646 | { | 767 | { |
@@ -683,6 +804,11 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
683 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 804 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
684 | } | 805 | } |
685 | 806 | ||
807 | static inline unsigned int ata_tag_internal(unsigned int tag) | ||
808 | { | ||
809 | return tag == ATA_MAX_QUEUE - 1; | ||
810 | } | ||
811 | |||
686 | static inline unsigned int ata_class_enabled(unsigned int class) | 812 | static inline unsigned int ata_class_enabled(unsigned int class) |
687 | { | 813 | { |
688 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | 814 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; |
@@ -791,20 +917,35 @@ static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) | |||
791 | qc->tf.ctl |= ATA_NIEN; | 917 | qc->tf.ctl |= ATA_NIEN; |
792 | } | 918 | } |
793 | 919 | ||
794 | static inline struct ata_queued_cmd *ata_qc_from_tag (struct ata_port *ap, | 920 | static inline struct ata_queued_cmd *__ata_qc_from_tag(struct ata_port *ap, |
795 | unsigned int tag) | 921 | unsigned int tag) |
796 | { | 922 | { |
797 | if (likely(ata_tag_valid(tag))) | 923 | if (likely(ata_tag_valid(tag))) |
798 | return &ap->qcmd[tag]; | 924 | return &ap->qcmd[tag]; |
799 | return NULL; | 925 | return NULL; |
800 | } | 926 | } |
801 | 927 | ||
802 | static inline void ata_tf_init(struct ata_port *ap, struct ata_taskfile *tf, unsigned int device) | 928 | static inline struct ata_queued_cmd *ata_qc_from_tag(struct ata_port *ap, |
929 | unsigned int tag) | ||
930 | { | ||
931 | struct ata_queued_cmd *qc = __ata_qc_from_tag(ap, tag); | ||
932 | |||
933 | if (unlikely(!qc) || !ap->ops->error_handler) | ||
934 | return qc; | ||
935 | |||
936 | if ((qc->flags & (ATA_QCFLAG_ACTIVE | | ||
937 | ATA_QCFLAG_FAILED)) == ATA_QCFLAG_ACTIVE) | ||
938 | return qc; | ||
939 | |||
940 | return NULL; | ||
941 | } | ||
942 | |||
943 | static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf) | ||
803 | { | 944 | { |
804 | memset(tf, 0, sizeof(*tf)); | 945 | memset(tf, 0, sizeof(*tf)); |
805 | 946 | ||
806 | tf->ctl = ap->ctl; | 947 | tf->ctl = dev->ap->ctl; |
807 | if (device == 0) | 948 | if (dev->devno == 0) |
808 | tf->device = ATA_DEVICE_OBS; | 949 | tf->device = ATA_DEVICE_OBS; |
809 | else | 950 | else |
810 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; | 951 | tf->device = ATA_DEVICE_OBS | ATA_DEV1; |
@@ -819,26 +960,11 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
819 | qc->nbytes = qc->curbytes = 0; | 960 | qc->nbytes = qc->curbytes = 0; |
820 | qc->err_mask = 0; | 961 | qc->err_mask = 0; |
821 | 962 | ||
822 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | 963 | ata_tf_init(qc->dev, &qc->tf); |
823 | } | ||
824 | |||
825 | /** | ||
826 | * ata_qc_complete - Complete an active ATA command | ||
827 | * @qc: Command to complete | ||
828 | * @err_mask: ATA Status register contents | ||
829 | * | ||
830 | * Indicate to the mid and upper layers that an ATA | ||
831 | * command has completed, with either an ok or not-ok status. | ||
832 | * | ||
833 | * LOCKING: | ||
834 | * spin_lock_irqsave(host_set lock) | ||
835 | */ | ||
836 | static inline void ata_qc_complete(struct ata_queued_cmd *qc) | ||
837 | { | ||
838 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
839 | return; | ||
840 | 964 | ||
841 | __ata_qc_complete(qc); | 965 | /* init result_tf such that it indicates normal completion */ |
966 | qc->result_tf.command = ATA_DRDY; | ||
967 | qc->result_tf.feature = 0; | ||
842 | } | 968 | } |
843 | 969 | ||
844 | /** | 970 | /** |
@@ -917,28 +1043,6 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
917 | return status; | 1043 | return status; |
918 | } | 1044 | } |
919 | 1045 | ||
920 | static inline u32 scr_read(struct ata_port *ap, unsigned int reg) | ||
921 | { | ||
922 | return ap->ops->scr_read(ap, reg); | ||
923 | } | ||
924 | |||
925 | static inline void scr_write(struct ata_port *ap, unsigned int reg, u32 val) | ||
926 | { | ||
927 | ap->ops->scr_write(ap, reg, val); | ||
928 | } | ||
929 | |||
930 | static inline void scr_write_flush(struct ata_port *ap, unsigned int reg, | ||
931 | u32 val) | ||
932 | { | ||
933 | ap->ops->scr_write(ap, reg, val); | ||
934 | (void) ap->ops->scr_read(ap, reg); | ||
935 | } | ||
936 | |||
937 | static inline unsigned int sata_dev_present(struct ata_port *ap) | ||
938 | { | ||
939 | return ((scr_read(ap, SCR_STATUS) & 0xf) == 0x3) ? 1 : 0; | ||
940 | } | ||
941 | |||
942 | static inline int ata_try_flush_cache(const struct ata_device *dev) | 1046 | static inline int ata_try_flush_cache(const struct ata_device *dev) |
943 | { | 1047 | { |
944 | return ata_id_wcache_enabled(dev->id) || | 1048 | return ata_id_wcache_enabled(dev->id) || |
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); | |||
151 | extern void scsi_put_command(struct scsi_cmnd *); | 151 | extern void scsi_put_command(struct scsi_cmnd *); |
152 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); | 152 | extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); |
153 | extern void scsi_finish_command(struct scsi_cmnd *cmd); | 153 | extern void scsi_finish_command(struct scsi_cmnd *cmd); |
154 | extern 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_eh.h b/include/scsi/scsi_eh.h index d160880b2a87..212c983a6a18 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h | |||
@@ -35,6 +35,7 @@ static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr) | |||
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
38 | extern void scsi_eh_wakeup(struct Scsi_Host *shost); | ||
38 | extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, | 39 | extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, |
39 | struct list_head *done_q); | 40 | struct list_head *done_q); |
40 | extern void scsi_eh_flush_done_q(struct list_head *done_q); | 41 | extern void scsi_eh_flush_done_q(struct list_head *done_q); |
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 */ |