libata-eh.c (341c2c958ec7bdd9f54733a8b0b432fe76842a82) | libata-eh.c (0a2c0f56159999e20015241d3b8fa89b1ab14309) |
---|---|
1/* 2 * libata-eh.c - libata error handling 3 * 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com> 5 * Please ALWAYS copy linux-ide@vger.kernel.org 6 * on emails. 7 * 8 * Copyright 2006 Tejun Heo <htejun@gmail.com> --- 53 unchanged lines hidden (view full) --- 62 ATA_ECAT_TOUT_HSM = 2, 63 ATA_ECAT_UNK_DEV = 3, 64 ATA_ECAT_DUBIOUS_NONE = 4, 65 ATA_ECAT_DUBIOUS_ATA_BUS = 5, 66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6, 67 ATA_ECAT_DUBIOUS_UNK_DEV = 7, 68 ATA_ECAT_NR = 8, 69 | 1/* 2 * libata-eh.c - libata error handling 3 * 4 * Maintained by: Jeff Garzik <jgarzik@pobox.com> 5 * Please ALWAYS copy linux-ide@vger.kernel.org 6 * on emails. 7 * 8 * Copyright 2006 Tejun Heo <htejun@gmail.com> --- 53 unchanged lines hidden (view full) --- 62 ATA_ECAT_TOUT_HSM = 2, 63 ATA_ECAT_UNK_DEV = 3, 64 ATA_ECAT_DUBIOUS_NONE = 4, 65 ATA_ECAT_DUBIOUS_ATA_BUS = 5, 66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6, 67 ATA_ECAT_DUBIOUS_UNK_DEV = 7, 68 ATA_ECAT_NR = 8, 69 |
70 /* always put at least this amount of time between resets */ 71 ATA_EH_RESET_COOL_DOWN = 5000, 72 |
|
70 /* Waiting in ->prereset can never be reliable. It's 71 * sometimes nice to wait there but it can't be depended upon; 72 * otherwise, we wouldn't be resetting. Just give it enough 73 * time for most drives to spin up. 74 */ 75 ATA_EH_PRERESET_TIMEOUT = 10000, 76 ATA_EH_FASTDRAIN_INTERVAL = 3000, 77}; --- 402 unchanged lines hidden (view full) --- 480 481 ata_link_for_each_dev(dev, link) { 482 int devno = dev->devno; 483 484 ehc->saved_xfer_mode[devno] = dev->xfer_mode; 485 if (ata_ncq_enabled(dev)) 486 ehc->saved_ncq_enabled |= 1 << devno; 487 } | 73 /* Waiting in ->prereset can never be reliable. It's 74 * sometimes nice to wait there but it can't be depended upon; 75 * otherwise, we wouldn't be resetting. Just give it enough 76 * time for most drives to spin up. 77 */ 78 ATA_EH_PRERESET_TIMEOUT = 10000, 79 ATA_EH_FASTDRAIN_INTERVAL = 3000, 80}; --- 402 unchanged lines hidden (view full) --- 483 484 ata_link_for_each_dev(dev, link) { 485 int devno = dev->devno; 486 487 ehc->saved_xfer_mode[devno] = dev->xfer_mode; 488 if (ata_ncq_enabled(dev)) 489 ehc->saved_ncq_enabled |= 1 << devno; 490 } |
491 492 /* set last reset timestamp to some time in the past */ 493 ehc->last_reset = jiffies - 60 * HZ; |
|
488 } 489 490 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 491 ap->pflags &= ~ATA_PFLAG_EH_PENDING; 492 ap->excl_link = NULL; /* don't maintain exclusion over EH */ 493 494 spin_unlock_irqrestore(ap->lock, flags); 495 --- 1587 unchanged lines hidden (view full) --- 2083 ata_reset_fn_t reset; 2084 unsigned long flags; 2085 u32 sstatus; 2086 int nr_known, rc; 2087 2088 /* 2089 * Prepare to reset 2090 */ | 494 } 495 496 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 497 ap->pflags &= ~ATA_PFLAG_EH_PENDING; 498 ap->excl_link = NULL; /* don't maintain exclusion over EH */ 499 500 spin_unlock_irqrestore(ap->lock, flags); 501 --- 1587 unchanged lines hidden (view full) --- 2089 ata_reset_fn_t reset; 2090 unsigned long flags; 2091 u32 sstatus; 2092 int nr_known, rc; 2093 2094 /* 2095 * Prepare to reset 2096 */ |
2097 now = jiffies; 2098 deadline = ata_deadline(ehc->last_reset, ATA_EH_RESET_COOL_DOWN); 2099 if (time_before(now, deadline)) 2100 schedule_timeout_uninterruptible(deadline - now); 2101 |
|
2091 spin_lock_irqsave(ap->lock, flags); 2092 ap->pflags |= ATA_PFLAG_RESETTING; 2093 spin_unlock_irqrestore(ap->lock, flags); 2094 2095 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); | 2102 spin_lock_irqsave(ap->lock, flags); 2103 ap->pflags |= ATA_PFLAG_RESETTING; 2104 spin_unlock_irqrestore(ap->lock, flags); 2105 2106 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); |
2107 ehc->last_reset = jiffies; |
|
2096 2097 ata_link_for_each_dev(dev, link) { 2098 /* If we issue an SRST then an ATA drive (not ATAPI) 2099 * may change configuration and be in PIO0 timing. If 2100 * we do a hard reset (or are coming from power on) 2101 * this is true for ATA or ATAPI. Until we've set a 2102 * suitable controller mode we should not touch the 2103 * bus as we may be talking too fast. --- 49 unchanged lines hidden (view full) --- 2153 goto out; 2154 } 2155 } 2156 2157 retry: 2158 /* 2159 * Perform reset 2160 */ | 2108 2109 ata_link_for_each_dev(dev, link) { 2110 /* If we issue an SRST then an ATA drive (not ATAPI) 2111 * may change configuration and be in PIO0 timing. If 2112 * we do a hard reset (or are coming from power on) 2113 * this is true for ATA or ATAPI. Until we've set a 2114 * suitable controller mode we should not touch the 2115 * bus as we may be talking too fast. --- 49 unchanged lines hidden (view full) --- 2165 goto out; 2166 } 2167 } 2168 2169 retry: 2170 /* 2171 * Perform reset 2172 */ |
2173 ehc->last_reset = jiffies; |
|
2161 if (ata_is_host_link(link)) 2162 ata_eh_freeze_port(ap); 2163 2164 deadline = ata_deadline(jiffies, ata_eh_reset_timeouts[try++]); 2165 2166 if (reset) { 2167 if (verbose) 2168 ata_link_printk(link, KERN_INFO, "%s resetting link\n", --- 104 unchanged lines hidden (view full) --- 2273 } 2274 ata_link_printk(link, KERN_WARNING, 2275 "link online but device misclassified, " 2276 "device detection might fail\n"); 2277 } 2278 2279 /* reset successful, schedule revalidation */ 2280 ata_eh_done(link, NULL, ATA_EH_RESET); | 2174 if (ata_is_host_link(link)) 2175 ata_eh_freeze_port(ap); 2176 2177 deadline = ata_deadline(jiffies, ata_eh_reset_timeouts[try++]); 2178 2179 if (reset) { 2180 if (verbose) 2181 ata_link_printk(link, KERN_INFO, "%s resetting link\n", --- 104 unchanged lines hidden (view full) --- 2286 } 2287 ata_link_printk(link, KERN_WARNING, 2288 "link online but device misclassified, " 2289 "device detection might fail\n"); 2290 } 2291 2292 /* reset successful, schedule revalidation */ 2293 ata_eh_done(link, NULL, ATA_EH_RESET); |
2294 ehc->last_reset = jiffies; |
|
2281 ehc->i.action |= ATA_EH_REVALIDATE; 2282 2283 rc = 0; 2284 out: 2285 /* clear hotplug flag */ 2286 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; 2287 2288 spin_lock_irqsave(ap->lock, flags); --- 10 unchanged lines hidden (view full) --- 2299 2300 if (rc == -ERESTART || try >= max_tries) 2301 goto out; 2302 2303 now = jiffies; 2304 if (time_before(now, deadline)) { 2305 unsigned long delta = deadline - now; 2306 | 2295 ehc->i.action |= ATA_EH_REVALIDATE; 2296 2297 rc = 0; 2298 out: 2299 /* clear hotplug flag */ 2300 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED; 2301 2302 spin_lock_irqsave(ap->lock, flags); --- 10 unchanged lines hidden (view full) --- 2313 2314 if (rc == -ERESTART || try >= max_tries) 2315 goto out; 2316 2317 now = jiffies; 2318 if (time_before(now, deadline)) { 2319 unsigned long delta = deadline - now; 2320 |
2307 ata_link_printk(link, KERN_WARNING, "reset failed " 2308 "(errno=%d), retrying in %u secs\n", 2309 rc, (jiffies_to_msecs(delta) + 999) / 1000); | 2321 ata_link_printk(link, KERN_WARNING, 2322 "reset failed (errno=%d), retrying in %u secs\n", 2323 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); |
2310 2311 while (delta) 2312 delta = schedule_timeout_uninterruptible(delta); 2313 } 2314 2315 if (rc == -EPIPE || try == max_tries - 1) 2316 sata_down_spd_limit(link); 2317 if (hardreset) --- 300 unchanged lines hidden (view full) --- 2618 */ 2619int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, 2620 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 2621 ata_postreset_fn_t postreset, 2622 struct ata_link **r_failed_link) 2623{ 2624 struct ata_link *link; 2625 struct ata_device *dev; | 2324 2325 while (delta) 2326 delta = schedule_timeout_uninterruptible(delta); 2327 } 2328 2329 if (rc == -EPIPE || try == max_tries - 1) 2330 sata_down_spd_limit(link); 2331 if (hardreset) --- 300 unchanged lines hidden (view full) --- 2632 */ 2633int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, 2634 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 2635 ata_postreset_fn_t postreset, 2636 struct ata_link **r_failed_link) 2637{ 2638 struct ata_link *link; 2639 struct ata_device *dev; |
2626 int nr_failed_devs, nr_disabled_devs; | 2640 int nr_failed_devs; |
2627 int rc; 2628 unsigned long flags; 2629 2630 DPRINTK("ENTER\n"); 2631 2632 /* prep for recovery */ 2633 ata_port_for_each_link(link, ap) { 2634 struct ata_eh_context *ehc = &link->eh_context; --- 26 unchanged lines hidden (view full) --- 2661 if (!ata_dev_enabled(dev)) 2662 ata_eh_schedule_probe(dev); 2663 } 2664 } 2665 2666 retry: 2667 rc = 0; 2668 nr_failed_devs = 0; | 2641 int rc; 2642 unsigned long flags; 2643 2644 DPRINTK("ENTER\n"); 2645 2646 /* prep for recovery */ 2647 ata_port_for_each_link(link, ap) { 2648 struct ata_eh_context *ehc = &link->eh_context; --- 26 unchanged lines hidden (view full) --- 2675 if (!ata_dev_enabled(dev)) 2676 ata_eh_schedule_probe(dev); 2677 } 2678 } 2679 2680 retry: 2681 rc = 0; 2682 nr_failed_devs = 0; |
2669 nr_disabled_devs = 0; | |
2670 2671 /* if UNLOADING, finish immediately */ 2672 if (ap->pflags & ATA_PFLAG_UNLOADING) 2673 goto out; 2674 2675 /* prep for EH */ 2676 ata_port_for_each_link(link, ap) { 2677 struct ata_eh_context *ehc = &link->eh_context; --- 50 unchanged lines hidden (view full) --- 2728 ata_dev_enable_pm(dev, ap->pm_policy); 2729 2730 /* this link is okay now */ 2731 ehc->i.flags = 0; 2732 continue; 2733 2734dev_fail: 2735 nr_failed_devs++; | 2683 2684 /* if UNLOADING, finish immediately */ 2685 if (ap->pflags & ATA_PFLAG_UNLOADING) 2686 goto out; 2687 2688 /* prep for EH */ 2689 ata_port_for_each_link(link, ap) { 2690 struct ata_eh_context *ehc = &link->eh_context; --- 50 unchanged lines hidden (view full) --- 2741 ata_dev_enable_pm(dev, ap->pm_policy); 2742 2743 /* this link is okay now */ 2744 ehc->i.flags = 0; 2745 continue; 2746 2747dev_fail: 2748 nr_failed_devs++; |
2736 if (ata_eh_handle_dev_fail(dev, rc)) 2737 nr_disabled_devs++; | 2749 ata_eh_handle_dev_fail(dev, rc); |
2738 2739 if (ap->pflags & ATA_PFLAG_FROZEN) { 2740 /* PMP reset requires working host port. 2741 * Can't retry if it's frozen. 2742 */ 2743 if (sata_pmp_attached(ap)) 2744 goto out; 2745 break; 2746 } 2747 } 2748 | 2750 2751 if (ap->pflags & ATA_PFLAG_FROZEN) { 2752 /* PMP reset requires working host port. 2753 * Can't retry if it's frozen. 2754 */ 2755 if (sata_pmp_attached(ap)) 2756 goto out; 2757 break; 2758 } 2759 } 2760 |
2749 if (nr_failed_devs) { 2750 if (nr_failed_devs != nr_disabled_devs) { 2751 ata_port_printk(ap, KERN_WARNING, "failed to recover " 2752 "some devices, retrying in 5 secs\n"); 2753 ssleep(5); 2754 } else { 2755 /* no device left to recover, repeat fast */ 2756 msleep(500); 2757 } 2758 | 2761 if (nr_failed_devs) |
2759 goto retry; | 2762 goto retry; |
2760 } | |
2761 2762 out: 2763 if (rc && r_failed_link) 2764 *r_failed_link = link; 2765 2766 DPRINTK("EXIT, rc=%d\n", rc); 2767 return rc; 2768} --- 203 unchanged lines hidden --- | 2763 2764 out: 2765 if (rc && r_failed_link) 2766 *r_failed_link = link; 2767 2768 DPRINTK("EXIT, rc=%d\n", rc); 2769 return rc; 2770} --- 203 unchanged lines hidden --- |