From owner-freebsd-bugs@FreeBSD.ORG Sat Dec 20 10:30:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 606AA1065673 for ; Sat, 20 Dec 2008 10:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3B3AF8FC1A for ; Sat, 20 Dec 2008 10:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mBKAU13e084571 for ; Sat, 20 Dec 2008 10:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mBKAU1CO084570; Sat, 20 Dec 2008 10:30:01 GMT (envelope-from gnats) Resent-Date: Sat, 20 Dec 2008 10:30:01 GMT Resent-Message-Id: <200812201030.mBKAU1CO084570@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "James R. Van Artsdalen" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 686581065673 for ; Sat, 20 Dec 2008 10:23:54 +0000 (UTC) (envelope-from james@jrv.org) Received: from mail.jrv.org (adsl-70-243-84-13.dsl.austtx.swbell.net [70.243.84.13]) by mx1.freebsd.org (Postfix) with ESMTP id E61248FC24 for ; Sat, 20 Dec 2008 10:23:53 +0000 (UTC) (envelope-from james@jrv.org) Received: from fearless.housenet.jrv (localhost.housenet.jrv [127.0.0.1]) by mail.jrv.org (8.14.3/8.13.1) with ESMTP id mBK9KGOH074531 for ; Sat, 20 Dec 2008 03:20:16 -0600 (CST) (envelope-from james@fearless.housenet.jrv) Received: (from root@localhost) by fearless.housenet.jrv (8.14.3/8.13.1/Submit) id mBK9KG9m074530; Sat, 20 Dec 2008 03:20:16 -0600 (CST) (envelope-from james) Message-Id: <200812200920.mBK9KG9m074530@fearless.housenet.jrv> Date: Sat, 20 Dec 2008 03:20:16 -0600 (CST) From: "James R. Van Artsdalen" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: kern/129784: [patch] SATA port multiplier disk detect bugs in -current (svn186316) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "James R. Van Artsdalen" List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Dec 2008 10:30:01 -0000 >Number: 129784 >Category: kern >Synopsis: [patch] SATA port multiplier disk detect bugs in -current (svn186316) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Dec 20 10:30:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: James R. Van Artsdalen >Release: FreeBSD 8 -current, svn186316 >Organization: Institute for Applied Stellar Nucleosynthesis >Environment: System: FreeBSD fearless 8 -current svn186316 #0: Fri Dec 24 01:47:55 CST 2004 james@jrv.org:/usr/src/sys/amd64/compile/GENERIC amd64 >Description: This only affects Silicon Image host controllers. It was only tested with a 3132. I have found two bugs in the port multiplier code and a place where an added delay is both necessary and sufficient to make my setup work, even though I can't explain why. With the included patch my setup, with a Sil3132 host controller, always detects the drives in my Sil3726 based port-multiplier enclosures. There are other problems trying to format and use the disks, but at least this may let people get past disk detection. >How-To-Repeat: Attach a port multiplier enclosure to a Silicon Image host adapter. Some or all disks in the enclosure may not be seen. >Fix: The first change in ata_siiprb_issue_cmd() increases the timeout count from 10,000 to 31,000 counts. When a soft reset is issued to a port multiplier disk port this loop may have to wait for the hard disk to spin up. I consistently saw 15,000 counts as needed by experiment; assuming counts are milliseconds then 31,000 is what ATA calls for. Note that currently empty disk ports behind a port multiplier are detected by letting this loop time out; i.e., an empty port multiplier enclosure can lengthen boot by 2.5 minutes. Some other strategy for disk detection might be needed later (the PHY probably is a good approach). The second change in ata_siiprb_issue_cmd() fixes a typo: failure was being returned if a command took more than 1,000 counts, even if it completed within the allotted 10,000 counts. The last change in ata_siiprb_softreset() is a delay that is mysteriously turns out to be necessary. I don't know why, how much or how little is needed. Hardware is like that sometimes. /usr/src-current# svn di Index: sys/dev/ata/chipsets/ata-siliconimage.c =================================================================== --- sys/dev/ata/chipsets/ata-siliconimage.c (revision 186316) +++ sys/dev/ata/chipsets/ata-siliconimage.c (working copy) @@ -679,7 +679,7 @@ ATA_OUTL(ctlr->r_res2, 0x1c04 + offset, prb_bus >> 32); /* poll for command finished */ - for (timeout = 0; timeout < 10000; timeout++) { + for (timeout = 0; timeout < 31000; timeout++) { DELAY(1000); if ((status = ATA_INL(ctlr->r_res2, 0x1008 + offset)) & 0x00010000) break; @@ -687,7 +687,7 @@ // SOS XXX ATA_OUTL(ctlr->r_res2, 0x1008 + offset, 0x00010000); ATA_OUTL(ctlr->r_res2, 0x1008 + offset, 0x08ff08ff); - if (timeout >= 1000) + if (timeout >= 31000) return EIO; if (bootverbose) @@ -761,6 +761,18 @@ prb->control = htole16(0x0080); prb->fis[1] = port & 0x0f; + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + ata_udelay(150000); + /* issue soft reset */ if (ata_siiprb_issue_cmd(dev)) return -1; /usr/src-current# >Release-Note: >Audit-Trail: >Unformatted: