Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Provide the timeout argument to ahci_exec_fis in ...



details:   https://anonhg.NetBSD.org/src/rev/db5aeaf45414
branches:  trunk
changeset: 333943:db5aeaf45414
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun Nov 23 01:38:49 2014 +0000

description:
Provide the timeout argument to ahci_exec_fis in ms. Use 1ms delays
when we are not allowed to sleep, full ticks otherwise.

Bump the timeout for reset to 100ms, 10ms is not enough on the
Cubietruck.

diffstat:

 sys/dev/ic/ahcisata_core.c |  22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 0f5a53dd584c -r db5aeaf45414 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Sat Nov 22 19:50:28 2014 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Sun Nov 23 01:38:49 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.51 2014/02/24 12:19:05 jmcneill Exp $      */
+/*     $NetBSD: ahcisata_core.c,v 1.52 2014/11/23 01:38:49 joerg Exp $ */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.51 2014/02/24 12:19:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.52 2014/11/23 01:38:49 joerg Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -636,7 +636,14 @@
        int i;
        uint32_t is;
 
-       timeout = timeout * 10; /* wait is 10ms */
+       /*
+        * Base timeout is specified in ms.
+        * If we are allowed to sleep, wait a tick each round.
+        * Otherwise delay for 1ms on each round.
+        */
+       if (flags & AT_WAIT)
+               timeout = MAX(1, mstohz(timeout));
+
        AHCI_CMDH_SYNC(sc, achp, 0, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
        /* start command */
        AHCI_WRITE(sc, AHCI_P_CI(chp->ch_channel), 1 << 0);
@@ -660,10 +667,11 @@
                        return ERR_DF;
                }
                if (flags & AT_WAIT)
-                       tsleep(&sc, PRIBIO, "ahcifis", mstohz(10));
+                       tsleep(&sc, PRIBIO, "ahcifis", 1);
                else
-                       delay(10000);
+                       delay(1000);
        }
+
        aprint_debug("%s channel %d: timeout sending FIS\n",
            AHCINAME(sc), chp->ch_channel);
        return TIMEOUT;
@@ -709,7 +717,7 @@
        cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;
        cmd_tbl->cmdt_cfis[rhd_c] = drive;
        cmd_tbl->cmdt_cfis[rhd_control] = WDCTL_RST;
-       switch(ahci_exec_fis(chp, 1, flags)) {
+       switch(ahci_exec_fis(chp, 100, flags)) {
        case ERR_DF:
        case TIMEOUT:
                aprint_error("%s channel %d: setting WDCTL_RST failed "
@@ -727,7 +735,7 @@
        cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;
        cmd_tbl->cmdt_cfis[rhd_c] = drive;
        cmd_tbl->cmdt_cfis[rhd_control] = 0;
-       switch(ahci_exec_fis(chp, 31, flags)) {
+       switch(ahci_exec_fis(chp, 310, flags)) {
        case ERR_DF:
        case TIMEOUT:
                if ((sc->sc_ahci_quirks & AHCI_QUIRK_BADPMPRESET) != 0 &&



Home | Main Index | Thread Index | Old Index