Subject: Re: lack of pciide transfer alignment checking causes crash
To: Erik E. Fair <fair@NetBSD.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 06/25/2005 16:31:17
On Sat, Jun 25, 2005 at 04:39:08AM -0700, Erik E. Fair wrote:
> [...]
> 
> The problem I want help with here on tech-kern is precisely where to enforce
> the cache-line (16 byte) alignment requirement for IDE DMA transfers. I have
> experimentally determined that any violation of that rule will cause the system
> to lock up hard, requiring a Power-cycle to reset. User mode access to the
> raw device, which, of course, invokes kern_physio().
> 
> This is probably why the NetBSD install failed at the disklabelling step (I
> subsequently installed NetBSD on an IDE disk on another system, and then moved
> the disk over).
> 
> The only reason that NetBSD runs at all on this box is that the typical FFS
> filesystem I/O requests are apparently aligned properly.
> 
> I think there are two basic choices for handling a misaligned transfer request:
> 
> 1. return an error (e.g. EIO).
> 
> 2. use PIO mode for misaligned transfers.

3. Do the I/O to a properly-aligned buffer and copy data from/to that.
I think this can easily be done by using geodide-specific callbacks for
wdc_softc->{dma_init,dma_finish}. As there can be only one transfer active
at a time, you can use only one properly-aligned buffer for all transfers,
which can be allocated at attach time.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--