Subject: Re: ALI M5229's "check 80 pins cable" and controling pciide(4)
To: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: current-users
Date: 10/27/2001 15:35:09
On Fri, Oct 26, 2001 at 08:04:43PM +0900, Takahiro Kambe wrote:
> Hi.
> 
> Changes sys/dev/pci/pciide.c between rev. 1.123 and 1.124 contains

Note that there have been fixes for ALI support after 1.124; you should
have at last 1.129.

> added code fragment bellow:
> 
> 	if ((chp->ch_drive[0].drive_flags | chp->ch_drive[1].drive_flags) &
> 	    DRIVE_UDMA) { /* check 80 pins cable */
> 		if (pciide_pci_read(sc->sc_pc, sc->sc_tag, ACER_0x4A) &
> 		    ACER_0x4A_80PIN(chp->channel)) {
> 			if (chp->ch_drive[0].UDMA_mode > 2)
> 				chp->ch_drive[0].UDMA_mode = 2;
> 			if (chp->ch_drive[1].UDMA_mode > 2)
> 				chp->ch_drive[1].UDMA_mode = 2;
> 		}
> 	}
> 
> Since that time, my Note PC (CASIO FIVA MPC-206VL) don't use Ultra-DMA
> mode 4 (Ultra/66) but Ultra-DMA mode 2 (Ultra/33).  I dumped some
> variable in above code.
> 
> Oct 26 11:56:55 edge /netbsd: pciide0: chp->ch_drive[0].drive_flags = 79
> Oct 26 11:56:55 edge /netbsd: pciide0: chp->ch_drive[1].drive_flags = 0
> Oct 26 11:56:55 edge /netbsd: pciide0: ACER_0x4A = 23
> Oct 26 11:56:55 edge /netbsd: pciide0: ACER_0x4A_80PIN = 1
> 
> I guess this checks some IDE cable types, but I'll happy this could be
> settable in some way.

Yes, it does check the cable type. Now we have to find why it doesn't work
for you. Can you try another, non-80pin cable to see if it changes values
here ?


> 
> And I wish some methods to control pciide(4):
> 
> 1. Setting DMA mode; CASIO FIVA MPC-20X model works fine with
>    Mr. Shiozaki's patch.
> 
> 	ftp://ftp.netbsd.org/pub/NetBSD/misc/tshiozak/fiva20x/
> 
>    In this patch, a hack is added that changes DMA mode before suspend
>    and after resume.  This PC's APM BIOS function (it is really APM
>    BIOS compatible function as this PC is ACPI based) has problem with
>    "save to disk" function in Ultra/66 mode.  But in other case, it
>    runs fine in Ultra/66 mode.
> 
>    So, ioctl to do DMA mode setting may be fine.

Yes, but this should work for both ATA and ATAPI devices. currently
atactl works only for ATA drives where some ioctls may be appropriate to
atapi too. scsictl is only for SCSI devices, where some features is
appropriate for ATAPI devices too. I'm thinking at a way to get this rigth.

> 
> 2. Setting downgrading DMA mode on error;
> 
>    Recent IDE hard disk drive has automatic bad sector replacement
>    function. It replaces a bad sector with spare one when writing to
>    the bad sector.  So, one could write IDE disk repair program as
>    bellow.
> 
> 	(1) read a sector.
> 	(2) if read error, try to write the sector.
> 	(3) read a sector again.
> 	(4) if succeed it fixed.
> 
>    In this case, downgrading DMA mode function make bad intreraction.
>    Since pciide(4) down grades to PIO mode with read error, disk
>    checking needs a little bit longer time.

Yes, I need to fix this too.

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