Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Dec 2003 01:44:35 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Soren Schmidt <sos@spider.deepcore.dk>
Cc:        current@freebsd.org
Subject:   Re: probing of ATA slaves with no master broken (was: Re: ATAPI CDstill not detected, verbose boot logs available)
Message-ID:  <20031211014217.P661@gamplex.bde.org>
In-Reply-To: <20031210230832.Y681@gamplex.bde.org>
References:  <200312030855.hB38t0VJ056332@spider.deepcore.dk> <20031210230832.Y681@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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: <HighPoint HPT366 UDMA66 controller> 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<ATAPI_SLAVE>
> 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: <HighPoint HPT366 UDMA66 controller> 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



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