I've just looked into the kernel sources and found that: #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) If you use ioremap to map PCI/ISA space, ioremap simply returns __va(phys_addr), assuming phys_addr >= 0xA0000 && (phys_addr + size) < 0x100000. And this is exactly the case if you map e.g. a ISA address. If you use 0xD0000 you will get 0xC000D0000. And this is the same for PCI, see: http://lxr.linux.no/source/arch/i386/mm/ioremap.c#L132 But I really wonder why you don't get the origin address. Yes, I know, we don't need to discuss about using or not using this macros in drivers, but if I simply look at the code, I don't see any reason why you don't get the original phys_addr? Am I wrong? Could you please post the code snippet and the address you use and get? From: Gregory CLEMENT > So if you use it in driver you can't expect good result. Ioremap do > more than a __va() on physicla address. You can't expect that > __va(ioremap(x)) = x. On a PCI/ISA I can expect: __pa(ioremap(x)) = x Just for clearness: __va is used by phys_to_virt __pa is used by virt_to_phys Sebastian On 08/09/2006 03:07 PM, srinivas bakki wrote: > > > On 8/9/06, *Sebastian Haas* <haas@xxxxxxxxxxxxxxxx > <mailto:haas@xxxxxxxxxxxxxxxx>> wrote: > > On 08/08/2006 10:52 AM, srinivas bakki wrote: > > hi, > > i have this doubt regarding the addresses returned by > > ioremap. > > i mapped my devices's registers using ioremap. again when i try to > > retrieve the physical address from the virtual address got from > ioremap > > using __pa(va) i see that the physical address is not the same > which i > > gave to ioremap function !! > Which kind of device did you try to map? (ISA, PCI, ...) > > Sebastian > > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > > > hi, > Thanks for the reply . I mapped PCI device registers. i had mailed > this query on arm mailing list as well and this is what i got as response. > > >> hi, > Hi, >> i have a strange doubt regarding the addresses returned by > ioremap. >> i mapped my devices's registers using ioremap. again when i try to > retrieve the physical address from the virtual address got from ioremap > using __pa(va) i see that the physical address is not the same which i > gave to ioremap function !! >> >> can anybody explain this please. > > __pa() use __virt_to_phys and with this function we ca read: > * Physical vs virtual RAM address space conversion. These are > * private definitions which should NOT be used outside memory.h > * files. Use virt_to_phys/phys_to_virt/__pa/__va instead. > and for virt_to_phys we can also read > * These are *only* valid on the kernel direct mapped RAM memory. > * Note: Drivers should NOT use these. They are the wrong > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h . > > So if you use it in driver you can't expect good result. Ioremap do > more than a __va() on physicla address. You can't expect that > __va(ioremap(x)) = x. > > -- > Gregory CLEMENT > Adeneo > > > > > -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/