* Kernel malloc buffers how to make contiguous in user space?
@ 2007-11-01 21:03 Dave Cogley
0 siblings, 0 replies; only message in thread
From: Dave Cogley @ 2007-11-01 21:03 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 1974 bytes --]
Hello,
I am using a scatter gather DMA operation provided on the PPC44EPx to handle
a large data move of 2MB from sixteen 128k kmalloc buffers. I have sixteen
scatter / gather descriptors pointing to the allocated memory which will be
transferred to a peripheral on the EBC. This all appears to be setup and
working correctly. Now I want to provide these 16 kmalloc buffers to a user
space process and make them all appear as a contiguous 2MB buffer.
When the handler is called pageptr appears to be a valid page but the kernel
traps with "Bad page state" "Trying to fix it up, but a reboot is needed"
when returned from the handler. Am I missing something required to modify
the page state for the requested page? Am I even handling the nopage
request correctly? I notice the nopage handler gets called for every 4096
byte page it is trying to map. How do I map my 128k memory area into the 4k
page requests? Is there example code somewhere that demonstrates using a
contiguous memory buffer in user space when it is comprised of multiple
buffers in the kernel space?
First I am allocating 16 buffers using kmalloc:
#define DMABLOCKSIZE 1024 * 128
for (I = 0; I < 16; i++)
{
device->dma_buf[i] = kmalloc(DMABLOCKSIZE, GFP_DMA |
GFP_KERNEL);
sgl->phyaddress = virt_to_phys(device->dma_buf[i]);
}
Then I am doing the following in the nopage handler:
page* nopage_handler(struct vma, ul address, int* type)
{
unsigned long physaddr = address - vma->start;
int index = physaddr / DMABLOCKSIZE;
int off = physaddr % DMABLOCKSIZE;
struct page* pageptr = virt_to_page(device->dma_buf[index] +
off);
get_page(pageptr);
if (type)
*type = VM_FAULT_MINOR;
return pageptr;
}
Dave Cogley
Software Engineer
Ultra Stereo Labs, Inc.
(805) 549-0161
mailto:dcogley@uslinc.com
[-- Attachment #2: Type: text/html, Size: 8883 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-11-01 21:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-01 21:03 Kernel malloc buffers how to make contiguous in user space? Dave Cogley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).