From owner-svn-src-all@freebsd.org Wed May 23 15:22:59 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 67077F0C18E; Wed, 23 May 2018 15:22:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1CADD6F89B; Wed, 23 May 2018 15:22:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F22722495F; Wed, 23 May 2018 15:22:58 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w4NFMwjF001379; Wed, 23 May 2018 15:22:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4NFMwgV001378; Wed, 23 May 2018 15:22:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201805231522.w4NFMwgV001378@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 23 May 2018 15:22:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334099 - head/sys/dev/ata/chipsets X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: head/sys/dev/ata/chipsets X-SVN-Commit-Revision: 334099 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2018 15:22:59 -0000 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)