diff options
author | Walter Murphy <wmurphy@google.com> | 2012-10-29 05:24:00 +0000 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-11-02 15:20:42 -0700 |
commit | 57847660bb9ddba1d4bc9c1dc551730f71c097a7 (patch) | |
tree | 543e0a1476f958dcd4d4e0450adc62a956a61360 /drivers | |
parent | 90b276f6a2a9e197eadce297fd593d85397bc430 (diff) | |
download | u-boot-imx-57847660bb9ddba1d4bc9c1dc551730f71c097a7.zip u-boot-imx-57847660bb9ddba1d4bc9c1dc551730f71c097a7.tar.gz u-boot-imx-57847660bb9ddba1d4bc9c1dc551730f71c097a7.tar.bz2 |
ahci: Adjust SATA timeouts for hard disk (spinup delay & command timeout)
Note: These are timeout values and not delay values, so the event being
timed out will complete whenever it is actually ready, with a
measurement granularity of 1 millisecond, up till the timeout value.
Therefore, there is no effect on SSD booting.
The values were determined by instrumenting the code and measuring the
actual time taken by several different models of HDD for each of the
parameters and then adding 50% more for the spinup value and just
doubling the command timeout value.
Signed-off-by: Walter Murphy <wmurphy@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/ahci.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/block/ahci.c b/drivers/block/ahci.c index a05d9cf..719574f 100644 --- a/drivers/block/ahci.c +++ b/drivers/block/ahci.c @@ -52,6 +52,10 @@ hd_driveid_t *ataid[AHCI_MAX_PORTS]; #define MAX_SATA_BLOCKS_READ_WRITE 0x80 #endif +/* Maximum timeouts for each event */ +#define WAIT_MS_DATAIO 5000 +#define WAIT_MS_LINKUP 4 + static inline u32 ahci_port_base(u32 base, u32 port) { return base + 0x100 + (port * 0x80); @@ -201,14 +205,14 @@ static int ahci_host_init(struct ahci_probe_ent *probe_ent) writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD); j = 0; - while (j < 1000) { + while (j < WAIT_MS_LINKUP) { tmp = readl(port_mmio + PORT_SCR_STAT); if ((tmp & 0xf) == 0x3) break; udelay(1000); j++; } - if (j == 1000) + if (j == WAIT_MS_LINKUP) debug("timeout.\n"); else debug("ok.\n"); @@ -429,7 +433,8 @@ static void ahci_set_feature(u8 port) writel(1, port_mmio + PORT_CMD_ISSUE); readl(port_mmio + PORT_CMD_ISSUE); - if (waiting_for_cmd_completed(port_mmio + PORT_CMD_ISSUE, 150, 0x1)) { + if (waiting_for_cmd_completed(port_mmio + PORT_CMD_ISSUE, + WAIT_MS_DATAIO, 0x1)) { printf("set feature error on port %d!\n", port); } } @@ -535,7 +540,8 @@ static int ahci_device_data_io(u8 port, u8 *fis, int fis_len, u8 *buf, writel_with_flush(1, port_mmio + PORT_CMD_ISSUE); - if (waiting_for_cmd_completed(port_mmio + PORT_CMD_ISSUE, 150, 0x1)) { + if (waiting_for_cmd_completed(port_mmio + PORT_CMD_ISSUE, + WAIT_MS_DATAIO, 0x1)) { printf("timeout exit!\n"); return -1; } |