Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Move ahci_channel_start() after BSY has cleared (...



details:   https://anonhg.NetBSD.org/src/rev/a89c439fd105
branches:  trunk
changeset: 752336:a89c439fd105
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Feb 23 21:38:36 2010 +0000

description:
Move ahci_channel_start() after BSY has cleared (what seems to matter
here is not touching SError while BSY is asserted). Fix random
behavior (serial console corruption/misfunction, misbehavior of USB
controllers, crasy interrupts crashing the Xen hypervisor, ...)
of Intel ESB2 controller with some brand of hitachi drives.

diffstat:

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

diffs (70 lines):

diff -r c2289b6d9085 -r a89c439fd105 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Tue Feb 23 20:51:25 2010 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Tue Feb 23 21:38:36 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.22 2009/11/21 23:47:01 jakllsch Exp $      */
+/*     $NetBSD: ahcisata_core.c,v 1.23 2010/02/23 21:38:36 bouyer Exp $        */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.22 2009/11/21 23:47:01 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.23 2010/02/23 21:38:36 bouyer Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -507,7 +507,6 @@
                chp->ch_queue->active_xfer->c_kill_xfer(chp,
                    chp->ch_queue->active_xfer, KILL_RESET);
        }
-       ahci_channel_start(sc, chp);
        /* wait 31s for BSY to clear */
        for (i = 0; i <3100; i++) {
                tfd = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
@@ -523,6 +522,8 @@
            DEBUG_PROBE);
        /* clear port interrupt register */
        AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
+       /* and start channel */
+       ahci_channel_start(sc, chp);
 
        return;
 }
@@ -567,8 +568,6 @@
        switch (sata_reset_interface(chp, sc->sc_ahcit, achp->ahcic_scontrol,
            achp->ahcic_sstatus)) {
        case SStatus_DET_DEV:
-               /* clear SErrors and start operations */
-               ahci_channel_start(sc, chp);
                /* wait 31s for BSY to clear */
                for (i = 0; i <3100; i++) {
                        sig = AHCI_READ(sc, AHCI_P_TFD(chp->ch_channel));
@@ -577,9 +576,11 @@
                                break;
                        tsleep(&sc, PRIBIO, "ahcid2h", mstohz(10));
                }
-               if (i == 1500)
+               if (i == 1500) {
                        aprint_error("%s: BSY never cleared, TD 0x%x\n",
                            AHCINAME(sc), sig);
+                       return;
+               }
                AHCIDEBUG_PRINT(("%s: BSY took %d ms\n", AHCINAME(sc), i * 10),
                    DEBUG_PROBE);
                sig = AHCI_READ(sc, AHCI_P_SIG(chp->ch_channel));
@@ -596,7 +597,11 @@
                } else
                        chp->ch_drive[0].drive_flags |= DRIVE_ATA;
                splx(s);
-               /* enable interrupts */
+               /* clear port interrupt register */
+               AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0xffffffff);
+               /* start channel */
+               ahci_channel_start(sc, chp);
+               /* and enable interrupts */
                AHCI_WRITE(sc, AHCI_P_IE(chp->ch_channel),
                    AHCI_P_IX_TFES | AHCI_P_IX_HBFS | AHCI_P_IX_IFS |
                    AHCI_P_IX_OFS | AHCI_P_IX_DPS | AHCI_P_IX_UFS |



Home | Main Index | Thread Index | Old Index