aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/ahci.c18
-rw-r--r--drivers/ata/ata_piix.c6
-rw-r--r--drivers/ata/libata-core.c161
-rw-r--r--drivers/ata/libata-eh.c10
-rw-r--r--drivers/ata/pata_amd.c11
-rw-r--r--drivers/ata/pata_artop.c8
-rw-r--r--drivers/ata/pata_atiixp.c4
-rw-r--r--drivers/ata/pata_cs5535.c1
-rw-r--r--drivers/ata/pata_efar.c5
-rw-r--r--drivers/ata/pata_hpt366.c4
-rw-r--r--drivers/ata/pata_hpt37x.c9
-rw-r--r--drivers/ata/pata_hpt3x2n.c5
-rw-r--r--drivers/ata/pata_it8213.c6
-rw-r--r--drivers/ata/pata_jmicron.c7
-rw-r--r--drivers/ata/pata_marvell.c4
-rw-r--r--drivers/ata/pata_mpiix.c5
-rw-r--r--drivers/ata/pata_ns87410.c6
-rw-r--r--drivers/ata/pata_oldpiix.c6
-rw-r--r--drivers/ata/pata_opti.c6
-rw-r--r--drivers/ata/pata_optidma.c5
-rw-r--r--drivers/ata/pata_pdc2027x.c5
-rw-r--r--drivers/ata/pata_serverworks.c4
-rw-r--r--drivers/ata/pata_sil680.c6
-rw-r--r--drivers/ata/pata_sis.c8
-rw-r--r--drivers/ata/pata_sl82c105.c5
-rw-r--r--drivers/ata/pata_triflex.c6
-rw-r--r--drivers/ata/pata_via.c5
-rw-r--r--drivers/ata/sata_inic162x.c14
-rw-r--r--drivers/ata/sata_nv.c5
-rw-r--r--drivers/ata/sata_sil24.c10
-rw-r--r--drivers/ata/sata_via.c5
31 files changed, 234 insertions, 126 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 34c5534ed64c..0319f10d42d5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -874,7 +874,8 @@ static int ahci_clo(struct ata_port *ap)
874 return 0; 874 return 0;
875} 875}
876 876
877static int ahci_softreset(struct ata_port *ap, unsigned int *class) 877static int ahci_softreset(struct ata_port *ap, unsigned int *class,
878 unsigned long deadline)
878{ 879{
879 struct ahci_port_priv *pp = ap->private_data; 880 struct ahci_port_priv *pp = ap->private_data;
880 void __iomem *port_mmio = ahci_port_base(ap); 881 void __iomem *port_mmio = ahci_port_base(ap);
@@ -961,8 +962,8 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
961 962
962 *class = ATA_DEV_NONE; 963 *class = ATA_DEV_NONE;
963 if (ata_port_online(ap)) { 964 if (ata_port_online(ap)) {
964 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { 965 rc = ata_wait_ready(ap, deadline);
965 rc = -EIO; 966 if (rc && rc != -ENODEV) {
966 reason = "device not ready"; 967 reason = "device not ready";
967 goto fail; 968 goto fail;
968 } 969 }
@@ -979,7 +980,8 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
979 return rc; 980 return rc;
980} 981}
981 982
982static int ahci_hardreset(struct ata_port *ap, unsigned int *class) 983static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
984 unsigned long deadline)
983{ 985{
984 struct ahci_port_priv *pp = ap->private_data; 986 struct ahci_port_priv *pp = ap->private_data;
985 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; 987 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
@@ -995,7 +997,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
995 tf.command = 0x80; 997 tf.command = 0x80;
996 ata_tf_to_fis(&tf, d2h_fis, 0); 998 ata_tf_to_fis(&tf, d2h_fis, 0);
997 999
998 rc = sata_std_hardreset(ap, class); 1000 rc = sata_std_hardreset(ap, class, deadline);
999 1001
1000 ahci_start_engine(ap); 1002 ahci_start_engine(ap);
1001 1003
@@ -1008,7 +1010,8 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
1008 return rc; 1010 return rc;
1009} 1011}
1010 1012
1011static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class) 1013static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
1014 unsigned long deadline)
1012{ 1015{
1013 int rc; 1016 int rc;
1014 1017
@@ -1016,7 +1019,8 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class)
1016 1019
1017 ahci_stop_engine(ap); 1020 ahci_stop_engine(ap);
1018 1021
1019 rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->eh_context)); 1022 rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->eh_context),
1023 deadline);
1020 1024
1021 /* vt8251 needs SError cleared for the port to operate */ 1025 /* vt8251 needs SError cleared for the port to operate */
1022 ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR)); 1026 ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR));
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 55d306a3e538..4a795fdb6a02 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -625,17 +625,18 @@ static int ich_pata_cable_detect(struct ata_port *ap)
625/** 625/**
626 * piix_pata_prereset - prereset for PATA host controller 626 * piix_pata_prereset - prereset for PATA host controller
627 * @ap: Target port 627 * @ap: Target port
628 * @deadline: deadline jiffies for the operation
628 * 629 *
629 * LOCKING: 630 * LOCKING:
630 * None (inherited from caller). 631 * None (inherited from caller).
631 */ 632 */
632static int piix_pata_prereset(struct ata_port *ap) 633static int piix_pata_prereset(struct ata_port *ap, unsigned long deadline)
633{ 634{
634 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 635 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
635 636
636 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) 637 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
637 return -ENOENT; 638 return -ENOENT;
638 return ata_std_prereset(ap); 639 return ata_std_prereset(ap, deadline);
639} 640}
640 641
641static void piix_pata_error_handler(struct ata_port *ap) 642static void piix_pata_error_handler(struct ata_port *ap)
@@ -644,7 +645,6 @@ static void piix_pata_error_handler(struct ata_port *ap)
644 ata_std_postreset); 645 ata_std_postreset);
645} 646}
646 647
647
648static void piix_sata_error_handler(struct ata_port *ap) 648static void piix_sata_error_handler(struct ata_port *ap)
649{ 649{
650 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL, 650 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
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);
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 2bff9adcacf1..b3f7d3c8ae60 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1558,14 +1558,14 @@ static void ata_eh_report(struct ata_port *ap)
1558} 1558}
1559 1559
1560static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset, 1560static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset,
1561 unsigned int *classes) 1561 unsigned int *classes, unsigned long deadline)
1562{ 1562{
1563 int i, rc; 1563 int i, rc;
1564 1564
1565 for (i = 0; i < ATA_MAX_DEVICES; i++) 1565 for (i = 0; i < ATA_MAX_DEVICES; i++)
1566 classes[i] = ATA_DEV_UNKNOWN; 1566 classes[i] = ATA_DEV_UNKNOWN;
1567 1567
1568 rc = reset(ap, classes); 1568 rc = reset(ap, classes, deadline);
1569 if (rc) 1569 if (rc)
1570 return rc; 1570 return rc;
1571 1571
@@ -1624,7 +1624,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1624 ehc->i.action |= ATA_EH_HARDRESET; 1624 ehc->i.action |= ATA_EH_HARDRESET;
1625 1625
1626 if (prereset) { 1626 if (prereset) {
1627 rc = prereset(ap); 1627 rc = prereset(ap, jiffies + 40 * HZ);
1628 if (rc) { 1628 if (rc) {
1629 if (rc == -ENOENT) { 1629 if (rc == -ENOENT) {
1630 ata_port_printk(ap, KERN_DEBUG, 1630 ata_port_printk(ap, KERN_DEBUG,
@@ -1676,7 +1676,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1676 else 1676 else
1677 ehc->i.flags |= ATA_EHI_DID_SOFTRESET; 1677 ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
1678 1678
1679 rc = ata_do_reset(ap, reset, classes); 1679 rc = ata_do_reset(ap, reset, classes, jiffies + 40 * HZ);
1680 1680
1681 did_followup_srst = 0; 1681 did_followup_srst = 0;
1682 if (reset == hardreset && 1682 if (reset == hardreset &&
@@ -1693,7 +1693,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
1693 } 1693 }
1694 1694
1695 ata_eh_about_to_do(ap, NULL, ATA_EH_RESET_MASK); 1695 ata_eh_about_to_do(ap, NULL, ATA_EH_RESET_MASK);
1696 rc = ata_do_reset(ap, reset, classes); 1696 rc = ata_do_reset(ap, reset, classes, jiffies + 40 * HZ);
1697 1697
1698 if (rc == 0 && classify && 1698 if (rc == 0 && classify &&
1699 classes[0] == ATA_DEV_UNKNOWN) { 1699 classes[0] == ATA_DEV_UNKNOWN) {
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 536ee892ab72..67c7e87dec04 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -121,12 +121,13 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
121/** 121/**
122 * amd_probe_init - perform reset handling 122 * amd_probe_init - perform reset handling
123 * @ap: ATA port 123 * @ap: ATA port
124 * @deadline: deadline jiffies for the operation
124 * 125 *
125 * Reset sequence checking enable bits to see which ports are 126 * Reset sequence checking enable bits to see which ports are
126 * active. 127 * active.
127 */ 128 */
128 129
129static int amd_pre_reset(struct ata_port *ap) 130static int amd_pre_reset(struct ata_port *ap, unsigned long deadline)
130{ 131{
131 static const struct pci_bits amd_enable_bits[] = { 132 static const struct pci_bits amd_enable_bits[] = {
132 { 0x40, 1, 0x02, 0x02 }, 133 { 0x40, 1, 0x02, 0x02 },
@@ -138,8 +139,7 @@ static int amd_pre_reset(struct ata_port *ap)
138 if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) 139 if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
139 return -ENOENT; 140 return -ENOENT;
140 141
141 return ata_std_prereset(ap); 142 return ata_std_prereset(ap, deadline);
142
143} 143}
144 144
145static void amd_error_handler(struct ata_port *ap) 145static void amd_error_handler(struct ata_port *ap)
@@ -227,7 +227,8 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
227 * space for us. 227 * space for us.
228 */ 228 */
229 229
230static int nv_pre_reset(struct ata_port *ap) { 230static int nv_pre_reset(struct ata_port *ap, unsigned long deadline)
231{
231 static const struct pci_bits nv_enable_bits[] = { 232 static const struct pci_bits nv_enable_bits[] = {
232 { 0x50, 1, 0x02, 0x02 }, 233 { 0x50, 1, 0x02, 0x02 },
233 { 0x50, 1, 0x01, 0x01 } 234 { 0x50, 1, 0x01, 0x01 }
@@ -238,7 +239,7 @@ static int nv_pre_reset(struct ata_port *ap) {
238 if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) 239 if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
239 return -ENOENT; 240 return -ENOENT;
240 241
241 return ata_std_prereset(ap); 242 return ata_std_prereset(ap, deadline);
242} 243}
243 244
244static void nv_error_handler(struct ata_port *ap) 245static void nv_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 00e9ec342db0..d472894a983b 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -39,7 +39,7 @@
39 39
40static int clock = 0; 40static int clock = 0;
41 41
42static int artop6210_pre_reset(struct ata_port *ap) 42static int artop6210_pre_reset(struct ata_port *ap, unsigned long deadline)
43{ 43{
44 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 44 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
45 const struct pci_bits artop_enable_bits[] = { 45 const struct pci_bits artop_enable_bits[] = {
@@ -49,7 +49,8 @@ static int artop6210_pre_reset(struct ata_port *ap)
49 49
50 if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) 50 if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
51 return -ENOENT; 51 return -ENOENT;
52 return ata_std_prereset(ap); 52
53 return ata_std_prereset(ap, deadline);
53} 54}
54 55
55/** 56/**
@@ -70,12 +71,13 @@ static void artop6210_error_handler(struct ata_port *ap)
70/** 71/**
71 * artop6260_pre_reset - check for 40/80 pin 72 * artop6260_pre_reset - check for 40/80 pin
72 * @ap: Port 73 * @ap: Port
74 * @deadline: deadline jiffies for the operation
73 * 75 *
74 * The ARTOP hardware reports the cable detect bits in register 0x49. 76 * The ARTOP hardware reports the cable detect bits in register 0x49.
75 * Nothing complicated needed here. 77 * Nothing complicated needed here.
76 */ 78 */
77 79
78static int artop6260_pre_reset(struct ata_port *ap) 80static int artop6260_pre_reset(struct ata_port *ap, unsigned long deadline)
79{ 81{
80 static const struct pci_bits artop_enable_bits[] = { 82 static const struct pci_bits artop_enable_bits[] = {
81 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 83 { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 39c871a3ddac..21515381b5b3 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -33,7 +33,7 @@ enum {
33 ATIIXP_IDE_UDMA_MODE = 0x56 33 ATIIXP_IDE_UDMA_MODE = 0x56
34}; 34};
35 35
36static int atiixp_pre_reset(struct ata_port *ap) 36static int atiixp_pre_reset(struct ata_port *ap, unsigned long deadline)
37{ 37{
38 static const struct pci_bits atiixp_enable_bits[] = { 38 static const struct pci_bits atiixp_enable_bits[] = {
39 { 0x48, 1, 0x01, 0x00 }, 39 { 0x48, 1, 0x01, 0x00 },
@@ -44,7 +44,7 @@ static int atiixp_pre_reset(struct ata_port *ap)
44 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) 44 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
45 return -ENOENT; 45 return -ENOENT;
46 46
47 return ata_std_prereset(ap); 47 return ata_std_prereset(ap, deadline);
48} 48}
49 49
50static void atiixp_error_handler(struct ata_port *ap) 50static void atiixp_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index 08cccc9c659b..22006ae71941 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -72,6 +72,7 @@
72/** 72/**
73 * cs5535_cable_detect - detect cable type 73 * cs5535_cable_detect - detect cable type
74 * @ap: Port to detect on 74 * @ap: Port to detect on
75 * @deadline: deadline jiffies for the operation
75 * 76 *
76 * Perform cable detection for ATA66 capable cable. Return a libata 77 * Perform cable detection for ATA66 capable cable. Return a libata
77 * cable type. 78 * cable type.
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index a3216850bba1..d0f52e034906 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -27,12 +27,13 @@
27/** 27/**
28 * efar_pre_reset - Enable bits 28 * efar_pre_reset - Enable bits
29 * @ap: Port 29 * @ap: Port
30 * @deadline: deadline jiffies for the operation
30 * 31 *
31 * Perform cable detection for the EFAR ATA interface. This is 32 * Perform cable detection for the EFAR ATA interface. This is
32 * different to the PIIX arrangement 33 * different to the PIIX arrangement
33 */ 34 */
34 35
35static int efar_pre_reset(struct ata_port *ap) 36static int efar_pre_reset(struct ata_port *ap, unsigned long deadline)
36{ 37{
37 static const struct pci_bits efar_enable_bits[] = { 38 static const struct pci_bits efar_enable_bits[] = {
38 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 39 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
@@ -43,7 +44,7 @@ static int efar_pre_reset(struct ata_port *ap)
43 if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) 44 if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no]))
44 return -ENOENT; 45 return -ENOENT;
45 46
46 return ata_std_prereset(ap); 47 return ata_std_prereset(ap, deadline);
47} 48}
48 49
49/** 50/**
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 93cfa6d300a5..e64e05e5c7fe 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -220,7 +220,7 @@ static int hpt36x_cable_detect(struct ata_port *ap)
220 return ATA_CBL_PATA80; 220 return ATA_CBL_PATA80;
221} 221}
222 222
223static int hpt36x_pre_reset(struct ata_port *ap) 223static int hpt36x_pre_reset(struct ata_port *ap, unsigned long deadline)
224{ 224{
225 static const struct pci_bits hpt36x_enable_bits[] = { 225 static const struct pci_bits hpt36x_enable_bits[] = {
226 { 0x50, 1, 0x04, 0x04 }, 226 { 0x50, 1, 0x04, 0x04 },
@@ -231,7 +231,7 @@ static int hpt36x_pre_reset(struct ata_port *ap)
231 if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no])) 231 if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
232 return -ENOENT; 232 return -ENOENT;
233 233
234 return ata_std_prereset(ap); 234 return ata_std_prereset(ap, deadline);
235} 235}
236 236
237/** 237/**
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 41d831296347..1614e8c822a4 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -307,11 +307,12 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
307/** 307/**
308 * hpt37x_pre_reset - reset the hpt37x bus 308 * hpt37x_pre_reset - reset the hpt37x bus
309 * @ap: ATA port to reset 309 * @ap: ATA port to reset
310 * @deadline: deadline jiffies for the operation
310 * 311 *
311 * Perform the initial reset handling for the 370/372 and 374 func 0 312 * Perform the initial reset handling for the 370/372 and 374 func 0
312 */ 313 */
313 314
314static int hpt37x_pre_reset(struct ata_port *ap) 315static int hpt37x_pre_reset(struct ata_port *ap, unsigned long deadline)
315{ 316{
316 u8 scr2, ata66; 317 u8 scr2, ata66;
317 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 318 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -338,7 +339,7 @@ static int hpt37x_pre_reset(struct ata_port *ap)
338 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 339 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
339 udelay(100); 340 udelay(100);
340 341
341 return ata_std_prereset(ap); 342 return ata_std_prereset(ap, deadline);
342} 343}
343 344
344/** 345/**
@@ -353,7 +354,7 @@ static void hpt37x_error_handler(struct ata_port *ap)
353 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 354 ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
354} 355}
355 356
356static int hpt374_pre_reset(struct ata_port *ap) 357static int hpt374_pre_reset(struct ata_port *ap, unsigned long deadline)
357{ 358{
358 static const struct pci_bits hpt37x_enable_bits[] = { 359 static const struct pci_bits hpt37x_enable_bits[] = {
359 { 0x50, 1, 0x04, 0x04 }, 360 { 0x50, 1, 0x04, 0x04 },
@@ -388,7 +389,7 @@ static int hpt374_pre_reset(struct ata_port *ap)
388 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 389 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
389 udelay(100); 390 udelay(100);
390 391
391 return ata_std_prereset(ap); 392 return ata_std_prereset(ap, deadline);
392} 393}
393 394
394/** 395/**
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 6a34521b9e01..ea1037d67860 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -148,13 +148,14 @@ static int hpt3x2n_cable_detect(struct ata_port *ap)
148 * Reset the hardware and state machine, 148 * Reset the hardware and state machine,
149 */ 149 */
150 150
151static int hpt3xn_pre_reset(struct ata_port *ap) 151static int hpt3xn_pre_reset(struct ata_port *ap, unsigned long deadline)
152{ 152{
153 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 153 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
154 /* Reset the state machine */ 154 /* Reset the state machine */
155 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); 155 pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
156 udelay(100); 156 udelay(100);
157 return ata_std_prereset(ap); 157
158 return ata_std_prereset(ap, deadline);
158} 159}
159 160
160/** 161/**
diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c
index 011306ef8334..17bf9f3ed013 100644
--- a/drivers/ata/pata_it8213.c
+++ b/drivers/ata/pata_it8213.c
@@ -24,12 +24,13 @@
24/** 24/**
25 * it8213_pre_reset - check for 40/80 pin 25 * it8213_pre_reset - check for 40/80 pin
26 * @ap: Port 26 * @ap: Port
27 * @deadline: deadline jiffies for the operation
27 * 28 *
28 * Filter out ports by the enable bits before doing the normal reset 29 * Filter out ports by the enable bits before doing the normal reset
29 * and probe. 30 * and probe.
30 */ 31 */
31 32
32static int it8213_pre_reset(struct ata_port *ap) 33static int it8213_pre_reset(struct ata_port *ap, unsigned long deadline)
33{ 34{
34 static const struct pci_bits it8213_enable_bits[] = { 35 static const struct pci_bits it8213_enable_bits[] = {
35 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ 36 { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
@@ -37,7 +38,8 @@ static int it8213_pre_reset(struct ata_port *ap)
37 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 38 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
38 if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no])) 39 if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no]))
39 return -ENOENT; 40 return -ENOENT;
40 return ata_std_prereset(ap); 41
42 return ata_std_prereset(ap, deadline);
41} 43}
42 44
43/** 45/**
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 43763c99ea02..1daf78ac6efb 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -30,16 +30,17 @@ typedef enum {
30/** 30/**
31 * jmicron_pre_reset - check for 40/80 pin 31 * jmicron_pre_reset - check for 40/80 pin
32 * @ap: Port 32 * @ap: Port
33 * @deadline: deadline jiffies for the operation
33 * 34 *
34 * Perform the PATA port setup we need. 35 * Perform the PATA port setup we need.
35 36 *
36 * On the Jmicron 361/363 there is a single PATA port that can be mapped 37 * On the Jmicron 361/363 there is a single PATA port that can be mapped
37 * either as primary or secondary (or neither). We don't do any policy 38 * either as primary or secondary (or neither). We don't do any policy
38 * and setup here. We assume that has been done by init_one and the 39 * and setup here. We assume that has been done by init_one and the
39 * BIOS. 40 * BIOS.
40 */ 41 */
41 42
42static int jmicron_pre_reset(struct ata_port *ap) 43static int jmicron_pre_reset(struct ata_port *ap, unsigned long deadline)
43{ 44{
44 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 45 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
45 u32 control; 46 u32 control;
@@ -102,7 +103,7 @@ static int jmicron_pre_reset(struct ata_port *ap)
102 ap->cbl = ATA_CBL_SATA; 103 ap->cbl = ATA_CBL_SATA;
103 break; 104 break;
104 } 105 }
105 return ata_std_prereset(ap); 106 return ata_std_prereset(ap, deadline);
106} 107}
107 108
108/** 109/**
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index d9b94a1b6954..8ab236c54823 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -25,11 +25,12 @@
25/** 25/**
26 * marvell_pre_reset - check for 40/80 pin 26 * marvell_pre_reset - check for 40/80 pin
27 * @ap: Port 27 * @ap: Port
28 * @deadline: deadline jiffies for the operation
28 * 29 *
29 * Perform the PATA port setup we need. 30 * Perform the PATA port setup we need.
30 */ 31 */
31 32
32static int marvell_pre_reset(struct ata_port *ap) 33static int marvell_pre_reset(struct ata_port *ap, unsigned long deadline)
33{ 34{
34 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 35 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
35 u32 devices; 36 u32 devices;
@@ -67,6 +68,7 @@ static int marvell_cable_detect(struct ata_port *ap)
67 case 1: /* Legacy SATA port */ 68 case 1: /* Legacy SATA port */
68 return ATA_CBL_SATA; 69 return ATA_CBL_SATA;
69 } 70 }
71
70 BUG(); 72 BUG();
71 return 0; /* Our BUG macro needs the right markup */ 73 return 0; /* Our BUG macro needs the right markup */
72} 74}
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 987c5fafab08..3bfbd495f643 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -46,14 +46,15 @@ enum {
46 SECONDARY = (1 << 14) 46 SECONDARY = (1 << 14)
47}; 47};
48 48
49static int mpiix_pre_reset(struct ata_port *ap) 49static int mpiix_pre_reset(struct ata_port *ap, unsigned long deadline)
50{ 50{
51 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 51 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
52 static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 }; 52 static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 };
53 53
54 if (!pci_test_config_bits(pdev, &mpiix_enable_bits)) 54 if (!pci_test_config_bits(pdev, &mpiix_enable_bits))
55 return -ENOENT; 55 return -ENOENT;
56 return ata_std_prereset(ap); 56
57 return ata_std_prereset(ap, deadline);
57} 58}
58 59
59/** 60/**
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 078aeda9cf8d..ebc58a907d26 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -33,11 +33,12 @@
33/** 33/**
34 * ns87410_pre_reset - probe begin 34 * ns87410_pre_reset - probe begin
35 * @ap: ATA port 35 * @ap: ATA port
36 * @deadline: deadline jiffies for the operation
36 * 37 *
37 * Check enabled ports 38 * Check enabled ports
38 */ 39 */
39 40
40static int ns87410_pre_reset(struct ata_port *ap) 41static int ns87410_pre_reset(struct ata_port *ap, unsigned long deadline)
41{ 42{
42 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 43 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
43 static const struct pci_bits ns87410_enable_bits[] = { 44 static const struct pci_bits ns87410_enable_bits[] = {
@@ -47,7 +48,8 @@ static int ns87410_pre_reset(struct ata_port *ap)
47 48
48 if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no])) 49 if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no]))
49 return -ENOENT; 50 return -ENOENT;
50 return ata_std_prereset(ap); 51
52 return ata_std_prereset(ap, deadline);
51} 53}
52 54
53/** 55/**
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index dea4690340d1..4d75d32e5826 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -30,11 +30,12 @@
30/** 30/**
31 * oldpiix_pre_reset - probe begin 31 * oldpiix_pre_reset - probe begin
32 * @ap: ATA port 32 * @ap: ATA port
33 * @deadline: deadline jiffies for the operation
33 * 34 *
34 * Set up cable type and use generic probe init 35 * Set up cable type and use generic probe init
35 */ 36 */
36 37
37static int oldpiix_pre_reset(struct ata_port *ap) 38static int oldpiix_pre_reset(struct ata_port *ap, unsigned long deadline)
38{ 39{
39 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 40 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
40 static const struct pci_bits oldpiix_enable_bits[] = { 41 static const struct pci_bits oldpiix_enable_bits[] = {
@@ -44,7 +45,8 @@ static int oldpiix_pre_reset(struct ata_port *ap)
44 45
45 if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no])) 46 if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no]))
46 return -ENOENT; 47 return -ENOENT;
47 return ata_std_prereset(ap); 48
49 return ata_std_prereset(ap, deadline);
48} 50}
49 51
50/** 52/**
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index 13b63e21838d..0af8a2c77cc9 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -47,11 +47,12 @@ enum {
47/** 47/**
48 * opti_pre_reset - probe begin 48 * opti_pre_reset - probe begin
49 * @ap: ATA port 49 * @ap: ATA port
50 * @deadline: deadline jiffies for the operation
50 * 51 *
51 * Set up cable type and use generic probe init 52 * Set up cable type and use generic probe init
52 */ 53 */
53 54
54static int opti_pre_reset(struct ata_port *ap) 55static int opti_pre_reset(struct ata_port *ap, unsigned long deadline)
55{ 56{
56 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 57 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
57 static const struct pci_bits opti_enable_bits[] = { 58 static const struct pci_bits opti_enable_bits[] = {
@@ -61,7 +62,8 @@ static int opti_pre_reset(struct ata_port *ap)
61 62
62 if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no])) 63 if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no]))
63 return -ENOENT; 64 return -ENOENT;
64 return ata_std_prereset(ap); 65
66 return ata_std_prereset(ap, deadline);
65} 67}
66 68
67/** 69/**
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index b70e04c144df..2843e480f216 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -48,11 +48,12 @@ static int pci_clock; /* 0 = 33 1 = 25 */
48/** 48/**
49 * optidma_pre_reset - probe begin 49 * optidma_pre_reset - probe begin
50 * @ap: ATA port 50 * @ap: ATA port
51 * @deadline: deadline jiffies for the operation
51 * 52 *
52 * Set up cable type and use generic probe init 53 * Set up cable type and use generic probe init
53 */ 54 */
54 55
55static int optidma_pre_reset(struct ata_port *ap) 56static int optidma_pre_reset(struct ata_port *ap, unsigned long deadline)
56{ 57{
57 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 58 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
58 static const struct pci_bits optidma_enable_bits = { 59 static const struct pci_bits optidma_enable_bits = {
@@ -62,7 +63,7 @@ static int optidma_pre_reset(struct ata_port *ap)
62 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) 63 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
63 return -ENOENT; 64 return -ENOENT;
64 65
65 return ata_std_prereset(ap); 66 return ata_std_prereset(ap, deadline);
66} 67}
67 68
68/** 69/**
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index a61cbc110688..0d2cc49fde4b 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -301,6 +301,7 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
301/** 301/**
302 * pdc2027x_prereset - prereset for PATA host controller 302 * pdc2027x_prereset - prereset for PATA host controller
303 * @ap: Target port 303 * @ap: Target port
304 * @deadline: deadline jiffies for the operation
304 * 305 *
305 * Probeinit including cable detection. 306 * Probeinit including cable detection.
306 * 307 *
@@ -308,12 +309,12 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
308 * None (inherited from caller). 309 * None (inherited from caller).
309 */ 310 */
310 311
311static int pdc2027x_prereset(struct ata_port *ap) 312static int pdc2027x_prereset(struct ata_port *ap, unsigned long deadline)
312{ 313{
313 /* Check whether port enabled */ 314 /* Check whether port enabled */
314 if (!pdc2027x_port_enabled(ap)) 315 if (!pdc2027x_port_enabled(ap))
315 return -ENOENT; 316 return -ENOENT;
316 return ata_std_prereset(ap); 317 return ata_std_prereset(ap, deadline);
317} 318}
318 319
319/** 320/**
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 3956ef26936d..b6e020383dd9 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -139,12 +139,14 @@ static struct sv_cable_table cable_detect[] = {
139/** 139/**
140 * serverworks_cable_detect - cable detection 140 * serverworks_cable_detect - cable detection
141 * @ap: ATA port 141 * @ap: ATA port
142 * @deadline: deadline jiffies for the operation
142 * 143 *
143 * Perform cable detection according to the device and subvendor 144 * Perform cable detection according to the device and subvendor
144 * identifications 145 * identifications
145 */ 146 */
146 147
147static int serverworks_cable_detect(struct ata_port *ap) { 148static int serverworks_cable_detect(struct ata_port *ap)
149{
148 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 150 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
149 struct sv_cable_table *cb = cable_detect; 151 struct sv_cable_table *cb = cable_detect;
150 152
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 6770820cfca9..a5886f061c0b 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -94,11 +94,13 @@ static int sil680_cable_detect(struct ata_port *ap) {
94/** 94/**
95 * sil680_bus_reset - reset the SIL680 bus 95 * sil680_bus_reset - reset the SIL680 bus
96 * @ap: ATA port to reset 96 * @ap: ATA port to reset
97 * @deadline: deadline jiffies for the operation
97 * 98 *
98 * Perform the SIL680 housekeeping when doing an ATA bus reset 99 * Perform the SIL680 housekeeping when doing an ATA bus reset
99 */ 100 */
100 101
101static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes) 102static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes,
103 unsigned long deadline)
102{ 104{
103 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 105 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
104 unsigned long addr = sil680_selreg(ap, 0); 106 unsigned long addr = sil680_selreg(ap, 0);
@@ -108,7 +110,7 @@ static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes)
108 pci_write_config_byte(pdev, addr, reset | 0x03); 110 pci_write_config_byte(pdev, addr, reset | 0x03);
109 udelay(25); 111 udelay(25);
110 pci_write_config_byte(pdev, addr, reset); 112 pci_write_config_byte(pdev, addr, reset);
111 return ata_std_softreset(ap, classes); 113 return ata_std_softreset(ap, classes, deadline);
112} 114}
113 115
114static void sil680_error_handler(struct ata_port *ap) 116static void sil680_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index a3fbcee6fb33..7c6b58223c79 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -88,6 +88,7 @@ static int sis_port_base(struct ata_device *adev)
88/** 88/**
89 * sis_133_cable_detect - check for 40/80 pin 89 * sis_133_cable_detect - check for 40/80 pin
90 * @ap: Port 90 * @ap: Port
91 * @deadline: deadline jiffies for the operation
91 * 92 *
92 * Perform cable detection for the later UDMA133 capable 93 * Perform cable detection for the later UDMA133 capable
93 * SiS chipset. 94 * SiS chipset.
@@ -108,6 +109,7 @@ static int sis_133_cable_detect(struct ata_port *ap)
108/** 109/**
109 * sis_66_cable_detect - check for 40/80 pin 110 * sis_66_cable_detect - check for 40/80 pin
110 * @ap: Port 111 * @ap: Port
112 * @deadline: deadline jiffies for the operation
111 * 113 *
112 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133 114 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133
113 * SiS IDE controllers. 115 * SiS IDE controllers.
@@ -130,11 +132,12 @@ static int sis_66_cable_detect(struct ata_port *ap)
130/** 132/**
131 * sis_pre_reset - probe begin 133 * sis_pre_reset - probe begin
132 * @ap: ATA port 134 * @ap: ATA port
135 * @deadline: deadline jiffies for the operation
133 * 136 *
134 * Set up cable type and use generic probe init 137 * Set up cable type and use generic probe init
135 */ 138 */
136 139
137static int sis_pre_reset(struct ata_port *ap) 140static int sis_old_pre_reset(struct ata_port *ap, unsigned long deadline)
138{ 141{
139 static const struct pci_bits sis_enable_bits[] = { 142 static const struct pci_bits sis_enable_bits[] = {
140 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 143 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
@@ -145,7 +148,8 @@ static int sis_pre_reset(struct ata_port *ap)
145 148
146 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) 149 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
147 return -ENOENT; 150 return -ENOENT;
148 return ata_std_prereset(ap); 151
152 return ata_std_prereset(ap, deadline);
149} 153}
150 154
151 155
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index da9e22b25753..9aeffdbe2829 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -44,11 +44,12 @@ enum {
44/** 44/**
45 * sl82c105_pre_reset - probe begin 45 * sl82c105_pre_reset - probe begin
46 * @ap: ATA port 46 * @ap: ATA port
47 * @deadline: deadline jiffies for the operation
47 * 48 *
48 * Set up cable type and use generic probe init 49 * Set up cable type and use generic probe init
49 */ 50 */
50 51
51static int sl82c105_pre_reset(struct ata_port *ap) 52static int sl82c105_pre_reset(struct ata_port *ap, unsigned long deadline)
52{ 53{
53 static const struct pci_bits sl82c105_enable_bits[] = { 54 static const struct pci_bits sl82c105_enable_bits[] = {
54 { 0x40, 1, 0x01, 0x01 }, 55 { 0x40, 1, 0x01, 0x01 },
@@ -58,7 +59,7 @@ static int sl82c105_pre_reset(struct ata_port *ap)
58 59
59 if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) 60 if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no]))
60 return -ENOENT; 61 return -ENOENT;
61 return ata_std_prereset(ap); 62 return ata_std_prereset(ap, deadline);
62} 63}
63 64
64 65
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index e618ffd6e944..349887bf5b93 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -48,11 +48,12 @@
48/** 48/**
49 * triflex_prereset - probe begin 49 * triflex_prereset - probe begin
50 * @ap: ATA port 50 * @ap: ATA port
51 * @deadline: deadline jiffies for the operation
51 * 52 *
52 * Set up cable type and use generic probe init 53 * Set up cable type and use generic probe init
53 */ 54 */
54 55
55static int triflex_prereset(struct ata_port *ap) 56static int triflex_prereset(struct ata_port *ap, unsigned long deadline)
56{ 57{
57 static const struct pci_bits triflex_enable_bits[] = { 58 static const struct pci_bits triflex_enable_bits[] = {
58 { 0x80, 1, 0x01, 0x01 }, 59 { 0x80, 1, 0x01, 0x01 },
@@ -63,7 +64,8 @@ static int triflex_prereset(struct ata_port *ap)
63 64
64 if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no])) 65 if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no]))
65 return -ENOENT; 66 return -ENOENT;
66 return ata_std_prereset(ap); 67
68 return ata_std_prereset(ap, deadline);
67} 69}
68 70
69 71
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 96b71791d2f4..362beb2f489c 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -154,7 +154,7 @@ static int via_cable_detect(struct ata_port *ap) {
154 return ATA_CBL_PATA40; 154 return ATA_CBL_PATA40;
155} 155}
156 156
157static int via_pre_reset(struct ata_port *ap) 157static int via_pre_reset(struct ata_port *ap, unsigned long deadline)
158{ 158{
159 const struct via_isa_bridge *config = ap->host->private_data; 159 const struct via_isa_bridge *config = ap->host->private_data;
160 160
@@ -167,7 +167,8 @@ static int via_pre_reset(struct ata_port *ap)
167 if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) 167 if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no]))
168 return -ENOENT; 168 return -ENOENT;
169 } 169 }
170 return ata_std_prereset(ap); 170
171 return ata_std_prereset(ap, deadline);
171} 172}
172 173
173 174
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index f099a1d83a00..25b747e26133 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -420,7 +420,8 @@ static void inic_thaw(struct ata_port *ap)
420 * SRST and SControl hardreset don't give valid signature on this 420 * SRST and SControl hardreset don't give valid signature on this
421 * controller. Only controller specific hardreset mechanism works. 421 * controller. Only controller specific hardreset mechanism works.
422 */ 422 */
423static int inic_hardreset(struct ata_port *ap, unsigned int *class) 423static int inic_hardreset(struct ata_port *ap, unsigned int *class,
424 unsigned long deadline)
424{ 425{
425 void __iomem *port_base = inic_port_base(ap); 426 void __iomem *port_base = inic_port_base(ap);
426 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL; 427 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
@@ -437,7 +438,7 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
437 msleep(1); 438 msleep(1);
438 writew(val & ~IDMA_CTL_RST_ATA, idma_ctl); 439 writew(val & ~IDMA_CTL_RST_ATA, idma_ctl);
439 440
440 rc = sata_phy_resume(ap, timing); 441 rc = sata_phy_resume(ap, timing, deadline);
441 if (rc) { 442 if (rc) {
442 ata_port_printk(ap, KERN_WARNING, "failed to resume " 443 ata_port_printk(ap, KERN_WARNING, "failed to resume "
443 "link after reset (errno=%d)\n", rc); 444 "link after reset (errno=%d)\n", rc);
@@ -451,10 +452,11 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
451 /* wait a while before checking status */ 452 /* wait a while before checking status */
452 msleep(150); 453 msleep(150);
453 454
454 if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { 455 rc = ata_wait_ready(ap, deadline);
455 ata_port_printk(ap, KERN_WARNING, 456 if (rc && rc != -ENODEV) {
456 "device busy after hardreset\n"); 457 ata_port_printk(ap, KERN_WARNING, "device not ready "
457 return -EIO; 458 "after hardreset (errno=%d)\n", rc);
459 return rc;
458 } 460 }
459 461
460 ata_tf_read(ap, &tf); 462 ata_tf_read(ap, &tf);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 02169740ed24..e2e795e58236 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -1405,7 +1405,8 @@ static void nv_ck804_thaw(struct ata_port *ap)
1405 writeb(mask, mmio_base + NV_INT_ENABLE_CK804); 1405 writeb(mask, mmio_base + NV_INT_ENABLE_CK804);
1406} 1406}
1407 1407
1408static int nv_hardreset(struct ata_port *ap, unsigned int *class) 1408static int nv_hardreset(struct ata_port *ap, unsigned int *class,
1409 unsigned long deadline)
1409{ 1410{
1410 unsigned int dummy; 1411 unsigned int dummy;
1411 1412
@@ -1413,7 +1414,7 @@ static int nv_hardreset(struct ata_port *ap, unsigned int *class)
1413 * some controllers. Don't classify on hardreset. For more 1414 * some controllers. Don't classify on hardreset. For more
1414 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352 1415 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352
1415 */ 1416 */
1416 return sata_std_hardreset(ap, &dummy); 1417 return sata_std_hardreset(ap, &dummy, deadline);
1417} 1418}
1418 1419
1419static void nv_error_handler(struct ata_port *ap) 1420static void nv_error_handler(struct ata_port *ap)
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index e6223ba667da..b97ee9f31aec 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -534,7 +534,8 @@ static int sil24_init_port(struct ata_port *ap)
534 return 0; 534 return 0;
535} 535}
536 536
537static int sil24_softreset(struct ata_port *ap, unsigned int *class) 537static int sil24_softreset(struct ata_port *ap, unsigned int *class,
538 unsigned long deadline)
538{ 539{
539 void __iomem *port = ap->ioaddr.cmd_addr; 540 void __iomem *port = ap->ioaddr.cmd_addr;
540 struct sil24_port_priv *pp = ap->private_data; 541 struct sil24_port_priv *pp = ap->private_data;
@@ -566,7 +567,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
566 567
567 mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT; 568 mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT;
568 irq_stat = ata_wait_register(port + PORT_IRQ_STAT, mask, 0x0, 569 irq_stat = ata_wait_register(port + PORT_IRQ_STAT, mask, 0x0,
569 100, ATA_TMOUT_BOOT / HZ * 1000); 570 100, jiffies_to_msecs(deadline - jiffies));
570 571
571 writel(irq_stat, port + PORT_IRQ_STAT); /* clear IRQs */ 572 writel(irq_stat, port + PORT_IRQ_STAT); /* clear IRQs */
572 irq_stat >>= PORT_IRQ_RAW_SHIFT; 573 irq_stat >>= PORT_IRQ_RAW_SHIFT;
@@ -594,7 +595,8 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
594 return -EIO; 595 return -EIO;
595} 596}
596 597
597static int sil24_hardreset(struct ata_port *ap, unsigned int *class) 598static int sil24_hardreset(struct ata_port *ap, unsigned int *class,
599 unsigned long deadline)
598{ 600{
599 void __iomem *port = ap->ioaddr.cmd_addr; 601 void __iomem *port = ap->ioaddr.cmd_addr;
600 const char *reason; 602 const char *reason;
@@ -615,7 +617,7 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
615 /* SStatus oscillates between zero and valid status after 617 /* SStatus oscillates between zero and valid status after
616 * DEV_RST, debounce it. 618 * DEV_RST, debounce it.
617 */ 619 */
618 rc = sata_phy_debounce(ap, sata_deb_timing_long); 620 rc = sata_phy_debounce(ap, sata_deb_timing_long, deadline);
619 if (rc) { 621 if (rc) {
620 reason = "PHY debouncing failed"; 622 reason = "PHY debouncing failed";
621 goto err; 623 goto err;
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 1d855f55f5f7..305ab7c68ca5 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -268,6 +268,7 @@ static void svia_noop_freeze(struct ata_port *ap)
268/** 268/**
269 * vt6420_prereset - prereset for vt6420 269 * vt6420_prereset - prereset for vt6420
270 * @ap: target ATA port 270 * @ap: target ATA port
271 * @deadline: deadline jiffies for the operation
271 * 272 *
272 * SCR registers on vt6420 are pieces of shit and may hang the 273 * SCR registers on vt6420 are pieces of shit and may hang the
273 * whole machine completely if accessed with the wrong timing. 274 * whole machine completely if accessed with the wrong timing.
@@ -284,7 +285,7 @@ static void svia_noop_freeze(struct ata_port *ap)
284 * RETURNS: 285 * RETURNS:
285 * 0 on success, -errno otherwise. 286 * 0 on success, -errno otherwise.
286 */ 287 */
287static int vt6420_prereset(struct ata_port *ap) 288static int vt6420_prereset(struct ata_port *ap, unsigned long deadline)
288{ 289{
289 struct ata_eh_context *ehc = &ap->eh_context; 290 struct ata_eh_context *ehc = &ap->eh_context;
290 unsigned long timeout = jiffies + (HZ * 5); 291 unsigned long timeout = jiffies + (HZ * 5);
@@ -329,7 +330,7 @@ static int vt6420_prereset(struct ata_port *ap)
329 330
330 skip_scr: 331 skip_scr:
331 /* wait for !BSY */ 332 /* wait for !BSY */
332 ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); 333 ata_wait_ready(ap, deadline);
333 334
334 return 0; 335 return 0;
335} 336}