Welcome to the Linux Foundation Forum!

DMA from Local memory to PCI device - DMA Address

I am working on a driver that uses PCI DMA transfers from processor local memory (slave memory) to the PCI device. The board that is use is MIPS based & the kernel version is linux 2.6.18.8. For some reason, i am not able to achieve this. Instead, if i use __get_free_pages which allocates pages from main memory, the dma transfer happens. Given below are the steps i followed for each case

Case 1 : (using get_free_pages)

a. allocate memory

__get_free_pages() ---> returns virtual address

b. assign the physical address to dma_handle

*dma_handle = __pa(ret)

c. Return the uncach address to the callee

return UNCAC_ADDR(ret);

With the above steps dma happen and the system works as expected.

Now, in the next case, i replace step a with my custom function which allocates memory from the system local memory (slave memory). All other steps are kept as is.

Case 2 :

a. allocate memory from slave memory

custom_allocate_memory () ---> returns physical address of the slave memory

__va( custom_allocate_memory () ) ---> this will convert the physical address to virtual memory. This is done so as to keep the step b & step c of Case 1 as it is.

b. assign the physical address to dma_handle

*dma_handle = __pa(ret)

c. Return the uncached address to the callee

return UNCAC_ADDR(ret);

In Case2, the DMA doesn't work and returns an error which indicates that the address provided to the DMA is wrong? What could be the probable mistake i am doing here? Is there anything else to be considered while replacing the __get_free_pages() with my custom function?

Can someone give me a pointer of how Case 2 can be acheived?

-Joe

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training