diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-29 15:11:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-29 15:11:54 -0400 |
commit | 00cda56d39f013cce60f44f1e3da19b87eba5d85 (patch) | |
tree | 2cfe7bf556562a846ff46a558a31ca1939d2e12c /drivers/ata/libata-core.c | |
parent | da8e5aa21e037be02e0752e80b9444ff60185a3f (diff) | |
parent | ab6fc95f609b372a19e18ea689986846ab1ba29c (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev:
[libata] AHCI: fix newly introduced host-reset bug
[libata] sata_nv: fix SWNCQ enabling
libata: add MAXTOR 7V300F0/VA111900 to NCQ blacklist
libata: no need to speed down if already at PIO0
libata: relocate forcing PIO0 on reset
pata_ns87415: define SUPERIO_IDE_MAX_RETRIES
[libata] Address some checkpatch-spotted issues
[libata] fix 'if(' and similar areas that lack whitespace
libata: implement ata_wait_after_reset()
libata: track SLEEP state and issue SRST to wake it up
libata: relocate and fix post-command processing
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r-- | drivers/ata/libata-core.c | 146 |
1 files changed, 106 insertions, 40 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 7ef515b3382d..e512903b8dbb 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -2219,6 +2219,25 @@ int ata_bus_probe(struct ata_port *ap) | |||
2219 | tries[dev->devno] = ATA_PROBE_MAX_TRIES; | 2219 | tries[dev->devno] = ATA_PROBE_MAX_TRIES; |
2220 | 2220 | ||
2221 | retry: | 2221 | retry: |
2222 | ata_link_for_each_dev(dev, &ap->link) { | ||
2223 | /* If we issue an SRST then an ATA drive (not ATAPI) | ||
2224 | * may change configuration and be in PIO0 timing. If | ||
2225 | * we do a hard reset (or are coming from power on) | ||
2226 | * this is true for ATA or ATAPI. Until we've set a | ||
2227 | * suitable controller mode we should not touch the | ||
2228 | * bus as we may be talking too fast. | ||
2229 | */ | ||
2230 | dev->pio_mode = XFER_PIO_0; | ||
2231 | |||
2232 | /* If the controller has a pio mode setup function | ||
2233 | * then use it to set the chipset to rights. Don't | ||
2234 | * touch the DMA setup as that will be dealt with when | ||
2235 | * configuring devices. | ||
2236 | */ | ||
2237 | if (ap->ops->set_piomode) | ||
2238 | ap->ops->set_piomode(ap, dev); | ||
2239 | } | ||
2240 | |||
2222 | /* reset and determine device classes */ | 2241 | /* reset and determine device classes */ |
2223 | ap->ops->phy_reset(ap); | 2242 | ap->ops->phy_reset(ap); |
2224 | 2243 | ||
@@ -2234,12 +2253,6 @@ int ata_bus_probe(struct ata_port *ap) | |||
2234 | 2253 | ||
2235 | ata_port_probe(ap); | 2254 | ata_port_probe(ap); |
2236 | 2255 | ||
2237 | /* after the reset the device state is PIO 0 and the controller | ||
2238 | state is undefined. Record the mode */ | ||
2239 | |||
2240 | ata_link_for_each_dev(dev, &ap->link) | ||
2241 | dev->pio_mode = XFER_PIO_0; | ||
2242 | |||
2243 | /* read IDENTIFY page and configure devices. We have to do the identify | 2256 | /* read IDENTIFY page and configure devices. We have to do the identify |
2244 | specific sequence bass-ackwards so that PDIAG- is released by | 2257 | specific sequence bass-ackwards so that PDIAG- is released by |
2245 | the slave device */ | 2258 | the slave device */ |
@@ -3118,6 +3131,55 @@ int ata_busy_sleep(struct ata_port *ap, | |||
3118 | } | 3131 | } |
3119 | 3132 | ||
3120 | /** | 3133 | /** |
3134 | * ata_wait_after_reset - wait before checking status after reset | ||
3135 | * @ap: port containing status register to be polled | ||
3136 | * @deadline: deadline jiffies for the operation | ||
3137 | * | ||
3138 | * After reset, we need to pause a while before reading status. | ||
3139 | * Also, certain combination of controller and device report 0xff | ||
3140 | * for some duration (e.g. until SATA PHY is up and running) | ||
3141 | * which is interpreted as empty port in ATA world. This | ||
3142 | * function also waits for such devices to get out of 0xff | ||
3143 | * status. | ||
3144 | * | ||
3145 | * LOCKING: | ||
3146 | * Kernel thread context (may sleep). | ||
3147 | */ | ||
3148 | void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline) | ||
3149 | { | ||
3150 | unsigned long until = jiffies + ATA_TMOUT_FF_WAIT; | ||
3151 | |||
3152 | if (time_before(until, deadline)) | ||
3153 | deadline = until; | ||
3154 | |||
3155 | /* Spec mandates ">= 2ms" before checking status. We wait | ||
3156 | * 150ms, because that was the magic delay used for ATAPI | ||
3157 | * devices in Hale Landis's ATADRVR, for the period of time | ||
3158 | * between when the ATA command register is written, and then | ||
3159 | * status is checked. Because waiting for "a while" before | ||
3160 | * checking status is fine, post SRST, we perform this magic | ||
3161 | * delay here as well. | ||
3162 | * | ||
3163 | * Old drivers/ide uses the 2mS rule and then waits for ready. | ||
3164 | */ | ||
3165 | msleep(150); | ||
3166 | |||
3167 | /* Wait for 0xff to clear. Some SATA devices take a long time | ||
3168 | * to clear 0xff after reset. For example, HHD424020F7SV00 | ||
3169 | * iVDR needs >= 800ms while. Quantum GoVault needs even more | ||
3170 | * than that. | ||
3171 | */ | ||
3172 | while (1) { | ||
3173 | u8 status = ata_chk_status(ap); | ||
3174 | |||
3175 | if (status != 0xff || time_after(jiffies, deadline)) | ||
3176 | return; | ||
3177 | |||
3178 | msleep(50); | ||
3179 | } | ||
3180 | } | ||
3181 | |||
3182 | /** | ||
3121 | * ata_wait_ready - sleep until BSY clears, or timeout | 3183 | * ata_wait_ready - sleep until BSY clears, or timeout |
3122 | * @ap: port containing status register to be polled | 3184 | * @ap: port containing status register to be polled |
3123 | * @deadline: deadline jiffies for the operation | 3185 | * @deadline: deadline jiffies for the operation |
@@ -3223,8 +3285,6 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
3223 | unsigned long deadline) | 3285 | unsigned long deadline) |
3224 | { | 3286 | { |
3225 | struct ata_ioports *ioaddr = &ap->ioaddr; | 3287 | struct ata_ioports *ioaddr = &ap->ioaddr; |
3226 | struct ata_device *dev; | ||
3227 | int i = 0; | ||
3228 | 3288 | ||
3229 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); | 3289 | DPRINTK("ata%u: bus reset via SRST\n", ap->print_id); |
3230 | 3290 | ||
@@ -3235,36 +3295,8 @@ static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, | |||
3235 | udelay(20); /* FIXME: flush */ | 3295 | udelay(20); /* FIXME: flush */ |
3236 | iowrite8(ap->ctl, ioaddr->ctl_addr); | 3296 | iowrite8(ap->ctl, ioaddr->ctl_addr); |
3237 | 3297 | ||
3238 | /* If we issued an SRST then an ATA drive (not ATAPI) | 3298 | /* wait a while before checking status */ |
3239 | * may have changed configuration and be in PIO0 timing. If | 3299 | ata_wait_after_reset(ap, deadline); |
3240 | * we did a hard reset (or are coming from power on) this is | ||
3241 | * true for ATA or ATAPI. Until we've set a suitable controller | ||
3242 | * mode we should not touch the bus as we may be talking too fast. | ||
3243 | */ | ||
3244 | |||
3245 | ata_link_for_each_dev(dev, &ap->link) | ||
3246 | dev->pio_mode = XFER_PIO_0; | ||
3247 | |||
3248 | /* If the controller has a pio mode setup function then use | ||
3249 | it to set the chipset to rights. Don't touch the DMA setup | ||
3250 | as that will be dealt with when revalidating */ | ||
3251 | if (ap->ops->set_piomode) { | ||
3252 | ata_link_for_each_dev(dev, &ap->link) | ||
3253 | if (devmask & (1 << i++)) | ||
3254 | ap->ops->set_piomode(ap, dev); | ||
3255 | } | ||
3256 | |||
3257 | /* spec mandates ">= 2ms" before checking status. | ||
3258 | * We wait 150ms, because that was the magic delay used for | ||
3259 | * ATAPI devices in Hale Landis's ATADRVR, for the period of time | ||
3260 | * between when the ATA command register is written, and then | ||
3261 | * status is checked. Because waiting for "a while" before | ||
3262 | * checking status is fine, post SRST, we perform this magic | ||
3263 | * delay here as well. | ||
3264 | * | ||
3265 | * Old drivers/ide uses the 2mS rule and then waits for ready | ||
3266 | */ | ||
3267 | msleep(150); | ||
3268 | 3300 | ||
3269 | /* Before we perform post reset processing we want to see if | 3301 | /* Before we perform post reset processing we want to see if |
3270 | * the bus shows 0xFF because the odd clown forgets the D7 | 3302 | * the bus shows 0xFF because the odd clown forgets the D7 |
@@ -3691,8 +3723,8 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class, | |||
3691 | return 0; | 3723 | return 0; |
3692 | } | 3724 | } |
3693 | 3725 | ||
3694 | /* wait a while before checking status, see SRST for more info */ | 3726 | /* wait a while before checking status */ |
3695 | msleep(150); | 3727 | ata_wait_after_reset(ap, deadline); |
3696 | 3728 | ||
3697 | /* If PMP is supported, we have to do follow-up SRST. Note | 3729 | /* If PMP is supported, we have to do follow-up SRST. Note |
3698 | * that some PMPs don't send D2H Reg FIS after hardreset at | 3730 | * that some PMPs don't send D2H Reg FIS after hardreset at |
@@ -3992,6 +4024,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { | |||
3992 | { "ST3160812AS", "3.ADJ", ATA_HORKAGE_NONCQ, }, | 4024 | { "ST3160812AS", "3.ADJ", ATA_HORKAGE_NONCQ, }, |
3993 | { "ST980813AS", "3.ADB", ATA_HORKAGE_NONCQ, }, | 4025 | { "ST980813AS", "3.ADB", ATA_HORKAGE_NONCQ, }, |
3994 | { "SAMSUNG HD401LJ", "ZZ100-15", ATA_HORKAGE_NONCQ, }, | 4026 | { "SAMSUNG HD401LJ", "ZZ100-15", ATA_HORKAGE_NONCQ, }, |
4027 | { "Maxtor 7V300F0", "VA111900", ATA_HORKAGE_NONCQ, }, | ||
3995 | 4028 | ||
3996 | /* devices which puke on READ_NATIVE_MAX */ | 4029 | /* devices which puke on READ_NATIVE_MAX */ |
3997 | { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, | 4030 | { "HDS724040KLSA80", "KFAOA20N", ATA_HORKAGE_BROKEN_HPA, }, |
@@ -5595,6 +5628,9 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
5595 | * taken care of. | 5628 | * taken care of. |
5596 | */ | 5629 | */ |
5597 | if (ap->ops->error_handler) { | 5630 | if (ap->ops->error_handler) { |
5631 | struct ata_device *dev = qc->dev; | ||
5632 | struct ata_eh_info *ehi = &dev->link->eh_info; | ||
5633 | |||
5598 | WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); | 5634 | WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); |
5599 | 5635 | ||
5600 | if (unlikely(qc->err_mask)) | 5636 | if (unlikely(qc->err_mask)) |
@@ -5613,6 +5649,27 @@ void ata_qc_complete(struct ata_queued_cmd *qc) | |||
5613 | if (qc->flags & ATA_QCFLAG_RESULT_TF) | 5649 | if (qc->flags & ATA_QCFLAG_RESULT_TF) |
5614 | fill_result_tf(qc); | 5650 | fill_result_tf(qc); |
5615 | 5651 | ||
5652 | /* Some commands need post-processing after successful | ||
5653 | * completion. | ||
5654 | */ | ||
5655 | switch (qc->tf.command) { | ||
5656 | case ATA_CMD_SET_FEATURES: | ||
5657 | if (qc->tf.feature != SETFEATURES_WC_ON && | ||
5658 | qc->tf.feature != SETFEATURES_WC_OFF) | ||
5659 | break; | ||
5660 | /* fall through */ | ||
5661 | case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ | ||
5662 | case ATA_CMD_SET_MULTI: /* multi_count changed */ | ||
5663 | /* revalidate device */ | ||
5664 | ehi->dev_action[dev->devno] |= ATA_EH_REVALIDATE; | ||
5665 | ata_port_schedule_eh(ap); | ||
5666 | break; | ||
5667 | |||
5668 | case ATA_CMD_SLEEP: | ||
5669 | dev->flags |= ATA_DFLAG_SLEEPING; | ||
5670 | break; | ||
5671 | } | ||
5672 | |||
5616 | __ata_qc_complete(qc); | 5673 | __ata_qc_complete(qc); |
5617 | } else { | 5674 | } else { |
5618 | if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) | 5675 | if (qc->flags & ATA_QCFLAG_EH_SCHEDULED) |
@@ -5750,6 +5807,14 @@ void ata_qc_issue(struct ata_queued_cmd *qc) | |||
5750 | qc->flags &= ~ATA_QCFLAG_DMAMAP; | 5807 | qc->flags &= ~ATA_QCFLAG_DMAMAP; |
5751 | } | 5808 | } |
5752 | 5809 | ||
5810 | /* if device is sleeping, schedule softreset and abort the link */ | ||
5811 | if (unlikely(qc->dev->flags & ATA_DFLAG_SLEEPING)) { | ||
5812 | link->eh_info.action |= ATA_EH_SOFTRESET; | ||
5813 | ata_ehi_push_desc(&link->eh_info, "waking up from sleep"); | ||
5814 | ata_link_abort(link); | ||
5815 | return; | ||
5816 | } | ||
5817 | |||
5753 | ap->ops->qc_prep(qc); | 5818 | ap->ops->qc_prep(qc); |
5754 | 5819 | ||
5755 | qc->err_mask |= ap->ops->qc_issue(qc); | 5820 | qc->err_mask |= ap->ops->qc_issue(qc); |
@@ -7327,6 +7392,7 @@ EXPORT_SYMBOL_GPL(ata_port_disable); | |||
7327 | EXPORT_SYMBOL_GPL(ata_ratelimit); | 7392 | EXPORT_SYMBOL_GPL(ata_ratelimit); |
7328 | EXPORT_SYMBOL_GPL(ata_wait_register); | 7393 | EXPORT_SYMBOL_GPL(ata_wait_register); |
7329 | EXPORT_SYMBOL_GPL(ata_busy_sleep); | 7394 | EXPORT_SYMBOL_GPL(ata_busy_sleep); |
7395 | EXPORT_SYMBOL_GPL(ata_wait_after_reset); | ||
7330 | EXPORT_SYMBOL_GPL(ata_wait_ready); | 7396 | EXPORT_SYMBOL_GPL(ata_wait_ready); |
7331 | EXPORT_SYMBOL_GPL(ata_port_queue_task); | 7397 | EXPORT_SYMBOL_GPL(ata_port_queue_task); |
7332 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); | 7398 | EXPORT_SYMBOL_GPL(ata_scsi_ioctl); |