Subject: kern/11960: ATA PIO fallback to mode 0 is too cautious
To: None <gnats-bugs@gnats.netbsd.org>
From: Lloyd Parkes <lloyd@must-have-coffee.gen.nz>
List: netbsd-bugs
Date: 01/14/2001 16:50:19
>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 have labelled this 'medium' because I will submit my code for ATAPI
tape support in the next few days, and 'serious' because of the
interraction with Apollo chipsets.

>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,

>Release-Note:
>Audit-Trail:
>Unformatted: