From owner-freebsd-current@FreeBSD.ORG Wed Dec 10 06:44:50 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EFCDB16A4CE for ; Wed, 10 Dec 2003 06:44:49 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id C07DC43D2A for ; Wed, 10 Dec 2003 06:44:47 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id BAA09399; Thu, 11 Dec 2003 01:44:36 +1100 Date: Thu, 11 Dec 2003 01:44:35 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Soren Schmidt In-Reply-To: <20031210230832.Y681@gamplex.bde.org> Message-ID: <20031211014217.P661@gamplex.bde.org> References: <200312030855.hB38t0VJ056332@spider.deepcore.dk> <20031210230832.Y681@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Christoph Sold cc: current@freebsd.org Subject: Re: probing of ATA slaves with no master broken (was: Re: ATAPI CDstill not detected, verbose boot logs available) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Dec 2003 14:44:50 -0000 On Wed, 10 Dec 2003, Bruce Evans wrote: > On Wed, 3 Dec 2003, Soren Schmidt wrote: > > > Could you try this simple patch and see if that helps? > > > > Index: ata-lowlevel.c > > =================================================================== > > RCS file: /home/ncvs/src/sys/dev/ata/ata-lowlevel.c,v > > retrieving revision 1.23 > > diff -u -r1.23 ata-lowlevel.c > > --- ata-lowlevel.c 2 Nov 2003 22:04:53 -0000 1.23 > > +++ ata-lowlevel.c 3 Dec 2003 07:50:44 -0000 > > @@ -575,7 +575,7 @@ > > } > > } > > } > > - if (stat1 & ATA_S_BUSY) { > > + if (!((mask == 0x03) && (stat0 & ATA_S_BUSY)) && (stat1 & ATA_S_BUSY)) { > > ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); > > DELAY(10); > > I finally got around to testing this although not on the machine that > it should fix problems for (one with a slow master and a slave; the > patch should help in this case). It breaks another machine with an > ATA slave with no master: it causes a 31 second delay and fails to > find the slave: > > Dec 10 22:31:42 gamplex kernel: atapci1: port 0xbc00-0xbcff,0xb800-0xb803,0xb400-0xb407 irq 11 at device 19.0 on pci0 > Dec 10 22:31:42 gamplex kernel: ithread_add_handler: atapci1: id -1 > Dec 10 22:31:42 gamplex kernel: atapci1: [MPSAFE] > Dec 10 22:31:42 gamplex kernel: ata2: reset tp1 mask=03 ostat0=7f ostat1=50 > Dec 10 22:31:42 gamplex kernel: ata2: master @1.061986: 7f 7f 7f 7f; slave @1.062015: 00 01 14 eb > Dec 10 22:31:42 gamplex kernel: ata2-master: stat=0x7f err=0x7f lsb=0x7f msb=0x7f > Dec 10 22:31:42 gamplex kernel: ata2-slave: stat=0x00 err=0x01 lsb=0x14 msb=0xeb > Dec 10 22:31:42 gamplex kernel: ata2: reset tp2 mask=03 stat0=7f stat1=00 devices=0x8 > Dec 10 22:31:42 gamplex kernel: ata2: at 0xb400 on atapci1 > Dec 10 22:31:42 gamplex kernel: ata2: [MPSAFE] Oops, these are the boot messages from a non-broken version. The messages for the broken version were: Dec 10 22:45:23 gamplex kernel: atapci1: port 0xbc00-0xbcff,0xb800-0xb803,0xb400-0xb407 irq 11 at device 19.0 on pci0 Dec 10 22:45:23 gamplex kernel: atapci1: [MPSAFE] Dec 10 22:45:23 gamplex kernel: ata2: reset tp1 mask=03 ostat0=7f ostat1=50 Dec 10 22:45:23 gamplex kernel: ata2-master: stat=0x7f err=0x7f lsb=0x7f msb=0x7f Dec 10 22:45:23 gamplex last message repeated 309 times Dec 10 22:45:23 gamplex kernel: ata2: reset tp2 mask=00 stat0=ff stat1=80 devices=0x0 Dec 10 22:45:23 gamplex kernel: ata2: at 0xb400 on atapci1 Dec 10 22:45:23 gamplex kernel: ata2: [MPSAFE] > > This is because stat0 is always frobbed back to ATA_S_BUSY, so the slave is > never probed. From ata-lowlevel.c: > > % if (!(stat0 & ATA_S_BUSY)) { > % if ((err & 0x7f) == ATA_E_ILI) { > % if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB) { > % ch->devices |= ATA_ATAPI_MASTER; > % } > % else if (stat0 & ATA_S_READY) { > % ch->devices |= ATA_ATA_MASTER; > % } > % } > % else if ((stat0 & 0x4f) && err == lsb && err == msb) { > % stat0 |= ATA_S_BUSY; > ^^^^^^^^^^^^^^^^^^^^ > The master's real-stat0/err/lsb/msb are always 0x7f with my hardware, so > this is always reached. > > % } > % } > % } > % if (!((mask == 0x03) && (stat0 & ATA_S_BUSY)) && (stat1 & ATA_S_BUSY)) { > ^^^^^^^^^^^^^^^^^^^^ > The above makes stat0 always unreal here, so the slave is never probed. > > Bruce Bruce