Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 May 2011 00:35:56 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r221864 - in stable/8/sys/dev: ahci mvs siis
Message-ID:  <201105140035.p4E0Zupj086853@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat May 14 00:35:56 2011
New Revision: 221864
URL: http://svn.freebsd.org/changeset/base/221864

Log:
  MFC r220829:
  According to specification. device should respond to COMRESET with COMINIT
  in no more then 10ms. If we detected no device presence within that time,
  there is no reason to wait longer.

Modified:
  stable/8/sys/dev/ahci/ahci.c
  stable/8/sys/dev/mvs/mvs.c
  stable/8/sys/dev/siis/siis.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/ahci/ahci.c
==============================================================================
--- stable/8/sys/dev/ahci/ahci.c	Sat May 14 00:28:09 2011	(r221863)
+++ stable/8/sys/dev/ahci/ahci.c	Sat May 14 00:35:56 2011	(r221864)
@@ -2575,11 +2575,13 @@ static int
 ahci_sata_connect(struct ahci_channel *ch)
 {
 	u_int32_t status;
-	int timeout;
+	int timeout, found = 0;
 
 	/* Wait up to 100ms for "connect well" */
 	for (timeout = 0; timeout < 1000 ; timeout++) {
 		status = ATA_INL(ch->r_mem, AHCI_P_SSTS);
+		if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE)
+			found = 1;
 		if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) &&
 		    ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) &&
 		    ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE))
@@ -2591,12 +2593,15 @@ ahci_sata_connect(struct ahci_channel *c
 			}
 			return (0);
 		}
+		if (found == 0 && timeout >= 100)
+			break;
 		DELAY(100);
 	}
-	if (timeout >= 1000) {
+	if (timeout >= 1000 || !found) {
 		if (bootverbose) {
-			device_printf(ch->dev, "SATA connect timeout status=%08x\n",
-			    status);
+			device_printf(ch->dev,
+			    "SATA connect timeout time=%dus status=%08x\n",
+			    timeout * 100, status);
 		}
 		return (0);
 	}

Modified: stable/8/sys/dev/mvs/mvs.c
==============================================================================
--- stable/8/sys/dev/mvs/mvs.c	Sat May 14 00:28:09 2011	(r221863)
+++ stable/8/sys/dev/mvs/mvs.c	Sat May 14 00:35:56 2011	(r221864)
@@ -2101,11 +2101,13 @@ static int
 mvs_sata_connect(struct mvs_channel *ch)
 {
 	u_int32_t status;
-	int timeout;
+	int timeout, found = 0;
 
 	/* Wait up to 100ms for "connect well" */
-	for (timeout = 0; timeout < 100 ; timeout++) {
+	for (timeout = 0; timeout < 1000 ; timeout++) {
 		status = ATA_INL(ch->r_mem, SATA_SS);
+		if ((status & SATA_SS_DET_MASK) != SATA_SS_DET_NO_DEVICE)
+			found = 1;
 		if (((status & SATA_SS_DET_MASK) == SATA_SS_DET_PHY_ONLINE) &&
 		    ((status & SATA_SS_SPD_MASK) != SATA_SS_SPD_NO_SPEED) &&
 		    ((status & SATA_SS_IPM_MASK) == SATA_SS_IPM_ACTIVE))
@@ -2117,18 +2119,21 @@ mvs_sata_connect(struct mvs_channel *ch)
 			}
 			return (0);
 		}
-		DELAY(1000);
+		if (found == 0 && timeout >= 100)
+			break;
+		DELAY(100);
 	}
-	if (timeout >= 100) {
+	if (timeout >= 1000 || !found) {
 		if (bootverbose) {
-			device_printf(ch->dev, "SATA connect timeout status=%08x\n",
-			    status);
+			device_printf(ch->dev,
+			    "SATA connect timeout time=%dus status=%08x\n",
+			    timeout * 100, status);
 		}
 		return (0);
 	}
 	if (bootverbose) {
-		device_printf(ch->dev, "SATA connect time=%dms status=%08x\n",
-		    timeout, status);
+		device_printf(ch->dev, "SATA connect time=%dus status=%08x\n",
+		    timeout * 100, status);
 	}
 	/* Clear SATA error register */
 	ATA_OUTL(ch->r_mem, SATA_SE, 0xffffffff);
@@ -2154,11 +2159,10 @@ mvs_sata_phy_reset(device_t dev)
 	ATA_OUTL(ch->r_mem, SATA_SC,
 	    SATA_SC_DET_RESET | val |
 	    SATA_SC_IPM_DIS_PARTIAL | SATA_SC_IPM_DIS_SLUMBER);
-	DELAY(5000);
+	DELAY(1000);
 	ATA_OUTL(ch->r_mem, SATA_SC,
 	    SATA_SC_DET_IDLE | val | ((ch->pm_level > 0) ? 0 :
 	    (SATA_SC_IPM_DIS_PARTIAL | SATA_SC_IPM_DIS_SLUMBER)));
-	DELAY(5000);
 	if (!mvs_sata_connect(ch)) {
 		if (ch->pm_level > 0)
 			ATA_OUTL(ch->r_mem, SATA_SC, SATA_SC_DET_DISABLE);

Modified: stable/8/sys/dev/siis/siis.c
==============================================================================
--- stable/8/sys/dev/siis/siis.c	Sat May 14 00:28:09 2011	(r221863)
+++ stable/8/sys/dev/siis/siis.c	Sat May 14 00:35:56 2011	(r221864)
@@ -1540,10 +1540,10 @@ siis_devreset(device_t dev)
 	ATA_OUTL(ch->r_mem, SIIS_P_CTLSET, SIIS_P_CTL_DEV_RESET);
 	while (((val = ATA_INL(ch->r_mem, SIIS_P_STS)) &
 	    SIIS_P_CTL_DEV_RESET) != 0) {
-		DELAY(1000);
-		if (timeout++ > 100) {
-			device_printf(dev, "device reset stuck (timeout %dms) "
-			    "status = %08x\n", timeout, val);
+		DELAY(100);
+		if (timeout++ > 1000) {
+			device_printf(dev, "device reset stuck "
+			    "(timeout 100ms) status = %08x\n", val);
 			return (EBUSY);
 		}
 	}
@@ -1731,27 +1731,39 @@ static int
 siis_sata_connect(struct siis_channel *ch)
 {
 	u_int32_t status;
-	int timeout;
+	int timeout, found = 0;
 
 	/* Wait up to 100ms for "connect well" */
-	for (timeout = 0; timeout < 100 ; timeout++) {
+	for (timeout = 0; timeout < 1000 ; timeout++) {
 		status = ATA_INL(ch->r_mem, SIIS_P_SSTS);
+		if ((status & ATA_SS_DET_MASK) != ATA_SS_DET_NO_DEVICE)
+			found = 1;
 		if (((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_ONLINE) &&
 		    ((status & ATA_SS_SPD_MASK) != ATA_SS_SPD_NO_SPEED) &&
 		    ((status & ATA_SS_IPM_MASK) == ATA_SS_IPM_ACTIVE))
 			break;
-		DELAY(1000);
+		if ((status & ATA_SS_DET_MASK) == ATA_SS_DET_PHY_OFFLINE) {
+			if (bootverbose) {
+				device_printf(ch->dev, "SATA offline status=%08x\n",
+				    status);
+			}
+			return (0);
+		}
+		if (found == 0 && timeout >= 100)
+			break;
+		DELAY(100);
 	}
-	if (timeout >= 100) {
+	if (timeout >= 1000 || !found) {
 		if (bootverbose) {
-			device_printf(ch->dev, "SATA connect timeout status=%08x\n",
-			    status);
+			device_printf(ch->dev,
+			    "SATA connect timeout time=%dus status=%08x\n",
+			    timeout * 100, status);
 		}
 		return (0);
 	}
 	if (bootverbose) {
-		device_printf(ch->dev, "SATA connect time=%dms status=%08x\n",
-		    timeout, status);
+		device_printf(ch->dev, "SATA connect time=%dus status=%08x\n",
+		    timeout * 100, status);
 	}
 	/* Clear SATA error register */
 	ATA_OUTL(ch->r_mem, SIIS_P_SERR, 0xffffffff);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105140035.p4E0Zupj086853>