I need to reserve around 3 or 4 memory regions that are used by a single device driver.
I followed the guide from Xilinx. which works for a single memory region.
The Device tree looks like this:
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
reserved_m1: buffer1@60000000 {
compatible = "shared-dma-pool";
no-map;
reg = <0x0 0x60000000 0x0 0x00400000>;
};
reserved_m2: buffer2@80000000 {
compatible = "shared-dma-pool";
no-map;
reg = <0x0 0x80000000 0x0 0x00100000>;
};
};
my_driver@0 {
compatible = "dummy,my_driver";
status = "okay";
memory-region = <&reserved_m1>, <&reserved_m2>;
};
and my Probing function in the “my_driver”
static int my_driver_probe(struct platform_device *pdev)
{
...
rc = of_reserved_mem_device_init(&pdev->dev);
debug = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
v_addr_m1 = dma_alloc_coherent(&pdev->dev, MY_MEM1_SIZE, &paddr, GFP_KERNEL);
printk("Allocated coherent memory Size: %d MB, vaddr: 0x%0llX paddr: 0x%0llXn", MY_MEM_SIZE / 1024 / 1024, (u64)v_addr, (u32)paddr);
rc = of_reserved_mem_device_init_by_idx(&pdev->dev, np, 1);
v_addr_m2 = dma_alloc_coherent(&pdev->dev, MY_MEM2_SIZE, &paddr_m2, GFP_KERNEL);
printk("Allocated coherent memory Size: %d MB, vaddr: 0x%0llX paddr: 0x%0llXn", MY_MEM_SIZE / 1024 / 1024, (u64)v_addr, (u32)paddr);
...
...
With the above probing method I can only allocate for the first reserved-memory
region.
How do I properly allocate for each regions?
5