Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic When resetting a drive, if the command list is ru...



details:   https://anonhg.NetBSD.org/src/rev/c304c544ee87
branches:  trunk
changeset: 1005829:c304c544ee87
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Dec 22 19:19:43 2019 +0000

description:
When resetting a drive, if the command list is running and CLO is not
supported, attempt to stop the drive first and fail gracefully if that
fails instead of triggering a KASSERT on DIAGNOSTIC kernels.

diffstat:

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

diffs (47 lines):

diff -r 2485d915879a -r c304c544ee87 sys/dev/ic/ahcisata_core.c
--- a/sys/dev/ic/ahcisata_core.c        Sun Dec 22 18:41:36 2019 +0000
+++ b/sys/dev/ic/ahcisata_core.c        Sun Dec 22 19:19:43 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahcisata_core.c,v 1.78 2019/09/29 21:28:20 jakllsch Exp $      */
+/*     $NetBSD: ahcisata_core.c,v 1.79 2019/12/22 19:19:43 jmcneill Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.78 2019/09/29 21:28:20 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.79 2019/12/22 19:19:43 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -808,7 +808,7 @@
        struct ahci_cmd_tbl *cmd_tbl;
        struct ahci_cmd_header *cmd_h;
        int i, error = 0;
-       uint32_t sig;
+       uint32_t sig, cmd;
        int noclo_retry = 0;
 
        ata_channel_lock_owned(chp);
@@ -826,6 +826,19 @@
                ahci_channel_start(sc, chp, flags, 1);
        } else {
                /* Can't handle command still running without CLO */
+               cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
+               if ((cmd & AHCI_P_CMD_CR) != 0) {
+                       ahci_channel_stop(sc, chp, flags);
+                       cmd = AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel));
+                       if ((cmd & AHCI_P_CMD_CR) != 0) {
+                               aprint_error("%s port %d: DMA engine busy "
+                                   "for drive %d\n", AHCINAME(sc),
+                                   chp->ch_channel, drive);
+                               error = EBUSY;
+                               goto end;
+                       }
+               }
+
                KASSERT((AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel)) & AHCI_P_CMD_CR) == 0);
 
                ahci_channel_start(sc, chp, flags, 0);



Home | Main Index | Thread Index | Old Index