Reserving memory for DMA usage

I am trying to make use of a contiguous memory i reserved while passing the "mem" parameter to Linux when booting.

Now, i have the physical address of this space i reserved earlier, and the length of it, and i wish to make use of this reserved space for DMA purposes in my driver.

Normally i would use dma_alloc_coherent() , and if i were using CMA i would use that too, but in this case, its different.

Now, i have read that an acceptable way of mapping a physical space to kernel virtual space is to use ioremap

And, an acceptable way of "taking over" a contiguous space for DMA purposes is to use dma_map_single (mapping it for bus address)

I'm having trouble combining the two. ioremap works and returns a virtual address. Now, i have read that this is no ordinary virtual address and i should only be using access methods to read/write from this memory.

Thing is, when i try to pass this virtual address to dma_map_single , it doesn't report an error, but i suspect that this is wrong.

Am i doing it right? What can i do to make it work like it should?

10x

Answers


You are doing right You don't need to allocate the memory because you already set it on boot time but you need to use dam_map_single to prevent cache problems for example if you want to do a DMA from memory to the device but the RAM is not synchronised with the L2 cache (the cache has a newer version) you will get the wrong data so you need to map and unmap before and after the DMA operation


Need Your Help

How to set cancel url paypal express checkout?

php paypal

How to set cancel url paypal express checkout ?

Store the value of output inserted._ID to local variable to reuse it in another query

sql sql-server sql-server-2008

I want to simply execute a SQL query that would return the current id of the row that was added to a table, example: