diff options
Diffstat (limited to 'include/linux/libata.h')
| -rw-r--r-- | include/linux/libata.h | 180 |
1 files changed, 137 insertions, 43 deletions
diff --git a/include/linux/libata.h b/include/linux/libata.h index c91be5e64ede..239408ecfddf 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 */ |
| @@ -61,15 +62,37 @@ | |||
| 61 | 62 | ||
| 62 | #define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) | 63 | #define BPRINTK(fmt, args...) if (ap->flags & ATA_FLAG_DEBUGMSG) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) |
| 63 | 64 | ||
| 64 | #ifdef ATA_NDEBUG | 65 | /* NEW: debug levels */ |
| 65 | #define assert(expr) | 66 | #define HAVE_LIBATA_MSG 1 |
| 66 | #else | 67 | |
| 67 | #define assert(expr) \ | 68 | enum { |
| 68 | if(unlikely(!(expr))) { \ | 69 | ATA_MSG_DRV = 0x0001, |
| 69 | printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ | 70 | ATA_MSG_INFO = 0x0002, |
| 70 | #expr,__FILE__,__FUNCTION__,__LINE__); \ | 71 | ATA_MSG_PROBE = 0x0004, |
| 71 | } | 72 | ATA_MSG_WARN = 0x0008, |
| 72 | #endif | 73 | ATA_MSG_MALLOC = 0x0010, |
| 74 | ATA_MSG_CTL = 0x0020, | ||
| 75 | ATA_MSG_INTR = 0x0040, | ||
| 76 | ATA_MSG_ERR = 0x0080, | ||
| 77 | }; | ||
| 78 | |||
| 79 | #define ata_msg_drv(p) ((p)->msg_enable & ATA_MSG_DRV) | ||
| 80 | #define ata_msg_info(p) ((p)->msg_enable & ATA_MSG_INFO) | ||
| 81 | #define ata_msg_probe(p) ((p)->msg_enable & ATA_MSG_PROBE) | ||
| 82 | #define ata_msg_warn(p) ((p)->msg_enable & ATA_MSG_WARN) | ||
| 83 | #define ata_msg_malloc(p) ((p)->msg_enable & ATA_MSG_MALLOC) | ||
| 84 | #define ata_msg_ctl(p) ((p)->msg_enable & ATA_MSG_CTL) | ||
| 85 | #define ata_msg_intr(p) ((p)->msg_enable & ATA_MSG_INTR) | ||
| 86 | #define ata_msg_err(p) ((p)->msg_enable & ATA_MSG_ERR) | ||
| 87 | |||
| 88 | static inline u32 ata_msg_init(int dval, int default_msg_enable_bits) | ||
| 89 | { | ||
| 90 | if (dval < 0 || dval >= (sizeof(u32) * 8)) | ||
| 91 | return default_msg_enable_bits; /* should be 0x1 - only driver info msgs */ | ||
| 92 | if (!dval) | ||
| 93 | return 0; | ||
| 94 | return (1 << dval) - 1; | ||
| 95 | } | ||
| 73 | 96 | ||
| 74 | /* defines only for the constants which don't work well as enums */ | 97 | /* defines only for the constants which don't work well as enums */ |
| 75 | #define ATA_TAG_POISON 0xfafbfcfdU | 98 | #define ATA_TAG_POISON 0xfafbfcfdU |
| @@ -99,8 +122,7 @@ enum { | |||
| 99 | /* struct ata_device stuff */ | 122 | /* struct ata_device stuff */ |
| 100 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ | 123 | ATA_DFLAG_LBA48 = (1 << 0), /* device supports LBA48 */ |
| 101 | ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ | 124 | ATA_DFLAG_PIO = (1 << 1), /* device currently in PIO mode */ |
| 102 | ATA_DFLAG_LOCK_SECTORS = (1 << 2), /* don't adjust max_sectors */ | 125 | ATA_DFLAG_LBA = (1 << 2), /* device supports LBA */ |
| 103 | ATA_DFLAG_LBA = (1 << 3), /* device supports LBA */ | ||
| 104 | 126 | ||
| 105 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 127 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
| 106 | ATA_DEV_ATA = 1, /* ATA device */ | 128 | ATA_DEV_ATA = 1, /* ATA device */ |
| @@ -115,9 +137,9 @@ enum { | |||
| 115 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ | 137 | ATA_FLAG_PORT_DISABLED = (1 << 2), /* port is disabled, ignore it */ |
| 116 | ATA_FLAG_SATA = (1 << 3), | 138 | ATA_FLAG_SATA = (1 << 3), |
| 117 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ | 139 | ATA_FLAG_NO_LEGACY = (1 << 4), /* no legacy mode check */ |
| 118 | ATA_FLAG_SRST = (1 << 5), /* use ATA SRST, not E.D.D. */ | 140 | ATA_FLAG_SRST = (1 << 5), /* (obsolete) use ATA SRST, not E.D.D. */ |
| 119 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ | 141 | ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ |
| 120 | ATA_FLAG_SATA_RESET = (1 << 7), /* use COMRESET */ | 142 | ATA_FLAG_SATA_RESET = (1 << 7), /* (obsolete) use COMRESET */ |
| 121 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ | 143 | ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ |
| 122 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once | 144 | ATA_FLAG_NOINTR = (1 << 9), /* FIXME: Remove this once |
| 123 | * proper HSM is in place. */ | 145 | * proper HSM is in place. */ |
| @@ -129,10 +151,14 @@ enum { | |||
| 129 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ | 151 | ATA_FLAG_PIO_LBA48 = (1 << 13), /* Host DMA engine is LBA28 only */ |
| 130 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ | 152 | ATA_FLAG_IRQ_MASK = (1 << 14), /* Mask IRQ in PIO xfers */ |
| 131 | 153 | ||
| 154 | ATA_FLAG_FLUSH_PORT_TASK = (1 << 15), /* Flush port task */ | ||
| 155 | ATA_FLAG_IN_EH = (1 << 16), /* EH in progress */ | ||
| 156 | |||
| 132 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ | 157 | ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ |
| 133 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ | 158 | ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ |
| 134 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ | 159 | ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ |
| 135 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, | 160 | ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE, |
| 161 | ATA_QCFLAG_EH_SCHEDULED = (1 << 5), /* EH scheduled */ | ||
| 136 | 162 | ||
| 137 | /* various lengths of time */ | 163 | /* various lengths of time */ |
| 138 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ | 164 | ATA_TMOUT_EDD = 5 * HZ, /* heuristic */ |
| @@ -162,11 +188,19 @@ enum { | |||
| 162 | PORT_DISABLED = 2, | 188 | PORT_DISABLED = 2, |
| 163 | 189 | ||
| 164 | /* encoding various smaller bitmaps into a single | 190 | /* encoding various smaller bitmaps into a single |
| 165 | * unsigned long bitmap | 191 | * unsigned int bitmap |
| 166 | */ | 192 | */ |
| 167 | ATA_SHIFT_UDMA = 0, | 193 | ATA_BITS_PIO = 5, |
| 168 | ATA_SHIFT_MWDMA = 8, | 194 | ATA_BITS_MWDMA = 3, |
| 169 | ATA_SHIFT_PIO = 11, | 195 | ATA_BITS_UDMA = 8, |
| 196 | |||
| 197 | ATA_SHIFT_PIO = 0, | ||
| 198 | ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_BITS_PIO, | ||
| 199 | ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA, | ||
| 200 | |||
| 201 | ATA_MASK_PIO = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO, | ||
| 202 | ATA_MASK_MWDMA = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA, | ||
| 203 | ATA_MASK_UDMA = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA, | ||
| 170 | 204 | ||
| 171 | /* size of buffer to pad xfers ending on unaligned boundaries */ | 205 | /* size of buffer to pad xfers ending on unaligned boundaries */ |
| 172 | ATA_DMA_PAD_SZ = 4, | 206 | ATA_DMA_PAD_SZ = 4, |
| @@ -189,10 +223,15 @@ enum hsm_task_states { | |||
| 189 | }; | 223 | }; |
| 190 | 224 | ||
| 191 | enum ata_completion_errors { | 225 | enum ata_completion_errors { |
| 192 | AC_ERR_OTHER = (1 << 0), | 226 | AC_ERR_DEV = (1 << 0), /* device reported error */ |
| 193 | AC_ERR_DEV = (1 << 1), | 227 | AC_ERR_HSM = (1 << 1), /* host state machine violation */ |
| 194 | AC_ERR_ATA_BUS = (1 << 2), | 228 | AC_ERR_TIMEOUT = (1 << 2), /* timeout */ |
| 195 | AC_ERR_HOST_BUS = (1 << 3), | 229 | AC_ERR_MEDIA = (1 << 3), /* media error */ |
| 230 | AC_ERR_ATA_BUS = (1 << 4), /* ATA bus error */ | ||
| 231 | AC_ERR_HOST_BUS = (1 << 5), /* host bus error */ | ||
| 232 | AC_ERR_SYSTEM = (1 << 6), /* system error */ | ||
| 233 | AC_ERR_INVALID = (1 << 7), /* invalid argument */ | ||
| 234 | AC_ERR_OTHER = (1 << 8), /* unknown */ | ||
| 196 | }; | 235 | }; |
| 197 | 236 | ||
| 198 | /* forward declarations */ | 237 | /* forward declarations */ |
| @@ -202,7 +241,10 @@ struct ata_port; | |||
| 202 | struct ata_queued_cmd; | 241 | struct ata_queued_cmd; |
| 203 | 242 | ||
| 204 | /* typedefs */ | 243 | /* typedefs */ |
| 205 | typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc); | 244 | typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); |
| 245 | typedef void (*ata_probeinit_fn_t)(struct ata_port *); | ||
| 246 | typedef int (*ata_reset_fn_t)(struct ata_port *, int, unsigned int *); | ||
| 247 | typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *); | ||
| 206 | 248 | ||
| 207 | struct ata_ioports { | 249 | struct ata_ioports { |
| 208 | unsigned long cmd_addr; | 250 | unsigned long cmd_addr; |
| @@ -305,7 +347,7 @@ struct ata_device { | |||
| 305 | unsigned long flags; /* ATA_DFLAG_xxx */ | 347 | unsigned long flags; /* ATA_DFLAG_xxx */ |
| 306 | unsigned int class; /* ATA_DEV_xxx */ | 348 | unsigned int class; /* ATA_DEV_xxx */ |
| 307 | unsigned int devno; /* 0 or 1 */ | 349 | unsigned int devno; /* 0 or 1 */ |
| 308 | u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */ | 350 | u16 *id; /* IDENTIFY xxx DEVICE data */ |
| 309 | u8 pio_mode; | 351 | u8 pio_mode; |
| 310 | u8 dma_mode; | 352 | u8 dma_mode; |
| 311 | u8 xfer_mode; | 353 | u8 xfer_mode; |
| @@ -313,6 +355,8 @@ struct ata_device { | |||
| 313 | 355 | ||
| 314 | unsigned int multi_count; /* sectors count for | 356 | unsigned int multi_count; /* sectors count for |
| 315 | READ/WRITE MULTIPLE */ | 357 | READ/WRITE MULTIPLE */ |
| 358 | unsigned int max_sectors; /* per-device max sectors */ | ||
| 359 | unsigned int cdb_len; | ||
| 316 | 360 | ||
| 317 | /* for CHS addressing */ | 361 | /* for CHS addressing */ |
| 318 | u16 cylinders; /* Number of cylinders */ | 362 | u16 cylinders; /* Number of cylinders */ |
| @@ -342,7 +386,6 @@ struct ata_port { | |||
| 342 | unsigned int mwdma_mask; | 386 | unsigned int mwdma_mask; |
| 343 | unsigned int udma_mask; | 387 | unsigned int udma_mask; |
| 344 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ | 388 | unsigned int cbl; /* cable type; ATA_CBL_xxx */ |
| 345 | unsigned int cdb_len; | ||
| 346 | 389 | ||
| 347 | struct ata_device device[ATA_MAX_DEVICES]; | 390 | struct ata_device device[ATA_MAX_DEVICES]; |
| 348 | 391 | ||
| @@ -353,12 +396,14 @@ struct ata_port { | |||
| 353 | struct ata_host_stats stats; | 396 | struct ata_host_stats stats; |
| 354 | struct ata_host_set *host_set; | 397 | struct ata_host_set *host_set; |
| 355 | 398 | ||
| 356 | struct work_struct packet_task; | 399 | struct work_struct port_task; |
| 357 | 400 | ||
| 358 | struct work_struct pio_task; | ||
| 359 | unsigned int hsm_task_state; | 401 | unsigned int hsm_task_state; |
| 360 | unsigned long pio_task_timeout; | 402 | unsigned long pio_task_timeout; |
| 361 | 403 | ||
| 404 | u32 msg_enable; | ||
| 405 | struct list_head eh_done_q; | ||
| 406 | |||
| 362 | void *private_data; | 407 | void *private_data; |
| 363 | }; | 408 | }; |
| 364 | 409 | ||
| @@ -378,7 +423,9 @@ struct ata_port_operations { | |||
| 378 | u8 (*check_altstatus)(struct ata_port *ap); | 423 | u8 (*check_altstatus)(struct ata_port *ap); |
| 379 | void (*dev_select)(struct ata_port *ap, unsigned int device); | 424 | void (*dev_select)(struct ata_port *ap, unsigned int device); |
| 380 | 425 | ||
| 381 | void (*phy_reset) (struct ata_port *ap); | 426 | void (*phy_reset) (struct ata_port *ap); /* obsolete */ |
| 427 | int (*probe_reset) (struct ata_port *ap, unsigned int *classes); | ||
| 428 | |||
| 382 | void (*post_set_mode) (struct ata_port *ap); | 429 | void (*post_set_mode) (struct ata_port *ap); |
| 383 | 430 | ||
| 384 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); | 431 | int (*check_atapi_dma) (struct ata_queued_cmd *qc); |
| @@ -387,7 +434,7 @@ struct ata_port_operations { | |||
| 387 | void (*bmdma_start) (struct ata_queued_cmd *qc); | 434 | void (*bmdma_start) (struct ata_queued_cmd *qc); |
| 388 | 435 | ||
| 389 | void (*qc_prep) (struct ata_queued_cmd *qc); | 436 | void (*qc_prep) (struct ata_queued_cmd *qc); |
| 390 | int (*qc_issue) (struct ata_queued_cmd *qc); | 437 | unsigned int (*qc_issue) (struct ata_queued_cmd *qc); |
| 391 | 438 | ||
| 392 | void (*eng_timeout) (struct ata_port *ap); | 439 | void (*eng_timeout) (struct ata_port *ap); |
| 393 | 440 | ||
| @@ -435,6 +482,18 @@ extern void ata_port_probe(struct ata_port *); | |||
| 435 | extern void __sata_phy_reset(struct ata_port *ap); | 482 | extern void __sata_phy_reset(struct ata_port *ap); |
| 436 | extern void sata_phy_reset(struct ata_port *ap); | 483 | extern void sata_phy_reset(struct ata_port *ap); |
| 437 | extern void ata_bus_reset(struct ata_port *ap); | 484 | extern void ata_bus_reset(struct ata_port *ap); |
| 485 | extern int ata_drive_probe_reset(struct ata_port *ap, | ||
| 486 | ata_probeinit_fn_t probeinit, | ||
| 487 | ata_reset_fn_t softreset, ata_reset_fn_t hardreset, | ||
| 488 | ata_postreset_fn_t postreset, unsigned int *classes); | ||
| 489 | extern void ata_std_probeinit(struct ata_port *ap); | ||
| 490 | extern int ata_std_softreset(struct ata_port *ap, int verbose, | ||
| 491 | unsigned int *classes); | ||
| 492 | extern int sata_std_hardreset(struct ata_port *ap, int verbose, | ||
| 493 | unsigned int *class); | ||
| 494 | extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); | ||
| 495 | extern int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev, | ||
| 496 | int post_reset); | ||
| 438 | extern void ata_port_disable(struct ata_port *); | 497 | extern void ata_port_disable(struct ata_port *); |
| 439 | extern void ata_std_ports(struct ata_ioports *ioaddr); | 498 | extern void ata_std_ports(struct ata_ioports *ioaddr); |
| 440 | #ifdef CONFIG_PCI | 499 | #ifdef CONFIG_PCI |
| @@ -449,7 +508,10 @@ extern void ata_host_set_remove(struct ata_host_set *host_set); | |||
| 449 | extern int ata_scsi_detect(struct scsi_host_template *sht); | 508 | 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); | 509 | 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 *)); | 510 | extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); |
| 511 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | ||
| 452 | extern int ata_scsi_error(struct Scsi_Host *host); | 512 | extern int ata_scsi_error(struct Scsi_Host *host); |
| 513 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 514 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 453 | extern int ata_scsi_release(struct Scsi_Host *host); | 515 | 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); | 516 | 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 *); | 517 | extern int ata_scsi_device_resume(struct scsi_device *); |
| @@ -457,6 +519,11 @@ extern int ata_scsi_device_suspend(struct scsi_device *); | |||
| 457 | extern int ata_device_resume(struct ata_port *, struct ata_device *); | 519 | extern int ata_device_resume(struct ata_port *, struct ata_device *); |
| 458 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); | 520 | extern int ata_device_suspend(struct ata_port *, struct ata_device *); |
| 459 | extern int ata_ratelimit(void); | 521 | extern int ata_ratelimit(void); |
| 522 | extern unsigned int ata_busy_sleep(struct ata_port *ap, | ||
| 523 | unsigned long timeout_pat, | ||
| 524 | unsigned long timeout); | ||
| 525 | extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), | ||
| 526 | void *data, unsigned long delay); | ||
| 460 | 527 | ||
| 461 | /* | 528 | /* |
| 462 | * Default driver ops implementations | 529 | * Default driver ops implementations |
| @@ -470,26 +537,28 @@ extern void ata_std_dev_select (struct ata_port *ap, unsigned int device); | |||
| 470 | extern u8 ata_check_status(struct ata_port *ap); | 537 | extern u8 ata_check_status(struct ata_port *ap); |
| 471 | extern u8 ata_altstatus(struct ata_port *ap); | 538 | extern u8 ata_altstatus(struct ata_port *ap); |
| 472 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); | 539 | extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf); |
| 540 | extern int ata_std_probe_reset(struct ata_port *ap, unsigned int *classes); | ||
| 473 | extern int ata_port_start (struct ata_port *ap); | 541 | extern int ata_port_start (struct ata_port *ap); |
| 474 | extern void ata_port_stop (struct ata_port *ap); | 542 | extern void ata_port_stop (struct ata_port *ap); |
| 475 | extern void ata_host_stop (struct ata_host_set *host_set); | 543 | 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); | 544 | 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); | 545 | extern void ata_qc_prep(struct ata_queued_cmd *qc); |
| 478 | extern int ata_qc_issue_prot(struct ata_queued_cmd *qc); | 546 | 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, | 547 | extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf, |
| 480 | unsigned int buflen); | 548 | unsigned int buflen); |
| 481 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, | 549 | extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, |
| 482 | unsigned int n_elem); | 550 | unsigned int n_elem); |
| 483 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); | 551 | extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); |
| 484 | extern void ata_dev_id_string(const u16 *id, unsigned char *s, | 552 | extern void ata_id_string(const u16 *id, unsigned char *s, |
| 485 | unsigned int ofs, unsigned int len); | 553 | unsigned int ofs, unsigned int len); |
| 486 | extern void ata_dev_config(struct ata_port *ap, unsigned int i); | 554 | extern void ata_id_c_string(const u16 *id, unsigned char *s, |
| 555 | unsigned int ofs, unsigned int len); | ||
| 487 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); | 556 | extern void ata_bmdma_setup (struct ata_queued_cmd *qc); |
| 488 | extern void ata_bmdma_start (struct ata_queued_cmd *qc); | 557 | extern void ata_bmdma_start (struct ata_queued_cmd *qc); |
| 489 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); | 558 | extern void ata_bmdma_stop(struct ata_queued_cmd *qc); |
| 490 | extern u8 ata_bmdma_status(struct ata_port *ap); | 559 | extern u8 ata_bmdma_status(struct ata_port *ap); |
| 491 | extern void ata_bmdma_irq_clear(struct ata_port *ap); | 560 | extern void ata_bmdma_irq_clear(struct ata_port *ap); |
| 492 | extern void ata_qc_complete(struct ata_queued_cmd *qc); | 561 | extern void __ata_qc_complete(struct ata_queued_cmd *qc); |
| 493 | extern void ata_eng_timeout(struct ata_port *ap); | 562 | extern void ata_eng_timeout(struct ata_port *ap); |
| 494 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, | 563 | extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, |
| 495 | struct scsi_cmnd *cmd, | 564 | struct scsi_cmnd *cmd, |
| @@ -586,10 +655,14 @@ static inline unsigned int ata_tag_valid(unsigned int tag) | |||
| 586 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; | 655 | return (tag < ATA_MAX_QUEUE) ? 1 : 0; |
| 587 | } | 656 | } |
| 588 | 657 | ||
| 658 | static inline unsigned int ata_class_present(unsigned int class) | ||
| 659 | { | ||
| 660 | return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI; | ||
| 661 | } | ||
| 662 | |||
| 589 | static inline unsigned int ata_dev_present(const struct ata_device *dev) | 663 | static inline unsigned int ata_dev_present(const struct ata_device *dev) |
| 590 | { | 664 | { |
| 591 | return ((dev->class == ATA_DEV_ATA) || | 665 | return ata_class_present(dev->class); |
| 592 | (dev->class == ATA_DEV_ATAPI)); | ||
| 593 | } | 666 | } |
| 594 | 667 | ||
| 595 | static inline u8 ata_chk_status(struct ata_port *ap) | 668 | static inline u8 ata_chk_status(struct ata_port *ap) |
| @@ -657,9 +730,9 @@ static inline u8 ata_wait_idle(struct ata_port *ap) | |||
| 657 | 730 | ||
| 658 | if (status & (ATA_BUSY | ATA_DRQ)) { | 731 | if (status & (ATA_BUSY | ATA_DRQ)) { |
| 659 | unsigned long l = ap->ioaddr.status_addr; | 732 | unsigned long l = ap->ioaddr.status_addr; |
| 660 | printk(KERN_WARNING | 733 | if (ata_msg_warn(ap)) |
| 661 | "ATA: abnormal status 0x%X on port 0x%lX\n", | 734 | printk(KERN_WARNING "ATA: abnormal status 0x%X on port 0x%lX\n", |
| 662 | status, l); | 735 | status, l); |
| 663 | } | 736 | } |
| 664 | 737 | ||
| 665 | return status; | 738 | return status; |
| @@ -701,6 +774,24 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) | |||
| 701 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); | 774 | ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); |
| 702 | } | 775 | } |
| 703 | 776 | ||
| 777 | /** | ||
| 778 | * ata_qc_complete - Complete an active ATA command | ||
| 779 | * @qc: Command to complete | ||
| 780 | * @err_mask: ATA Status register contents | ||
| 781 | * | ||
| 782 | * Indicate to the mid and upper layers that an ATA | ||
| 783 | * command has completed, with either an ok or not-ok status. | ||
| 784 | * | ||
| 785 | * LOCKING: | ||
| 786 | * spin_lock_irqsave(host_set lock) | ||
| 787 | */ | ||
| 788 | static inline void ata_qc_complete(struct ata_queued_cmd *qc) | ||
| 789 | { | ||
| 790 | if (unlikely(qc->flags & ATA_QCFLAG_EH_SCHEDULED)) | ||
| 791 | return; | ||
| 792 | |||
| 793 | __ata_qc_complete(qc); | ||
| 794 | } | ||
| 704 | 795 | ||
| 705 | /** | 796 | /** |
| 706 | * ata_irq_on - Enable interrupts on a port. | 797 | * ata_irq_on - Enable interrupts on a port. |
| @@ -751,7 +842,8 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
| 751 | 842 | ||
| 752 | status = ata_busy_wait(ap, bits, 1000); | 843 | status = ata_busy_wait(ap, bits, 1000); |
| 753 | if (status & bits) | 844 | if (status & bits) |
| 754 | DPRINTK("abnormal status 0x%X\n", status); | 845 | if (ata_msg_err(ap)) |
| 846 | printk(KERN_ERR "abnormal status 0x%X\n", status); | ||
| 755 | 847 | ||
| 756 | /* get controller status; clear intr, err bits */ | 848 | /* get controller status; clear intr, err bits */ |
| 757 | if (ap->flags & ATA_FLAG_MMIO) { | 849 | if (ap->flags & ATA_FLAG_MMIO) { |
| @@ -769,8 +861,10 @@ static inline u8 ata_irq_ack(struct ata_port *ap, unsigned int chk_drq) | |||
| 769 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); | 861 | post_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); |
| 770 | } | 862 | } |
| 771 | 863 | ||
| 772 | VPRINTK("irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", | 864 | if (ata_msg_intr(ap)) |
| 773 | host_stat, post_stat, status); | 865 | printk(KERN_INFO "%s: irq ack: host_stat 0x%X, new host_stat 0x%X, drv_stat 0x%X\n", |
| 866 | __FUNCTION__, | ||
| 867 | host_stat, post_stat, status); | ||
| 774 | 868 | ||
| 775 | return status; | 869 | return status; |
| 776 | } | 870 | } |
| @@ -807,7 +901,7 @@ static inline int ata_try_flush_cache(const struct ata_device *dev) | |||
| 807 | static inline unsigned int ac_err_mask(u8 status) | 901 | static inline unsigned int ac_err_mask(u8 status) |
| 808 | { | 902 | { |
| 809 | if (status & ATA_BUSY) | 903 | if (status & ATA_BUSY) |
| 810 | return AC_ERR_ATA_BUS; | 904 | return AC_ERR_HSM; |
| 811 | if (status & (ATA_ERR | ATA_DF)) | 905 | if (status & (ATA_ERR | ATA_DF)) |
| 812 | return AC_ERR_DEV; | 906 | return AC_ERR_DEV; |
| 813 | return 0; | 907 | return 0; |
