Is it bad to call ioremap()
on system DRAM. I would like to reserve a space in system DRAM that will not be used by any other process. Would this be the way to do it? I know that DRAM is not actually IO memory so I wasn't sure if this was considered bad practice.
reserve system memory, ioremap()?
5.1k views Asked by whh4000 At
2
There are 2 answers
0
On
Memory can be reserved during system boot time by using "mem" in the kernel command line argument.
LDD3 Ch-15 Pg 443
For example, if you have 256 MB, the argument mem=255M keeps the kernel from using the top megabyte. Your module could later use the following code to gain access to such memory:
dmabuf = ioremap (0xFF00000 /* 255M /, 0x100000 / 1M */);
However this is not efficient way of doing it since the kernel cannot use this reserved memory. On the SoC I'm currently working, memory is reserved using Contiguous Memory Allocator(CMA) which allows memory to be reused by other processes when the SoC drivers are not using this memory.
System memory that is managed by the kernel should not also be remapped using ioremap(). These multiple mappings can cause data corruption on some architectures/processors. Refer to this article on this issue for ARM.
You could try to ensure a single mapping (using ioremap()) by excluding the memory region in question at boot time from the kernel's management.
On ARM specify the reduced physical memory using ATAGs (the
ATAG_MEM
tag(s)) or the Device Tree (thememory
property).Otherwise use the memmap= kernel parameter in the kernel command line:
The memory region should also be declared through request_mem_region() to prevent multiple requests and for completeness/accuracy of /proc/iomem.