DMA cause system crash/hang (I think)



Lynx40 - Device Driver.

I have a requirement to transmit data and receive data at the same
time. The received data is not done during the read(). It is performed
during the write().

the user calls the ioctl first specifying a buffer for the receive
buffer. Then the write() is performed as follows:
getpid of the write task.
getpriority() of write task,
stsetprio() of the interrupt thread ID to (stgetprio() <<1)+1.

setup output dma using the following steps:
mem_lock() /*locks users' output buffer using write task id*/
caculate number of DMA pages required for operation.
mmchain() to retrieve physical address of output DMA pages.

setup receive dma using the following steps:
mem_lock() /*locks users' output buffer using write task id*/
caculate number of DMA pages required for operation.
mmchain() to retrieve physical address of received buffer DMA pages.

Setup hardware for output and input DMA.
Enable the hardward for DMA operation.

when interrupt occurs, mem_unlock() both output and input buffers.

The above operation works find the first time. However, if I try it
again, the system either crashes(most of the time) or hangs up.

If I do strictly write() operations, it works find...no crashes.

It looks like the receive buffer is causing a problem but I haven't
been able to figure it out. It has been 3 days, and I need to solve
this problem.

I noticed that I'm using the write task ID to lock the memory for
receive buffer although the buffer was give to the driver during an
ioctl call. Is this correct? Could this be causing my problem? should
I be locking the received buffer during the ioctl call?

My experience with LynxOS is limitted. I'm a Windows Device Driver
guy.

Any suggestion?
.



Relevant Pages

  • Re: Problems doing bus master DMA on a PLX9056 chip
    ... > Im am writing a device driver for Windows XP for a pci board with the PLX ... > The PLX 9056 chip is capable of doing bus master dma with hardware ... > But the user supplied buffer is not filled by the data and has the same ... that the DMA controller reads all entries of the SC list ...
    (microsoft.public.development.device.drivers)
  • Re: [PATCH] asm-generic: add dma-mapping-linear.h
    ... * performing DMA. ... * Free a DMA buffer previously allocated by ... +static inline dma_addr_t ...
    (Linux-Kernel)
  • Re: [PATCH 10/17] Blackfin: convert dma/pci to asm-generic
    ... * performing DMA. ... * Map a single buffer of the indicated size for DMA in streaming mode. ... static inline dma_addr_t ...
    (Linux-Kernel)
  • [PATCH] asm-generic: add dma-mapping-linear.h
    ... * performing DMA. ... * Free a DMA buffer previously allocated by ... +static inline dma_addr_t ...
    (Linux-Kernel)
  • Re: High-performance IO
    ... The size of contigious buffer is meaningfull for common buffer DMA ... I would say that for scatter-gather DMA it depends on how much memory ... I know that AWE can give the programmer a way to use ...
    (microsoft.public.win32.programmer.kernel)