driver DMA mem alloc question

driver DMA mem alloc question

Post by Philip Bro » Fri, 14 Dec 2001 20:32:12



I have a problem:
I need to allocate some memory in my driver, that can be mapped to physical
addresses for DMA (well, AGP actually), but can be addressed normally by
user-level programs after mmapping.

Normally, I would think of using ddi_dma_buf_bind_handle(), except that
the user is not passing in a struct buf with a userland memory
address; I have to allocate the memory in my driver.

So the fallback I know of is ddi_dma_mem_alloc() ....
except that the manpage says "
     The data access handle is returned in  handlep.  handlep  is
     opaque - drivers may not attempt to interpret its value.  To
     access the data content, the driver must invoke ddi_get8(9F)
     or   ddi_put8(9F) (depending on the data transfer direction)
     with the data access handle."

That implies to me that I'm not supposed to mmap it and let the user
read/write to it "directly".

Am I being overly paranoid, and mmaping is still allowed?
Or should I be using a different alloc strategy altogether?

--
[Trim the no-bots from my address to reply to me by email!]
[ Do NOT email-CC me on posts. Pick one or the other.]

The word of the day is mispergitude

 
 
 

driver DMA mem alloc question

Post by Philip Bro » Mon, 17 Dec 2001 20:54:07


Turns out that I need to use page-aligned memory also.
So I started looking at ddi_umem_alloc.
Trouble was, the "ddi_umem_" related routine ddi_umem_iosetup() mentioned
that it specifically wanted notification whether this was for reading, OR
writing, not both.
So I was further stuck... until I found that some other folks like to
initially allocate the memory with ddi_umem_alloc(), LOCK it down with
ddi_umem_lock(), but then use ddi_dma_addr_bind_handle() to get the
physical address mappings.
[and I can use kvtoppid() as "normal" for mmap(9e) on the kernel
  address from ddi_umem_alloc()]

So I'm going with that...
with the caviat that in solaris 8, apparently there is a kernel bug that
may lead to memory leaks with ddi_umem_lock() unless you have MU3 or
better.

--
[Trim the no-bots from my address to reply to me by email!]
[ Do NOT email-CC me on posts. Pick one or the other.]

The word of the day is mispergitude

 
 
 

1. How can i alloc a big phys mem for DMA?

My question is  to allocate a block of continuous physical memory from
the kernel for my driver's DMA.
I've heard that there is a way in patching the kernel, but I failed to
find it in internet by myself. Could anybody help me?
And whether there's a normal way (by kernel API) to solve it?
Any suggestion is welcome.
                               pubb

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Top 10 subjects comp.unix.shell

3. Meaning of: "panic: dup mem alloc" ???

4. PPC SUSE 7.1 installation problem

5. Mem alloc fails-while lots of swap available

6. commercial security packages

7. physically cont. mem. alloc/mapping

8. natd machine freezing

9. aha1542 driver vs DMA, dvr=1,DMA=0

10. dma-mem and mmap()

11. Sound card DMA & Mem. Address?

12. Floppy Disk Kernel Error: Can't allocate DMA mem

13. QUESTION: Device Driver for VME/DMA parms on HP-UX 10.20 743i