Use Reserved-Memory in custom device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I write a new device driver which is using a reserved-memory area.
Where I followed the description from
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841683/Linux+Reserved+Memory

The memory reservation in the device tree works as expected. But now
I'm curious about the address mapping in the device driver. In the
prob function I use "memremap()" to get the reserved area remapped
into the virtual memory area of the kernel space (and later on into
user space). Later I work with the virtual address returned from
"memremap()", for that and to understand the kernel functions, I used
"virt_to_phys()" function to convert the vaddr back to the physical
address. Unfortunately, I don't get the same physical address back.

What is wrong there? Or what do I miss? I see a delta of 0x847000
bytes when convert the address back, so where do this come from?

Here is a code sequence used:

paddr = r.start;
vaddr = memremap(paddr, 4096, MEMREMAP_WB);
printk("Allocated reserved memory, vaddr: 0x%0X, paddr: 0x%0X\n",
(u32)vaddr, paddr);
printk("Allocated reserved memory, paddr (2): 0x%0x\n", virt_to_phys(vaddr));


where the output is

[10370.743577] Allocated reserved memory, vaddr: 0xE0847000, paddr: 0x20000000
[10370.750564] Allocated reserved memory, paddr (2): 0x20847000




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux