What's wrong with reading DMA residue count ?

Ulf Griesmann (ulfg@groundhog.phy.nist.gov)
Sat, 17 Feb 1996 11:36:36 -0500 (EST)


Hello All,

the file ./linux/include/asm-i386/dma.h contains the following:

/* Get DMA residue count. After a DMA transfer, this
* should return zero. Reading this while a DMA transfer is
* still in progress will return unpredictable results.
* If called before the channel has been used, it may return 1.
* Otherwise, it returns the number of _bytes_ left to transfer.
*
* Assumes DMA flip-flop is clear.
*/
static __inline__ int get_dma_residue(unsigned int dmanr)

What does the ominous warning "reading the residue count while a DMA
transfer is in progress will return unpredictable results" mean and
why can it go wrong?

For anyone still interested, here is our story:

We have a home made data acquisition board based on a soundboard ADC which
uses two DMA channels to transfer data form the board to a Pentium
machine. DMA channel 5 fills up at a rate of 40kHz while DMA channel 6 is
used to transfer additional data at a rate of 1kHz - both run
simultaneously. Whenever a block of data has been transferred on channel 5
we need to know how many data have arrived in channel 6 and we try to
figure that out by reading the DMA residue count of channel 6, necessarily
while DMA on that channel is in progress. Well, I wouldn't be writing
this if it worked. Maybe someone who has written e.g. soundboard drivers
can help us to get out of the ditch?

Thank you,
Ulf

-- 
  Ulf Griesmann                       \\\   Tel.: (301) 975 3212 (x73220)
  National Institute of                \\\   Fax.: (301) 990 1350
  Standards & Technology                \\\   e-mail:
  Atomic Physics Division, Bld. 221/A167 \\\   ulfg@groundhog.phy.nist.gov
  Gaithersburg MD 20899, U.S.A.           \\\   ulfg@aeldata.phy.nist.gov