diff options
author | Tejun Heo <htejun@gmail.com> | 2008-03-25 09:16:41 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-17 15:44:18 -0400 |
commit | 624d5c514eed18d5a93062e9d86d67065175f30a (patch) | |
tree | 61f89b05b70e9b443cf09083b4ae3d102dd357b7 /drivers/ata/libata-core.c | |
parent | 272f7884e8c0effe594e5537092b9c0ccc0140b0 (diff) |
libata: reorganize SFF related stuff
* Move SFF related functions from libata-core.c to libata-sff.c.
ata_[bmdma_]sff_port_ops, ata_devchk(), ata_dev_try_classify(),
ata_std_dev_select(), ata_tf_to_host(), ata_busy_sleep(),
ata_wait_after_reset(), ata_wait_ready(), ata_bus_post_reset(),
ata_bus_softreset(), ata_bus_reset(), ata_std_softreset(),
sata_std_hardreset(), ata_fill_sg(), ata_fill_sg_dumb(),
ata_qc_prep(), ata_dump_qc_prep(), ata_data_xfer(),
ata_data_xfer_noirq(), ata_pio_sector(), ata_pio_sectors(),
atapi_send_cdb(), __atapi_pio_bytes(), atapi_pio_bytes(),
ata_hsm_ok_in_wq(), ata_hsm_qc_complete(), ata_hsm_move(),
ata_pio_task(), ata_qc_issue_prot(), ata_host_intr(),
ata_interrupt(), ata_std_ports()
* Make ata_pio_queue_task() global as it's now called from
libata-sff.c.
* Move SFF related stuff in include/linux/libata.h and
drivers/ata/libata.h into one place. While at it, move timing
constants into the global enum definition and fortify comments a
bit.
This patch strictly moves stuff around and as such doesn't cause any
functional difference.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 1884 |
1 files changed, 9 insertions, 1875 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 7860d9f60ae4..34c068f18350 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/list.h> | 47 | #include <linux/list.h> |
48 | #include <linux/mm.h> | 48 | #include <linux/mm.h> |
49 | #include <linux/highmem.h> | ||
50 | #include <linux/spinlock.h> | 49 | #include <linux/spinlock.h> |
51 | #include <linux/blkdev.h> | 50 | #include <linux/blkdev.h> |
52 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
@@ -98,41 +97,6 @@ const struct ata_port_operations sata_pmp_port_ops = { | |||
98 | .error_handler = sata_pmp_error_handler, | 97 | .error_handler = sata_pmp_error_handler, |
99 | }; | 98 | }; |
100 | 99 | ||
101 | const struct ata_port_operations ata_sff_port_ops = { | ||
102 | .inherits = &ata_base_port_ops, | ||
103 | |||
104 | .qc_prep = ata_qc_prep, | ||
105 | .qc_issue = ata_qc_issue_prot, | ||
106 | |||
107 | .freeze = ata_bmdma_freeze, | ||
108 | .thaw = ata_bmdma_thaw, | ||
109 | .softreset = ata_std_softreset, | ||
110 | .error_handler = ata_bmdma_error_handler, | ||
111 | .post_internal_cmd = ata_bmdma_post_internal_cmd, | ||
112 | |||
113 | .dev_select = ata_std_dev_select, | ||
114 | .check_status = ata_check_status, | ||
115 | .tf_load = ata_tf_load, | ||
116 | .tf_read = ata_tf_read, | ||
117 | .exec_command = ata_exec_command, | ||
118 | .data_xfer = ata_data_xfer, | ||
119 | .irq_on = ata_irq_on, | ||
120 | |||
121 | .port_start = ata_sff_port_start, | ||
122 | }; | ||
123 | |||
124 | const struct ata_port_operations ata_bmdma_port_ops = { | ||
125 | .inherits = &ata_sff_port_ops, | ||
126 | |||
127 | .mode_filter = ata_pci_default_filter, | ||
128 | |||
129 | .bmdma_setup = ata_bmdma_setup, | ||
130 | .bmdma_start = ata_bmdma_start, | ||
131 | .bmdma_stop = ata_bmdma_stop, | ||
132 | .bmdma_status = ata_bmdma_status, | ||
133 | .irq_clear = ata_bmdma_irq_clear, | ||
134 | }; | ||
135 | |||
136 | static unsigned int ata_dev_init_params(struct ata_device *dev, | 100 | static unsigned int ata_dev_init_params(struct ata_device *dev, |
137 | u16 heads, u16 sectors); | 101 | u16 heads, u16 sectors); |
138 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); | 102 | static unsigned int ata_dev_set_xfermode(struct ata_device *dev); |
@@ -423,6 +387,14 @@ int atapi_cmd_type(u8 opcode) | |||
423 | } | 387 | } |
424 | 388 | ||
425 | /** | 389 | /** |
390 | * ata_noop_irq_clear - Noop placeholder for irq_clear | ||
391 | * @ap: Port associated with this ATA transaction. | ||
392 | */ | ||
393 | void ata_noop_irq_clear(struct ata_port *ap) | ||
394 | { | ||
395 | } | ||
396 | |||
397 | /** | ||
426 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure | 398 | * ata_tf_to_fis - Convert ATA taskfile to SATA FIS structure |
427 | * @tf: Taskfile to convert | 399 | * @tf: Taskfile to convert |
428 | * @pmp: Port multiplier port | 400 | * @pmp: Port multiplier port |
@@ -1102,50 +1074,6 @@ static void ata_lpm_disable(struct ata_host *host) | |||
1102 | } | 1074 | } |
1103 | #endif /* CONFIG_PM */ | 1075 | #endif /* CONFIG_PM */ |
1104 | 1076 | ||
1105 | |||
1106 | /** | ||
1107 | * ata_devchk - PATA device presence detection | ||
1108 | * @ap: ATA channel to examine | ||
1109 | * @device: Device to examine (starting at zero) | ||
1110 | * | ||
1111 | * This technique was originally described in | ||
1112 | * Hale Landis's ATADRVR (www.ata-atapi.com), and | ||
1113 | * later found its way into the ATA/ATAPI spec. | ||
1114 | * | ||
1115 | * Write a pattern to the ATA shadow registers, | ||
1116 | * and if a device is present, it will respond by | ||
1117 | * correctly storing and echoing back the | ||
1118 | * ATA shadow register contents. | ||
1119 | * | ||
1120 | * LOCKING: | ||
1121 | * caller. | ||
1122 | */ | ||
1123 | |||
1124 | static unsigned int ata_devchk(struct ata_port *ap, unsigned int device) | ||
1125 | { | ||
1126 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
1127 | u8 nsect, lbal; | ||
1128 | |||
1129 | ap->ops->dev_select(ap, device); | ||
1130 | |||
1131 | iowrite8(0x55, ioaddr->nsect_addr); | ||
1132 | iowrite8(0xaa, ioaddr->lbal_addr); | ||
1133 | |||
1134 | iowrite8(0xaa, ioaddr->nsect_addr); | ||
1135 | iowrite8(0x55, ioaddr->lbal_addr); | ||
1136 | |||
1137 | iowrite8(0x55, ioaddr->nsect_addr); | ||
1138 | iowrite8(0xaa, ioaddr->lbal_addr); | ||
1139 | |||
1140 | nsect = ioread8(ioaddr->nsect_addr); | ||
1141 | lbal = ioread8(ioaddr->lbal_addr); | ||
1142 | |||
1143 | if ((nsect == 0x55) && (lbal == 0xaa)) | ||
1144 | return 1; /* we found a device */ | ||
1145 | |||
1146 | return 0; /* nothing found */ | ||
1147 | } | ||
1148 | |||
1149 | /** | 1077 | /** |
1150 | * ata_dev_classify - determine device type based on ATA-spec signature | 1078 | * ata_dev_classify - determine device type based on ATA-spec signature |
1151 | * @tf: ATA taskfile register set for device to be identified | 1079 | * @tf: ATA taskfile register set for device to be identified |
@@ -1206,75 +1134,6 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf) | |||
1206 | } | 1134 | } |
1207 | 1135 | ||
1208 | /** | 1136 | /** |
1209 | * ata_dev_try_classify - Parse returned ATA device signature | ||
1210 | * @dev: ATA device to classify (starting at zero) | ||
1211 | * @present: device seems present | ||
1212 | * @r_err: Value of error register on completion | ||
1213 | * | ||
1214 | * After an event -- SRST, E.D.D., or SATA COMRESET -- occurs, | ||
1215 | * an ATA/ATAPI-defined set of values is placed in the ATA | ||
1216 | * shadow registers, indicating the results of device detection | ||
1217 | * and diagnostics. | ||
1218 | * | ||
1219 | * Select the ATA device, and read the values from the ATA shadow | ||
1220 | * registers. Then parse according to the Error register value, | ||
1221 | * and the spec-defined values examined by ata_dev_classify(). | ||
1222 | * | ||
1223 | * LOCKING: | ||
1224 | * caller. | ||
1225 | * | ||
1226 | * RETURNS: | ||
1227 | * Device type - %ATA_DEV_ATA, %ATA_DEV_ATAPI or %ATA_DEV_NONE. | ||
1228 | */ | ||
1229 | unsigned int ata_dev_try_classify(struct ata_device *dev, int present, | ||
1230 | u8 *r_err) | ||
1231 | { | ||
1232 | struct ata_port *ap = dev->link->ap; | ||
1233 | struct ata_taskfile tf; | ||
1234 | unsigned int class; | ||
1235 | u8 err; | ||
1236 | |||
1237 | ap->ops->dev_select(ap, dev->devno); | ||
1238 | |||
1239 | memset(&tf, 0, sizeof(tf)); | ||
1240 | |||
1241 | ap->ops->tf_read(ap, &tf); | ||
1242 | err = tf.feature; | ||
1243 | if (r_err) | ||
1244 | *r_err = err; | ||
1245 | |||
1246 | /* see if device passed diags: continue and warn later */ | ||
1247 | if (err == 0) | ||
1248 | /* diagnostic fail : do nothing _YET_ */ | ||
1249 | dev->horkage |= ATA_HORKAGE_DIAGNOSTIC; | ||
1250 | else if (err == 1) | ||
1251 | /* do nothing */ ; | ||
1252 | else if ((dev->devno == 0) && (err == 0x81)) | ||
1253 | /* do nothing */ ; | ||
1254 | else | ||
1255 | return ATA_DEV_NONE; | ||
1256 | |||
1257 | /* determine if device is ATA or ATAPI */ | ||
1258 | class = ata_dev_classify(&tf); | ||
1259 | |||
1260 | if (class == ATA_DEV_UNKNOWN) { | ||
1261 | /* If the device failed diagnostic, it's likely to | ||
1262 | * have reported incorrect device signature too. | ||
1263 | * Assume ATA device if the device seems present but | ||
1264 | * device signature is invalid with diagnostic | ||
1265 | * failure. | ||
1266 | */ | ||
1267 | if (present && (dev->horkage & ATA_HORKAGE_DIAGNOSTIC)) | ||
1268 | class = ATA_DEV_ATA; | ||
1269 | else | ||
1270 | class = ATA_DEV_NONE; | ||
1271 | } else if ((class == ATA_DEV_ATA) && (ata_chk_status(ap) == 0)) | ||
1272 | class = ATA_DEV_NONE; | ||
1273 | |||
1274 | return class; | ||
1275 | } | ||
1276 | |||
1277 | /** | ||
1278 | * ata_id_string - Convert IDENTIFY DEVICE page into string | 1137 | * ata_id_string - Convert IDENTIFY DEVICE page into string |
1279 | * @id: IDENTIFY DEVICE results we will examine | 1138 | * @id: IDENTIFY DEVICE results we will examine |
1280 | * @s: string into which data is output | 1139 | * @s: string into which data is output |
@@ -1597,73 +1456,6 @@ void ata_noop_dev_select(struct ata_port *ap, unsigned int device) | |||
1597 | { | 1456 | { |
1598 | } | 1457 | } |
1599 | 1458 | ||
1600 | |||
1601 | /** | ||
1602 | * ata_std_dev_select - Select device 0/1 on ATA bus | ||
1603 | * @ap: ATA channel to manipulate | ||
1604 | * @device: ATA device (numbered from zero) to select | ||
1605 | * | ||
1606 | * Use the method defined in the ATA specification to | ||
1607 | * make either device 0, or device 1, active on the | ||
1608 | * ATA channel. Works with both PIO and MMIO. | ||
1609 | * | ||
1610 | * May be used as the dev_select() entry in ata_port_operations. | ||
1611 | * | ||
1612 | * LOCKING: | ||
1613 | * caller. | ||
1614 | */ | ||
1615 | |||
1616 | void ata_std_dev_select(struct ata_port *ap, unsigned int device) | ||
1617 | { | ||
1618 | u8 tmp; | ||
1619 | |||
1620 | if (device == 0) | ||
1621 | tmp = ATA_DEVICE_OBS; | ||
1622 | else | ||
1623 | tmp = ATA_DEVICE_OBS | ATA_DEV1; | ||
1624 | |||
1625 | iowrite8(tmp, ap->ioaddr.device_addr); | ||
1626 | ata_pause(ap); /* needed; also flushes, for mmio */ | ||
1627 | } | ||
1628 | |||
1629 | /** | ||
1630 | * ata_dev_select - Select device 0/1 on ATA bus | ||
1631 | * @ap: ATA channel to manipulate | ||
1632 | * @device: ATA device (numbered from zero) to select | ||
1633 | * @wait: non-zero to wait for Status register BSY bit to clear | ||
1634 | * @can_sleep: non-zero if context allows sleeping | ||
1635 | * | ||
1636 | * Use the method defined in the ATA specification to | ||
1637 | * make either device 0, or device 1, active on the | ||
1638 | * ATA channel. | ||
1639 | * | ||
1640 | * This is a high-level version of ata_std_dev_select(), | ||
1641 | * which additionally provides the services of inserting | ||
1642 | * the proper pauses and status polling, where needed. | ||
1643 | * | ||
1644 | * LOCKING: | ||
1645 | * caller. | ||
1646 | */ | ||
1647 | |||
1648 | void ata_dev_select(struct ata_port *ap, unsigned int device, | ||
1649 | unsigned int wait, unsigned int can_sleep) | ||
1650 | { | ||
1651 | if (ata_msg_probe(ap)) | ||
1652 | ata_port_printk(ap, KERN_INFO, "ata_dev_select: ENTER, " | ||
1653 | "device %u, wait %u\n", device, wait); | ||
1654 | |||
1655 | if (wait) | ||
1656 | ata_wait_idle(ap); | ||
1657 | |||
1658 | ap->ops->dev_select(ap, device); | ||
1659 | |||
1660 | if (wait) { | ||
1661 | if (can_sleep && ap->link.device[device].class == ATA_DEV_ATAPI) | ||
1662 | msleep(150); | ||
1663 | ata_wait_idle(ap); | ||
1664 | } | ||
1665 | } | ||
1666 | |||
1667 | /** | 1459 | /** |
1668 | * ata_dump_id - IDENTIFY DEVICE info debugging output | 1460 | * ata_dump_id - IDENTIFY DEVICE info debugging output |
1669 | * @id: IDENTIFY DEVICE page to dump | 1461 | * @id: IDENTIFY DEVICE page to dump |
@@ -1791,8 +1583,7 @@ unsigned long ata_id_xfermask(const u16 *id) | |||
1791 | * LOCKING: | 1583 | * LOCKING: |
1792 | * Inherited from caller. | 1584 | * Inherited from caller. |
1793 | */ | 1585 | */ |
1794 | static void ata_pio_queue_task(struct ata_port *ap, void *data, | 1586 | void ata_pio_queue_task(struct ata_port *ap, void *data, unsigned long delay) |
1795 | unsigned long delay) | ||
1796 | { | 1587 | { |
1797 | ap->port_task_data = data; | 1588 | ap->port_task_data = data; |
1798 | 1589 | ||
@@ -3532,353 +3323,6 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev) | |||
3532 | } | 3323 | } |
3533 | 3324 | ||
3534 | /** | 3325 | /** |
3535 | * ata_tf_to_host - issue ATA taskfile to host controller | ||
3536 | * @ap: port to which command is being issued | ||
3537 | * @tf: ATA taskfile register set | ||
3538 | * | ||
3539 | * Issues ATA taskfile register set to ATA host controller, | ||
3540 | * with proper synchronization with interrupt handler and | ||
3541 | * other threads. | ||
3542 | * | ||
3543 | * LOCKING: | ||
3544 | * spin_lock_irqsave(host lock) | ||
3545 | */ | ||
3546 | |||
3547 | static inline void ata_tf_to_host(struct ata_port *ap, | ||
3548 | const struct ata_taskfile *tf) | ||
3549 | { | ||
3550 | ap->ops->tf_load(ap, tf); | ||
3551 | ap->ops->exec_command(ap, tf); | ||
3552 | } | ||
3553 | |||
3554 | /** | ||
3555 | * ata_busy_sleep - sleep until BSY clears, or timeout | ||
3556 | * @ap: port containing status register to be polled | ||
3557 | * @tmout_pat: impatience timeout | ||
3558 | * @tmout: overall timeout | ||
3559 | * | ||
3560 | * Sleep until ATA Status register bit BSY clears, | ||
3561 | * or a timeout occurs. | ||
3562 | * | ||
3563 | * LOCKING: | ||
3564 | * Kernel thread context (may sleep). | ||
3565 | * | ||
3566 | * RETURNS: | ||
3567 | * 0 on success, -errno otherwise. | ||
3568 | */ | ||
3569 | int ata_busy_sleep(struct ata_port *ap, | ||
3570 | unsigned long tmout_pat, unsigned long tmout) | ||
3571 | { | ||
3572 | unsigned long timer_start, timeout; | ||
3573 | u8 status; | ||
3574 | |||
3575 | status = ata_busy_wait(ap, ATA_BUSY, 300); | ||
3576 | timer_start = jiffies; | ||
3577 | timeout = timer_start + tmout_pat; | ||
3578 | while (status != 0xff && (status & ATA_BUSY) && | ||
3579 | time_before(jiffies, timeout)) { | ||
3580 | msleep(50); | ||
3581 | status = ata_busy_wait(ap, ATA_BUSY, 3); | ||
3582 | } | ||
3583 | |||
3584 | if (status != 0xff && (status & ATA_BUSY)) | ||
3585 | ata_port_printk(ap, KERN_WARNING, | ||
3586 | "port is slow to respond, please be patient " | ||
3587 | "(Status 0x%x)\n", status); | ||
3588 | |||
3589 | timeout = timer_start + tmout; | ||
3590 | while (status != 0xff && (status & ATA_BUSY) && | ||
3591 | time_before(jiffies, timeout)) { | ||
3592 | msleep(50); | ||
3593 | status = ata_chk_status(ap); | ||
3594 | } | ||
3595 | |||
3596 | if (status == 0xff) | ||
3597 | return -ENODEV; | ||
3598 | |||
3599 | if (status & ATA_BUSY) { | ||
3600 | ata_port_printk(ap, KERN_ERR, "port failed to respond " | ||
3601 | "(%lu secs, Status 0x%x)\n", | ||
3602 | tmout / HZ, status); | ||
3603 | return -EBUSY; | ||
3604 | } | ||
3605 | |||
3606 | return 0; | ||
3607 | } | ||
3608 | |||
3609 | /** | ||
3610 | * ata_wait_after_reset - wait before checking status after reset | ||
3611 | * @ap: port containing status register to be polled | ||
3612 | * @deadline: deadline jiffies for the operation | ||
3613 | * | ||
3614 | * After reset, we need to pause a while before reading status. | ||
3615 | * Also, certain combination of controller and device report 0xff | ||
3616 | * for some duration (e.g. until SATA PHY is up and running) | ||
3617 | * which is interpreted as empty port in ATA world. This | ||
3618 | * function also waits for such devices to get out of 0xff | ||
3619 | * status. | ||
3620 | * | ||
3621 | * LOCKING: | ||
3622 | * Kernel thread context (may sleep). | ||
3623 | */ | ||
3624 | void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline) | ||
3625 | { | ||
3626 | unsigned long until = jiffies + ATA_TMOUT_FF_WAIT; | ||
3627 | |||
3628 | if (time_before(until, deadline)) | ||
3629 | deadline = until; | ||
3630 | |||
3631 | /* Spec mandates ">= 2ms" before checking status. We wait | ||
3632 | * 150ms, because that was the magic delay used for ATAPI | ||
3633 | * devices in Hale Landis's ATADRVR, for the period of time | ||
3634 | * between when the ATA command register is written, and then | ||
3635 | * status is checked. Because waiting for "a while" before | ||
3636 | * checking status is fine, post SRST, we perform this magic | ||
3637 | * delay here as well. | ||
3638 | * | ||
3639 | * Old drivers/ide uses the 2mS rule and then waits for ready. | ||
3640 | */ | ||
3641 | msleep(150); | ||
3642 | |||
3643 | /* Wait for 0xff to clear. Some SATA devices take a long time | ||
3644 | * to clear 0xff after reset. For example, HHD424020F7SV00 | ||
3645 | * iVDR needs >= 800ms while. Quantum GoVault needs even more | ||
3646 | * than that. | ||
3647 | * | ||
3648 | * Note that some PATA controllers (pata_ali) explode if | ||
3649 | * status register is read more than once when there's no | ||
3650 | * device attached. | ||
3651 | */ | ||
3652 | if (ap->flags & ATA_FLAG_SATA) { | ||
3653 | while (1) { | ||
3654 | u8 status = ata_chk_status(ap); | ||
3655 | |||
3656 | if (status != 0xff || time_after(jiffies, deadline)) | ||
3657 | return; | ||
3658 | |||
3659 | msleep(50); | ||
3660 | } | ||
3661 | } | ||
3662 | } | ||
3663 | |||
3664 | /** | ||
3665 | * ata_wait_ready - sleep until BSY clears, or timeout | ||
3666 | * @ap: port containing status register to be polled | ||
3667 | * @deadline: deadline jiffies for the operation | ||
3668 | * | ||
3669 | * Sleep until ATA Status register bit BSY clears, or timeout | ||
3670 | * occurs. | ||
3671 | * | ||
3672 | * LOCKING: | ||
3673 | * Kernel thread context (may sleep). | ||
3674 | * | ||
3675 | * RETURNS: | ||
3676 | * 0 on success, -errno otherwise. | ||
3677 | */ | ||
3678 | int ata_wait_ready(struct ata_port *ap, unsigned long deadline) | ||
3679 | { | ||
3680 | unsigned long start = jiffies; | ||
3681 | int warned = 0; | ||
3682 | |||
3683 | while (1) { | ||
3684 | u8 status = ata_chk_status(ap); | ||
3685 | unsigned long now = jiffies; | ||
3686 | |||
3687 | if (!(status & ATA_BUSY)) | ||
3688 | return 0; | ||
3689 | if (!ata_link_online(&ap->link) && status == 0xff) | ||
3690 | return -ENODEV; | ||
3691 | if (time_after(now, deadline)) | ||
3692 | return -EBUSY; | ||
3693 | |||
3694 | if (!warned && time_after(now, start + 5 * HZ) && | ||
3695 | (deadline - now > 3 * HZ)) { | ||
3696 | ata_port_printk(ap, KERN_WARNING, | ||
3697 | "port is slow to respond, please be patient " | ||
3698 | "(Status 0x%x)\n", status); | ||
3699 | warned = 1; | ||
3700 | } | ||
3701 | |||
3702 | msleep(50); | ||
3703 | } | ||
3704 | } | ||
3705 | |||
3706 | static int ata_bus_post_reset(struct ata_port *ap, unsigned int devmask, | ||
3707 | unsigned long deadline) | ||
3708 | { | ||
3709 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
3710 | unsigned int dev0 = devmask & (1 << 0); | ||
3711 | unsigned int dev1 = devmask & (1 << 1); | ||
3712 | int rc, ret = 0; | ||
3713 | |||
3714 | /* if device 0 was found in ata_devchk, wait for its | ||
3715 | * BSY bit to clear | ||
3716 | */ | ||
3717 | if (dev0) { | ||
3718 | rc = ata_wait_ready(ap, deadline); | ||
3719 | if (rc) { | ||
3720 | if (rc != -ENODEV) | ||
3721 | return rc; | ||
3722 | ret = rc; | ||
3723 | } | ||
3724 | } | ||
3725 | |||
3726 | /* if device 1 was found in ata_devchk, wait for register | ||
3727 | * access briefly, then wait for BSY to clear. | ||
3728 | */ | ||
3729 | if (dev1) { | ||
3730 | int i; | ||
3731 | |||
3732 | ap->ops->dev_select(ap, 1); | ||
3733 | |||
3734 | /* Wait for register access. Some ATAPI devices fail | ||
3735 | * to set nsect/lbal after reset, so don't waste too | ||
3736 | * much time on it. We're gonna wait for !BSY anyway. | ||
3737 | */ | ||
3738 | for (i = 0; i < 2; i++) { | ||
3739 | u8 nsect, lbal; | ||
3740 | |||
3741 | nsect = ioread8(ioaddr->nsect_addr); | ||
3742 | lbal = ioread8(ioaddr->lbal_addr); | ||
3743 | if ((nsect == 1) && (lbal == 1)) | ||
3744 | break; | ||
3745 | msleep(50); /* give drive a breather */ | ||
3746 | } | ||
3747 | |||
3748 | rc = ata_wait_ready(ap, deadline); | ||
3749 | if (rc) { | ||
3750 | if (rc != -ENODEV) | ||
3751 | return rc; | ||
3752 | ret = rc; | ||
3753 | } | ||
3754 | } | ||
3755 | |||
3756 | /* is all this really necessary? */ | ||
3757 | ap->ops->dev_select(ap, 0); | ||
3758 | if (dev1) | ||
3759 | ap->ops->dev_select(ap, 1); | ||
3760 | if (dev0) | ||
3761 | ap->ops->dev_select(ap, 0); | ||
3762 | |||
3763 | return ret; | ||
3764 | } | ||
3765 | |||
3766 | static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | ||
3767 | unsigned long deadline) | ||
3768 | { | ||
3769 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
3770 | |||
3771 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); | ||
3772 | |||
3773 | /* software reset. causes dev0 to be selected */ | ||
3774 | iowrite8(ap->ctl, ioaddr->ctl_addr); | ||
3775 | udelay(20); /* FIXME: flush */ | ||
3776 | iowrite8(ap->ctl | ATA_SRST, ioaddr->ctl_addr); | ||
3777 | udelay(20); /* FIXME: flush */ | ||
3778 | iowrite8(ap->ctl, ioaddr->ctl_addr); | ||
3779 | |||
3780 | /* wait a while before checking status */ | ||
3781 | ata_wait_after_reset(ap, deadline); | ||
3782 | |||
3783 | /* Before we perform post reset processing we want to see if | ||
3784 | * the bus shows 0xFF because the odd clown forgets the D7 | ||
3785 | * pulldown resistor. | ||
3786 | */ | ||
3787 | if (ata_chk_status(ap) == 0xFF) | ||
3788 | return -ENODEV; | ||
3789 | |||
3790 | return ata_bus_post_reset(ap, devmask, deadline); | ||
3791 | } | ||
3792 | |||
3793 | /** | ||
3794 | * ata_bus_reset - reset host port and associated ATA channel | ||
3795 | * @ap: port to reset | ||
3796 | * | ||
3797 | * This is typically the first time we actually start issuing | ||
3798 | * commands to the ATA channel. We wait for BSY to clear, then | ||
3799 | * issue EXECUTE DEVICE DIAGNOSTIC command, polling for its | ||
3800 | * result. Determine what devices, if any, are on the channel | ||
3801 | * by looking at the device 0/1 error register. Look at the signature | ||
3802 | * stored in each device's taskfile registers, to determine if | ||
3803 | * the device is ATA or ATAPI. | ||
3804 | * | ||
3805 | * LOCKING: | ||
3806 | * PCI/etc. bus probe sem. | ||
3807 | * Obtains host lock. | ||
3808 | * | ||
3809 | * SIDE EFFECTS: | ||
3810 | * Sets ATA_FLAG_DISABLED if bus reset fails. | ||
3811 | */ | ||
3812 | |||
3813 | void ata_bus_reset(struct ata_port *ap) | ||
3814 | { | ||
3815 | struct ata_device *device = ap->link.device; | ||
3816 | struct ata_ioports *ioaddr = &ap->ioaddr; | ||
3817 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | ||
3818 | u8 err; | ||
3819 | unsigned int dev0, dev1 = 0, devmask = 0; | ||
3820 | int rc; | ||
3821 | |||
3822 | DPRINTK("ENTER, host %u, port %u\n", ap->print_id, ap->port_no); | ||
3823 | |||
3824 | /* determine if device 0/1 are present */ | ||
3825 | if (ap->flags & ATA_FLAG_SATA_RESET) | ||
3826 | dev0 = 1; | ||
3827 | else { | ||
3828 | dev0 = ata_devchk(ap, 0); | ||
3829 | if (slave_possible) | ||
3830 | dev1 = ata_devchk(ap, 1); | ||
3831 | } | ||
3832 | |||
3833 | if (dev0) | ||
3834 | devmask |= (1 << 0); | ||
3835 | if (dev1) | ||
3836 | devmask |= (1 << 1); | ||
3837 | |||
3838 | /* select device 0 again */ | ||
3839 | ap->ops->dev_select(ap, 0); | ||
3840 | |||
3841 | /* issue bus reset */ | ||
3842 | if (ap->flags & ATA_FLAG_SRST) { | ||
3843 | rc = ata_bus_softreset(ap, devmask, jiffies + 40 * HZ); | ||
3844 | if (rc && rc != -ENODEV) | ||
3845 | goto err_out; | ||
3846 | } | ||
3847 | |||
3848 | /* | ||
3849 | * determine by signature whether we have ATA or ATAPI devices | ||
3850 | */ | ||
3851 | device[0].class = ata_dev_try_classify(&device[0], dev0, &err); | ||
3852 | if ((slave_possible) && (err != 0x81)) | ||
3853 | device[1].class = ata_dev_try_classify(&device[1], dev1, &err); | ||
3854 | |||
3855 | /* is double-select really necessary? */ | ||
3856 | if (device[1].class != ATA_DEV_NONE) | ||
3857 | ap->ops->dev_select(ap, 1); | ||
3858 | if (device[0].class != ATA_DEV_NONE) | ||
3859 | ap->ops->dev_select(ap, 0); | ||
3860 | |||
3861 | /* if no devices were detected, disable this port */ | ||
3862 | if ((device[0].class == ATA_DEV_NONE) && | ||
3863 | (device[1].class == ATA_DEV_NONE)) | ||
3864 | goto err_out; | ||
3865 | |||
3866 | if (ap->flags & (ATA_FLAG_SATA_RESET | ATA_FLAG_SRST)) { | ||
3867 | /* set up device control for ATA_FLAG_SATA_RESET */ | ||
3868 | iowrite8(ap->ctl, ioaddr->ctl_addr); | ||
3869 | } | ||
3870 | |||
3871 | DPRINTK("EXIT\n"); | ||
3872 | return; | ||
3873 | |||
3874 | err_out: | ||
3875 | ata_port_printk(ap, KERN_ERR, "disabling port\n"); | ||
3876 | ata_port_disable(ap); | ||
3877 | |||
3878 | DPRINTK("EXIT\n"); | ||
3879 | } | ||
3880 | |||
3881 | /** | ||
3882 | * sata_link_debounce - debounce SATA phy status | 3326 | * sata_link_debounce - debounce SATA phy status |
3883 | * @link: ATA link to debounce SATA phy status for | 3327 | * @link: ATA link to debounce SATA phy status for |
3884 | * @params: timing parameters { interval, duratinon, timeout } in msec | 3328 | * @params: timing parameters { interval, duratinon, timeout } in msec |
@@ -4034,66 +3478,6 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline) | |||
4034 | } | 3478 | } |
4035 | 3479 | ||
4036 | /** | 3480 | /** |
4037 | * ata_std_softreset - reset host port via ATA SRST | ||
4038 | * @link: ATA link to reset | ||
4039 | * @classes: resulting classes of attached devices | ||
4040 | * @deadline: deadline jiffies for the operation | ||
4041 | * | ||
4042 | * Reset host port using ATA SRST. | ||
4043 | * | ||
4044 | * LOCKING: | ||
4045 | * Kernel thread context (may sleep) | ||
4046 | * | ||
4047 | * RETURNS: | ||
4048 | * 0 on success, -errno otherwise. | ||
4049 | */ | ||
4050 | int ata_std_softreset(struct ata_link *link, unsigned int *classes, | ||
4051 | unsigned long deadline) | ||
4052 | { | ||
4053 | struct ata_port *ap = link->ap; | ||
4054 | unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; | ||
4055 | unsigned int devmask = 0; | ||
4056 | int rc; | ||
4057 | u8 err; | ||
4058 | |||
4059 | DPRINTK("ENTER\n"); | ||
4060 | |||
4061 | if (ata_link_offline(link)) { | ||
4062 | classes[0] = ATA_DEV_NONE; | ||
4063 | goto out; | ||
4064 | } | ||
4065 | |||
4066 | /* determine if device 0/1 are present */ | ||
4067 | if (ata_devchk(ap, 0)) | ||
4068 | devmask |= (1 << 0); | ||
4069 | if (slave_possible && ata_devchk(ap, 1)) | ||
4070 | devmask |= (1 << 1); | ||
4071 | |||
4072 | /* select device 0 again */ | ||
4073 | ap->ops->dev_select(ap, 0); | ||
4074 | |||
4075 | /* issue bus reset */ | ||
4076 | DPRINTK("about to softreset, devmask=%x\n", devmask); | ||
4077 | rc = ata_bus_softreset(ap, devmask, deadline); | ||
4078 | /* if link is occupied, -ENODEV too is an error */ | ||
4079 | if (rc && (rc != -ENODEV || sata_scr_valid(link))) { | ||
4080 | ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc); | ||
4081 | return rc; | ||
4082 | } | ||
4083 | |||
4084 | /* determine by signature whether we have ATA or ATAPI devices */ | ||
4085 | classes[0] = ata_dev_try_classify(&link->device[0], | ||
4086 | devmask & (1 << 0), &err); | ||
4087 | if (slave_possible && err != 0x81) | ||
4088 | classes[1] = ata_dev_try_classify(&link->device[1], | ||
4089 | devmask & (1 << 1), &err); | ||
4090 | |||
4091 | out: | ||
4092 | DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); | ||
4093 | return 0; | ||
4094 | } | ||
4095 | |||
4096 | /** | ||
4097 | * sata_link_hardreset - reset link via SATA phy reset | 3481 | * sata_link_hardreset - reset link via SATA phy reset |
4098 | * @link: link to reset | 3482 | * @link: link to reset |
4099 | * @timing: timing parameters { interval, duratinon, timeout } in msec | 3483 | * @timing: timing parameters { interval, duratinon, timeout } in msec |
@@ -4154,74 +3538,6 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing, | |||
4154 | } | 3538 | } |
4155 | 3539 | ||
4156 | /** | 3540 | /** |
4157 | * sata_std_hardreset - reset host port via SATA phy reset | ||
4158 | * @link: link to reset | ||
4159 | * @class: resulting class of attached device | ||
4160 | * @deadline: deadline jiffies for the operation | ||
4161 | * | ||
4162 | * SATA phy-reset host port using DET bits of SControl register, | ||
4163 | * wait for !BSY and classify the attached device. | ||
4164 | * | ||
4165 | * LOCKING: | ||
4166 | * Kernel thread context (may sleep) | ||
4167 | * | ||
4168 | * RETURNS: | ||
4169 | * 0 on success, -errno otherwise. | ||
4170 | */ | ||
4171 | int sata_std_hardreset(struct ata_link *link, unsigned int *class, | ||
4172 | unsigned long deadline) | ||
4173 | { | ||
4174 | struct ata_port *ap = link->ap; | ||
4175 | const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); | ||
4176 | int rc; | ||
4177 | |||
4178 | DPRINTK("ENTER\n"); | ||
4179 | |||
4180 | /* do hardreset */ | ||
4181 | rc = sata_link_hardreset(link, timing, deadline); | ||
4182 | if (rc) { | ||
4183 | ata_link_printk(link, KERN_ERR, | ||
4184 | "COMRESET failed (errno=%d)\n", rc); | ||
4185 | return rc; | ||
4186 | } | ||
4187 | |||
4188 | /* TODO: phy layer with polling, timeouts, etc. */ | ||
4189 | if (ata_link_offline(link)) { | ||
4190 | *class = ATA_DEV_NONE; | ||
4191 | DPRINTK("EXIT, link offline\n"); | ||
4192 | return 0; | ||
4193 | } | ||
4194 | |||
4195 | /* wait a while before checking status */ | ||
4196 | ata_wait_after_reset(ap, deadline); | ||
4197 | |||
4198 | /* If PMP is supported, we have to do follow-up SRST. Note | ||
4199 | * that some PMPs don't send D2H Reg FIS after hardreset at | ||
4200 | * all if the first port is empty. Wait for it just for a | ||
4201 | * second and request follow-up SRST. | ||
4202 | */ | ||
4203 | if (ap->flags & ATA_FLAG_PMP) { | ||
4204 | ata_wait_ready(ap, jiffies + HZ); | ||
4205 | return -EAGAIN; | ||
4206 | } | ||
4207 | |||
4208 | rc = ata_wait_ready(ap, deadline); | ||
4209 | /* link occupied, -ENODEV too is an error */ | ||
4210 | if (rc) { | ||
4211 | ata_link_printk(link, KERN_ERR, | ||
4212 | "COMRESET failed (errno=%d)\n", rc); | ||
4213 | return rc; | ||
4214 | } | ||
4215 | |||
4216 | ap->ops->dev_select(ap, 0); /* probably unnecessary */ | ||
4217 | |||
4218 | *class = ata_dev_try_classify(link->device, 1, NULL); | ||
4219 | |||
4220 | DPRINTK("EXIT, class=%u\n", *class); | ||
4221 | return 0; | ||
4222 | } | ||
4223 | |||
4224 | /** | ||
4225 | * ata_std_postreset - standard postreset callback | 3541 | * ata_std_postreset - standard postreset callback |
4226 | * @link: the target ata_link | 3542 | * @link: the target ata_link |
4227 | * @classes: classes of attached devices | 3543 | * @classes: classes of attached devices |
@@ -4804,112 +4120,6 @@ void ata_sg_clean(struct ata_queued_cmd *qc) | |||
4804 | } | 4120 | } |
4805 | 4121 | ||
4806 | /** | 4122 | /** |
4807 | * ata_fill_sg - Fill PCI IDE PRD table | ||
4808 | * @qc: Metadata associated with taskfile to be transferred | ||
4809 | * | ||
4810 | * Fill PCI IDE PRD (scatter-gather) table with segments | ||
4811 | * associated with the current disk command. | ||
4812 | * | ||
4813 | * LOCKING: | ||
4814 | * spin_lock_irqsave(host lock) | ||
4815 | * | ||
4816 | */ | ||
4817 | static void ata_fill_sg(struct ata_queued_cmd *qc) | ||
4818 | { | ||
4819 | struct ata_port *ap = qc->ap; | ||
4820 | struct scatterlist *sg; | ||
4821 | unsigned int si, pi; | ||
4822 | |||
4823 | pi = 0; | ||
4824 | for_each_sg(qc->sg, sg, qc->n_elem, si) { | ||
4825 | u32 addr, offset; | ||
4826 | u32 sg_len, len; | ||
4827 | |||
4828 | /* determine if physical DMA addr spans 64K boundary. | ||
4829 | * Note h/w doesn't support 64-bit, so we unconditionally | ||
4830 | * truncate dma_addr_t to u32. | ||
4831 | */ | ||
4832 | addr = (u32) sg_dma_address(sg); | ||
4833 | sg_len = sg_dma_len(sg); | ||
4834 | |||
4835 | while (sg_len) { | ||
4836 | offset = addr & 0xffff; | ||
4837 | len = sg_len; | ||
4838 | if ((offset + sg_len) > 0x10000) | ||
4839 | len = 0x10000 - offset; | ||
4840 | |||
4841 | ap->prd[pi].addr = cpu_to_le32(addr); | ||
4842 | ap->prd[pi].flags_len = cpu_to_le32(len & 0xffff); | ||
4843 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, len); | ||
4844 | |||
4845 | pi++; | ||
4846 | sg_len -= len; | ||
4847 | addr += len; | ||
4848 | } | ||
4849 | } | ||
4850 | |||
4851 | ap->prd[pi - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); | ||
4852 | } | ||
4853 | |||
4854 | /** | ||
4855 | * ata_fill_sg_dumb - Fill PCI IDE PRD table | ||
4856 | * @qc: Metadata associated with taskfile to be transferred | ||
4857 | * | ||
4858 | * Fill PCI IDE PRD (scatter-gather) table with segments | ||
4859 | * associated with the current disk command. Perform the fill | ||
4860 | * so that we avoid writing any length 64K records for | ||
4861 | * controllers that don't follow the spec. | ||
4862 | * | ||
4863 | * LOCKING: | ||
4864 | * spin_lock_irqsave(host lock) | ||
4865 | * | ||
4866 | */ | ||
4867 | static void ata_fill_sg_dumb(struct ata_queued_cmd *qc) | ||
4868 | { | ||
4869 | struct ata_port *ap = qc->ap; | ||
4870 | struct scatterlist *sg; | ||
4871 | unsigned int si, pi; | ||
4872 | |||
4873 | pi = 0; | ||
4874 | for_each_sg(qc->sg, sg, qc->n_elem, si) { | ||
4875 | u32 addr, offset; | ||
4876 | u32 sg_len, len, blen; | ||
4877 | |||
4878 | /* determine if physical DMA addr spans 64K boundary. | ||
4879 | * Note h/w doesn't support 64-bit, so we unconditionally | ||
4880 | * truncate dma_addr_t to u32. | ||
4881 | */ | ||
4882 | addr = (u32) sg_dma_address(sg); | ||
4883 | sg_len = sg_dma_len(sg); | ||
4884 | |||
4885 | while (sg_len) { | ||
4886 | offset = addr & 0xffff; | ||
4887 | len = sg_len; | ||
4888 | if ((offset + sg_len) > 0x10000) | ||
4889 | len = 0x10000 - offset; | ||
4890 | |||
4891 | blen = len & 0xffff; | ||
4892 | ap->prd[pi].addr = cpu_to_le32(addr); | ||
4893 | if (blen == 0) { | ||
4894 | /* Some PATA chipsets like the CS5530 can't | ||
4895 | cope with 0x0000 meaning 64K as the spec says */ | ||
4896 | ap->prd[pi].flags_len = cpu_to_le32(0x8000); | ||
4897 | blen = 0x8000; | ||
4898 | ap->prd[++pi].addr = cpu_to_le32(addr + 0x8000); | ||
4899 | } | ||
4900 | ap->prd[pi].flags_len = cpu_to_le32(blen); | ||
4901 | VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, len); | ||
4902 | |||
4903 | pi++; | ||
4904 | sg_len -= len; | ||
4905 | addr += len; | ||
4906 | } | ||
4907 | } | ||
4908 | |||
4909 | ap->prd[pi - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT); | ||
4910 | } | ||
4911 | |||
4912 | /** | ||
4913 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported | 4123 | * ata_check_atapi_dma - Check whether ATAPI DMA can be supported |
4914 | * @qc: Metadata associated with taskfile to check | 4124 | * @qc: Metadata associated with taskfile to check |
4915 | * | 4125 | * |
@@ -4969,40 +4179,6 @@ int ata_std_qc_defer(struct ata_queued_cmd *qc) | |||
4969 | return ATA_DEFER_LINK; | 4179 | return ATA_DEFER_LINK; |
4970 | } | 4180 | } |
4971 | 4181 | ||
4972 | /** | ||
4973 | * ata_qc_prep - Prepare taskfile for submission | ||
4974 | * @qc: Metadata associated with taskfile to be prepared | ||
4975 | * | ||
4976 | * Prepare ATA taskfile for submission. | ||
4977 | * | ||
4978 | * LOCKING: | ||
4979 | * spin_lock_irqsave(host lock) | ||
4980 | */ | ||
4981 | void ata_qc_prep(struct ata_queued_cmd *qc) | ||
4982 | { | ||
4983 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
4984 | return; | ||
4985 | |||
4986 | ata_fill_sg(qc); | ||
4987 | } | ||
4988 | |||
4989 | /** | ||
4990 | * ata_dumb_qc_prep - Prepare taskfile for submission | ||
4991 | * @qc: Metadata associated with taskfile to be prepared | ||
4992 | * | ||
4993 | * Prepare ATA taskfile for submission. | ||
4994 | * | ||
4995 | * LOCKING: | ||
4996 | * spin_lock_irqsave(host lock) | ||
4997 | */ | ||
4998 | void ata_dumb_qc_prep(struct ata_queued_cmd *qc) | ||
4999 | { | ||
5000 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
5001 | return; | ||
5002 | |||
5003 | ata_fill_sg_dumb(qc); | ||
5004 | } | ||
5005 | |||
5006 | void ata_noop_qc_prep(struct ata_queued_cmd *qc) { } | 4182 | void ata_noop_qc_prep(struct ata_queued_cmd *qc) { } |
5007 | 4183 | ||
5008 | /** | 4184 | /** |
@@ -5081,698 +4257,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
5081 | } | 4257 | } |
5082 | 4258 | ||
5083 | /** | 4259 | /** |
5084 | * ata_data_xfer - Transfer data by PIO | ||
5085 | * @dev: device to target | ||
5086 | * @buf: data buffer | ||
5087 | * @buflen: buffer length | ||
5088 | * @rw: read/write | ||
5089 | * | ||
5090 | * Transfer data from/to the device data register by PIO. | ||
5091 | * | ||
5092 | * LOCKING: | ||
5093 | * Inherited from caller. | ||
5094 | * | ||
5095 | * RETURNS: | ||
5096 | * Bytes consumed. | ||
5097 | */ | ||
5098 | unsigned int ata_data_xfer(struct ata_device *dev, unsigned char *buf, | ||
5099 | unsigned int buflen, int rw) | ||
5100 | { | ||
5101 | struct ata_port *ap = dev->link->ap; | ||
5102 | void __iomem *data_addr = ap->ioaddr.data_addr; | ||
5103 | unsigned int words = buflen >> 1; | ||
5104 | |||
5105 | /* Transfer multiple of 2 bytes */ | ||
5106 | if (rw == READ) | ||
5107 | ioread16_rep(data_addr, buf, words); | ||
5108 | else | ||
5109 | iowrite16_rep(data_addr, buf, words); | ||
5110 | |||
5111 | /* Transfer trailing 1 byte, if any. */ | ||
5112 | if (unlikely(buflen & 0x01)) { | ||
5113 | __le16 align_buf[1] = { 0 }; | ||
5114 | unsigned char *trailing_buf = buf + buflen - 1; | ||
5115 | |||
5116 | if (rw == READ) { | ||
5117 | align_buf[0] = cpu_to_le16(ioread16(data_addr)); | ||
5118 | memcpy(trailing_buf, align_buf, 1); | ||
5119 | } else { | ||
5120 | memcpy(align_buf, trailing_buf, 1); | ||
5121 | iowrite16(le16_to_cpu(align_buf[0]), data_addr); | ||
5122 | } | ||
5123 | words++; | ||
5124 | } | ||
5125 | |||
5126 | return words << 1; | ||
5127 | } | ||
5128 | |||
5129 | /** | ||
5130 | * ata_data_xfer_noirq - Transfer data by PIO | ||
5131 | * @dev: device to target | ||
5132 | * @buf: data buffer | ||
5133 | * @buflen: buffer length | ||
5134 | * @rw: read/write | ||
5135 | * | ||
5136 | * Transfer data from/to the device data register by PIO. Do the | ||
5137 | * transfer with interrupts disabled. | ||
5138 | * | ||
5139 | * LOCKING: | ||
5140 | * Inherited from caller. | ||
5141 | * | ||
5142 | * RETURNS: | ||
5143 | * Bytes consumed. | ||
5144 | */ | ||
5145 | unsigned int ata_data_xfer_noirq(struct ata_device *dev, unsigned char *buf, | ||
5146 | unsigned int buflen, int rw) | ||
5147 | { | ||
5148 | unsigned long flags; | ||
5149 | unsigned int consumed; | ||
5150 | |||
5151 | local_irq_save(flags); | ||
5152 | consumed = ata_data_xfer(dev, buf, buflen, rw); | ||
5153 | local_irq_restore(flags); | ||
5154 | |||
5155 | return consumed; | ||
5156 | } | ||
5157 | |||
5158 | |||
5159 | /** | ||
5160 | * ata_pio_sector - Transfer a sector of data. | ||
5161 | * @qc: Command on going | ||
5162 | * | ||
5163 | * Transfer qc->sect_size bytes of data from/to the ATA device. | ||
5164 | * | ||
5165 | * LOCKING: | ||
5166 | * Inherited from caller. | ||
5167 | */ | ||
5168 | |||
5169 | static void ata_pio_sector(struct ata_queued_cmd *qc) | ||
5170 | { | ||
5171 | int do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | ||
5172 | struct ata_port *ap = qc->ap; | ||
5173 | struct page *page; | ||
5174 | unsigned int offset; | ||
5175 | unsigned char *buf; | ||
5176 | |||
5177 | if (qc->curbytes == qc->nbytes - qc->sect_size) | ||
5178 | ap->hsm_task_state = HSM_ST_LAST; | ||
5179 | |||
5180 | page = sg_page(qc->cursg); | ||
5181 | offset = qc->cursg->offset + qc->cursg_ofs; | ||
5182 | |||
5183 | /* get the current page and offset */ | ||
5184 | page = nth_page(page, (offset >> PAGE_SHIFT)); | ||
5185 | offset %= PAGE_SIZE; | ||
5186 | |||
5187 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); | ||
5188 | |||
5189 | if (PageHighMem(page)) { | ||
5190 | unsigned long flags; | ||
5191 | |||
5192 | /* FIXME: use a bounce buffer */ | ||
5193 | local_irq_save(flags); | ||
5194 | buf = kmap_atomic(page, KM_IRQ0); | ||
5195 | |||
5196 | /* do the actual data transfer */ | ||
5197 | ap->ops->data_xfer(qc->dev, buf + offset, qc->sect_size, do_write); | ||
5198 | |||
5199 | kunmap_atomic(buf, KM_IRQ0); | ||
5200 | local_irq_restore(flags); | ||
5201 | } else { | ||
5202 | buf = page_address(page); | ||
5203 | ap->ops->data_xfer(qc->dev, buf + offset, qc->sect_size, do_write); | ||
5204 | } | ||
5205 | |||
5206 | qc->curbytes += qc->sect_size; | ||
5207 | qc->cursg_ofs += qc->sect_size; | ||
5208 | |||
5209 | if (qc->cursg_ofs == qc->cursg->length) { | ||
5210 | qc->cursg = sg_next(qc->cursg); | ||
5211 | qc->cursg_ofs = 0; | ||
5212 | } | ||
5213 | } | ||
5214 | |||
5215 | /** | ||
5216 | * ata_pio_sectors - Transfer one or many sectors. | ||
5217 | * @qc: Command on going | ||
5218 | * | ||
5219 | * Transfer one or many sectors of data from/to the | ||
5220 | * ATA device for the DRQ request. | ||
5221 | * | ||
5222 | * LOCKING: | ||
5223 | * Inherited from caller. | ||
5224 | */ | ||
5225 | |||
5226 | static void ata_pio_sectors(struct ata_queued_cmd *qc) | ||
5227 | { | ||
5228 | if (is_multi_taskfile(&qc->tf)) { | ||
5229 | /* READ/WRITE MULTIPLE */ | ||
5230 | unsigned int nsect; | ||
5231 | |||
5232 | WARN_ON(qc->dev->multi_count == 0); | ||
5233 | |||
5234 | nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size, | ||
5235 | qc->dev->multi_count); | ||
5236 | while (nsect--) | ||
5237 | ata_pio_sector(qc); | ||
5238 | } else | ||
5239 | ata_pio_sector(qc); | ||
5240 | |||
5241 | ata_altstatus(qc->ap); /* flush */ | ||
5242 | } | ||
5243 | |||
5244 | /** | ||
5245 | * atapi_send_cdb - Write CDB bytes to hardware | ||
5246 | * @ap: Port to which ATAPI device is attached. | ||
5247 | * @qc: Taskfile currently active | ||
5248 | * | ||
5249 | * When device has indicated its readiness to accept | ||
5250 | * a CDB, this function is called. Send the CDB. | ||
5251 | * | ||
5252 | * LOCKING: | ||
5253 | * caller. | ||
5254 | */ | ||
5255 | |||
5256 | static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) | ||
5257 | { | ||
5258 | /* send SCSI cdb */ | ||
5259 | DPRINTK("send cdb\n"); | ||
5260 | WARN_ON(qc->dev->cdb_len < 12); | ||
5261 | |||
5262 | ap->ops->data_xfer(qc->dev, qc->cdb, qc->dev->cdb_len, 1); | ||
5263 | ata_altstatus(ap); /* flush */ | ||
5264 | |||
5265 | switch (qc->tf.protocol) { | ||
5266 | case ATAPI_PROT_PIO: | ||
5267 | ap->hsm_task_state = HSM_ST; | ||
5268 | break; | ||
5269 | case ATAPI_PROT_NODATA: | ||
5270 | ap->hsm_task_state = HSM_ST_LAST; | ||
5271 | break; | ||
5272 | case ATAPI_PROT_DMA: | ||
5273 | ap->hsm_task_state = HSM_ST_LAST; | ||
5274 | /* initiate bmdma */ | ||
5275 | ap->ops->bmdma_start(qc); | ||
5276 | break; | ||
5277 | } | ||
5278 | } | ||
5279 | |||
5280 | /** | ||
5281 | * __atapi_pio_bytes - Transfer data from/to the ATAPI device. | ||
5282 | * @qc: Command on going | ||
5283 | * @bytes: number of bytes | ||
5284 | * | ||
5285 | * Transfer Transfer data from/to the ATAPI device. | ||
5286 | * | ||
5287 | * LOCKING: | ||
5288 | * Inherited from caller. | ||
5289 | * | ||
5290 | */ | ||
5291 | static int __atapi_pio_bytes(struct ata_queued_cmd *qc, unsigned int bytes) | ||
5292 | { | ||
5293 | int rw = (qc->tf.flags & ATA_TFLAG_WRITE) ? WRITE : READ; | ||
5294 | struct ata_port *ap = qc->ap; | ||
5295 | struct ata_device *dev = qc->dev; | ||
5296 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5297 | struct scatterlist *sg; | ||
5298 | struct page *page; | ||
5299 | unsigned char *buf; | ||
5300 | unsigned int offset, count, consumed; | ||
5301 | |||
5302 | next_sg: | ||
5303 | sg = qc->cursg; | ||
5304 | if (unlikely(!sg)) { | ||
5305 | ata_ehi_push_desc(ehi, "unexpected or too much trailing data " | ||
5306 | "buf=%u cur=%u bytes=%u", | ||
5307 | qc->nbytes, qc->curbytes, bytes); | ||
5308 | return -1; | ||
5309 | } | ||
5310 | |||
5311 | page = sg_page(sg); | ||
5312 | offset = sg->offset + qc->cursg_ofs; | ||
5313 | |||
5314 | /* get the current page and offset */ | ||
5315 | page = nth_page(page, (offset >> PAGE_SHIFT)); | ||
5316 | offset %= PAGE_SIZE; | ||
5317 | |||
5318 | /* don't overrun current sg */ | ||
5319 | count = min(sg->length - qc->cursg_ofs, bytes); | ||
5320 | |||
5321 | /* don't cross page boundaries */ | ||
5322 | count = min(count, (unsigned int)PAGE_SIZE - offset); | ||
5323 | |||
5324 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); | ||
5325 | |||
5326 | if (PageHighMem(page)) { | ||
5327 | unsigned long flags; | ||
5328 | |||
5329 | /* FIXME: use bounce buffer */ | ||
5330 | local_irq_save(flags); | ||
5331 | buf = kmap_atomic(page, KM_IRQ0); | ||
5332 | |||
5333 | /* do the actual data transfer */ | ||
5334 | consumed = ap->ops->data_xfer(dev, buf + offset, count, rw); | ||
5335 | |||
5336 | kunmap_atomic(buf, KM_IRQ0); | ||
5337 | local_irq_restore(flags); | ||
5338 | } else { | ||
5339 | buf = page_address(page); | ||
5340 | consumed = ap->ops->data_xfer(dev, buf + offset, count, rw); | ||
5341 | } | ||
5342 | |||
5343 | bytes -= min(bytes, consumed); | ||
5344 | qc->curbytes += count; | ||
5345 | qc->cursg_ofs += count; | ||
5346 | |||
5347 | if (qc->cursg_ofs == sg->length) { | ||
5348 | qc->cursg = sg_next(qc->cursg); | ||
5349 | qc->cursg_ofs = 0; | ||
5350 | } | ||
5351 | |||
5352 | /* consumed can be larger than count only for the last transfer */ | ||
5353 | WARN_ON(qc->cursg && count != consumed); | ||
5354 | |||
5355 | if (bytes) | ||
5356 | goto next_sg; | ||
5357 | return 0; | ||
5358 | } | ||
5359 | |||
5360 | /** | ||
5361 | * atapi_pio_bytes - Transfer data from/to the ATAPI device. | ||
5362 | * @qc: Command on going | ||
5363 | * | ||
5364 | * Transfer Transfer data from/to the ATAPI device. | ||
5365 | * | ||
5366 | * LOCKING: | ||
5367 | * Inherited from caller. | ||
5368 | */ | ||
5369 | |||
5370 | static void atapi_pio_bytes(struct ata_queued_cmd *qc) | ||
5371 | { | ||
5372 | struct ata_port *ap = qc->ap; | ||
5373 | struct ata_device *dev = qc->dev; | ||
5374 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5375 | unsigned int ireason, bc_lo, bc_hi, bytes; | ||
5376 | int i_write, do_write = (qc->tf.flags & ATA_TFLAG_WRITE) ? 1 : 0; | ||
5377 | |||
5378 | /* Abuse qc->result_tf for temp storage of intermediate TF | ||
5379 | * here to save some kernel stack usage. | ||
5380 | * For normal completion, qc->result_tf is not relevant. For | ||
5381 | * error, qc->result_tf is later overwritten by ata_qc_complete(). | ||
5382 | * So, the correctness of qc->result_tf is not affected. | ||
5383 | */ | ||
5384 | ap->ops->tf_read(ap, &qc->result_tf); | ||
5385 | ireason = qc->result_tf.nsect; | ||
5386 | bc_lo = qc->result_tf.lbam; | ||
5387 | bc_hi = qc->result_tf.lbah; | ||
5388 | bytes = (bc_hi << 8) | bc_lo; | ||
5389 | |||
5390 | /* shall be cleared to zero, indicating xfer of data */ | ||
5391 | if (unlikely(ireason & (1 << 0))) | ||
5392 | goto atapi_check; | ||
5393 | |||
5394 | /* make sure transfer direction matches expected */ | ||
5395 | i_write = ((ireason & (1 << 1)) == 0) ? 1 : 0; | ||
5396 | if (unlikely(do_write != i_write)) | ||
5397 | goto atapi_check; | ||
5398 | |||
5399 | if (unlikely(!bytes)) | ||
5400 | goto atapi_check; | ||
5401 | |||
5402 | VPRINTK("ata%u: xfering %d bytes\n", ap->print_id, bytes); | ||
5403 | |||
5404 | if (unlikely(__atapi_pio_bytes(qc, bytes))) | ||
5405 | goto err_out; | ||
5406 | ata_altstatus(ap); /* flush */ | ||
5407 | |||
5408 | return; | ||
5409 | |||
5410 | atapi_check: | ||
5411 | ata_ehi_push_desc(ehi, "ATAPI check failed (ireason=0x%x bytes=%u)", | ||
5412 | ireason, bytes); | ||
5413 | err_out: | ||
5414 | qc->err_mask |= AC_ERR_HSM; | ||
5415 | ap->hsm_task_state = HSM_ST_ERR; | ||
5416 | } | ||
5417 | |||
5418 | /** | ||
5419 | * ata_hsm_ok_in_wq - Check if the qc can be handled in the workqueue. | ||
5420 | * @ap: the target ata_port | ||
5421 | * @qc: qc on going | ||
5422 | * | ||
5423 | * RETURNS: | ||
5424 | * 1 if ok in workqueue, 0 otherwise. | ||
5425 | */ | ||
5426 | |||
5427 | static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *qc) | ||
5428 | { | ||
5429 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
5430 | return 1; | ||
5431 | |||
5432 | if (ap->hsm_task_state == HSM_ST_FIRST) { | ||
5433 | if (qc->tf.protocol == ATA_PROT_PIO && | ||
5434 | (qc->tf.flags & ATA_TFLAG_WRITE)) | ||
5435 | return 1; | ||
5436 | |||
5437 | if (ata_is_atapi(qc->tf.protocol) && | ||
5438 | !(qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
5439 | return 1; | ||
5440 | } | ||
5441 | |||
5442 | return 0; | ||
5443 | } | ||
5444 | |||
5445 | /** | ||
5446 | * ata_hsm_qc_complete - finish a qc running on standard HSM | ||
5447 | * @qc: Command to complete | ||
5448 | * @in_wq: 1 if called from workqueue, 0 otherwise | ||
5449 | * | ||
5450 | * Finish @qc which is running on standard HSM. | ||
5451 | * | ||
5452 | * LOCKING: | ||
5453 | * If @in_wq is zero, spin_lock_irqsave(host lock). | ||
5454 | * Otherwise, none on entry and grabs host lock. | ||
5455 | */ | ||
5456 | static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq) | ||
5457 | { | ||
5458 | struct ata_port *ap = qc->ap; | ||
5459 | unsigned long flags; | ||
5460 | |||
5461 | if (ap->ops->error_handler) { | ||
5462 | if (in_wq) { | ||
5463 | spin_lock_irqsave(ap->lock, flags); | ||
5464 | |||
5465 | /* EH might have kicked in while host lock is | ||
5466 | * released. | ||
5467 | */ | ||
5468 | qc = ata_qc_from_tag(ap, qc->tag); | ||
5469 | if (qc) { | ||
5470 | if (likely(!(qc->err_mask & AC_ERR_HSM))) { | ||
5471 | ap->ops->irq_on(ap); | ||
5472 | ata_qc_complete(qc); | ||
5473 | } else | ||
5474 | ata_port_freeze(ap); | ||
5475 | } | ||
5476 | |||
5477 | spin_unlock_irqrestore(ap->lock, flags); | ||
5478 | } else { | ||
5479 | if (likely(!(qc->err_mask & AC_ERR_HSM))) | ||
5480 | ata_qc_complete(qc); | ||
5481 | else | ||
5482 | ata_port_freeze(ap); | ||
5483 | } | ||
5484 | } else { | ||
5485 | if (in_wq) { | ||
5486 | spin_lock_irqsave(ap->lock, flags); | ||
5487 | ap->ops->irq_on(ap); | ||
5488 | ata_qc_complete(qc); | ||
5489 | spin_unlock_irqrestore(ap->lock, flags); | ||
5490 | } else | ||
5491 | ata_qc_complete(qc); | ||
5492 | } | ||
5493 | } | ||
5494 | |||
5495 | /** | ||
5496 | * ata_hsm_move - move the HSM to the next state. | ||
5497 | * @ap: the target ata_port | ||
5498 | * @qc: qc on going | ||
5499 | * @status: current device status | ||
5500 | * @in_wq: 1 if called from workqueue, 0 otherwise | ||
5501 | * | ||
5502 | * RETURNS: | ||
5503 | * 1 when poll next status needed, 0 otherwise. | ||
5504 | */ | ||
5505 | int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
5506 | u8 status, int in_wq) | ||
5507 | { | ||
5508 | unsigned long flags = 0; | ||
5509 | int poll_next; | ||
5510 | |||
5511 | WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0); | ||
5512 | |||
5513 | /* Make sure ata_qc_issue_prot() does not throw things | ||
5514 | * like DMA polling into the workqueue. Notice that | ||
5515 | * in_wq is not equivalent to (qc->tf.flags & ATA_TFLAG_POLLING). | ||
5516 | */ | ||
5517 | WARN_ON(in_wq != ata_hsm_ok_in_wq(ap, qc)); | ||
5518 | |||
5519 | fsm_start: | ||
5520 | DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n", | ||
5521 | ap->print_id, qc->tf.protocol, ap->hsm_task_state, status); | ||
5522 | |||
5523 | switch (ap->hsm_task_state) { | ||
5524 | case HSM_ST_FIRST: | ||
5525 | /* Send first data block or PACKET CDB */ | ||
5526 | |||
5527 | /* If polling, we will stay in the work queue after | ||
5528 | * sending the data. Otherwise, interrupt handler | ||
5529 | * takes over after sending the data. | ||
5530 | */ | ||
5531 | poll_next = (qc->tf.flags & ATA_TFLAG_POLLING); | ||
5532 | |||
5533 | /* check device status */ | ||
5534 | if (unlikely((status & ATA_DRQ) == 0)) { | ||
5535 | /* handle BSY=0, DRQ=0 as error */ | ||
5536 | if (likely(status & (ATA_ERR | ATA_DF))) | ||
5537 | /* device stops HSM for abort/error */ | ||
5538 | qc->err_mask |= AC_ERR_DEV; | ||
5539 | else | ||
5540 | /* HSM violation. Let EH handle this */ | ||
5541 | qc->err_mask |= AC_ERR_HSM; | ||
5542 | |||
5543 | ap->hsm_task_state = HSM_ST_ERR; | ||
5544 | goto fsm_start; | ||
5545 | } | ||
5546 | |||
5547 | /* Device should not ask for data transfer (DRQ=1) | ||
5548 | * when it finds something wrong. | ||
5549 | * We ignore DRQ here and stop the HSM by | ||
5550 | * changing hsm_task_state to HSM_ST_ERR and | ||
5551 | * let the EH abort the command or reset the device. | ||
5552 | */ | ||
5553 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
5554 | /* Some ATAPI tape drives forget to clear the ERR bit | ||
5555 | * when doing the next command (mostly request sense). | ||
5556 | * We ignore ERR here to workaround and proceed sending | ||
5557 | * the CDB. | ||
5558 | */ | ||
5559 | if (!(qc->dev->horkage & ATA_HORKAGE_STUCK_ERR)) { | ||
5560 | ata_port_printk(ap, KERN_WARNING, | ||
5561 | "DRQ=1 with device error, " | ||
5562 | "dev_stat 0x%X\n", status); | ||
5563 | qc->err_mask |= AC_ERR_HSM; | ||
5564 | ap->hsm_task_state = HSM_ST_ERR; | ||
5565 | goto fsm_start; | ||
5566 | } | ||
5567 | } | ||
5568 | |||
5569 | /* Send the CDB (atapi) or the first data block (ata pio out). | ||
5570 | * During the state transition, interrupt handler shouldn't | ||
5571 | * be invoked before the data transfer is complete and | ||
5572 | * hsm_task_state is changed. Hence, the following locking. | ||
5573 | */ | ||
5574 | if (in_wq) | ||
5575 | spin_lock_irqsave(ap->lock, flags); | ||
5576 | |||
5577 | if (qc->tf.protocol == ATA_PROT_PIO) { | ||
5578 | /* PIO data out protocol. | ||
5579 | * send first data block. | ||
5580 | */ | ||
5581 | |||
5582 | /* ata_pio_sectors() might change the state | ||
5583 | * to HSM_ST_LAST. so, the state is changed here | ||
5584 | * before ata_pio_sectors(). | ||
5585 | */ | ||
5586 | ap->hsm_task_state = HSM_ST; | ||
5587 | ata_pio_sectors(qc); | ||
5588 | } else | ||
5589 | /* send CDB */ | ||
5590 | atapi_send_cdb(ap, qc); | ||
5591 | |||
5592 | if (in_wq) | ||
5593 | spin_unlock_irqrestore(ap->lock, flags); | ||
5594 | |||
5595 | /* if polling, ata_pio_task() handles the rest. | ||
5596 | * otherwise, interrupt handler takes over from here. | ||
5597 | */ | ||
5598 | break; | ||
5599 | |||
5600 | case HSM_ST: | ||
5601 | /* complete command or read/write the data register */ | ||
5602 | if (qc->tf.protocol == ATAPI_PROT_PIO) { | ||
5603 | /* ATAPI PIO protocol */ | ||
5604 | if ((status & ATA_DRQ) == 0) { | ||
5605 | /* No more data to transfer or device error. | ||
5606 | * Device error will be tagged in HSM_ST_LAST. | ||
5607 | */ | ||
5608 | ap->hsm_task_state = HSM_ST_LAST; | ||
5609 | goto fsm_start; | ||
5610 | } | ||
5611 | |||
5612 | /* Device should not ask for data transfer (DRQ=1) | ||
5613 | * when it finds something wrong. | ||
5614 | * We ignore DRQ here and stop the HSM by | ||
5615 | * changing hsm_task_state to HSM_ST_ERR and | ||
5616 | * let the EH abort the command or reset the device. | ||
5617 | */ | ||
5618 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
5619 | ata_port_printk(ap, KERN_WARNING, "DRQ=1 with " | ||
5620 | "device error, dev_stat 0x%X\n", | ||
5621 | status); | ||
5622 | qc->err_mask |= AC_ERR_HSM; | ||
5623 | ap->hsm_task_state = HSM_ST_ERR; | ||
5624 | goto fsm_start; | ||
5625 | } | ||
5626 | |||
5627 | atapi_pio_bytes(qc); | ||
5628 | |||
5629 | if (unlikely(ap->hsm_task_state == HSM_ST_ERR)) | ||
5630 | /* bad ireason reported by device */ | ||
5631 | goto fsm_start; | ||
5632 | |||
5633 | } else { | ||
5634 | /* ATA PIO protocol */ | ||
5635 | if (unlikely((status & ATA_DRQ) == 0)) { | ||
5636 | /* handle BSY=0, DRQ=0 as error */ | ||
5637 | if (likely(status & (ATA_ERR | ATA_DF))) | ||
5638 | /* device stops HSM for abort/error */ | ||
5639 | qc->err_mask |= AC_ERR_DEV; | ||
5640 | else | ||
5641 | /* HSM violation. Let EH handle this. | ||
5642 | * Phantom devices also trigger this | ||
5643 | * condition. Mark hint. | ||
5644 | */ | ||
5645 | qc->err_mask |= AC_ERR_HSM | | ||
5646 | AC_ERR_NODEV_HINT; | ||
5647 | |||
5648 | ap->hsm_task_state = HSM_ST_ERR; | ||
5649 | goto fsm_start; | ||
5650 | } | ||
5651 | |||
5652 | /* For PIO reads, some devices may ask for | ||
5653 | * data transfer (DRQ=1) alone with ERR=1. | ||
5654 | * We respect DRQ here and transfer one | ||
5655 | * block of junk data before changing the | ||
5656 | * hsm_task_state to HSM_ST_ERR. | ||
5657 | * | ||
5658 | * For PIO writes, ERR=1 DRQ=1 doesn't make | ||
5659 | * sense since the data block has been | ||
5660 | * transferred to the device. | ||
5661 | */ | ||
5662 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
5663 | /* data might be corrputed */ | ||
5664 | qc->err_mask |= AC_ERR_DEV; | ||
5665 | |||
5666 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) { | ||
5667 | ata_pio_sectors(qc); | ||
5668 | status = ata_wait_idle(ap); | ||
5669 | } | ||
5670 | |||
5671 | if (status & (ATA_BUSY | ATA_DRQ)) | ||
5672 | qc->err_mask |= AC_ERR_HSM; | ||
5673 | |||
5674 | /* ata_pio_sectors() might change the | ||
5675 | * state to HSM_ST_LAST. so, the state | ||
5676 | * is changed after ata_pio_sectors(). | ||
5677 | */ | ||
5678 | ap->hsm_task_state = HSM_ST_ERR; | ||
5679 | goto fsm_start; | ||
5680 | } | ||
5681 | |||
5682 | ata_pio_sectors(qc); | ||
5683 | |||
5684 | if (ap->hsm_task_state == HSM_ST_LAST && | ||
5685 | (!(qc->tf.flags & ATA_TFLAG_WRITE))) { | ||
5686 | /* all data read */ | ||
5687 | status = ata_wait_idle(ap); | ||
5688 | goto fsm_start; | ||
5689 | } | ||
5690 | } | ||
5691 | |||
5692 | poll_next = 1; | ||
5693 | break; | ||
5694 | |||
5695 | case HSM_ST_LAST: | ||
5696 | if (unlikely(!ata_ok(status))) { | ||
5697 | qc->err_mask |= __ac_err_mask(status); | ||
5698 | ap->hsm_task_state = HSM_ST_ERR; | ||
5699 | goto fsm_start; | ||
5700 | } | ||
5701 | |||
5702 | /* no more data to transfer */ | ||
5703 | DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", | ||
5704 | ap->print_id, qc->dev->devno, status); | ||
5705 | |||
5706 | WARN_ON(qc->err_mask); | ||
5707 | |||
5708 | ap->hsm_task_state = HSM_ST_IDLE; | ||
5709 | |||
5710 | /* complete taskfile transaction */ | ||
5711 | ata_hsm_qc_complete(qc, in_wq); | ||
5712 | |||
5713 | poll_next = 0; | ||
5714 | break; | ||
5715 | |||
5716 | case HSM_ST_ERR: | ||
5717 | /* make sure qc->err_mask is available to | ||
5718 | * know what's wrong and recover | ||
5719 | */ | ||
5720 | WARN_ON(qc->err_mask == 0); | ||
5721 | |||
5722 | ap->hsm_task_state = HSM_ST_IDLE; | ||
5723 | |||
5724 | /* complete taskfile transaction */ | ||
5725 | ata_hsm_qc_complete(qc, in_wq); | ||
5726 | |||
5727 | poll_next = 0; | ||
5728 | break; | ||
5729 | default: | ||
5730 | poll_next = 0; | ||
5731 | BUG(); | ||
5732 | } | ||
5733 | |||
5734 | return poll_next; | ||
5735 | } | ||
5736 | |||
5737 | static void ata_pio_task(struct work_struct *work) | ||
5738 | { | ||
5739 | struct ata_port *ap = | ||
5740 | container_of(work, struct ata_port, port_task.work); | ||
5741 | struct ata_queued_cmd *qc = ap->port_task_data; | ||
5742 | u8 status; | ||
5743 | int poll_next; | ||
5744 | |||
5745 | fsm_start: | ||
5746 | WARN_ON(ap->hsm_task_state == HSM_ST_IDLE); | ||
5747 | |||
5748 | /* | ||
5749 | * This is purely heuristic. This is a fast path. | ||
5750 | * Sometimes when we enter, BSY will be cleared in | ||
5751 | * a chk-status or two. If not, the drive is probably seeking | ||
5752 | * or something. Snooze for a couple msecs, then | ||
5753 | * chk-status again. If still busy, queue delayed work. | ||
5754 | */ | ||
5755 | status = ata_busy_wait(ap, ATA_BUSY, 5); | ||
5756 | if (status & ATA_BUSY) { | ||
5757 | msleep(2); | ||
5758 | status = ata_busy_wait(ap, ATA_BUSY, 10); | ||
5759 | if (status & ATA_BUSY) { | ||
5760 | ata_pio_queue_task(ap, qc, ATA_SHORT_PAUSE); | ||
5761 | return; | ||
5762 | } | ||
5763 | } | ||
5764 | |||
5765 | /* move the HSM */ | ||
5766 | poll_next = ata_hsm_move(ap, qc, status, 1); | ||
5767 | |||
5768 | /* another command or interrupt handler | ||
5769 | * may be running at this point. | ||
5770 | */ | ||
5771 | if (poll_next) | ||
5772 | goto fsm_start; | ||
5773 | } | ||
5774 | |||
5775 | /** | ||
5776 | * ata_qc_new - Request an available ATA command, for queueing | 4260 | * ata_qc_new - Request an available ATA command, for queueing |
5777 | * @ap: Port associated with device @dev | 4261 | * @ap: Port associated with device @dev |
5778 | * @dev: Device from whom we request an available command structure | 4262 | * @dev: Device from whom we request an available command structure |
@@ -6122,285 +4606,6 @@ err: | |||
6122 | } | 4606 | } |
6123 | 4607 | ||
6124 | /** | 4608 | /** |
6125 | * ata_qc_issue_prot - issue taskfile to device in proto-dependent manner | ||
6126 | * @qc: command to issue to device | ||
6127 | * | ||
6128 | * Using various libata functions and hooks, this function | ||
6129 | * starts an ATA command. ATA commands are grouped into | ||
6130 | * classes called "protocols", and issuing each type of protocol | ||
6131 | * is slightly different. | ||
6132 | * | ||
6133 | * May be used as the qc_issue() entry in ata_port_operations. | ||
6134 | * | ||
6135 | * LOCKING: | ||
6136 | * spin_lock_irqsave(host lock) | ||
6137 | * | ||
6138 | * RETURNS: | ||
6139 | * Zero on success, AC_ERR_* mask on failure | ||
6140 | */ | ||
6141 | |||
6142 | unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | ||
6143 | { | ||
6144 | struct ata_port *ap = qc->ap; | ||
6145 | |||
6146 | /* Use polling pio if the LLD doesn't handle | ||
6147 | * interrupt driven pio and atapi CDB interrupt. | ||
6148 | */ | ||
6149 | if (ap->flags & ATA_FLAG_PIO_POLLING) { | ||
6150 | switch (qc->tf.protocol) { | ||
6151 | case ATA_PROT_PIO: | ||
6152 | case ATA_PROT_NODATA: | ||
6153 | case ATAPI_PROT_PIO: | ||
6154 | case ATAPI_PROT_NODATA: | ||
6155 | qc->tf.flags |= ATA_TFLAG_POLLING; | ||
6156 | break; | ||
6157 | case ATAPI_PROT_DMA: | ||
6158 | if (qc->dev->flags & ATA_DFLAG_CDB_INTR) | ||
6159 | /* see ata_dma_blacklisted() */ | ||
6160 | BUG(); | ||
6161 | break; | ||
6162 | default: | ||
6163 | break; | ||
6164 | } | ||
6165 | } | ||
6166 | |||
6167 | /* select the device */ | ||
6168 | ata_dev_select(ap, qc->dev->devno, 1, 0); | ||
6169 | |||
6170 | /* start the command */ | ||
6171 | switch (qc->tf.protocol) { | ||
6172 | case ATA_PROT_NODATA: | ||
6173 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
6174 | ata_qc_set_polling(qc); | ||
6175 | |||
6176 | ata_tf_to_host(ap, &qc->tf); | ||
6177 | ap->hsm_task_state = HSM_ST_LAST; | ||
6178 | |||
6179 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
6180 | ata_pio_queue_task(ap, qc, 0); | ||
6181 | |||
6182 | break; | ||
6183 | |||
6184 | case ATA_PROT_DMA: | ||
6185 | WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); | ||
6186 | |||
6187 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | ||
6188 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | ||
6189 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | ||
6190 | ap->hsm_task_state = HSM_ST_LAST; | ||
6191 | break; | ||
6192 | |||
6193 | case ATA_PROT_PIO: | ||
6194 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
6195 | ata_qc_set_polling(qc); | ||
6196 | |||
6197 | ata_tf_to_host(ap, &qc->tf); | ||
6198 | |||
6199 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | ||
6200 | /* PIO data out protocol */ | ||
6201 | ap->hsm_task_state = HSM_ST_FIRST; | ||
6202 | ata_pio_queue_task(ap, qc, 0); | ||
6203 | |||
6204 | /* always send first data block using | ||
6205 | * the ata_pio_task() codepath. | ||
6206 | */ | ||
6207 | } else { | ||
6208 | /* PIO data in protocol */ | ||
6209 | ap->hsm_task_state = HSM_ST; | ||
6210 | |||
6211 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
6212 | ata_pio_queue_task(ap, qc, 0); | ||
6213 | |||
6214 | /* if polling, ata_pio_task() handles the rest. | ||
6215 | * otherwise, interrupt handler takes over from here. | ||
6216 | */ | ||
6217 | } | ||
6218 | |||
6219 | break; | ||
6220 | |||
6221 | case ATAPI_PROT_PIO: | ||
6222 | case ATAPI_PROT_NODATA: | ||
6223 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
6224 | ata_qc_set_polling(qc); | ||
6225 | |||
6226 | ata_tf_to_host(ap, &qc->tf); | ||
6227 | |||
6228 | ap->hsm_task_state = HSM_ST_FIRST; | ||
6229 | |||
6230 | /* send cdb by polling if no cdb interrupt */ | ||
6231 | if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) || | ||
6232 | (qc->tf.flags & ATA_TFLAG_POLLING)) | ||
6233 | ata_pio_queue_task(ap, qc, 0); | ||
6234 | break; | ||
6235 | |||
6236 | case ATAPI_PROT_DMA: | ||
6237 | WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); | ||
6238 | |||
6239 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | ||
6240 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | ||
6241 | ap->hsm_task_state = HSM_ST_FIRST; | ||
6242 | |||
6243 | /* send cdb by polling if no cdb interrupt */ | ||
6244 | if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
6245 | ata_pio_queue_task(ap, qc, 0); | ||
6246 | break; | ||
6247 | |||
6248 | default: | ||
6249 | WARN_ON(1); | ||
6250 | return AC_ERR_SYSTEM; | ||
6251 | } | ||
6252 | |||
6253 | return 0; | ||
6254 | } | ||
6255 | |||
6256 | /** | ||
6257 | * ata_host_intr - Handle host interrupt for given (port, task) | ||
6258 | * @ap: Port on which interrupt arrived (possibly...) | ||
6259 | * @qc: Taskfile currently active in engine | ||
6260 | * | ||
6261 | * Handle host interrupt for given queued command. Currently, | ||
6262 | * only DMA interrupts are handled. All other commands are | ||
6263 | * handled via polling with interrupts disabled (nIEN bit). | ||
6264 | * | ||
6265 | * LOCKING: | ||
6266 | * spin_lock_irqsave(host lock) | ||
6267 | * | ||
6268 | * RETURNS: | ||
6269 | * One if interrupt was handled, zero if not (shared irq). | ||
6270 | */ | ||
6271 | |||
6272 | inline unsigned int ata_host_intr(struct ata_port *ap, | ||
6273 | struct ata_queued_cmd *qc) | ||
6274 | { | ||
6275 | struct ata_eh_info *ehi = &ap->link.eh_info; | ||
6276 | u8 status, host_stat = 0; | ||
6277 | |||
6278 | VPRINTK("ata%u: protocol %d task_state %d\n", | ||
6279 | ap->print_id, qc->tf.protocol, ap->hsm_task_state); | ||
6280 | |||
6281 | /* Check whether we are expecting interrupt in this state */ | ||
6282 | switch (ap->hsm_task_state) { | ||
6283 | case HSM_ST_FIRST: | ||
6284 | /* Some pre-ATAPI-4 devices assert INTRQ | ||
6285 | * at this state when ready to receive CDB. | ||
6286 | */ | ||
6287 | |||
6288 | /* Check the ATA_DFLAG_CDB_INTR flag is enough here. | ||
6289 | * The flag was turned on only for atapi devices. No | ||
6290 | * need to check ata_is_atapi(qc->tf.protocol) again. | ||
6291 | */ | ||
6292 | if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
6293 | goto idle_irq; | ||
6294 | break; | ||
6295 | case HSM_ST_LAST: | ||
6296 | if (qc->tf.protocol == ATA_PROT_DMA || | ||
6297 | qc->tf.protocol == ATAPI_PROT_DMA) { | ||
6298 | /* check status of DMA engine */ | ||
6299 | host_stat = ap->ops->bmdma_status(ap); | ||
6300 | VPRINTK("ata%u: host_stat 0x%X\n", | ||
6301 | ap->print_id, host_stat); | ||
6302 | |||
6303 | /* if it's not our irq... */ | ||
6304 | if (!(host_stat & ATA_DMA_INTR)) | ||
6305 | goto idle_irq; | ||
6306 | |||
6307 | /* before we do anything else, clear DMA-Start bit */ | ||
6308 | ap->ops->bmdma_stop(qc); | ||
6309 | |||
6310 | if (unlikely(host_stat & ATA_DMA_ERR)) { | ||
6311 | /* error when transfering data to/from memory */ | ||
6312 | qc->err_mask |= AC_ERR_HOST_BUS; | ||
6313 | ap->hsm_task_state = HSM_ST_ERR; | ||
6314 | } | ||
6315 | } | ||
6316 | break; | ||
6317 | case HSM_ST: | ||
6318 | break; | ||
6319 | default: | ||
6320 | goto idle_irq; | ||
6321 | } | ||
6322 | |||
6323 | /* check altstatus */ | ||
6324 | status = ata_altstatus(ap); | ||
6325 | if (status & ATA_BUSY) | ||
6326 | goto idle_irq; | ||
6327 | |||
6328 | /* check main status, clearing INTRQ */ | ||
6329 | status = ata_chk_status(ap); | ||
6330 | if (unlikely(status & ATA_BUSY)) | ||
6331 | goto idle_irq; | ||
6332 | |||
6333 | /* ack bmdma irq events */ | ||
6334 | ap->ops->irq_clear(ap); | ||
6335 | |||
6336 | ata_hsm_move(ap, qc, status, 0); | ||
6337 | |||
6338 | if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA || | ||
6339 | qc->tf.protocol == ATAPI_PROT_DMA)) | ||
6340 | ata_ehi_push_desc(ehi, "BMDMA stat 0x%x", host_stat); | ||
6341 | |||
6342 | return 1; /* irq handled */ | ||
6343 | |||
6344 | idle_irq: | ||
6345 | ap->stats.idle_irq++; | ||
6346 | |||
6347 | #ifdef ATA_IRQ_TRAP | ||
6348 | if ((ap->stats.idle_irq % 1000) == 0) { | ||
6349 | ata_chk_status(ap); | ||
6350 | ap->ops->irq_clear(ap); | ||
6351 | ata_port_printk(ap, KERN_WARNING, "irq trap\n"); | ||
6352 | return 1; | ||
6353 | } | ||
6354 | #endif | ||
6355 | return 0; /* irq not handled */ | ||
6356 | } | ||
6357 | |||
6358 | /** | ||
6359 | * ata_interrupt - Default ATA host interrupt handler | ||
6360 | * @irq: irq line (unused) | ||
6361 | * @dev_instance: pointer to our ata_host information structure | ||
6362 | * | ||
6363 | * Default interrupt handler for PCI IDE devices. Calls | ||
6364 | * ata_host_intr() for each port that is not disabled. | ||
6365 | * | ||
6366 | * LOCKING: | ||
6367 | * Obtains host lock during operation. | ||
6368 | * | ||
6369 | * RETURNS: | ||
6370 | * IRQ_NONE or IRQ_HANDLED. | ||
6371 | */ | ||
6372 | |||
6373 | irqreturn_t ata_interrupt(int irq, void *dev_instance) | ||
6374 | { | ||
6375 | struct ata_host *host = dev_instance; | ||
6376 | unsigned int i; | ||
6377 | unsigned int handled = 0; | ||
6378 | unsigned long flags; | ||
6379 | |||
6380 | /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */ | ||
6381 | spin_lock_irqsave(&host->lock, flags); | ||
6382 | |||
6383 | for (i = 0; i < host->n_ports; i++) { | ||
6384 | struct ata_port *ap; | ||
6385 | |||
6386 | ap = host->ports[i]; | ||
6387 | if (ap && | ||
6388 | !(ap->flags & ATA_FLAG_DISABLED)) { | ||
6389 | struct ata_queued_cmd *qc; | ||
6390 | |||
6391 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | ||
6392 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && | ||
6393 | (qc->flags & ATA_QCFLAG_ACTIVE)) | ||
6394 | handled |= ata_host_intr(ap, qc); | ||
6395 | } | ||
6396 | } | ||
6397 | |||
6398 | spin_unlock_irqrestore(&host->lock, flags); | ||
6399 | |||
6400 | return IRQ_RETVAL(handled); | ||
6401 | } | ||
6402 | |||
6403 | /** | ||
6404 | * sata_scr_valid - test whether SCRs are accessible | 4609 | * sata_scr_valid - test whether SCRs are accessible |
6405 | * @link: ATA link to test SCR accessibility for | 4610 | * @link: ATA link to test SCR accessibility for |
6406 | * | 4611 | * |
@@ -7432,33 +5637,6 @@ void ata_host_detach(struct ata_host *host) | |||
7432 | ata_acpi_dissociate(host); | 5637 | ata_acpi_dissociate(host); |
7433 | } | 5638 | } |
7434 | 5639 | ||
7435 | /** | ||
7436 | * ata_std_ports - initialize ioaddr with standard port offsets. | ||
7437 | * @ioaddr: IO address structure to be initialized | ||
7438 | * | ||
7439 | * Utility function which initializes data_addr, error_addr, | ||
7440 | * feature_addr, nsect_addr, lbal_addr, lbam_addr, lbah_addr, | ||
7441 | * device_addr, status_addr, and command_addr to standard offsets | ||
7442 | * relative to cmd_addr. | ||
7443 | * | ||
7444 | * Does not set ctl_addr, altstatus_addr, bmdma_addr, or scr_addr. | ||
7445 | */ | ||
7446 | |||
7447 | void ata_std_ports(struct ata_ioports *ioaddr) | ||
7448 | { | ||
7449 | ioaddr->data_addr = ioaddr->cmd_addr + ATA_REG_DATA; | ||
7450 | ioaddr->error_addr = ioaddr->cmd_addr + ATA_REG_ERR; | ||
7451 | ioaddr->feature_addr = ioaddr->cmd_addr + ATA_REG_FEATURE; | ||
7452 | ioaddr->nsect_addr = ioaddr->cmd_addr + ATA_REG_NSECT; | ||
7453 | ioaddr->lbal_addr = ioaddr->cmd_addr + ATA_REG_LBAL; | ||
7454 | ioaddr->lbam_addr = ioaddr->cmd_addr + ATA_REG_LBAM; | ||
7455 | ioaddr->lbah_addr = ioaddr->cmd_addr + ATA_REG_LBAH; | ||
7456 | ioaddr->device_addr = ioaddr->cmd_addr + ATA_REG_DEVICE; | ||
7457 | ioaddr->status_addr = ioaddr->cmd_addr + ATA_REG_STATUS; | ||
7458 | ioaddr->command_addr = ioaddr->cmd_addr + ATA_REG_CMD; | ||
7459 | } | ||
7460 | |||
7461 | |||
7462 | #ifdef CONFIG_PCI | 5640 | #ifdef CONFIG_PCI |
7463 | 5641 | ||
7464 | /** | 5642 | /** |
@@ -7890,12 +6068,9 @@ EXPORT_SYMBOL_GPL(sata_deb_timing_long); | |||
7890 | EXPORT_SYMBOL_GPL(ata_base_port_ops); | 6068 | EXPORT_SYMBOL_GPL(ata_base_port_ops); |
7891 | EXPORT_SYMBOL_GPL(sata_port_ops); | 6069 | EXPORT_SYMBOL_GPL(sata_port_ops); |
7892 | EXPORT_SYMBOL_GPL(sata_pmp_port_ops); | 6070 | EXPORT_SYMBOL_GPL(sata_pmp_port_ops); |
7893 | EXPORT_SYMBOL_GPL(ata_sff_port_ops); | ||
7894 | EXPORT_SYMBOL_GPL(ata_bmdma_port_ops); | ||
7895 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); | 6071 | EXPORT_SYMBOL_GPL(ata_dummy_port_ops); |
7896 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); | 6072 | EXPORT_SYMBOL_GPL(ata_dummy_port_info); |
7897 | EXPORT_SYMBOL_GPL(ata_std_bios_param); | 6073 | EXPORT_SYMBOL_GPL(ata_std_bios_param); |
7898 | EXPORT_SYMBOL_GPL(ata_std_ports); | ||
7899 | EXPORT_SYMBOL_GPL(ata_host_init); | 6074 | EXPORT_SYMBOL_GPL(ata_host_init); |
7900 | EXPORT_SYMBOL_GPL(ata_host_alloc); | 6075 | EXPORT_SYMBOL_GPL(ata_host_alloc); |
7901 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); | 6076 | EXPORT_SYMBOL_GPL(ata_host_alloc_pinfo); |
@@ -7904,14 +6079,9 @@ EXPORT_SYMBOL_GPL(ata_host_register); | |||
7904 | EXPORT_SYMBOL_GPL(ata_host_activate); | 6079 | EXPORT_SYMBOL_GPL(ata_host_activate); |
7905 | EXPORT_SYMBOL_GPL(ata_host_detach); | 6080 | EXPORT_SYMBOL_GPL(ata_host_detach); |
7906 | EXPORT_SYMBOL_GPL(ata_sg_init); | 6081 | EXPORT_SYMBOL_GPL(ata_sg_init); |
7907 | EXPORT_SYMBOL_GPL(ata_hsm_move); | ||
7908 | EXPORT_SYMBOL_GPL(ata_qc_complete); | 6082 | EXPORT_SYMBOL_GPL(ata_qc_complete); |
7909 | EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); | 6083 | EXPORT_SYMBOL_GPL(ata_qc_complete_multiple); |
7910 | EXPORT_SYMBOL_GPL(ata_qc_issue_prot); | ||
7911 | EXPORT_SYMBOL_GPL(ata_tf_load); | ||
7912 | EXPORT_SYMBOL_GPL(ata_tf_read); | ||
7913 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); | 6084 | EXPORT_SYMBOL_GPL(ata_noop_dev_select); |
7914 | EXPORT_SYMBOL_GPL(ata_std_dev_select); | ||
7915 | EXPORT_SYMBOL_GPL(sata_print_link_status); | 6085 | EXPORT_SYMBOL_GPL(sata_print_link_status); |
7916 | EXPORT_SYMBOL_GPL(atapi_cmd_type); | 6086 | EXPORT_SYMBOL_GPL(atapi_cmd_type); |
7917 | EXPORT_SYMBOL_GPL(ata_tf_to_fis); | 6087 | EXPORT_SYMBOL_GPL(ata_tf_to_fis); |
@@ -7923,54 +6093,27 @@ EXPORT_SYMBOL_GPL(ata_xfer_mode2mask); | |||
7923 | EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); | 6093 | EXPORT_SYMBOL_GPL(ata_xfer_mode2shift); |
7924 | EXPORT_SYMBOL_GPL(ata_mode_string); | 6094 | EXPORT_SYMBOL_GPL(ata_mode_string); |
7925 | EXPORT_SYMBOL_GPL(ata_id_xfermask); | 6095 | EXPORT_SYMBOL_GPL(ata_id_xfermask); |
7926 | EXPORT_SYMBOL_GPL(ata_check_status); | ||
7927 | EXPORT_SYMBOL_GPL(ata_altstatus); | ||
7928 | EXPORT_SYMBOL_GPL(ata_exec_command); | ||
7929 | EXPORT_SYMBOL_GPL(ata_port_start); | 6096 | EXPORT_SYMBOL_GPL(ata_port_start); |
7930 | EXPORT_SYMBOL_GPL(ata_sff_port_start); | ||
7931 | EXPORT_SYMBOL_GPL(ata_interrupt); | ||
7932 | EXPORT_SYMBOL_GPL(ata_do_set_mode); | 6097 | EXPORT_SYMBOL_GPL(ata_do_set_mode); |
7933 | EXPORT_SYMBOL_GPL(ata_data_xfer); | ||
7934 | EXPORT_SYMBOL_GPL(ata_data_xfer_noirq); | ||
7935 | EXPORT_SYMBOL_GPL(ata_std_qc_defer); | 6098 | EXPORT_SYMBOL_GPL(ata_std_qc_defer); |
7936 | EXPORT_SYMBOL_GPL(ata_qc_prep); | ||
7937 | EXPORT_SYMBOL_GPL(ata_dumb_qc_prep); | ||
7938 | EXPORT_SYMBOL_GPL(ata_noop_qc_prep); | 6099 | EXPORT_SYMBOL_GPL(ata_noop_qc_prep); |
7939 | EXPORT_SYMBOL_GPL(ata_bmdma_setup); | ||
7940 | EXPORT_SYMBOL_GPL(ata_bmdma_start); | ||
7941 | EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear); | ||
7942 | EXPORT_SYMBOL_GPL(ata_noop_irq_clear); | 6100 | EXPORT_SYMBOL_GPL(ata_noop_irq_clear); |
7943 | EXPORT_SYMBOL_GPL(ata_bmdma_status); | ||
7944 | EXPORT_SYMBOL_GPL(ata_bmdma_stop); | ||
7945 | EXPORT_SYMBOL_GPL(ata_bmdma_freeze); | ||
7946 | EXPORT_SYMBOL_GPL(ata_bmdma_thaw); | ||
7947 | EXPORT_SYMBOL_GPL(ata_bmdma_error_handler); | ||
7948 | EXPORT_SYMBOL_GPL(ata_bmdma_post_internal_cmd); | ||
7949 | EXPORT_SYMBOL_GPL(ata_port_probe); | 6101 | EXPORT_SYMBOL_GPL(ata_port_probe); |
7950 | EXPORT_SYMBOL_GPL(ata_dev_disable); | 6102 | EXPORT_SYMBOL_GPL(ata_dev_disable); |
7951 | EXPORT_SYMBOL_GPL(sata_set_spd); | 6103 | EXPORT_SYMBOL_GPL(sata_set_spd); |
7952 | EXPORT_SYMBOL_GPL(sata_link_debounce); | 6104 | EXPORT_SYMBOL_GPL(sata_link_debounce); |
7953 | EXPORT_SYMBOL_GPL(sata_link_resume); | 6105 | EXPORT_SYMBOL_GPL(sata_link_resume); |
7954 | EXPORT_SYMBOL_GPL(ata_bus_reset); | ||
7955 | EXPORT_SYMBOL_GPL(ata_std_prereset); | ||
7956 | EXPORT_SYMBOL_GPL(ata_std_softreset); | ||
7957 | EXPORT_SYMBOL_GPL(sata_link_hardreset); | 6106 | EXPORT_SYMBOL_GPL(sata_link_hardreset); |
7958 | EXPORT_SYMBOL_GPL(sata_std_hardreset); | ||
7959 | EXPORT_SYMBOL_GPL(ata_std_postreset); | ||
7960 | EXPORT_SYMBOL_GPL(ata_dev_classify); | 6107 | EXPORT_SYMBOL_GPL(ata_dev_classify); |
7961 | EXPORT_SYMBOL_GPL(ata_dev_pair); | 6108 | EXPORT_SYMBOL_GPL(ata_dev_pair); |
7962 | EXPORT_SYMBOL_GPL(ata_port_disable); | 6109 | EXPORT_SYMBOL_GPL(ata_port_disable); |
7963 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 6110 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
7964 | EXPORT_SYMBOL_GPL(ata_wait_register); | 6111 | EXPORT_SYMBOL_GPL(ata_wait_register); |
7965 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | ||
7966 | EXPORT_SYMBOL_GPL(ata_wait_after_reset); | ||
7967 | EXPORT_SYMBOL_GPL(ata_wait_ready); | ||
7968 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 6112 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |
7969 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); | 6113 | EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); |
7970 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); | 6114 | EXPORT_SYMBOL_GPL(ata_scsi_slave_config); |
7971 | EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); | 6115 | EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); |
7972 | EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth); | 6116 | EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth); |
7973 | EXPORT_SYMBOL_GPL(ata_host_intr); | ||
7974 | EXPORT_SYMBOL_GPL(sata_scr_valid); | 6117 | EXPORT_SYMBOL_GPL(sata_scr_valid); |
7975 | EXPORT_SYMBOL_GPL(sata_scr_read); | 6118 | EXPORT_SYMBOL_GPL(sata_scr_read); |
7976 | EXPORT_SYMBOL_GPL(sata_scr_write); | 6119 | EXPORT_SYMBOL_GPL(sata_scr_write); |
@@ -7993,11 +6136,6 @@ EXPORT_SYMBOL_GPL(ata_timing_cycle2mode); | |||
7993 | 6136 | ||
7994 | #ifdef CONFIG_PCI | 6137 | #ifdef CONFIG_PCI |
7995 | EXPORT_SYMBOL_GPL(pci_test_config_bits); | 6138 | EXPORT_SYMBOL_GPL(pci_test_config_bits); |
7996 | EXPORT_SYMBOL_GPL(ata_pci_init_sff_host); | ||
7997 | EXPORT_SYMBOL_GPL(ata_pci_init_bmdma); | ||
7998 | EXPORT_SYMBOL_GPL(ata_pci_prepare_sff_host); | ||
7999 | EXPORT_SYMBOL_GPL(ata_pci_activate_sff_host); | ||
8000 | EXPORT_SYMBOL_GPL(ata_pci_init_one); | ||
8001 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); | 6139 | EXPORT_SYMBOL_GPL(ata_pci_remove_one); |
8002 | #ifdef CONFIG_PM | 6140 | #ifdef CONFIG_PM |
8003 | EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); | 6141 | EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend); |
@@ -8005,8 +6143,6 @@ EXPORT_SYMBOL_GPL(ata_pci_device_do_resume); | |||
8005 | EXPORT_SYMBOL_GPL(ata_pci_device_suspend); | 6143 | EXPORT_SYMBOL_GPL(ata_pci_device_suspend); |
8006 | EXPORT_SYMBOL_GPL(ata_pci_device_resume); | 6144 | EXPORT_SYMBOL_GPL(ata_pci_device_resume); |
8007 | #endif /* CONFIG_PM */ | 6145 | #endif /* CONFIG_PM */ |
8008 | EXPORT_SYMBOL_GPL(ata_pci_default_filter); | ||
8009 | EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); | ||
8010 | #endif /* CONFIG_PCI */ | 6146 | #endif /* CONFIG_PCI */ |
8011 | 6147 | ||
8012 | EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch); | 6148 | EXPORT_SYMBOL_GPL(sata_pmp_qc_defer_cmd_switch); |
@@ -8033,8 +6169,6 @@ EXPORT_SYMBOL_GPL(ata_eh_qc_complete); | |||
8033 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); | 6169 | EXPORT_SYMBOL_GPL(ata_eh_qc_retry); |
8034 | EXPORT_SYMBOL_GPL(ata_do_eh); | 6170 | EXPORT_SYMBOL_GPL(ata_do_eh); |
8035 | EXPORT_SYMBOL_GPL(ata_std_error_handler); | 6171 | EXPORT_SYMBOL_GPL(ata_std_error_handler); |
8036 | EXPORT_SYMBOL_GPL(ata_irq_on); | ||
8037 | EXPORT_SYMBOL_GPL(ata_dev_try_classify); | ||
8038 | 6172 | ||
8039 | EXPORT_SYMBOL_GPL(ata_cable_40wire); | 6173 | EXPORT_SYMBOL_GPL(ata_cable_40wire); |
8040 | EXPORT_SYMBOL_GPL(ata_cable_80wire); | 6174 | EXPORT_SYMBOL_GPL(ata_cable_80wire); |