libata-eh.c (dc98c32cbe80750ae2d9d9fbdae305d38f005de7) libata-eh.c (f046519fc85a8fdf6a058b4ac9d897cdee6f3e52)
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>

--- 2033 unchanged lines hidden (view full) ---

2042 __ata_port_for_each_link(link, ap)
2043 ata_eh_link_report(link);
2044}
2045
2046static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
2047 unsigned int *classes, unsigned long deadline)
2048{
2049 struct ata_device *dev;
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>

--- 2033 unchanged lines hidden (view full) ---

2042 __ata_port_for_each_link(link, ap)
2043 ata_eh_link_report(link);
2044}
2045
2046static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
2047 unsigned int *classes, unsigned long deadline)
2048{
2049 struct ata_device *dev;
2050 int rc;
2051
2052 ata_link_for_each_dev(dev, link)
2053 classes[dev->devno] = ATA_DEV_UNKNOWN;
2054
2050
2051 ata_link_for_each_dev(dev, link)
2052 classes[dev->devno] = ATA_DEV_UNKNOWN;
2053
2055 rc = reset(link, classes, deadline);
2056
2057 /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */
2058 ata_link_for_each_dev(dev, link)
2059 if (classes[dev->devno] == ATA_DEV_UNKNOWN)
2060 classes[dev->devno] = ATA_DEV_NONE;
2061
2062 return rc;
2054 return reset(link, classes, deadline);
2063}
2064
2065static int ata_eh_followup_srst_needed(struct ata_link *link,
2066 int rc, int classify,
2067 const unsigned int *classes)
2068{
2069 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link))
2070 return 0;

--- 20 unchanged lines hidden (view full) ---

2091 unsigned int lflags = link->flags;
2092 int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
2093 int try = 0;
2094 struct ata_device *dev;
2095 unsigned long deadline, now;
2096 ata_reset_fn_t reset;
2097 unsigned long flags;
2098 u32 sstatus;
2055}
2056
2057static int ata_eh_followup_srst_needed(struct ata_link *link,
2058 int rc, int classify,
2059 const unsigned int *classes)
2060{
2061 if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link))
2062 return 0;

--- 20 unchanged lines hidden (view full) ---

2083 unsigned int lflags = link->flags;
2084 int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
2085 int try = 0;
2086 struct ata_device *dev;
2087 unsigned long deadline, now;
2088 ata_reset_fn_t reset;
2089 unsigned long flags;
2090 u32 sstatus;
2099 int rc;
2091 int nr_known, rc;
2100
2101 /*
2102 * Prepare to reset
2103 */
2104 spin_lock_irqsave(ap->lock, flags);
2105 ap->pflags |= ATA_PFLAG_RESETTING;
2106 spin_unlock_irqrestore(ap->lock, flags);
2107

--- 132 unchanged lines hidden (view full) ---

2240 /* record current link speed */
2241 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2242 link->sata_spd = (sstatus >> 4) & 0xf;
2243
2244 /* thaw the port */
2245 if (ata_is_host_link(link))
2246 ata_eh_thaw_port(ap);
2247
2092
2093 /*
2094 * Prepare to reset
2095 */
2096 spin_lock_irqsave(ap->lock, flags);
2097 ap->pflags |= ATA_PFLAG_RESETTING;
2098 spin_unlock_irqrestore(ap->lock, flags);
2099

--- 132 unchanged lines hidden (view full) ---

2232 /* record current link speed */
2233 if (sata_scr_read(link, SCR_STATUS, &sstatus) == 0)
2234 link->sata_spd = (sstatus >> 4) & 0xf;
2235
2236 /* thaw the port */
2237 if (ata_is_host_link(link))
2238 ata_eh_thaw_port(ap);
2239
2240 /* postreset() should clear hardware SError. Although SError
2241 * is cleared during link resume, clearing SError here is
2242 * necessary as some PHYs raise hotplug events after SRST.
2243 * This introduces race condition where hotplug occurs between
2244 * reset and here. This race is mediated by cross checking
2245 * link onlineness and classification result later.
2246 */
2248 if (postreset)
2249 postreset(link, classes);
2250
2247 if (postreset)
2248 postreset(link, classes);
2249
2250 /* clear cached SError */
2251 spin_lock_irqsave(link->ap->lock, flags);
2252 link->eh_info.serror = 0;
2253 spin_unlock_irqrestore(link->ap->lock, flags);
2254
2255 /* Make sure onlineness and classification result correspond.
2256 * Hotplug could have happened during reset and some
2257 * controllers fail to wait while a drive is spinning up after
2258 * being hotplugged causing misdetection. By cross checking
2259 * link onlineness and classification result, those conditions
2260 * can be reliably detected and retried.
2261 */
2262 nr_known = 0;
2263 ata_link_for_each_dev(dev, link) {
2264 /* convert all ATA_DEV_UNKNOWN to ATA_DEV_NONE */
2265 if (classes[dev->devno] == ATA_DEV_UNKNOWN)
2266 classes[dev->devno] = ATA_DEV_NONE;
2267 else
2268 nr_known++;
2269 }
2270
2271 if (classify && !nr_known && ata_link_online(link)) {
2272 if (try < max_tries) {
2273 ata_link_printk(link, KERN_WARNING, "link online but "
2274 "device misclassified, retrying\n");
2275 rc = -EAGAIN;
2276 goto fail;
2277 }
2278 ata_link_printk(link, KERN_WARNING,
2279 "link online but device misclassified, "
2280 "device detection might fail\n");
2281 }
2282
2251 /* reset successful, schedule revalidation */
2252 ata_eh_done(link, NULL, ATA_EH_RESET);
2253 ehc->i.action |= ATA_EH_REVALIDATE;
2254
2255 rc = 0;
2256 out:
2257 /* clear hotplug flag */
2258 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED;

--- 685 unchanged lines hidden ---
2283 /* reset successful, schedule revalidation */
2284 ata_eh_done(link, NULL, ATA_EH_RESET);
2285 ehc->i.action |= ATA_EH_REVALIDATE;
2286
2287 rc = 0;
2288 out:
2289 /* clear hotplug flag */
2290 ehc->i.flags &= ~ATA_EHI_HOTPLUGGED;

--- 685 unchanged lines hidden ---