Subject: Re: CF/IDE performance problem...
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Matthew Orgass <darkstar@city-net.com>
List: tech-kern
Date: 11/21/2005 01:25:30
On 2005-11-19 bouyer@antioche.eu.org wrote:
> On Fri, Nov 18, 2005 at 11:52:29PM -0500, Matthew Orgass wrote:
> >
> >   I just purchased a Rosewill 512MB Compact Flash card and an IDE to CF
> > adaptor.  Performance was horrible (<800KB/s bonnie++ read (with small
> > data size)), and I noticed this in dmesg:
> >
> > wd1: drive supports 1-sector PIO transfers, LBA addressing
> > wd1: 488 MB, 993 cyl, 16 head, 63 sec, 512 bytes/sect x 1000944 sectors
> > wd1: 32-bit data port
> > wd1(viaide0:1:0): using PIO mode 0
>
> Does't it report something like:
> wd1: drive supports PIO mode 4

  No.

> It not, then that's probably the cause of the problem: it doesn't report
> its capabilities, and the driver assumes it's too old to do anything else
> but PIO mode 0. You should be able to workaround this by forcing the
> modes in the kernel config using flags (see wd(4) for details on the
> flags).

  When I try to add PIO flags, I get "piomode error (4)", even with flags
0x0008 (I've updated my source to 2.1 now).  The microdrive works with
that kernel, as does another CF card that reports support for PIO mode 4.
Another card that does not report capabilities also fails the same as the
rosewill.

 The second half of the rosewill drive paramters structure is zero.  The
first half is: (b = bytes, w = word, not swapped)

b000/w000: 8a 84  e1 03   00 00  10 00
b008/w004: 00 00  00 02   3f 00  0f 00
b016/w008: f0 45  00 00   30 58  30 32
b024/w012: 20 37  30 32   35 30  30 31
b032/w016: 31 31  38 31   35 31  34 35
b040/w020: 02 00  02 00   04 00  65 52
b048/w024: 20 76  2e 33   30 30  69 48
b056/w028: 61 74  68 63   20 69  58 58
b064/w032: 32 4d  33 2e   30 2e  20 20
b072/w036: 20 20  20 20   20 20  20 20
b080/w040: 20 20  20 20   20 20  20 20
b088/w044: 20 20  20 20   20 20  01 00
b096/w048: 00 00  00 02   00 00  00 01
b104/w052: 00 00  01 00   e1 03  10 00
b112/w056: 3f 00  f0 45   0f 00  01 01
b120/w060: f0 45  0f 00   00 00  00 00

  0x848a in word 0 or bit 2 of word 83 apparently identifies the CFA
feature set (according to a draft ATA/ATAPI spec).  I guess this could at
least be used to print a warning message if capabilites are not reported.
The draft also mentions that PIO mode 1 and 2 can be identified in word
51, and this drive seems to indicate PIO mode 2 there.  However, I tried a
SET FEATURES with pio mode 2, which failed, and with 0 (default mode),
which also failed.

  In windows ME I wall clocked a large file (190MB) copy to the drive at
about 1.8MB/s with the IDE adaptor, vs. NetBSD dd (bs=60k) .818MB on the
IDE adaptor and .559MB on the PCMCIA adaptor (the PCMCIA controller
doesn't work in ME, so I don't know if that would go any faster).  I tried
altering the PIO mode without setting DRIVE_MODE (with the IDE adaptor)
and this worked, getting a transfer rate of about 1MB/s (I unmounted,
remounted, and compared and the file was good).

> >  [...]
> >   I also tried a microdrive in the CF to IDE adaptor and it reported:
> >
> > wd1 at atabus1 drive 0: <IBM-DSCM-11000>
> > wd1: drive supports 16-sector PIO transfers, LBA addressing
> > wd1: 1027 MB, 2088 cyl, 16 head, 63 sec, 512 bytes/sect x 2104704 sectors
> > wd1: 32-bit data port
> > wd1: drive supports PIO mode 3, DMA mode 1
> > wd1(viaide0:1:0): using PIO mode 3, DMA mode 1 (using DMA data transfers)
> > viaide0:1:0: lost interrupt
> > 	type: ata tc_bcount: 512 tc_skip: 0
> > viaide0:1:0: bus-master DMA error: missing interrupt, status=0x21
> > wd1: transfer error, downgrading to PIO mode 3
> > wd1(viaide0:1:0): using PIO mode 3
> > wd1d: DMA error reading fsbn 0 (wd1 bn 0; cn 0 tn 0 sn 0), retrying
> > wd1: soft error (corrected)
>
> That's another problem: The controller supports DMA, the drive supports
> DMA, but there's something between the controller and the drive which
> doesn't support DMA. The driver has no way to know this. Fortunably it's
> smart enouth to downgrade to PIO when DMA fails.

  The adaptor is a Syba IDE to CF adaptor and I see that DMARQ and DMACK
are not connected :(.

Matthew Orgass
darkstar@city-net.com