Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 May 2018 15:22:58 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334099 - head/sys/dev/ata/chipsets
Message-ID:  <201805231522.w4NFMwgV001378@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed May 23 15:22:58 2018
New Revision: 334099
URL: https://svnweb.freebsd.org/changeset/base/334099

Log:
  Add ready polling after PHY reset on VIA SATA controllers.
  
  According to PR there are cases of controller hang if soft reset is
  sent before device report ready status after the hard reset.
  
  I don't think this patch is perfect, but it was reported as working
  by the submitter, and I have neither the old hardware nor interest to
  test some improved version, so just done some style cleaning.
  
  PR:		183294
  Submitted by:	alexandre.martins@netasq.com
  MFC after:	1 month

Modified:
  head/sys/dev/ata/chipsets/ata-via.c

Modified: head/sys/dev/ata/chipsets/ata-via.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-via.c	Wed May 23 14:19:06 2018	(r334098)
+++ head/sys/dev/ata/chipsets/ata-via.c	Wed May 23 15:22:58 2018	(r334099)
@@ -449,12 +449,29 @@ static void
 ata_via_sata_reset(device_t dev)
 {
 	struct ata_channel *ch = device_get_softc(dev);
-	int devs;
+	int devs, count;
+	uint8_t status;
 
 	if (ch->unit == 0) {
 		devs = ata_sata_phy_reset(dev, 0, 0);
-		DELAY(10000);
+		count = 0;
+		do {
+			ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA |
+			    ATA_DEV(ATA_MASTER));
+			DELAY(1000);
+			status = ATA_IDX_INB(ch, ATA_STATUS);
+			count++;
+		} while (status & ATA_S_BUSY && count < 100);
+
 		devs += ata_sata_phy_reset(dev, 1, 0);
+		count = 0;
+		do {
+			ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA |
+			    ATA_DEV(ATA_SLAVE));
+			DELAY(1000);
+			status = ATA_IDX_INB(ch, ATA_STATUS);
+			count++;
+		} while (status & ATA_S_BUSY && count < 100);
 	} else
 		devs = 1;
 	if (devs)



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