Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Aug 1995 10:41:27 +0200 (MET DST)
From:      Luigi Rizzo <luigi@labinfo.iet.unipi.it>
To:        freebsd-hackers@freebsd.org
Subject:   Re: How to abort a DMA transfer ?
Message-ID:  <199508210841.KAA13733@labinfo.iet.unipi.it>
In-Reply-To: <199508201813.UAA01188@uriah.heep.sax.de> from "J Wunsch" at Aug 20, 95 08:12:57 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> As Luigi Rizzo wrote:
> > 
> > How (within a device driver) do I abort a DMA transfer which has
> > been started but has not completed yet ? I am having this problem
> > in the driver for a hand-scanner (the scanner does some read ahead;
> > meanwhile, a user might close the device and we want to abort the
> > transfer and free the buffer). I am surprised I haven't seen (or
> > understood!) anything like this in existing drivers, not even in
> > the floppy driver!
> 
> You are surprised to have not seen this in the floppy driver?  This
> surprises me. :-)
> 
> Actually, i'd immediately kill the floppy controller if i would abort
> a transfer in progress.  The only means then would raise the reset
> line of the FDC.
> 
> I'm not sure if setting some masking bit in one of the DMAC registers
> will actually _abort_ a transfer.  Van Gilluwe does only speak about
> masking a request.  The culprit is that DMA operation is usually
> IO-controlled (via the TC signal) instead of being software-
> controlled.
> 
> Why don't you simply continue the started request, and throw away its
> results once the DMAC has signalled the command completetion by an
> interrupt (and the interrupt handler sees that the device is closed

Consider the following scenario (working with a hand scanner):
1) on open, a buffer is allocated with sufficient room for reading N
   scanlines (the size of a scanline depends on the resolution, and the
   number of lines might be in the range 10..100)
2) the device is closed while the DMA is active (which is essentially
   all the times) *and* there will be no further data coming from the
   scanner (this is likely: the user knows he wants to close the
   device, thus he stops scanning and then gives the appropriate
   commands);
3) a new open is requested, possibly with different parameters, which
   causes the need for a larger buffer; now I need to abort the
   previous transfer, free the old memory, and malloc a newer block.

> now)?  I would personally do everything in avoiding even touching such
> a hot iron like the DMAC.

I'll see if I can get the data sheets for an 8237.

	Thanks
	Luigi
====================================================================
Luigi Rizzo                     Dip. di Ingegneria dell'Informazione
email: luigi@iet.unipi.it       Universita' di Pisa
tel: +39-50-568533              via Diotisalvi 2, 56126 PISA (Italy)
fax: +39-50-568522              http://www.iet.unipi.it/~luigi/
====================================================================



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508210841.KAA13733>