Subject: ALI M5229's "check 80 pins cable" and controling pciide(4)
To: None <>
From: Takahiro Kambe <>
List: current-users
Date: 10/26/2001 20:04:43

Changes sys/dev/pci/pciide.c between rev. 1.123 and 1.124 contains
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.

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.

   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.

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

	(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.

Of course, careless use of those functions leads worse.  But I feel
those functions are useful.

Thanks in advise and please turn a blind eye to my bad English.

Takahiro Kambe <>