LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-03-2010, 06:51 PM   #1
SI_TW
LQ Newbie
 
Registered: Dec 2007
Posts: 17

Rep: Reputation: 0
generic dma layer


Hi,

I'm trying to update my driver such that it uses the generic dma layer. I can't even get past the first step of allocating/mapping memory. I first tried using dma_alloc_coherent but that didn't work. I was unsure whether the struct device member of my pci_dev structure was actually initialized(not sure if pci_get_device() sets the needed struct device value in there) so I then tried pci_alloc_consistent. That still gives me an Oops in dma_alloc_coherent or dma_generic_alloc_coherent.

[ 91.745091] BUG: unable to handle kernel NULL pointer dereference at (null)
[ 91.745096] IP: [<c010797f>] dma_generic_alloc_coherent+0xaf/0xc0
[ 91.745104] *pde = 00000000

I've also seen an oops such that:

[ 91.745104] *pde = 324235 *pte = 0000000

Either way I have no idea why I am getting the "killing" message here.

Are there any dma driver examples to be found? I can't seem to find anything. Any idea what causes this Oops?


The driver currently uses a method that I believe is unsafe and not portable but seems to work:

*ptr = (ulong *)__get_free_pages((GFP_DMA | GFP_ATOMIC), order);
if (ptr == NULL)
return(-1);

for (addr=(ulong)*ptr; addr <= (((ulong)*ptr)+(PAGE_SIZE<<order)); addr+=PAGE_SIZE)
set_bit(PG_reserved, &((virt_to_page(addr))->flags));

I tried to replace this with:

pdx[card_num].virt_rdAddr = pci_alloc_consistent(pdx[card_num].dev, bCount, pdx[card_num].dma_handle);

I also tried:
pdx[card_num].virt_rdAddr = dma_alloc_coherent(&(pdx[card_num].dev->dev), bCount, pdx[card_num].dma_handle, GFP_KERNEL);


Either way I get a NULL pointer dereferencing error and the Oops.

I have no idea what I'm doing wrong or where to find a simple example.
 
Old 11-04-2010, 03:40 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,845

Rep: Reputation: 161Reputation: 161
You have to initialize DMA staff in PCI driver.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing info from MAC to network layer (cross layer) tassadaque Programming 1 12-31-2008 02:22 PM
DMA not working slackware 12.1 Generic Stock SMP kernel duryodhan Slackware 8 09-18-2008 12:54 PM
Passing the message/packet from layer to layer in OSI Or Unix. dina3e Linux - Networking 8 08-12-2008 04:15 PM
What DVD recorders/writers burn dual-layer/double-layer DVD's under Linux? bgoodr Linux - Hardware 5 02-06-2008 03:30 AM
simple way to make k9copy shrink dual layer to single layer DVD replica9000 Linux - Software 2 12-06-2007 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration