Module Name: src
Committed By: jmcneill
Date: Sun Dec 22 19:19:43 UTC 2019
Modified Files:
src/sys/dev/ic: ahcisata_core.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/ic/ahcisata_core.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.78 src/sys/dev/ic/ahcisata_core.c:1.79
--- src/sys/dev/ic/ahcisata_core.c:1.78 Sun Sep 29 21:28:20 2019
+++ src/sys/dev/ic/ahcisata_core.c Sun Dec 22 19:19:43 2019
@@ -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 @@ ahci_do_reset_drive(struct ata_channel *
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 @@ again:
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);