Mapping of Device Physical Address to Kernel Virtual address
Dear All, Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...). For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF. My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF Thanks, Prabhu
Hi Prabhu, On Tue, Jul 10, 2012 at 6:56 AM, Prabhu nath <gprabhunath@gmail.com> wrote:
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
I don't think this is possible, because these virtual address ranges are handled by the kernel VMA system and are allocated dynamically, so that is not just a bitmask or something to change.
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
You could change PAGE_OFFSET. From [1]: PHYS_OFFSET Physical start address of the first bank of RAM. PAGE_OFFSET Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE. But I'm curious: Why do you want to change it? Greetings, Philipp [1]: http://www.kernelport.org/defines.html
Thanks for your reply. Plz see inline On Tue, Jul 10, 2012 at 11:17 AM, Philipp Ittershagen < p.ittershagen@googlemail.com> wrote:
Hi Prabhu,
On Tue, Jul 10, 2012 at 6:56 AM, Prabhu nath <gprabhunath@gmail.com> wrote:
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
I don't think this is possible, because these virtual address ranges are handled by the kernel VMA system and are allocated dynamically, so that is not just a bitmask or something to change.
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
You could change PAGE_OFFSET. From [1]:
PHYS_OFFSET Physical start address of the first bank of RAM.
PAGE_OFFSET Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE.
But I'm curious: Why do you want to change it?
Just wanted to have a constant mapping from PA to VA of devices and wanted to have a separate region for vmalloc.
Greetings,
Philipp
在 2012-7-10,17:16,"Prabhu nath" <gprabhunath@gmail.com> 写道:
Thanks for your reply. Plz see inline
On Tue, Jul 10, 2012 at 11:17 AM, Philipp Ittershagen <p.ittershagen@googlemail.com> wrote: Hi Prabhu,
On Tue, Jul 10, 2012 at 6:56 AM, Prabhu nath <gprabhunath@gmail.com> wrote:
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
I don't think this is possible, because these virtual address ranges are handled by the kernel VMA system and are allocated dynamically, so that is not just a bitmask or something to change.
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
You could change PAGE_OFFSET. From [1]:
PHYS_OFFSET Physical start address of the first bank of RAM.
PAGE_OFFSET Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE.
But I'm curious: Why do you want to change it?
Just wanted to have a constant mapping from PA to VA of devices and wanted to have a separate region for vmalloc.
what do you mean constant? After mapping, it is constant. Before mapping, it is constant for Low memory region, but is not Constant for vmalloc region. Vmalloc region is separate in default. Your change doesn't make any sense. The most difficult thing for you is To make sure what do you want to Do really. Please give detail demand.
Greetings,
Philipp
[1]: http://www.kernelport.org/defines.html
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Tue, Jul 10, 2012 at 10:03 PM, 弋天 卜 <buyit@live.cn> wrote:
在 2012-7-10,17:16,"Prabhu nath" < <gprabhunath@gmail.com> gprabhunath@gmail.com> 写道:
Thanks for your reply. Plz see inline
On Tue, Jul 10, 2012 at 11:17 AM, Philipp Ittershagen <<p.ittershagen@googlemail.com><p.ittershagen@googlemail.com> p.ittershagen@googlemail.com> wrote:
Hi Prabhu,
On Tue, Jul 10, 2012 at 6:56 AM, Prabhu nath < <gprabhunath@gmail.com><gprabhunath@gmail.com> gprabhunath@gmail.com> wrote:
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
I don't think this is possible, because these virtual address ranges are handled by the kernel VMA system and are allocated dynamically, so that is not just a bitmask or something to change.
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
You could change PAGE_OFFSET. From [1]:
PHYS_OFFSET Physical start address of the first bank of RAM.
PAGE_OFFSET Virtual start address of the first bank of RAM. During the kernel boot phase, virtual address PAGE_OFFSET will be mapped to physical address PHYS_OFFSET, along with any other mappings you supply. This should be the same value as TASK_SIZE.
But I'm curious: Why do you want to change it?
Just wanted to have a constant mapping from PA to VA of devices and wanted to have a separate region for vmalloc.
what do you mean constant? After mapping, it is constant. Before mapping, it is constant for Low memory region, but is not Constant for vmalloc region.
I mean fixed/static mapping rather than kernel allocating kernel virtual address dynamically.
Vmalloc region is separate in default. Your change doesn't make any sense.
You mean ioremap(...) will not map the physical address of the device into vmalloc region ?
The most difficult thing for you is To make sure what do you want to Do really. Please give detail demand.
My requirement is very simple. I have designed a layout showing mapping of physical address to kernel virtual address. I also want to implement in the same way. 1. Low mem region - which is already fixed by the kernel based on the memory size. 2. Vmalloc region which can be fixed as per your previous mail 3. Also have a fixed mapping of device physical address by ioremap_page_range(...) I think I got what I needed. Thank you all very much for your valuable time.
Greetings,
Philipp
[1]: <http://www.kernelport.org/defines.html><http://www.kernelport.org/defines.html> http://www.kernelport.org/defines.html
_______________________________________________ Kernelnewbies mailing list <Kernelnewbies@kernelnewbies.org>Kernelnewbies@kernelnewbies.org <http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Prabhu, On Mon, Jul 9, 2012 at 9:56 PM, Prabhu nath <gprabhunath@gmail.com> wrote:
Dear All,
Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...).
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
About the only way to do this is to use static mappings. I was under the impression that static mappings are on the way out, and that dynamic mappings are required when using device tree. An example of using static mappings can be found here: http://lxr.linux.no/linux+v3.4.4/arch/arm/mach-integrator/integrator_ap.c#L8...
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
I believe that you can only control the vmalloc start by controlling the amount of SDRAM that you have. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
Thanks for your reply. Plz see inline On Tue, Jul 10, 2012 at 11:50 AM, Dave Hylands <dhylands@gmail.com> wrote:
Hi Prabhu,
On Mon, Jul 9, 2012 at 9:56 PM, Prabhu nath <gprabhunath@gmail.com> wrote:
Dear All,
Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...).
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
About the only way to do this is to use static mappings. I was under the impression that static mappings are on the way out, and that dynamic mappings are required when using device tree.
An example of using static mappings can be found here:
http://lxr.linux.no/linux+v3.4.4/arch/arm/mach-integrator/integrator_ap.c#L8...
In this file, how did they mark IO_BASE. Is the allocator not aware of this region in the kernel virtual address space. ?
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
I believe that you can only control the vmalloc start by controlling the amount of SDRAM that you have.
-- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
HI Prabhu, On Tue, Jul 10, 2012 at 2:00 AM, Prabhu nath <gprabhunath@gmail.com> wrote:
Thanks for your reply. Plz see inline
On Tue, Jul 10, 2012 at 11:50 AM, Dave Hylands <dhylands@gmail.com> wrote:
Hi Prabhu,
On Mon, Jul 9, 2012 at 9:56 PM, Prabhu nath <gprabhunath@gmail.com> wrote:
Dear All,
Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...).
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
About the only way to do this is to use static mappings. I was under the impression that static mappings are on the way out, and that dynamic mappings are required when using device tree.
An example of using static mappings can be found here:
http://lxr.linux.no/linux+v3.4.4/arch/arm/mach-integrator/integrator_ap.c#L8...
In this file, how did they mark IO_BASE. Is the allocator not aware of this region in the kernel virtual address space. ?
Well for a given device it's really kind of arbitrary. For the integrator device IO_BASE is found here: http://lxr.linux.no/linux+v3.4.4/arch/arm/mach-integrator/include/mach/hardw... Nornally you would make sure that the I/O area doesn't overlap with the vmalloc area by controlling VMALLOC_END. But since the default VMALLOC_END is now 0xff000000 it looks like they're trying to make you use dynamic mappings. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com
在 2012-7-10,12:58,Prabhu nath <gprabhunath@gmail.com> 写道:
Dear All,
Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...).
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
you can do this if you know exactly what you are doing, please follow below steps: 1. ask yourself why you need this fix map to a device io address? if you only want to get a fix formula to calculate device virutal address from physical address, you can call ioremap(), and store the return value into a global variable. 2. ask the architecturer of you platform provider, or you search into source code by yourself, make sure whether the virtual address range 0xF0008000 to 0xF0008FFF has not been mapped yet, this is very important because kernel region cannot be mapped twice. othersie you will get warning from log and without remap this region finally. 3. suppose step 2 is ok, the region is not mapped, then call function ioremap_page_range(0xF0008000, 0xF0009000, 0x80008000, pgprot); kernel will map virtual address [0xF0008000~0xF0009000] to physical address [0x80008000~0x80009000] . Note! you must make sure this region has not been mapped before on your platform. as i guess, they are 99% mapped already :=)
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
you can try to do it as below: 1. find the definition of VMALLOC_END, define it to be 0xD0800000, the original value will be something like 0xF0000000: #define VMALLOC_END 0xD0800000 2. pass in parameter from u-boot to kernel, set "vmalloc=128M" 3. now you should get result from boot log as below: [ 0.000000] vmalloc : 0xc8800000 - 0xd0800000 ( 128 MB) [ 0.000000] lowmem : 0xc0000000 - 0xc8000000 ( 128 MB) 4. although you did what you want to do, i am sure that you don't know what you really want to do because these steps make no sense. keep in mind that vmalloc region, which is from VMALLOC_START to VMALLOC_END, does not use direct memory map.
Thanks, Prabhu
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Wonderful. I liked it. Please see inline On Tue, Jul 10, 2012 at 7:37 PM, 弋天 卜 <buyit@live.cn> wrote:
在 2012-7-10,12:58,Prabhu nath < <gprabhunath@gmail.com> gprabhunath@gmail.com> 写道:
Dear All,
Is it possible to map a physical address of a device to a known Kernel virtual address. I know about ioremap_xxx (...). which will map a physical address of a device to a kernel virtual address allocated by ioremap_xxx(...).
For E.g. I have a device whose physical address range is 0x80008000 to 0x80008FFF. Is it possible to map this device physical address to a known virtual address range 0xF0008000 to 0xF0008FFF.
you can do this if you know exactly what you are doing, please follow below steps: 1. ask yourself why you need this fix map to a device io address? if you only want to get a fix formula to calculate device virutal address from physical address, you can call ioremap(), and store the return value into a global variable.
2. ask the architecturer of you platform provider, or you search into source code by yourself, make sure whether the virtual address range 0xF0008000 to 0xF0008FFF has not been mapped yet, this is very important because kernel region cannot be mapped twice. othersie you will get warning from log and without remap this region finally.
3. suppose step 2 is ok, the region is not mapped, then call function ioremap_page_range(0xF0008000, 0xF0009000, 0x80008000, pgprot); kernel will map virtual address [0xF0008000~0xF0009000] to physical address [0x80008000~0x80009000] .
Note! you must make sure this region has not been mapped before on your platform. as i guess, they are 99% mapped already :=)
My hardware configuration has 128 MB of system RAM which will have been MAPPED to the Kernel virtual address from 0xC0000000 to 0xC7FFFFFF
Also is it possible to configure the vmalloc kernel virtual address region to a fixed range of 128 MB from 0xC8000000 to 0xCFFFFFFF
you can try to do it as below: 1. find the definition of VMALLOC_END, define it to be 0xD0800000, the original value will be something like 0xF0000000: #define VMALLOC_END 0xD0800000
2. pass in parameter from u-boot to kernel, set "vmalloc=128M"
3. now you should get result from boot log as below: [ 0.000000] vmalloc : 0xc8800000 - 0xd0800000 ( 128 MB) [ 0.000000] lowmem : 0xc0000000 - 0xc8000000 ( 128 MB) 4. although you did what you want to do, i am sure that you don't know what you really want to do because these steps make no sense. keep in mind that vmalloc region, which is from VMALLOC_START to VMALLOC_END, does not use direct memory map.
Very humbly I should confess that I know what I am doing. I want a clear demarkation betwen vmalloc region and kernel virtual address of the physical devices, so that it will help me in future debugging.
Thanks, Prabhu
_______________________________________________ Kernelnewbies mailing list <Kernelnewbies@kernelnewbies.org>Kernelnewbies@kernelnewbies.org <http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
participants (4)
-
Dave Hylands -
Philipp Ittershagen -
Prabhu nath -
弋天 卜