I been fighting with this issue for some days now. I need to reserve and allocate 2 MB of RAM to my device driver. I followed the this guide from Xilinx [+Reserved+Memory][1].
my Device tree looks like this
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
reserved: buffer@0x60000000 {
compatible = "shared-dma-pool";
no-map;
reg = <0x0 0x60000000 0x0 0x00400000>;
};
};
my_driver@0 {
compatible = "dummy,my_driver";
status = "okay";
memory-region = <&reserved>;
};
and my Probing funtion 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 = dma_alloc_coherent(&pdev->dev, MY_MEM_SIZE, &paddr, GFP_KERNEL);
printk("Allocated coherent memory Size: %d MB, vaddr: 0x%0llX paddr: 0x%0llX\n",\
( MY_MEM_SIZE / 1024 / 1024 ), (u64)v_addr, (u32)paddr);
...
Kernel boot log:
[ 0.000000] Reserved memory: created DMA memory pool at 0x60000000, size 2 MiB
[ 0.000000] OF: reserved mem: initialized node buffer@0x60000000, compatible id shared-dma-pool
Before inserting a new module I write some data to the physical RAM mem region
$devmem 0x60000000 0x12345678
my_driver log output
[ 415.244373] [ my_driver ] Device Tree Probing
[ 415.248912] my_driver my_driver@0: assigned reserved memory node buffer@0x60000000
[ 415.262226] [ my_driver ] Mask set.
[ 415.266104] [ my_driver ] Memory allocated.
[ 415.266107] [ my_driver ] Allocated coherent memory Size: 2 MB, vaddr: 0xFFFF80000A600000 paddr: 0x60000000
[ 415.280364] [ my_driver ]Reading virt_addr 0xFFFF80000A600000 0x0
After inserting the driver
root@demo:~# devmem 0x60000000
0x00000000
So I see two problems: my memory is being cleared after allocation and the virtual memory is not readable/writable.
Any ideas what I might be missing ? I would be tremendously grateful if someone could share some wisdom ;-)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742266886a4411965.html
评论列表(0条)