Module Name:    src
Committed By:   jdolecek
Date:           Sat Jan 12 15:16:51 UTC 2019

Modified Files:
        src/sys/dev/ic: ahcisata_core.c

Log Message:
partially back-off rev. 1.68 - when the drive reset for port 15 fails,
on some systems controller isn't actually able to process further commands,
it's really necessary to do explicitely reset for drive 0 too

towards resolution of PR kern/53307


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 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.72 src/sys/dev/ic/ahcisata_core.c:1.73
--- src/sys/dev/ic/ahcisata_core.c:1.72	Fri Dec  7 22:22:12 2018
+++ src/sys/dev/ic/ahcisata_core.c	Sat Jan 12 15:16:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.72 2018/12/07 22:22:12 jdolecek Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.73 2019/01/12 15:16:51 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.72 2018/12/07 22:22:12 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.73 2019/01/12 15:16:51 jdolecek Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -850,6 +850,8 @@ ahci_do_reset_drive(struct ata_channel *
 	case TIMEOUT:
 		aprint_error("%s port %d: setting WDCTL_RST failed "
 		    "for drive %d\n", AHCINAME(sc), chp->ch_channel, drive);
+		if (sigp)
+			*sigp = 0xffffffff;
 		error = EBUSY;
 		goto end;
 	default:
@@ -875,6 +877,8 @@ ahci_do_reset_drive(struct ata_channel *
 	case TIMEOUT:
 		aprint_error("%s port %d: clearing WDCTL_RST failed "
 		    "for drive %d\n", AHCINAME(sc), chp->ch_channel, drive);
+		if (sigp)
+			*sigp = 0xffffffff;
 		error = EBUSY;
 		goto end;
 	default:
@@ -896,6 +900,8 @@ skip_reset:
 	if (i == AHCI_RST_WAIT) {
 		aprint_error("%s: BSY never cleared, TD 0x%x\n",
 		    AHCINAME(sc), sig);
+		if (sigp)
+			*sigp = 0xffffffff;
 		goto end;
 	}
 	AHCIDEBUG_PRINT(("%s: BSY took %d ms\n", AHCINAME(sc), i * 10),
@@ -994,6 +1000,7 @@ ahci_probe_drive(struct ata_channel *chp
 		return;
 	}
 
+again:
 	/* bring interface up, accept FISs, power up and spin up device */
 	AHCI_WRITE(sc, AHCI_P_CMD(chp->ch_channel),
 	    AHCI_P_CMD_ICC_AC | AHCI_P_CMD_FRE |
@@ -1004,9 +1011,6 @@ ahci_probe_drive(struct ata_channel *chp
 	case SStatus_DET_DEV:
 		ata_delay(chp, 500, "ahcidv", AT_WAIT);
 
-		/* Initial value, used in case the soft reset fails */
-		sig = AHCI_READ(sc, AHCI_P_SIG(chp->ch_channel));
-
 		if (sc->sc_ahci_cap & AHCI_CAP_SPM) {
 			error = ahci_do_reset_drive(chp, PMP_PORT_CTL, AT_WAIT,
 			    &sig, c_slot);
@@ -1019,7 +1023,7 @@ ahci_probe_drive(struct ata_channel *chp
 				PMP_PORT_CTL);
 
 				sc->sc_ahci_cap &= ~AHCI_CAP_SPM;
-				ahci_reset_channel(chp, AT_WAIT);
+				goto again;
 			}
 		} else {
 			ahci_do_reset_drive(chp, 0, AT_WAIT, &sig, c_slot);

Reply via email to