Subject: Re: kern/11960: ATA PIO fallback to mode 0 is too cautious
To: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: netbsd-bugs
Date: 01/15/2001 20:31:06
On Mon, Jan 15, 2001 at 01:49:37PM +1300, Lloyd Parkes wrote:
> 
> >Number:         11960
> >Category:       kern
> >Synopsis:       ATA PIO fallback to mode 0 is too cautious
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    kern-bug-people
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Sun Jan 14 16:50:01 PST 2001
> >Closed-Date:
> >Last-Modified:
> >Originator:     Lloyd Parkes
> >Release:        NetBSD-1.5Q
> >Organization:
> Must Have Coffee
> >Environment:
> 
> System: NetBSD ophidian.must-have-coffee.gen.nz 1.5Q NetBSD 1.5Q (Ophidian) #0: lloyd@ophidian.must-have-coffee.gen.nz:/vol/NetBSD/build/src/sys/arch/i386/compile/Ophidian i386
> 
> 
> >Description:
> 
> ATAPI devices usually advertise what PIO modes they can do. If they
> refuse a mode that they have said they can do, then the kernel drops
> them back to PIO mode 0. This is too cautious, particularly for some
> PCIIDE chipsets where the DMA mode is tied to the PIO mode. I have
> found that dropping the PIO mode back one notch seems to work.

I wonder if it'll work for all devices. On the other hand, ATAPI devices are
supposed to be able to do PIO 3 at last (but we know what "supposed to" means
in PC land :(, so maybe falling back to PIO 3, DMA 1 would be enouth.

> 
> I have labelled this 'medium' because I will submit my code for ATAPI

Cool !

> tape support in the next few days, and 'serious' because of the
> interraction with Apollo chipsets.

How does it interract ?

> 
> >How-To-Repeat:
> 
> Plug a Seagate ST220000A into an Apollo chipset and try and implement
> st? over atapibus.
> 
> >Fix:
> 
> Index: atapi_wdc.c
> ===================================================================
> RCS file: /vol/NetBSD/cvs-src/syssrc/sys/dev/scsipi/atapi_wdc.c,v
> retrieving revision 1.38
> diff -c -r1.38 atapi_wdc.c
> *** atapi_wdc.c	2000/08/03 23:14:31	1.38
> --- atapi_wdc.c	2001/01/15 00:27:23
> ***************
> *** 855,864 ****
>   				 * some ATAPI drives rejects pio settings.
>   				 * all we can do here is fall back to PIO 0
>   				 */
> ! 				drvp->drive_flags &= ~DRIVE_MODE;
> ! 				drvp->drive_flags &= ~(DRIVE_DMA|DRIVE_UDMA);
> ! 				drvp->PIO_mode = 0;
> ! 				drvp->DMA_mode = 0;
>   				printf("%s:%d:%d: pio setting rejected, "
>   				    "falling back to PIO mode 0\n",
>   				    chp->wdc->sc_dev.dv_xname,
> --- 855,864 ----
>   				 * some ATAPI drives rejects pio settings.
>   				 * all we can do here is fall back to PIO 0
>   				 */
> ! 				if (drvp->PIO_mode > 0)
> ! 				    drvp->PIO_mode -= 1;
> ! 				if (drvp->PIO_mode == 0)
> ! 				    drvp->drive_flags &= ~DRIVE_MODE;
>   				printf("%s:%d:%d: pio setting rejected, "
>   				    "falling back to PIO mode 0\n",
>   				    chp->wdc->sc_dev.dv_xname,

Your patch is incomplete, at best :) comments and printf should be changed too.

--
Manuel Bouyer <bouyer@antioche.eu.org>
--