From: "Dave Cogley" <dcogley@uslinc.com>
To: <linuxppc-embedded@ozlabs.org>
Subject: Kernel malloc buffers how to make contiguous in user space?
Date: Thu, 1 Nov 2007 14:03:10 -0700 [thread overview]
Message-ID: <008101c81cca$9c95be90$2001a8c0@DCOGLEYNEW> (raw)
[-- 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 --]
reply other threads:[~2007-11-01 21:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='008101c81cca$9c95be90$2001a8c0@DCOGLEYNEW' \
--to=dcogley@uslinc.com \
--cc=linuxppc-embedded@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).