Commit 4750def5 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'reset-seq' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'reset-seq' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev:
  [libata reset-seq] build and merge fixes
  libata: reimplement reset sequencing
  libata: improve ata_std_prereset()
  libata: improve 0xff status handling
  libata: add deadline support to prereset and reset methods
parents 9028780a 27c78b37
...@@ -874,7 +874,8 @@ static int ahci_clo(struct ata_port *ap) ...@@ -874,7 +874,8 @@ static int ahci_clo(struct ata_port *ap)
return 0; return 0;
} }
static int ahci_softreset(struct ata_port *ap, unsigned int *class) static int ahci_softreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
struct ahci_port_priv *pp = ap->private_data; struct ahci_port_priv *pp = ap->private_data;
void __iomem *port_mmio = ahci_port_base(ap); void __iomem *port_mmio = ahci_port_base(ap);
...@@ -959,15 +960,13 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class) ...@@ -959,15 +960,13 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
*/ */
msleep(150); msleep(150);
*class = ATA_DEV_NONE; rc = ata_wait_ready(ap, deadline);
if (ata_port_online(ap)) { /* link occupied, -ENODEV too is an error */
if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { if (rc) {
rc = -EIO;
reason = "device not ready"; reason = "device not ready";
goto fail; goto fail;
} }
*class = ahci_dev_classify(ap); *class = ahci_dev_classify(ap);
}
DPRINTK("EXIT, class=%u\n", *class); DPRINTK("EXIT, class=%u\n", *class);
return 0; return 0;
...@@ -979,7 +978,8 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class) ...@@ -979,7 +978,8 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
return rc; return rc;
} }
static int ahci_hardreset(struct ata_port *ap, unsigned int *class) static int ahci_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
struct ahci_port_priv *pp = ap->private_data; struct ahci_port_priv *pp = ap->private_data;
u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
...@@ -995,7 +995,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -995,7 +995,7 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
tf.command = 0x80; tf.command = 0x80;
ata_tf_to_fis(&tf, d2h_fis, 0); ata_tf_to_fis(&tf, d2h_fis, 0);
rc = sata_std_hardreset(ap, class); rc = sata_std_hardreset(ap, class, deadline);
ahci_start_engine(ap); ahci_start_engine(ap);
...@@ -1008,7 +1008,8 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -1008,7 +1008,8 @@ static int ahci_hardreset(struct ata_port *ap, unsigned int *class)
return rc; return rc;
} }
static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class) static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
int rc; int rc;
...@@ -1016,7 +1017,8 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -1016,7 +1017,8 @@ static int ahci_vt8251_hardreset(struct ata_port *ap, unsigned int *class)
ahci_stop_engine(ap); ahci_stop_engine(ap);
rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->eh_context)); rc = sata_port_hardreset(ap, sata_ehc_deb_timing(&ap->eh_context),
deadline);
/* vt8251 needs SError cleared for the port to operate */ /* vt8251 needs SError cleared for the port to operate */
ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR)); ahci_scr_write(ap, SCR_ERROR, ahci_scr_read(ap, SCR_ERROR));
......
...@@ -625,17 +625,18 @@ static int ich_pata_cable_detect(struct ata_port *ap) ...@@ -625,17 +625,18 @@ static int ich_pata_cable_detect(struct ata_port *ap)
/** /**
* piix_pata_prereset - prereset for PATA host controller * piix_pata_prereset - prereset for PATA host controller
* @ap: Target port * @ap: Target port
* @deadline: deadline jiffies for the operation
* *
* LOCKING: * LOCKING:
* None (inherited from caller). * None (inherited from caller).
*/ */
static int piix_pata_prereset(struct ata_port *ap) static int piix_pata_prereset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
static void piix_pata_error_handler(struct ata_port *ap) static void piix_pata_error_handler(struct ata_port *ap)
...@@ -644,7 +645,6 @@ static void piix_pata_error_handler(struct ata_port *ap) ...@@ -644,7 +645,6 @@ static void piix_pata_error_handler(struct ata_port *ap)
ata_std_postreset); ata_std_postreset);
} }
static void piix_sata_error_handler(struct ata_port *ap) static void piix_sata_error_handler(struct ata_port *ap)
{ {
ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL, ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, NULL,
......
This diff is collapsed.
...@@ -50,6 +50,28 @@ enum { ...@@ -50,6 +50,28 @@ enum {
ATA_EH_SPDN_FALLBACK_TO_PIO = (1 << 2), ATA_EH_SPDN_FALLBACK_TO_PIO = (1 << 2),
}; };
/* Waiting in ->prereset can never be reliable. It's sometimes nice
* to wait there but it can't be depended upon; otherwise, we wouldn't
* be resetting. Just give it enough time for most drives to spin up.
*/
enum {
ATA_EH_PRERESET_TIMEOUT = 10 * HZ,
};
/* The following table determines how we sequence resets. Each entry
* represents timeout for that try. The first try can be soft or
* hardreset. All others are hardreset if available. In most cases
* the first reset w/ 10sec timeout should succeed. Following entries
* are mostly for error handling, hotplug and retarded devices.
*/
static const unsigned long ata_eh_reset_timeouts[] = {
10 * HZ, /* most drives spin up by 10sec */
10 * HZ, /* > 99% working drives spin up before 20sec */
35 * HZ, /* give > 30 secs of idleness for retarded devices */
5 * HZ, /* and sweet one last chance */
/* > 1 min has elapsed, give up */
};
static void __ata_port_freeze(struct ata_port *ap); static void __ata_port_freeze(struct ata_port *ap);
static void ata_eh_finish(struct ata_port *ap); static void ata_eh_finish(struct ata_port *ap);
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -1558,14 +1580,14 @@ static void ata_eh_report(struct ata_port *ap) ...@@ -1558,14 +1580,14 @@ static void ata_eh_report(struct ata_port *ap)
} }
static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset, static int ata_do_reset(struct ata_port *ap, ata_reset_fn_t reset,
unsigned int *classes) unsigned int *classes, unsigned long deadline)
{ {
int i, rc; int i, rc;
for (i = 0; i < ATA_MAX_DEVICES; i++) for (i = 0; i < ATA_MAX_DEVICES; i++)
classes[i] = ATA_DEV_UNKNOWN; classes[i] = ATA_DEV_UNKNOWN;
rc = reset(ap, classes); rc = reset(ap, classes, deadline);
if (rc) if (rc)
return rc; return rc;
...@@ -1603,8 +1625,9 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1603,8 +1625,9 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
{ {
struct ata_eh_context *ehc = &ap->eh_context; struct ata_eh_context *ehc = &ap->eh_context;
unsigned int *classes = ehc->classes; unsigned int *classes = ehc->classes;
int tries = ATA_EH_RESET_TRIES;
int verbose = !(ehc->i.flags & ATA_EHI_QUIET); int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
int try = 0;
unsigned long deadline;
unsigned int action; unsigned int action;
ata_reset_fn_t reset; ata_reset_fn_t reset;
int i, did_followup_srst, rc; int i, did_followup_srst, rc;
...@@ -1624,7 +1647,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1624,7 +1647,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
ehc->i.action |= ATA_EH_HARDRESET; ehc->i.action |= ATA_EH_HARDRESET;
if (prereset) { if (prereset) {
rc = prereset(ap); rc = prereset(ap, jiffies + ATA_EH_PRERESET_TIMEOUT);
if (rc) { if (rc) {
if (rc == -ENOENT) { if (rc == -ENOENT) {
ata_port_printk(ap, KERN_DEBUG, ata_port_printk(ap, KERN_DEBUG,
...@@ -1665,6 +1688,8 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1665,6 +1688,8 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
} }
retry: retry:
deadline = jiffies + ata_eh_reset_timeouts[try++];
/* shut up during boot probing */ /* shut up during boot probing */
if (verbose) if (verbose)
ata_port_printk(ap, KERN_INFO, "%s resetting port\n", ata_port_printk(ap, KERN_INFO, "%s resetting port\n",
...@@ -1676,7 +1701,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1676,7 +1701,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
else else
ehc->i.flags |= ATA_EHI_DID_SOFTRESET; ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
rc = ata_do_reset(ap, reset, classes); rc = ata_do_reset(ap, reset, classes, deadline);
did_followup_srst = 0; did_followup_srst = 0;
if (reset == hardreset && if (reset == hardreset &&
...@@ -1693,7 +1718,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1693,7 +1718,7 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
} }
ata_eh_about_to_do(ap, NULL, ATA_EH_RESET_MASK); ata_eh_about_to_do(ap, NULL, ATA_EH_RESET_MASK);
rc = ata_do_reset(ap, reset, classes); rc = ata_do_reset(ap, reset, classes, deadline);
if (rc == 0 && classify && if (rc == 0 && classify &&
classes[0] == ATA_DEV_UNKNOWN) { classes[0] == ATA_DEV_UNKNOWN) {
...@@ -1703,22 +1728,21 @@ static int ata_eh_reset(struct ata_port *ap, int classify, ...@@ -1703,22 +1728,21 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
} }
} }
if (rc && --tries) { if (rc && try < ARRAY_SIZE(ata_eh_reset_timeouts)) {
const char *type; unsigned long now = jiffies;
if (reset == softreset) { if (time_before(now, deadline)) {
if (did_followup_srst) unsigned long delta = deadline - jiffies;
type = "follow-up soft";
else
type = "soft";
} else
type = "hard";
ata_port_printk(ap, KERN_WARNING, ata_port_printk(ap, KERN_WARNING, "reset failed "
"%sreset failed, retrying in 5 secs\n", type); "(errno=%d), retrying in %u secs\n",
ssleep(5); rc, (jiffies_to_msecs(delta) + 999) / 1000);
if (reset == hardreset) schedule_timeout_uninterruptible(delta);
}
if (reset == hardreset &&
try == ARRAY_SIZE(ata_eh_reset_timeouts) - 1)
sata_down_spd_limit(ap); sata_down_spd_limit(ap);
if (hardreset) if (hardreset)
reset = hardreset; reset = hardreset;
......
...@@ -121,12 +121,13 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse ...@@ -121,12 +121,13 @@ static void timing_setup(struct ata_port *ap, struct ata_device *adev, int offse
/** /**
* amd_probe_init - perform reset handling * amd_probe_init - perform reset handling
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Reset sequence checking enable bits to see which ports are * Reset sequence checking enable bits to see which ports are
* active. * active.
*/ */
static int amd_pre_reset(struct ata_port *ap) static int amd_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits amd_enable_bits[] = { static const struct pci_bits amd_enable_bits[] = {
{ 0x40, 1, 0x02, 0x02 }, { 0x40, 1, 0x02, 0x02 },
...@@ -138,8 +139,7 @@ static int amd_pre_reset(struct ata_port *ap) ...@@ -138,8 +139,7 @@ static int amd_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
static void amd_error_handler(struct ata_port *ap) static 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,7 +227,8 @@ static void amd133_set_dmamode(struct ata_port *ap, struct ata_device *adev)
* space for us. * space for us.
*/ */
static int nv_pre_reset(struct ata_port *ap) { static int nv_pre_reset(struct ata_port *ap, unsigned long deadline)
{
static const struct pci_bits nv_enable_bits[] = { static const struct pci_bits nv_enable_bits[] = {
{ 0x50, 1, 0x02, 0x02 }, { 0x50, 1, 0x02, 0x02 },
{ 0x50, 1, 0x01, 0x01 } { 0x50, 1, 0x01, 0x01 }
...@@ -238,7 +239,7 @@ static int nv_pre_reset(struct ata_port *ap) { ...@@ -238,7 +239,7 @@ static int nv_pre_reset(struct ata_port *ap) {
if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
static void nv_error_handler(struct ata_port *ap) static void nv_error_handler(struct ata_port *ap)
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
static int clock = 0; static int clock = 0;
static int artop6210_pre_reset(struct ata_port *ap) static int artop6210_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
const struct pci_bits artop_enable_bits[] = { const struct pci_bits artop_enable_bits[] = {
...@@ -49,7 +49,8 @@ static int artop6210_pre_reset(struct ata_port *ap) ...@@ -49,7 +49,8 @@ static int artop6210_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
...@@ -70,12 +71,13 @@ static void artop6210_error_handler(struct ata_port *ap) ...@@ -70,12 +71,13 @@ static void artop6210_error_handler(struct ata_port *ap)
/** /**
* artop6260_pre_reset - check for 40/80 pin * artop6260_pre_reset - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* The ARTOP hardware reports the cable detect bits in register 0x49. * The ARTOP hardware reports the cable detect bits in register 0x49.
* Nothing complicated needed here. * Nothing complicated needed here.
*/ */
static int artop6260_pre_reset(struct ata_port *ap) static int artop6260_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits artop_enable_bits[] = { static const struct pci_bits artop_enable_bits[] = {
{ 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */
...@@ -87,7 +89,8 @@ static int artop6260_pre_reset(struct ata_port *ap) ...@@ -87,7 +89,8 @@ static int artop6260_pre_reset(struct ata_port *ap)
/* Odd numbered device ids are the units with enable bits (the -R cards) */ /* Odd numbered device ids are the units with enable bits (the -R cards) */
if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -33,7 +33,7 @@ enum { ...@@ -33,7 +33,7 @@ enum {
ATIIXP_IDE_UDMA_MODE = 0x56 ATIIXP_IDE_UDMA_MODE = 0x56
}; };
static int atiixp_pre_reset(struct ata_port *ap) static int atiixp_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits atiixp_enable_bits[] = { static const struct pci_bits atiixp_enable_bits[] = {
{ 0x48, 1, 0x01, 0x00 }, { 0x48, 1, 0x01, 0x00 },
...@@ -44,7 +44,7 @@ static int atiixp_pre_reset(struct ata_port *ap) ...@@ -44,7 +44,7 @@ static int atiixp_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
static void atiixp_error_handler(struct ata_port *ap) static void atiixp_error_handler(struct ata_port *ap)
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
/** /**
* cs5535_cable_detect - detect cable type * cs5535_cable_detect - detect cable type
* @ap: Port to detect on * @ap: Port to detect on
* @deadline: deadline jiffies for the operation
* *
* Perform cable detection for ATA66 capable cable. Return a libata * Perform cable detection for ATA66 capable cable. Return a libata
* cable type. * cable type.
......
...@@ -27,12 +27,13 @@ ...@@ -27,12 +27,13 @@
/** /**
* efar_pre_reset - Enable bits * efar_pre_reset - Enable bits
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Perform cable detection for the EFAR ATA interface. This is * Perform cable detection for the EFAR ATA interface. This is
* different to the PIIX arrangement * different to the PIIX arrangement
*/ */
static int efar_pre_reset(struct ata_port *ap) static int efar_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits efar_enable_bits[] = { static const struct pci_bits efar_enable_bits[] = {
{ 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
...@@ -43,7 +44,7 @@ static int efar_pre_reset(struct ata_port *ap) ...@@ -43,7 +44,7 @@ static int efar_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -220,7 +220,7 @@ static int hpt36x_cable_detect(struct ata_port *ap) ...@@ -220,7 +220,7 @@ static int hpt36x_cable_detect(struct ata_port *ap)
return ATA_CBL_PATA80; return ATA_CBL_PATA80;
} }
static int hpt36x_pre_reset(struct ata_port *ap) static int hpt36x_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits hpt36x_enable_bits[] = { static const struct pci_bits hpt36x_enable_bits[] = {
{ 0x50, 1, 0x04, 0x04 }, { 0x50, 1, 0x04, 0x04 },
...@@ -231,7 +231,7 @@ static int hpt36x_pre_reset(struct ata_port *ap) ...@@ -231,7 +231,7 @@ static int hpt36x_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &hpt36x_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -307,11 +307,12 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask) ...@@ -307,11 +307,12 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
/** /**
* hpt37x_pre_reset - reset the hpt37x bus * hpt37x_pre_reset - reset the hpt37x bus
* @ap: ATA port to reset * @ap: ATA port to reset
* @deadline: deadline jiffies for the operation
* *
* Perform the initial reset handling for the 370/372 and 374 func 0 * Perform the initial reset handling for the 370/372 and 374 func 0
*/ */
static int hpt37x_pre_reset(struct ata_port *ap) static int hpt37x_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
u8 scr2, ata66; u8 scr2, ata66;
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
...@@ -338,7 +339,7 @@ static int hpt37x_pre_reset(struct ata_port *ap) ...@@ -338,7 +339,7 @@ static int hpt37x_pre_reset(struct ata_port *ap)
pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
udelay(100); udelay(100);
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
...@@ -353,7 +354,7 @@ static void hpt37x_error_handler(struct ata_port *ap) ...@@ -353,7 +354,7 @@ static void hpt37x_error_handler(struct ata_port *ap)
ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset); ata_bmdma_drive_eh(ap, hpt37x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
} }
static int hpt374_pre_reset(struct ata_port *ap) static int hpt374_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits hpt37x_enable_bits[] = { static const struct pci_bits hpt37x_enable_bits[] = {
{ 0x50, 1, 0x04, 0x04 }, { 0x50, 1, 0x04, 0x04 },
...@@ -388,7 +389,7 @@ static int hpt374_pre_reset(struct ata_port *ap) ...@@ -388,7 +389,7 @@ static int hpt374_pre_reset(struct ata_port *ap)
pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
udelay(100); udelay(100);
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -148,13 +148,14 @@ static int hpt3x2n_cable_detect(struct ata_port *ap) ...@@ -148,13 +148,14 @@ static int hpt3x2n_cable_detect(struct ata_port *ap)
* Reset the hardware and state machine, * Reset the hardware and state machine,
*/ */
static int hpt3xn_pre_reset(struct ata_port *ap) static int hpt3xn_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
/* Reset the state machine */ /* Reset the state machine */
pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37);
udelay(100); udelay(100);
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -24,12 +24,13 @@ ...@@ -24,12 +24,13 @@
/** /**
* it8213_pre_reset - check for 40/80 pin * it8213_pre_reset - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Filter out ports by the enable bits before doing the normal reset * Filter out ports by the enable bits before doing the normal reset
* and probe. * and probe.
*/ */
static int it8213_pre_reset(struct ata_port *ap) static int it8213_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits it8213_enable_bits[] = { static const struct pci_bits it8213_enable_bits[] = {
{ 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */ { 0x41U, 1U, 0x80UL, 0x80UL }, /* port 0 */
...@@ -37,7 +38,8 @@ static int it8213_pre_reset(struct ata_port *ap) ...@@ -37,7 +38,8 @@ static int it8213_pre_reset(struct ata_port *ap)
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -30,16 +30,17 @@ typedef enum { ...@@ -30,16 +30,17 @@ typedef enum {
/** /**
* jmicron_pre_reset - check for 40/80 pin * jmicron_pre_reset - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Perform the PATA port setup we need. * Perform the PATA port setup we need.
*
* On the Jmicron 361/363 there is a single PATA port that can be mapped * On the Jmicron 361/363 there is a single PATA port that can be mapped
* either as primary or secondary (or neither). We don't do any policy * either as primary or secondary (or neither). We don't do any policy
* and setup here. We assume that has been done by init_one and the * and setup here. We assume that has been done by init_one and the
* BIOS. * BIOS.
*/ */
static int jmicron_pre_reset(struct ata_port *ap) static int jmicron_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u32 control; u32 control;
...@@ -102,7 +103,7 @@ static int jmicron_pre_reset(struct ata_port *ap) ...@@ -102,7 +103,7 @@ static int jmicron_pre_reset(struct ata_port *ap)
ap->cbl = ATA_CBL_SATA; ap->cbl = ATA_CBL_SATA;
break; break;
} }
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -25,11 +25,12 @@ ...@@ -25,11 +25,12 @@
/** /**
* marvell_pre_reset - check for 40/80 pin * marvell_pre_reset - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Perform the PATA port setup we need. * Perform the PATA port setup we need.
*/ */
static int marvell_pre_reset(struct ata_port *ap) static int marvell_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
u32 devices; u32 devices;
...@@ -52,7 +53,8 @@ static int marvell_pre_reset(struct ata_port *ap) ...@@ -52,7 +53,8 @@ static int marvell_pre_reset(struct ata_port *ap)
if ((pdev->device == 0x6145) && (ap->port_no == 0) && if ((pdev->device == 0x6145) && (ap->port_no == 0) &&
(!(devices & 0x10))) /* PATA enable ? */ (!(devices & 0x10))) /* PATA enable ? */
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
static int marvell_cable_detect(struct ata_port *ap) static int marvell_cable_detect(struct ata_port *ap)
...@@ -67,6 +69,7 @@ static int marvell_cable_detect(struct ata_port *ap) ...@@ -67,6 +69,7 @@ static int marvell_cable_detect(struct ata_port *ap)
case 1: /* Legacy SATA port */ case 1: /* Legacy SATA port */
return ATA_CBL_SATA; return ATA_CBL_SATA;
} }
BUG(); BUG();
return 0; /* Our BUG macro needs the right markup */ return 0; /* Our BUG macro needs the right markup */
} }
......
...@@ -46,14 +46,15 @@ enum { ...@@ -46,14 +46,15 @@ enum {
SECONDARY = (1 << 14) SECONDARY = (1 << 14)
}; };
static int mpiix_pre_reset(struct ata_port *ap) static int mpiix_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 }; static const struct pci_bits mpiix_enable_bits = { 0x6D, 1, 0x80, 0x80 };
if (!pci_test_config_bits(pdev, &mpiix_enable_bits)) if (!pci_test_config_bits(pdev, &mpiix_enable_bits))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -33,11 +33,12 @@ ...@@ -33,11 +33,12 @@
/** /**
* ns87410_pre_reset - probe begin * ns87410_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Check enabled ports * Check enabled ports
*/ */
static int ns87410_pre_reset(struct ata_port *ap) static int ns87410_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits ns87410_enable_bits[] = { static const struct pci_bits ns87410_enable_bits[] = {
...@@ -47,7 +48,8 @@ static int ns87410_pre_reset(struct ata_port *ap) ...@@ -47,7 +48,8 @@ static int ns87410_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -30,11 +30,12 @@ ...@@ -30,11 +30,12 @@
/** /**
* oldpiix_pre_reset - probe begin * oldpiix_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int oldpiix_pre_reset(struct ata_port *ap) static int oldpiix_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits oldpiix_enable_bits[] = { static const struct pci_bits oldpiix_enable_bits[] = {
...@@ -44,7 +45,8 @@ static int oldpiix_pre_reset(struct ata_port *ap) ...@@ -44,7 +45,8 @@ static int oldpiix_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -47,11 +47,12 @@ enum { ...@@ -47,11 +47,12 @@ enum {
/** /**
* opti_pre_reset - probe begin * opti_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int opti_pre_reset(struct ata_port *ap) static int opti_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits opti_enable_bits[] = { static const struct pci_bits opti_enable_bits[] = {
...@@ -61,7 +62,8 @@ static int opti_pre_reset(struct ata_port *ap) ...@@ -61,7 +62,8 @@ static int opti_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -48,11 +48,12 @@ static int pci_clock; /* 0 = 33 1 = 25 */ ...@@ -48,11 +48,12 @@ static int pci_clock; /* 0 = 33 1 = 25 */
/** /**
* optidma_pre_reset - probe begin * optidma_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int optidma_pre_reset(struct ata_port *ap) static int optidma_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
static const struct pci_bits optidma_enable_bits = { static const struct pci_bits optidma_enable_bits = {
...@@ -62,7 +63,7 @@ static int optidma_pre_reset(struct ata_port *ap) ...@@ -62,7 +63,7 @@ static int optidma_pre_reset(struct ata_port *ap)
if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -301,6 +301,7 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap) ...@@ -301,6 +301,7 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
/** /**
* pdc2027x_prereset - prereset for PATA host controller * pdc2027x_prereset - prereset for PATA host controller
* @ap: Target port * @ap: Target port
* @deadline: deadline jiffies for the operation
* *
* Probeinit including cable detection. * Probeinit including cable detection.
* *
...@@ -308,12 +309,12 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap) ...@@ -308,12 +309,12 @@ static inline int pdc2027x_port_enabled(struct ata_port *ap)
* None (inherited from caller). * None (inherited from caller).
*/ */
static int pdc2027x_prereset(struct ata_port *ap) static int pdc2027x_prereset(struct ata_port *ap, unsigned long deadline)
{ {
/* Check whether port enabled */ /* Check whether port enabled */
if (!pdc2027x_port_enabled(ap)) if (!pdc2027x_port_enabled(ap))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
/** /**
......
...@@ -139,12 +139,14 @@ static struct sv_cable_table cable_detect[] = { ...@@ -139,12 +139,14 @@ static struct sv_cable_table cable_detect[] = {
/** /**
* serverworks_cable_detect - cable detection * serverworks_cable_detect - cable detection
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Perform cable detection according to the device and subvendor * Perform cable detection according to the device and subvendor
* identifications * identifications
*/ */
static int serverworks_cable_detect(struct ata_port *ap) { static int serverworks_cable_detect(struct ata_port *ap)
{
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
struct sv_cable_table *cb = cable_detect; struct sv_cable_table *cb = cable_detect;
......
...@@ -94,11 +94,13 @@ static int sil680_cable_detect(struct ata_port *ap) { ...@@ -94,11 +94,13 @@ static int sil680_cable_detect(struct ata_port *ap) {
/** /**
* sil680_bus_reset - reset the SIL680 bus * sil680_bus_reset - reset the SIL680 bus
* @ap: ATA port to reset * @ap: ATA port to reset
* @deadline: deadline jiffies for the operation
* *
* Perform the SIL680 housekeeping when doing an ATA bus reset * Perform the SIL680 housekeeping when doing an ATA bus reset
*/ */
static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes) static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes,
unsigned long deadline)
{ {
struct pci_dev *pdev = to_pci_dev(ap->host->dev); struct pci_dev *pdev = to_pci_dev(ap->host->dev);
unsigned long addr = sil680_selreg(ap, 0); unsigned long addr = sil680_selreg(ap, 0);
...@@ -108,7 +110,7 @@ static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes) ...@@ -108,7 +110,7 @@ static int sil680_bus_reset(struct ata_port *ap,unsigned int *classes)
pci_write_config_byte(pdev, addr, reset | 0x03); pci_write_config_byte(pdev, addr, reset | 0x03);
udelay(25); udelay(25);
pci_write_config_byte(pdev, addr, reset); pci_write_config_byte(pdev, addr, reset);
return ata_std_softreset(ap, classes); return ata_std_softreset(ap, classes, deadline);
} }
static void sil680_error_handler(struct ata_port *ap) static void sil680_error_handler(struct ata_port *ap)
......
...@@ -88,6 +88,7 @@ static int sis_port_base(struct ata_device *adev) ...@@ -88,6 +88,7 @@ static int sis_port_base(struct ata_device *adev)
/** /**
* sis_133_cable_detect - check for 40/80 pin * sis_133_cable_detect - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Perform cable detection for the later UDMA133 capable * Perform cable detection for the later UDMA133 capable
* SiS chipset. * SiS chipset.
...@@ -108,6 +109,7 @@ static int sis_133_cable_detect(struct ata_port *ap) ...@@ -108,6 +109,7 @@ static int sis_133_cable_detect(struct ata_port *ap)
/** /**
* sis_66_cable_detect - check for 40/80 pin * sis_66_cable_detect - check for 40/80 pin
* @ap: Port * @ap: Port
* @deadline: deadline jiffies for the operation
* *
* Perform cable detection on the UDMA66, UDMA100 and early UDMA133 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133
* SiS IDE controllers. * SiS IDE controllers.
...@@ -130,11 +132,12 @@ static int sis_66_cable_detect(struct ata_port *ap) ...@@ -130,11 +132,12 @@ static int sis_66_cable_detect(struct ata_port *ap)
/** /**
* sis_pre_reset - probe begin * sis_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int sis_pre_reset(struct ata_port *ap) static int sis_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits sis_enable_bits[] = { static const struct pci_bits sis_enable_bits[] = {
{ 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */ { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
...@@ -145,7 +148,8 @@ static int sis_pre_reset(struct ata_port *ap) ...@@ -145,7 +148,8 @@ static int sis_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
......
...@@ -44,11 +44,12 @@ enum { ...@@ -44,11 +44,12 @@ enum {
/** /**
* sl82c105_pre_reset - probe begin * sl82c105_pre_reset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int sl82c105_pre_reset(struct ata_port *ap) static int sl82c105_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits sl82c105_enable_bits[] = { static const struct pci_bits sl82c105_enable_bits[] = {
{ 0x40, 1, 0x01, 0x01 }, { 0x40, 1, 0x01, 0x01 },
...@@ -58,7 +59,7 @@ static int sl82c105_pre_reset(struct ata_port *ap) ...@@ -58,7 +59,7 @@ static int sl82c105_pre_reset(struct ata_port *ap)
if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap); return ata_std_prereset(ap, deadline);
} }
......
...@@ -48,11 +48,12 @@ ...@@ -48,11 +48,12 @@
/** /**
* triflex_prereset - probe begin * triflex_prereset - probe begin
* @ap: ATA port * @ap: ATA port
* @deadline: deadline jiffies for the operation
* *
* Set up cable type and use generic probe init * Set up cable type and use generic probe init
*/ */
static int triflex_prereset(struct ata_port *ap) static int triflex_prereset(struct ata_port *ap, unsigned long deadline)
{ {
static const struct pci_bits triflex_enable_bits[] = { static const struct pci_bits triflex_enable_bits[] = {
{ 0x80, 1, 0x01, 0x01 }, { 0x80, 1, 0x01, 0x01 },
...@@ -63,7 +64,8 @@ static int triflex_prereset(struct ata_port *ap) ...@@ -63,7 +64,8 @@ static int triflex_prereset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
......
...@@ -154,7 +154,7 @@ static int via_cable_detect(struct ata_port *ap) { ...@@ -154,7 +154,7 @@ static int via_cable_detect(struct ata_port *ap) {
return ATA_CBL_PATA40; return ATA_CBL_PATA40;
} }
static int via_pre_reset(struct ata_port *ap) static int via_pre_reset(struct ata_port *ap, unsigned long deadline)
{ {
const struct via_isa_bridge *config = ap->host->private_data; const struct via_isa_bridge *config = ap->host->private_data;
...@@ -167,7 +167,8 @@ static int via_pre_reset(struct ata_port *ap) ...@@ -167,7 +167,8 @@ static int via_pre_reset(struct ata_port *ap)
if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no]))
return -ENOENT; return -ENOENT;
} }
return ata_std_prereset(ap);
return ata_std_prereset(ap, deadline);
} }
......
...@@ -420,7 +420,8 @@ static void inic_thaw(struct ata_port *ap) ...@@ -420,7 +420,8 @@ static void inic_thaw(struct ata_port *ap)
* SRST and SControl hardreset don't give valid signature on this * SRST and SControl hardreset don't give valid signature on this
* controller. Only controller specific hardreset mechanism works. * controller. Only controller specific hardreset mechanism works.
*/ */
static int inic_hardreset(struct ata_port *ap, unsigned int *class) static int inic_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
void __iomem *port_base = inic_port_base(ap); void __iomem *port_base = inic_port_base(ap);
void __iomem *idma_ctl = port_base + PORT_IDMA_CTL; 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,7 +438,7 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
msleep(1); msleep(1);
writew(val & ~IDMA_CTL_RST_ATA, idma_ctl); writew(val & ~IDMA_CTL_RST_ATA, idma_ctl);
rc = sata_phy_resume(ap, timing); rc = sata_phy_resume(ap, timing, deadline);
if (rc) { if (rc) {
ata_port_printk(ap, KERN_WARNING, "failed to resume " ata_port_printk(ap, KERN_WARNING, "failed to resume "
"link after reset (errno=%d)\n", rc); "link after reset (errno=%d)\n", rc);
...@@ -451,10 +452,12 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -451,10 +452,12 @@ static int inic_hardreset(struct ata_port *ap, unsigned int *class)
/* wait a while before checking status */ /* wait a while before checking status */
msleep(150); msleep(150);
if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) { rc = ata_wait_ready(ap, deadline);
ata_port_printk(ap, KERN_WARNING, /* link occupied, -ENODEV too is an error */
"device busy after hardreset\n"); if (rc) {
return -EIO; ata_port_printk(ap, KERN_WARNING, "device not ready "
"after hardreset (errno=%d)\n", rc);
return rc;
} }
ata_tf_read(ap, &tf); ata_tf_read(ap, &tf);
......
...@@ -1405,7 +1405,8 @@ static void nv_ck804_thaw(struct ata_port *ap) ...@@ -1405,7 +1405,8 @@ static void nv_ck804_thaw(struct ata_port *ap)
writeb(mask, mmio_base + NV_INT_ENABLE_CK804); writeb(mask, mmio_base + NV_INT_ENABLE_CK804);
} }
static int nv_hardreset(struct ata_port *ap, unsigned int *class) static int nv_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
unsigned int dummy; unsigned int dummy;
...@@ -1413,7 +1414,7 @@ static int nv_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -1413,7 +1414,7 @@ static int nv_hardreset(struct ata_port *ap, unsigned int *class)
* some controllers. Don't classify on hardreset. For more * some controllers. Don't classify on hardreset. For more
* info, see http://bugme.osdl.org/show_bug.cgi?id=3352 * info, see http://bugme.osdl.org/show_bug.cgi?id=3352
*/ */
return sata_std_hardreset(ap, &dummy); return sata_std_hardreset(ap, &dummy, deadline);
} }
static void nv_error_handler(struct ata_port *ap) static void nv_error_handler(struct ata_port *ap)
......
...@@ -534,7 +534,8 @@ static int sil24_init_port(struct ata_port *ap) ...@@ -534,7 +534,8 @@ static int sil24_init_port(struct ata_port *ap)
return 0; return 0;
} }
static int sil24_softreset(struct ata_port *ap, unsigned int *class) static int sil24_softreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
void __iomem *port = ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
struct sil24_port_priv *pp = ap->private_data; struct sil24_port_priv *pp = ap->private_data;
...@@ -566,7 +567,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class) ...@@ -566,7 +567,7 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT; mask = (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR) << PORT_IRQ_RAW_SHIFT;
irq_stat = ata_wait_register(port + PORT_IRQ_STAT, mask, 0x0, irq_stat = ata_wait_register(port + PORT_IRQ_STAT, mask, 0x0,
100, ATA_TMOUT_BOOT / HZ * 1000); 100, jiffies_to_msecs(deadline - jiffies));
writel(irq_stat, port + PORT_IRQ_STAT); /* clear IRQs */ writel(irq_stat, port + PORT_IRQ_STAT); /* clear IRQs */
irq_stat >>= PORT_IRQ_RAW_SHIFT; irq_stat >>= PORT_IRQ_RAW_SHIFT;
...@@ -594,7 +595,8 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class) ...@@ -594,7 +595,8 @@ static int sil24_softreset(struct ata_port *ap, unsigned int *class)
return -EIO; return -EIO;
} }
static int sil24_hardreset(struct ata_port *ap, unsigned int *class) static int sil24_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline)
{ {
void __iomem *port = ap->ioaddr.cmd_addr; void __iomem *port = ap->ioaddr.cmd_addr;
const char *reason; const char *reason;
...@@ -615,7 +617,7 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class) ...@@ -615,7 +617,7 @@ static int sil24_hardreset(struct ata_port *ap, unsigned int *class)
/* SStatus oscillates between zero and valid status after /* SStatus oscillates between zero and valid status after
* DEV_RST, debounce it. * DEV_RST, debounce it.
*/ */
rc = sata_phy_debounce(ap, sata_deb_timing_long); rc = sata_phy_debounce(ap, sata_deb_timing_long, deadline);
if (rc) { if (rc) {
reason = "PHY debouncing failed"; reason = "PHY debouncing failed";
goto err; goto err;
......
...@@ -268,6 +268,7 @@ static void svia_noop_freeze(struct ata_port *ap) ...@@ -268,6 +268,7 @@ static void svia_noop_freeze(struct ata_port *ap)
/** /**
* vt6420_prereset - prereset for vt6420 * vt6420_prereset - prereset for vt6420
* @ap: target ATA port * @ap: target ATA port
* @deadline: deadline jiffies for the operation
* *
* SCR registers on vt6420 are pieces of shit and may hang the * SCR registers on vt6420 are pieces of shit and may hang the
* whole machine completely if accessed with the wrong timing. * whole machine completely if accessed with the wrong timing.
...@@ -284,7 +285,7 @@ static void svia_noop_freeze(struct ata_port *ap) ...@@ -284,7 +285,7 @@ static void svia_noop_freeze(struct ata_port *ap)
* RETURNS: * RETURNS:
* 0 on success, -errno otherwise. * 0 on success, -errno otherwise.
*/ */
static int vt6420_prereset(struct ata_port *ap) static int vt6420_prereset(struct ata_port *ap, unsigned long deadline)
{ {
struct ata_eh_context *ehc = &ap->eh_context; struct ata_eh_context *ehc = &ap->eh_context;
unsigned long timeout = jiffies + (HZ * 5); unsigned long timeout = jiffies + (HZ * 5);
...@@ -329,7 +330,7 @@ static int vt6420_prereset(struct ata_port *ap) ...@@ -329,7 +330,7 @@ static int vt6420_prereset(struct ata_port *ap)
skip_scr: skip_scr:
/* wait for !BSY */ /* wait for !BSY */
ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT); ata_wait_ready(ap, deadline);
return 0; return 0;
} }
......
...@@ -296,18 +296,8 @@ enum { ...@@ -296,18 +296,8 @@ enum {
/* how hard are we gonna try to probe/recover devices */ /* how hard are we gonna try to probe/recover devices */
ATA_PROBE_MAX_TRIES = 3, ATA_PROBE_MAX_TRIES = 3,
ATA_EH_RESET_TRIES = 3,
ATA_EH_DEV_TRIES = 3, ATA_EH_DEV_TRIES = 3,
/* Drive spinup time (time from power-on to the first D2H FIS)
* in msecs - 8s currently. Failing to get ready in this time
* isn't critical. It will result in reset failure for
* controllers which can't wait for the first D2H FIS. libata
* will retry, so it just has to be long enough to spin up
* most devices.
*/
ATA_SPINUP_WAIT = 8000,
/* Horkage types. May be set by libata or controller on drives /* Horkage types. May be set by libata or controller on drives
(some horkage may be drive/controller pair dependant */ (some horkage may be drive/controller pair dependant */
...@@ -348,8 +338,9 @@ struct ata_queued_cmd; ...@@ -348,8 +338,9 @@ struct ata_queued_cmd;
/* typedefs */ /* typedefs */
typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc); typedef void (*ata_qc_cb_t) (struct ata_queued_cmd *qc);
typedef int (*ata_prereset_fn_t)(struct ata_port *ap); typedef int (*ata_prereset_fn_t)(struct ata_port *ap, unsigned long deadline);
typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes); typedef int (*ata_reset_fn_t)(struct ata_port *ap, unsigned int *classes,
unsigned long deadline);
typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes); typedef void (*ata_postreset_fn_t)(struct ata_port *ap, unsigned int *classes);
struct ata_ioports { struct ata_ioports {
...@@ -494,7 +485,6 @@ struct ata_eh_info { ...@@ -494,7 +485,6 @@ struct ata_eh_info {
unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */ unsigned int dev_action[ATA_MAX_DEVICES]; /* dev EH action */
unsigned int flags; /* ATA_EHI_* flags */ unsigned int flags; /* ATA_EHI_* flags */
unsigned long hotplug_timestamp;
unsigned int probe_mask; unsigned int probe_mask;
char desc[ATA_EH_DESC_LEN]; char desc[ATA_EH_DESC_LEN];
...@@ -688,13 +678,17 @@ extern void __sata_phy_reset(struct ata_port *ap); ...@@ -688,13 +678,17 @@ extern void __sata_phy_reset(struct ata_port *ap);
extern void sata_phy_reset(struct ata_port *ap); extern void sata_phy_reset(struct ata_port *ap);
extern void ata_bus_reset(struct ata_port *ap); extern void ata_bus_reset(struct ata_port *ap);
extern int sata_set_spd(struct ata_port *ap); extern int sata_set_spd(struct ata_port *ap);
extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param); extern int sata_phy_debounce(struct ata_port *ap, const unsigned long *param,
extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param); unsigned long deadline);
extern int ata_std_prereset(struct ata_port *ap); extern int sata_phy_resume(struct ata_port *ap, const unsigned long *param,
extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); unsigned long deadline);
extern int sata_port_hardreset(struct ata_port *ap, extern int ata_std_prereset(struct ata_port *ap, unsigned long deadline);
const unsigned long *timing); extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes,
extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); unsigned long deadline);
extern int sata_port_hardreset(struct ata_port *ap, const unsigned long *timing,
unsigned long deadline);
extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class,
unsigned long deadline);
extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
extern void ata_port_disable(struct ata_port *); extern void ata_port_disable(struct ata_port *);
extern void ata_std_ports(struct ata_ioports *ioaddr); extern void ata_std_ports(struct ata_ioports *ioaddr);
...@@ -750,6 +744,7 @@ extern void ata_host_resume(struct ata_host *host); ...@@ -750,6 +744,7 @@ extern void ata_host_resume(struct ata_host *host);
extern int ata_ratelimit(void); extern int ata_ratelimit(void);
extern int ata_busy_sleep(struct ata_port *ap, extern int ata_busy_sleep(struct ata_port *ap,
unsigned long timeout_pat, unsigned long timeout); unsigned long timeout_pat, unsigned long timeout);
extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn, extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
void *data, unsigned long delay); void *data, unsigned long delay);
extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
...@@ -919,12 +914,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, ...@@ -919,12 +914,7 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi) static inline void __ata_ehi_hotplugged(struct ata_eh_info *ehi)
{ {
if (ehi->flags & ATA_EHI_HOTPLUGGED)
return;
ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK; ehi->flags |= ATA_EHI_HOTPLUGGED | ATA_EHI_RESUME_LINK;
ehi->hotplug_timestamp = jiffies;
ehi->action |= ATA_EH_SOFTRESET; ehi->action |= ATA_EH_SOFTRESET;
ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1; ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment