The HyperNews Linux KHG Discussion Pages

Question: Remapping Memory Buffer using vmalloc/vma_nopage

Forum: The Linux Kernel Hackers' Guide
Keywords: mmap, vmalloc, DMA, and Interrupts
Date: Wed, 03 Jun 1998 16:43:15 GMT
From: Brian W. Taylor <>

Hello All!

Here is an interesting/odd problem that has arisen while trying to setup a large buffer of memory allocated by a kernel driver to be remapped into user space. The driver is for a CCD camera that is DMA and Interrupt driven system and I am able to get good consistant images using "memcpy_tofs()". What I would like to do is to have a large buffer that can be remapped to user space so that the data can be transferred via the network while the CCD is reading out. The camera DMAs a line at a time(1712 bytes) to a kmalloc'ed buffer of 2048 bytes and is copied into the remappable buffer when the problem occurs. Using two different methods I have come up with some really strange results.

The Problem:

When I readout a full frame(~1.3MB of integers), if the data is realatively uniform there is no problem. But if the data is not uniform some of the lines will transfer fine but most will end up with zeros filling up some or all of the values in the line. This will happen no matter how many lines are readout at a time.

The Method:

I am using the 2.0.33 kernel, initially with Matt Welsh's bigphysarea and recently using vmalloc and the example of remapping virtual memory example in Alessandro Rubini's "Linux Device Drivers". From what I have been able to determine the values are good until the copy from the DMA buffer into the remapped buffer.

I am also locking the application memory using the driver and using SCHED_FIFO for priority scheduling. The driver functions very well until I start trying to use the remapped memory.

   Any Ideas????

	Thanks In Advance,
	Brian W. Taylor