aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-02-02 02:50:52 -0500
committerJeff Garzik <jeff@garzik.org>2007-05-01 07:49:53 -0400
commitd4b2bab4f26345ea1803feb23ea92fbe3f6b77bc (patch)
tree30a9826351e597828de2b402f1c41b9fca94cf95 /drivers/ata/libata-core.c
parentdc87c3985e9b442c60994308a96f887579addc39 (diff)
libata: add deadline support to prereset and reset methods
Add @deadline to prereset and reset methods and make them honor it. ata_wait_ready() which directly takes @deadline is implemented to be used as the wait function. This patch is in preparation for EH timing improvements. * ata_wait_ready() never does busy sleep. It's only used from EH and no wait in EH is that urgent. This function also prints 'be patient' message automatically after 5 secs of waiting if more than 3 secs is remaining till deadline. * ata_bus_post_reset() now fails with error code if any of its wait fails. This is important because earlier reset tries will have shorter timeout than the spec requires. If a device fails to respond before the short timeout, reset should be retried with longer timeout rather than silently ignoring the device. There are three behavior differences. 1. Timeout is applied to both devices at once, not separately. This is more consistent with what the spec says. 2. When a device passes devchk but fails to become ready before deadline. Previouly, post_reset would just succeed and let device classification remove the device. New code fails the reset thus causing reset retry. After a few times, EH will give up disabling the port. 3. When slave device passes devchk but fails to become accessible (TF-wise) after reset. Original code disables dev1 after 30s timeout and continues as if the device doesn't exist, while the patched code fails reset. When this happens, new code fails reset on whole port rather than proceeding with only the primary device. If the failing device is suffering transient problems, new code retries reset which is a better behavior. If the failing device is actually broken, the net effect is identical to it, but not to the other device sharing the channel. In the previous code, reset would have succeeded after 30s thus detecting the working one. In the new code, reset fails and whole port gets disabled. IMO, it's a pathological case anyway (broken device sharing bus with working one) and doesn't really matter. * ata_bus_softreset() is changed to return error code from ata_bus_post_reset(). It used to return 0 unconditionally. * Spin up waiting is to be removed and not converted to honor deadline. * To be on the safe side, deadline is set to 40s for the time being. 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.c161
1 files changed, 113 insertions, 48 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ca67484af1eb..84e9448c12d4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2979,23 +2979,68 @@ int ata_busy_sleep(struct ata_port *ap,
2979 return 0; 2979 return 0;
2980} 2980}
2981 2981
2982static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask) 2982/**
2983 * ata_wait_ready - sleep until BSY clears, or timeout
2984 * @ap: port containing status register to be polled
2985 * @deadline: deadline jiffies for the operation
2986 *
2987 * Sleep until ATA Status register bit BSY clears, or timeout
2988 * occurs.
2989 *
2990 * LOCKING:
2991 * Kernel thread context (may sleep).
2992 *
2993 * RETURNS:
2994 * 0 on success, -errno otherwise.
2995 */
2996int ata_wait_ready(struct ata_port *ap, unsigned long deadline)
2997{
2998 unsigned long start = jiffies;
2999 int warned = 0;
3000
3001 while (1) {
3002 u8 status = ata_chk_status(ap);
3003 unsigned long now = jiffies;
3004
3005 if (!(status & ATA_BUSY))
3006 return 0;
3007 if (status == 0xff)
3008 return -ENODEV;
3009 if (time_after(now, deadline))
3010 return -EBUSY;
3011
3012 if (!warned && time_after(now, start + 5 * HZ) &&
3013 (deadline - now > 3 * HZ)) {
3014 ata_port_printk(ap, KERN_WARNING,
3015 "port is slow to respond, please be patient "
3016 "(Status 0x%x)\n", status);
3017 warned = 1;
3018 }
3019
3020 msleep(50);
3021 }
3022}
3023
3024static int ata_bus_post_reset(struct ata_port *ap, unsigned int devmask,
3025 unsigned long deadline)
2983{ 3026{
2984 struct ata_ioports *ioaddr = &ap->ioaddr; 3027 struct ata_ioports *ioaddr = &ap->ioaddr;
2985 unsigned int dev0 = devmask & (1 << 0); 3028 unsigned int dev0 = devmask & (1 << 0);
2986 unsigned int dev1 = devmask & (1 << 1); 3029 unsigned int dev1 = devmask & (1 << 1);
2987 unsigned long timeout; 3030 int rc;
2988 3031
2989 /* if device 0 was found in ata_devchk, wait for its 3032 /* if device 0 was found in ata_devchk, wait for its
2990 * BSY bit to clear 3033 * BSY bit to clear
2991 */ 3034 */
2992 if (dev0) 3035 if (dev0) {
2993 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 3036 rc = ata_wait_ready(ap, deadline);
3037 if (rc && rc != -ENODEV)
3038 return rc;
3039 }
2994 3040
2995 /* if device 1 was found in ata_devchk, wait for 3041 /* if device 1 was found in ata_devchk, wait for
2996 * register access, then wait for BSY to clear 3042 * register access, then wait for BSY to clear
2997 */ 3043 */
2998 timeout = jiffies + ATA_TMOUT_BOOT;
2999 while (dev1) { 3044 while (dev1) {
3000 u8 nsect, lbal; 3045 u8 nsect, lbal;
3001 3046
@@ -3004,14 +3049,15 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
3004 lbal = ioread8(ioaddr->lbal_addr); 3049 lbal = ioread8(ioaddr->lbal_addr);
3005 if ((nsect == 1) && (lbal == 1)) 3050 if ((nsect == 1) && (lbal == 1))
3006 break; 3051 break;
3007 if (time_after(jiffies, timeout)) { 3052 if (time_after(jiffies, deadline))
3008 dev1 = 0; 3053 return -EBUSY;
3009 break;
3010 }
3011 msleep(50); /* give drive a breather */ 3054 msleep(50); /* give drive a breather */
3012 } 3055 }
3013 if (dev1) 3056 if (dev1) {
3014 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 3057 rc = ata_wait_ready(ap, deadline);
3058 if (rc && rc != -ENODEV)
3059 return rc;
3060 }
3015 3061
3016 /* is all this really necessary? */ 3062 /* is all this really necessary? */
3017 ap->ops->dev_select(ap, 0); 3063 ap->ops->dev_select(ap, 0);
@@ -3019,10 +3065,12 @@ static void ata_bus_post_reset(struct ata_port *ap, unsigned int devmask)
3019 ap->ops->dev_select(ap, 1); 3065 ap->ops->dev_select(ap, 1);
3020 if (dev0) 3066 if (dev0)
3021 ap->ops->dev_select(ap, 0); 3067 ap->ops->dev_select(ap, 0);
3068
3069 return 0;
3022} 3070}
3023 3071
3024static unsigned int ata_bus_softreset(struct ata_port *ap, 3072static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask,
3025 unsigned int devmask) 3073 unsigned long deadline)
3026{ 3074{
3027 struct ata_ioports *ioaddr = &ap->ioaddr; 3075 struct ata_ioports *ioaddr = &ap->ioaddr;
3028 3076
@@ -3054,9 +3102,7 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
3054 if (ata_check_status(ap) == 0xFF) 3102 if (ata_check_status(ap) == 0xFF)
3055 return 0; 3103 return 0;
3056 3104
3057 ata_bus_post_reset(ap, devmask); 3105 return ata_bus_post_reset(ap, devmask, deadline);
3058
3059 return 0;
3060} 3106}
3061 3107
3062/** 3108/**
@@ -3107,7 +3153,7 @@ void ata_bus_reset(struct ata_port *ap)
3107 3153
3108 /* issue bus reset */ 3154 /* issue bus reset */
3109 if (ap->flags & ATA_FLAG_SRST) 3155 if (ap->flags & ATA_FLAG_SRST)
3110 if (ata_bus_softreset(ap, devmask)) 3156 if (ata_bus_softreset(ap, devmask, jiffies + 40 * HZ))
3111 goto err_out; 3157 goto err_out;
3112 3158
3113 /* 3159 /*
@@ -3150,29 +3196,37 @@ err_out:
3150 * sata_phy_debounce - debounce SATA phy status 3196 * sata_phy_debounce - debounce SATA phy status
3151 * @ap: ATA port to debounce SATA phy status for 3197 * @ap: ATA port to debounce SATA phy status for
3152 * @params: timing parameters { interval, duratinon, timeout } in msec 3198 * @params: timing parameters { interval, duratinon, timeout } in msec
3199 * @deadline: deadline jiffies for the operation
3153 * 3200 *
3154 * Make sure SStatus of @ap reaches stable state, determined by 3201 * Make sure SStatus of @ap reaches stable state, determined by
3155 * holding the same value where DET is not 1 for @duration polled 3202 * holding the same value where DET is not 1 for @duration polled
3156 * every @interval, before @timeout. Timeout constraints the 3203 * every @interval, before @timeout. Timeout constraints the
3157 * beginning of the stable state. Because, after hot unplugging, 3204 * beginning of the stable state. Because DET gets stuck at 1 on
3158 * DET gets stuck at 1 on some controllers, this functions waits 3205 * some controllers after hot unplugging, this functions waits
3159 * until timeout then returns 0 if DET is stable at 1. 3206 * until timeout then returns 0 if DET is stable at 1.
3160 * 3207 *
3208 * @timeout is further limited by @deadline. The sooner of the
3209 * two is used.
3210 *
3161 * LOCKING: 3211 * LOCKING:
3162 * Kernel thread context (may sleep) 3212 * Kernel thread context (may sleep)
3163 * 3213 *
3164 * RETURNS: 3214 * RETURNS:
3165 * 0 on success, -errno on failure. 3215 * 0 on success, -errno on failure.
3166 */ 3216 */
3167int sata_phy_debounce(struct ata_port *ap, const unsigned long *params) 3217int sata_phy_debounce(struct ata_port *ap, const unsigned long *params,
3218 unsigned long deadline)
3168{ 3219{
3169 unsigned long interval_msec = params[0]; 3220 unsigned long interval_msec = params[0];
3170 unsigned long duration = params[1] * HZ / 1000; 3221 unsigned long duration = msecs_to_jiffies(params[1]);
3171 unsigned long timeout = jiffies + params[2] * HZ / 1000; 3222 unsigned long last_jiffies, t;
3172 unsigned long last_jiffies;
3173 u32 last, cur; 3223 u32 last, cur;
3174 int rc; 3224 int rc;
3175 3225
3226 t = jiffies + msecs_to_jiffies(params[2]);
3227 if (time_before(t, deadline))
3228 deadline = t;
3229
3176 if ((rc = sata_scr_read(ap, SCR_STATUS, &cur))) 3230 if ((rc = sata_scr_read(ap, SCR_STATUS, &cur)))
3177 return rc; 3231 return rc;
3178 cur &= 0xf; 3232 cur &= 0xf;
@@ -3188,7 +3242,7 @@ int sata_phy_debounce(struct ata_port *ap, const unsigned long *params)
3188 3242
3189 /* DET stable? */ 3243 /* DET stable? */
3190 if (cur == last) { 3244 if (cur == last) {
3191 if (cur == 1 && time_before(jiffies, timeout)) 3245 if (cur == 1 && time_before(jiffies, deadline))
3192 continue; 3246 continue;
3193 if (time_after(jiffies, last_jiffies + duration)) 3247 if (time_after(jiffies, last_jiffies + duration))
3194 return 0; 3248 return 0;
@@ -3199,8 +3253,8 @@ int sata_phy_debounce(struct ata_port *ap, const unsigned long *params)
3199 last = cur; 3253 last = cur;
3200 last_jiffies = jiffies; 3254 last_jiffies = jiffies;
3201 3255
3202 /* check timeout */ 3256 /* check deadline */
3203 if (time_after(jiffies, timeout)) 3257 if (time_after(jiffies, deadline))
3204 return -EBUSY; 3258 return -EBUSY;
3205 } 3259 }
3206} 3260}
@@ -3209,6 +3263,7 @@ int sata_phy_debounce(struct ata_port *ap, const unsigned long *params)
3209 * sata_phy_resume - resume SATA phy 3263 * sata_phy_resume - resume SATA phy
3210 * @ap: ATA port to resume SATA phy for 3264 * @ap: ATA port to resume SATA phy for
3211 * @params: timing parameters { interval, duratinon, timeout } in msec 3265 * @params: timing parameters { interval, duratinon, timeout } in msec
3266 * @deadline: deadline jiffies for the operation
3212 * 3267 *
3213 * Resume SATA phy of @ap and debounce it. 3268 * Resume SATA phy of @ap and debounce it.
3214 * 3269 *
@@ -3218,7 +3273,8 @@ int sata_phy_debounce(struct ata_port *ap, const unsigned long *params)
3218 * RETURNS: 3273 * RETURNS:
3219 * 0 on success, -errno on failure. 3274 * 0 on success, -errno on failure.
3220 */ 3275 */
3221int sata_phy_resume(struct ata_port *ap, const unsigned long *params) 3276int sata_phy_resume(struct ata_port *ap, const unsigned long *params,
3277 unsigned long deadline)
3222{ 3278{
3223 u32 scontrol; 3279 u32 scontrol;
3224 int rc; 3280 int rc;
@@ -3236,10 +3292,10 @@ int sata_phy_resume(struct ata_port *ap, const unsigned long *params)
3236 */ 3292 */
3237 msleep(200); 3293 msleep(200);
3238 3294
3239 return sata_phy_debounce(ap, params); 3295 return sata_phy_debounce(ap, params, deadline);
3240} 3296}
3241 3297
3242static void ata_wait_spinup(struct ata_port *ap) 3298static void ata_wait_spinup(struct ata_port *ap, unsigned long deadline)
3243{ 3299{
3244 struct ata_eh_context *ehc = &ap->eh_context; 3300 struct ata_eh_context *ehc = &ap->eh_context;
3245 unsigned long end, secs; 3301 unsigned long end, secs;
@@ -3247,7 +3303,7 @@ static void ata_wait_spinup(struct ata_port *ap)
3247 3303
3248 /* first, debounce phy if SATA */ 3304 /* first, debounce phy if SATA */
3249 if (ap->cbl == ATA_CBL_SATA) { 3305 if (ap->cbl == ATA_CBL_SATA) {
3250 rc = sata_phy_debounce(ap, sata_deb_timing_hotplug); 3306 rc = sata_phy_debounce(ap, sata_deb_timing_hotplug, deadline);
3251 3307
3252 /* if debounced successfully and offline, no need to wait */ 3308 /* if debounced successfully and offline, no need to wait */
3253 if ((rc == 0 || rc == -EOPNOTSUPP) && ata_port_offline(ap)) 3309 if ((rc == 0 || rc == -EOPNOTSUPP) && ata_port_offline(ap))
@@ -3271,6 +3327,7 @@ static void ata_wait_spinup(struct ata_port *ap)
3271/** 3327/**
3272 * ata_std_prereset - prepare for reset 3328 * ata_std_prereset - prepare for reset
3273 * @ap: ATA port to be reset 3329 * @ap: ATA port to be reset
3330 * @deadline: deadline jiffies for the operation
3274 * 3331 *
3275 * @ap is about to be reset. Initialize it. 3332 * @ap is about to be reset. Initialize it.
3276 * 3333 *
@@ -3280,7 +3337,7 @@ static void ata_wait_spinup(struct ata_port *ap)
3280 * RETURNS: 3337 * RETURNS:
3281 * 0 on success, -errno otherwise. 3338 * 0 on success, -errno otherwise.
3282 */ 3339 */
3283int ata_std_prereset(struct ata_port *ap) 3340int ata_std_prereset(struct ata_port *ap, unsigned long deadline)
3284{ 3341{
3285 struct ata_eh_context *ehc = &ap->eh_context; 3342 struct ata_eh_context *ehc = &ap->eh_context;
3286 const unsigned long *timing = sata_ehc_deb_timing(ehc); 3343 const unsigned long *timing = sata_ehc_deb_timing(ehc);
@@ -3293,7 +3350,7 @@ int ata_std_prereset(struct ata_port *ap)
3293 3350
3294 if ((ehc->i.flags & ATA_EHI_HOTPLUGGED) && 3351 if ((ehc->i.flags & ATA_EHI_HOTPLUGGED) &&
3295 (ap->flags & ATA_FLAG_SKIP_D2H_BSY)) 3352 (ap->flags & ATA_FLAG_SKIP_D2H_BSY))
3296 ata_wait_spinup(ap); 3353 ata_wait_spinup(ap, deadline);
3297 3354
3298 /* if we're about to do hardreset, nothing more to do */ 3355 /* if we're about to do hardreset, nothing more to do */
3299 if (ehc->i.action & ATA_EH_HARDRESET) 3356 if (ehc->i.action & ATA_EH_HARDRESET)
@@ -3301,7 +3358,7 @@ int ata_std_prereset(struct ata_port *ap)
3301 3358
3302 /* if SATA, resume phy */ 3359 /* if SATA, resume phy */
3303 if (ap->cbl == ATA_CBL_SATA) { 3360 if (ap->cbl == ATA_CBL_SATA) {
3304 rc = sata_phy_resume(ap, timing); 3361 rc = sata_phy_resume(ap, timing, deadline);
3305 if (rc && rc != -EOPNOTSUPP) { 3362 if (rc && rc != -EOPNOTSUPP) {
3306 /* phy resume failed */ 3363 /* phy resume failed */
3307 ata_port_printk(ap, KERN_WARNING, "failed to resume " 3364 ata_port_printk(ap, KERN_WARNING, "failed to resume "
@@ -3314,7 +3371,7 @@ int ata_std_prereset(struct ata_port *ap)
3314 * Reg FIS and we don't know that no device is attached. 3371 * Reg FIS and we don't know that no device is attached.
3315 */ 3372 */
3316 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap)) 3373 if (!(ap->flags & ATA_FLAG_SKIP_D2H_BSY) && !ata_port_offline(ap))
3317 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 3374 ata_wait_ready(ap, deadline);
3318 3375
3319 return 0; 3376 return 0;
3320} 3377}
@@ -3323,6 +3380,7 @@ int ata_std_prereset(struct ata_port *ap)
3323 * ata_std_softreset - reset host port via ATA SRST 3380 * ata_std_softreset - reset host port via ATA SRST
3324 * @ap: port to reset 3381 * @ap: port to reset
3325 * @classes: resulting classes of attached devices 3382 * @classes: resulting classes of attached devices
3383 * @deadline: deadline jiffies for the operation
3326 * 3384 *
3327 * Reset host port using ATA SRST. 3385 * Reset host port using ATA SRST.
3328 * 3386 *
@@ -3332,10 +3390,12 @@ int ata_std_prereset(struct ata_port *ap)
3332 * RETURNS: 3390 * RETURNS:
3333 * 0 on success, -errno otherwise. 3391 * 0 on success, -errno otherwise.
3334 */ 3392 */
3335int ata_std_softreset(struct ata_port *ap, unsigned int *classes) 3393int ata_std_softreset(struct ata_port *ap, unsigned int *classes,
3394 unsigned long deadline)
3336{ 3395{
3337 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS; 3396 unsigned int slave_possible = ap->flags & ATA_FLAG_SLAVE_POSS;
3338 unsigned int devmask = 0, err_mask; 3397 unsigned int devmask = 0;
3398 int rc;
3339 u8 err; 3399 u8 err;
3340 3400
3341 DPRINTK("ENTER\n"); 3401 DPRINTK("ENTER\n");
@@ -3356,11 +3416,10 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
3356 3416
3357 /* issue bus reset */ 3417 /* issue bus reset */
3358 DPRINTK("about to softreset, devmask=%x\n", devmask); 3418 DPRINTK("about to softreset, devmask=%x\n", devmask);
3359 err_mask = ata_bus_softreset(ap, devmask); 3419 rc = ata_bus_softreset(ap, devmask, deadline);
3360 if (err_mask) { 3420 if (rc) {
3361 ata_port_printk(ap, KERN_ERR, "SRST failed (err_mask=0x%x)\n", 3421 ata_port_printk(ap, KERN_ERR, "SRST failed (errno=%d)\n", rc);
3362 err_mask); 3422 return rc;
3363 return -EIO;
3364 } 3423 }
3365 3424
3366 /* determine by signature whether we have ATA or ATAPI devices */ 3425 /* determine by signature whether we have ATA or ATAPI devices */
@@ -3377,6 +3436,7 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
3377 * sata_port_hardreset - reset port via SATA phy reset 3436 * sata_port_hardreset - reset port via SATA phy reset
3378 * @ap: port to reset 3437 * @ap: port to reset
3379 * @timing: timing parameters { interval, duratinon, timeout } in msec 3438 * @timing: timing parameters { interval, duratinon, timeout } in msec
3439 * @deadline: deadline jiffies for the operation
3380 * 3440 *
3381 * SATA phy-reset host port using DET bits of SControl register. 3441 * SATA phy-reset host port using DET bits of SControl register.
3382 * 3442 *
@@ -3386,7 +3446,8 @@ int ata_std_softreset(struct ata_port *ap, unsigned int *classes)
3386 * RETURNS: 3446 * RETURNS:
3387 * 0 on success, -errno otherwise. 3447 * 0 on success, -errno otherwise.
3388 */ 3448 */
3389int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing) 3449int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing,
3450 unsigned long deadline)
3390{ 3451{
3391 u32 scontrol; 3452 u32 scontrol;
3392 int rc; 3453 int rc;
@@ -3425,7 +3486,7 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing)
3425 msleep(1); 3486 msleep(1);
3426 3487
3427 /* bring phy back */ 3488 /* bring phy back */
3428 rc = sata_phy_resume(ap, timing); 3489 rc = sata_phy_resume(ap, timing, deadline);
3429 out: 3490 out:
3430 DPRINTK("EXIT, rc=%d\n", rc); 3491 DPRINTK("EXIT, rc=%d\n", rc);
3431 return rc; 3492 return rc;
@@ -3435,6 +3496,7 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing)
3435 * sata_std_hardreset - reset host port via SATA phy reset 3496 * sata_std_hardreset - reset host port via SATA phy reset
3436 * @ap: port to reset 3497 * @ap: port to reset
3437 * @class: resulting class of attached device 3498 * @class: resulting class of attached device
3499 * @deadline: deadline jiffies for the operation
3438 * 3500 *
3439 * SATA phy-reset host port using DET bits of SControl register, 3501 * SATA phy-reset host port using DET bits of SControl register,
3440 * wait for !BSY and classify the attached device. 3502 * wait for !BSY and classify the attached device.
@@ -3445,7 +3507,8 @@ int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing)
3445 * RETURNS: 3507 * RETURNS:
3446 * 0 on success, -errno otherwise. 3508 * 0 on success, -errno otherwise.
3447 */ 3509 */
3448int sata_std_hardreset(struct ata_port *ap, unsigned int *class) 3510int sata_std_hardreset(struct ata_port *ap, unsigned int *class,
3511 unsigned long deadline)
3449{ 3512{
3450 const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context); 3513 const unsigned long *timing = sata_ehc_deb_timing(&ap->eh_context);
3451 int rc; 3514 int rc;
@@ -3453,7 +3516,7 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
3453 DPRINTK("ENTER\n"); 3516 DPRINTK("ENTER\n");
3454 3517
3455 /* do hardreset */ 3518 /* do hardreset */
3456 rc = sata_port_hardreset(ap, timing); 3519 rc = sata_port_hardreset(ap, timing, deadline);
3457 if (rc) { 3520 if (rc) {
3458 ata_port_printk(ap, KERN_ERR, 3521 ata_port_printk(ap, KERN_ERR,
3459 "COMRESET failed (errno=%d)\n", rc); 3522 "COMRESET failed (errno=%d)\n", rc);
@@ -3470,10 +3533,11 @@ int sata_std_hardreset(struct ata_port *ap, unsigned int *class)
3470 /* wait a while before checking status, see SRST for more info */ 3533 /* wait a while before checking status, see SRST for more info */
3471 msleep(150); 3534 msleep(150);
3472 3535
3473 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { 3536 rc = ata_wait_ready(ap, deadline);
3537 if (rc && rc != -ENODEV) {
3474 ata_port_printk(ap, KERN_ERR, 3538 ata_port_printk(ap, KERN_ERR,
3475 "COMRESET failed (device not ready)\n"); 3539 "COMRESET failed (errno=%d)\n", rc);
3476 return -EIO; 3540 return rc;
3477 } 3541 }
3478 3542
3479 ap->ops->dev_select(ap, 0); /* probably unnecessary */ 3543 ap->ops->dev_select(ap, 0); /* probably unnecessary */
@@ -6793,6 +6857,7 @@ EXPORT_SYMBOL_GPL(ata_port_disable);
6793EXPORT_SYMBOL_GPL(ata_ratelimit); 6857EXPORT_SYMBOL_GPL(ata_ratelimit);
6794EXPORT_SYMBOL_GPL(ata_wait_register); 6858EXPORT_SYMBOL_GPL(ata_wait_register);
6795EXPORT_SYMBOL_GPL(ata_busy_sleep); 6859EXPORT_SYMBOL_GPL(ata_busy_sleep);
6860EXPORT_SYMBOL_GPL(ata_wait_ready);
6796EXPORT_SYMBOL_GPL(ata_port_queue_task); 6861EXPORT_SYMBOL_GPL(ata_port_queue_task);
6797EXPORT_SYMBOL_GPL(ata_scsi_ioctl); 6862EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
6798EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 6863EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);