diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/ata.h | 12 | ||||
-rw-r--r-- | include/linux/libata.h | 106 |
2 files changed, 100 insertions, 18 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 94f77cce27fa..a8155ca4947f 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -302,4 +302,16 @@ static inline int ata_ok(u8 status) | |||
302 | == ATA_DRDY); | 302 | == ATA_DRDY); |
303 | } | 303 | } |
304 | 304 | ||
305 | static inline int lba_28_ok(u64 block, u32 n_block) | ||
306 | { | ||
307 | /* check the ending block number */ | ||
308 | return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256); | ||
309 | } | ||
310 | |||
311 | static inline int lba_48_ok(u64 block, u32 n_block) | ||
312 | { | ||
313 | /* check the ending block number */ | ||
314 | return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); | ||
315 | } | ||
316 | |||
305 | #endif /* __LINUX_ATA_H__ */ | 317 | #endif /* __LINUX_ATA_H__ */ |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 9e5db2949c58..c1e198655bb1 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -35,7 +35,8 @@ | |||
35 | #include <linux/workqueue.h> | 35 | #include <linux/workqueue.h> |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * compile-time options | 38 | * compile-time options: to be removed as soon as all the drivers are |
39 | * converted to the new debugging mechanism | ||
39 | */ | 40 | */ |
40 | #undef ATA_DEBUG /* debugging output */ | 41 | #undef ATA_DEBUG /* debugging output */ |
41 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ | 42 | #undef ATA_VERBOSE_DEBUG /* yet more debugging output */ |
@@ -71,6 +72,38 @@ | |||
71 | } | 72 | } |
72 | #endif | 73 | #endif |
73 | 74 | ||
75 | /* NEW: debug levels */ | ||
76 | #define HAVE_LIBATA_MSG 1 | ||
77 | |||
78 | enum { | ||
79 | ATA_MSG_DRV = 0x0001, | ||
80 | ATA_MSG_INFO = 0x0002, | ||
81 | ATA_MSG_PROBE = 0x0004, | ||
82 | ATA_MSG_WARN = 0x0008, | ||
83 | ATA_MSG_MALLOC = 0x0010, | ||
84 | ATA_MSG_CTL = 0x0020, | ||
85 | ATA_MSG_INTR = 0x0040, | ||
86 | ATA_MSG_ERR = 0x0080, | ||
87 | }; | ||
88 | |||
89 | #define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV) | ||
90 | #define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO) | ||
91 | #define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE) | ||
92 | #define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN) | ||
93 | #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC) | ||
94 | #define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL) | ||
95 | #define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR) | ||
96 | #define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR) | ||
97 | |||
98 | static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) | ||
99 | { | ||
100 | if (dval < 0 || dval >= (sizeof(u32) * 8)) | ||
101 | return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */ | ||
102 | if (!dval) | ||
103 | return 0; | ||
104 | return (1 << dval) - 1; | ||
105 | } | ||
106 | |||
74 | /* defines only for the constants which don't work well as enums */ | 107 | /* defines only for the constants which don't work well as enums */ |
75 | #define ATA_TAG_POISON 0xfafbfcfdU | 108 | #define ATA_TAG_POISON 0xfafbfcfdU |
76 | 109 | ||
@@ -115,9 +148,9 @@ enum { | |||
115 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 148 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ |
116 | ATA_FLAG_SATA = (1 << 3), | 149 | ATA_FLAG_SATA = (1 << 3), |
117 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 150 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ |
118 | ATA_FLAG_SRST = (1 << 5), /* use ATA SRST, not E.D.D. */ | 151 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ |
119 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 152 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ |
120 | ATA_FLAG_SATA_RESET = (1 << 7), /* use COMRESET */ | 153 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ |
121 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 154 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ |
122 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 155 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once |
123 | * proper HSM is in place. */ | 156 | * proper HSM is in place. */ |
@@ -129,10 +162,14 @@ enum { | |||
129 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 162 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ |
130 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 163 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ |
131 | 164 | ||
165 | ATA_FLAG_FLUSH_PIO_TASK = (1 << 15), /* Flush PIO task */ | ||
166 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | ||
167 | |||
132 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 168 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ |
133 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 169 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ |
134 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 170 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ |
135 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 171 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
172 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | ||
136 | 173 | ||
137 | /* various lengths of time */ | 174 | /* various lengths of time */ |
138 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ | 175 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ |
@@ -189,10 +226,15 @@ enum hsm_task_states { | |||
189 | }; | 226 | }; |
190 | 227 | ||
191 | enum ata_completion_errors { | 228 | enum ata_completion_errors { |
192 | AC_ERR_OTHER = (1 << 0), | 229 | AC_ERR_DEV = (1 << 0), /* device reported error */ |
193 | AC_ERR_DEV = (1 << 1), | 230 | AC_ERR_HSM = (1 << 1), /* host state machine violation */ |
194 | AC_ERR_ATA_BUS = (1 << 2), | 231 | AC_ERR_TIMEOUT = (1 << 2), /* timeout */ |
195 | AC_ERR_HOST_BUS = (1 << 3), | 232 | AC_ERR_MEDIA = (1 << 3), /* media error */ |
233 | AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */ | ||
234 | AC_ERR_HOST_BUS = (1 << 5), /* host bus error */ | ||
235 | AC_ERR_SYSTEM = (1 << 6), /* system error */ | ||
236 | AC_ERR_INVALID = (1 << 7), /* invalid argument */ | ||
237 | AC_ERR_OTHER = (1 << 8), /* unknown */ | ||
196 | }; | 238 | }; |
197 | 239 | ||
198 | /* forward declarations */ | 240 | /* forward declarations */ |
@@ -202,7 +244,10 @@ struct ata_port; | |||
202 | struct ata_queued_cmd; | 244 | struct ata_queued_cmd; |
203 | 245 | ||
204 | /* typedefs */ | 246 | /* typedefs */ |
205 | typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 247 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
248 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | ||
249 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | ||
250 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | ||
206 | 251 | ||
207 | struct ata_ioports { | 252 | struct ata_ioports { |
208 | unsigned long cmd_addr; | 253 | unsigned long cmd_addr; |
@@ -359,6 +404,9 @@ struct ata_port { | |||
359 | unsigned int hsm_task_state; | 404 | unsigned int hsm_task_state; |
360 | unsigned long pio_task_timeout; | 405 | unsigned long pio_task_timeout; |
361 | 406 | ||
407 | u32 msg_enable; | ||
408 | struct list_head eh_done_q; | ||
409 | |||
362 | void *private_data; | 410 | void *private_data; |
363 | }; | 411 | }; |
364 | 412 | ||
@@ -378,7 +426,9 @@ struct ata_port_operations { | |||
378 | u8 (*check_altstatus)(struct ata_port *ap); | 426 | u8 (*check_altstatus)(struct ata_port *ap); |
379 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 427 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
380 | 428 | ||
381 | void (*phy_reset) (struct ata_port *ap); | 429 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
430 | int (*probe_reset) (struct ata_port *ap, unsigned int *classes); | ||
431 | |||
382 | void (*post_set_mode) (struct ata_port *ap); | 432 | void (*post_set_mode) (struct ata_port *ap); |
383 | 433 | ||
384 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | 434 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); |
@@ -387,7 +437,7 @@ struct ata_port_operations { | |||
387 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 437 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
388 | 438 | ||
389 | void (*qc_prep) (struct ata_queued_cmd *qc); | 439 | void (*qc_prep) (struct ata_queued_cmd *qc); |
390 | int (*qc_issue) (struct ata_queued_cmd *qc); | 440 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
391 | 441 | ||
392 | void (*eng_timeout) (struct ata_port *ap); | 442 | void (*eng_timeout) (struct ata_port *ap); |
393 | 443 | ||
@@ -435,6 +485,16 @@ extern void ata_port_probe(struct ata_port *); | |||
435 | extern void __sata_phy_reset(struct ata_port *ap); | 485 | extern void __sata_phy_reset(struct ata_port *ap); |
436 | extern void sata_phy_reset(struct ata_port *ap); | 486 | extern void sata_phy_reset(struct ata_port *ap); |
437 | extern void ata_bus_reset(struct ata_port *ap); | 487 | extern void ata_bus_reset(struct ata_port *ap); |
488 | extern int ata_drive_probe_reset(struct ata_port *ap, | ||
489 | ata_probeinit_fn_t probeinit, | ||
490 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
491 | ata_postreset_fn_t postreset, unsigned int *classes); | ||
492 | extern void ata_std_probeinit(struct ata_port *ap); | ||
493 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | ||
494 | unsigned int *classes); | ||
495 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
496 | unsigned int *class); | ||
497 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | ||
438 | extern void ata_port_disable(struct ata_port *); | 498 | extern void ata_port_disable(struct ata_port *); |
439 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 499 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
440 | #ifdef CONFIG_PCI | 500 | #ifdef CONFIG_PCI |
@@ -449,7 +509,10 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
449 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 509 | extern int ata_scsi_detect(struct scsi_host_template *sht); |
450 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); | 510 | extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg); |
451 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); | 511 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
512 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
452 | extern int ata_scsi_error(struct Scsi_Host *host); | 513 | extern int ata_scsi_error(struct Scsi_Host *host); |
514 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
515 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
453 | extern int ata_scsi_release(struct Scsi_Host *host); | 516 | extern int ata_scsi_release(struct Scsi_Host *host); |
454 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); | 517 | extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); |
455 | extern int ata_scsi_device_resume(struct scsi_device *); | 518 | extern int ata_scsi_device_resume(struct scsi_device *); |
@@ -457,6 +520,9 @@ extern int ata_scsi_device_suspend(struct scsi_device *); | |||
457 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 520 | extern int ata_device_resume(struct ata_port *, struct ata_device *); |
458 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); | 521 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); |
459 | extern int ata_ratelimit(void); | 522 | extern int ata_ratelimit(void); |
523 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | ||
524 | unsigned long timeout_pat, | ||
525 | unsigned long timeout); | ||
460 | 526 | ||
461 | /* | 527 | /* |
462 | * Default driver ops implementations | 528 | * Default driver ops implementations |
@@ -470,12 +536,13 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | |||
470 | extern u8 ata_check_status(struct ata_port *ap); | 536 | extern u8 ata_check_status(struct ata_port *ap); |
471 | extern u8 ata_altstatus(struct ata_port *ap); | 537 | extern u8 ata_altstatus(struct ata_port *ap); |
472 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 538 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
539 | extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes); | ||
473 | extern int ata_port_start (struct ata_port *ap); | 540 | extern int ata_port_start (struct ata_port *ap); |
474 | extern void ata_port_stop (struct ata_port *ap); | 541 | extern void ata_port_stop (struct ata_port *ap); |
475 | extern void ata_host_stop (struct ata_host_set *host_set); | 542 | extern void ata_host_stop (struct ata_host_set *host_set); |
476 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); | 543 | extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs); |
477 | extern void ata_qc_prep(struct ata_queued_cmd *qc); | 544 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
478 | extern int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 545 | extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); |
479 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, | 546 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, |
480 | unsigned int buflen); | 547 | unsigned int buflen); |
481 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 548 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
@@ -645,9 +712,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
645 | 712 | ||
646 | if (status & (ATA_BUSY | ATA_DRQ)) { | 713 | if (status & (ATA_BUSY | ATA_DRQ)) { |
647 | unsigned long l = ap->ioaddr.status_addr; | 714 | unsigned long l = ap->ioaddr.status_addr; |
648 | printk(KERN_WARNING | 715 | if (ata_msg_warn(ap)) |
649 | "ATA: abnormal status 0x%X on port 0x%lX\n", | 716 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", |
650 | status, l); | 717 | status, l); |
651 | } | 718 | } |
652 | 719 | ||
653 | return status; | 720 | return status; |
@@ -739,7 +806,8 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
739 | 806 | ||
740 | status = ata_busy_wait(ap, bits, 1000); | 807 | status = ata_busy_wait(ap, bits, 1000); |
741 | if (status & bits) | 808 | if (status & bits) |
742 | DPRINTK("abnormal status 0x%X\n", status); | 809 | if (ata_msg_err(ap)) |
810 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
743 | 811 | ||
744 | /* get controller status; clear intr, err bits */ | 812 | /* get controller status; clear intr, err bits */ |
745 | if (ap->flags & ATA_FLAG_MMIO) { | 813 | if (ap->flags & ATA_FLAG_MMIO) { |
@@ -757,8 +825,10 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
757 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 825 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); |
758 | } | 826 | } |
759 | 827 | ||
760 | VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | 828 | if (ata_msg_intr(ap)) |
761 | host_stat, post_stat, status); | 829 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", |
830 | __FUNCTION__, | ||
831 | host_stat, post_stat, status); | ||
762 | 832 | ||
763 | return status; | 833 | return status; |
764 | } | 834 | } |
@@ -795,7 +865,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
795 | static inline unsigned int ac_err_mask(u8 status) | 865 | static inline unsigned int ac_err_mask(u8 status) |
796 | { | 866 | { |
797 | if (status & ATA_BUSY) | 867 | if (status & ATA_BUSY) |
798 | return AC_ERR_ATA_BUS; | 868 | return AC_ERR_HSM; |
799 | if (status & (ATA_ERR | ATA_DF)) | 869 | if (status & (ATA_ERR | ATA_DF)) |
800 | return AC_ERR_DEV; | 870 | return AC_ERR_DEV; |
801 | return 0; | 871 | return 0; |