Subject: Re: ISA bounce buffer/DMA interface
To: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
From: Chris G Demetriou <Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU>
List: tech-kern
Date: 09/15/1995 15:28:41
> >     in other words:
> > 	(1) the interface was _NOT_ meant to do sub-page-size
> > 	    scatter-gather DMA; as far as i can tell, that's not
> > 	    possible on any ISA implementation i've seen.  (though
> > 	    the Alpha, for instance, _does_ allow one to do
> > 	    scatter-gather DMA with 8k (system page size) granularity.
> And here it comes. I did the implementation for an Adaptec 1542C (aha1542.c).
> Like many other BUSMASTER DMA controllers this device would be able to do
> byte-size scatter-gather DMA. The main reason for the 'sizes' is a more
> general interface and simpler usage because there is no need to collect
> the 'mappings' returned from 'isadma_map' into individual segments for
> scatter-gather DMA.
> Throughout the whole kernel scatter-gather is done on (addr,size) pairs.

collecting the mappings is not difficult; it's just a matter of where
you do it.

if you want to supply address/size pairs, to allow mapping of multiple
VAs at once, then either:
	(1) the dma_map code must break 'large' va/size sets into
	    smaller regions as necessary, or,
	(2) the code that calls dma_map must break them down.

if the latter, then you end up doing more work than necessary, in
drivers that don't need to do DMA to disjoint virtual addresses.

if the former, then you no longer have an easy correspondence between
the mapping request, and the size of the resultant mapping array.
i.e. right now, the mapping array is "(size + NBPG - 1) / NBPG + 2"
pages long, max.  if the dma_map code examines multiple va/size
sets, and breaks them down, then the maximum is "sum for each
set, of ((size + NBPG - 1) / NBPG + 2)" (or at most, N * number of
mappings for the max size given).  One also needs to do something to
help determine where the mapping for each segment begins and ends.


> > 	    If a given piece of hardware can do scatter-gather
> > 	    DMA, then one should call the map/copy/unmap functions
> > 	    multiple times (at the appropriate times!), once each
> > 	    for each 'piece' of the scatter-gather DMA.
> Sorry, this is impossible for BUSMASTER DMA. There is no notifaction when
> one segment is done. There will be a notification when ALL scatter-gather
> segments have ben transferred.

note that i said "at the appropriate times."  for instance, one could do:

	map + copy	1
	map + copy	2
	map + copy	3

	unmap		1
	unmap		3
	unmap		2

etc.



cgd