virt_to_phys() on 440
I think the virt_to_phys() function is incorrect for PPC440. It should call iopa for all 4xx, not only the
405. By chance, it happens to work currently if the address is in SDRAM, but is always incorrect for ioremapped addresses. virt_to_bus() does the right thing.
Also, to be correct, shouldn't this function return a phys_addr_t rather than an unsigned long, as the physical address is >32 bits on 44x?
Regards,
Brian
asm/io.h Mon Sep 8 14:21:08 2003 renamed from asm/io.h.new Thu Aug 28 14:30:33 2003 +0 -0
@@ -309,7 +309,7 @@ */ extern inline unsigned long virt_to_phys(volatile
void * address)
{
-#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_40x)
+#if defined(CONFIG_APUS) || defined(CONFIG_8xx) || defined(CONFIG_4xx)
return iopa ((unsigned long) address);
#else
return (unsigned long) address - KERNELBASE;** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Brian Kuschak
I think the
virt_to_phys()function is incorrect for PPC440. It should call iopa for all 4xx, not only the 405.
You won't get any argument for me, but everyone else will argue with us. A long, long time ago I got spoiled using, designing, and implementing orthogonal VM functions. When I bring up this discussion I'm continually reminded that Linux isn't this way, it's supposed to be lightweight and fast.....meaning you have to use different functions to manage different memory regions with subtle side effects.
Quoted 4 lines
.... By chance, it happens to work currently if the address is in SDRAM, but is always incorrect for ioremapped addresses.
virt_to_bus()does the right thing.
It will likely always be this way. You have to keep track of your own mappings and compute what you need from that, especially when mapping things for DMA.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 6 lines · Brian Kuschak
I think the
virt_to_phys()function is incorrect for PPC440. It should call iopa for all 4xx, not only the
405. By chance, it happens to work currently if the address is in SDRAM, but is always incorrect for ioremapped addresses.virt_to_bus()does the right thing.
No, it shouldn't call iopa even for 405. Look at 2.6 version for example.
virt_to_phys is used only for directly mapped addresses not for ioremaped peripherals or vmalloc space.
Quoted 3 lines
Also, to be correct, shouldn't this function return a
phys_addr_trather than an unsigned long, as the physical address is >32 bits on 44x?
440 cannot handle more than 2G of RAM, so physaddr_t is not needed.
Eugene.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 11 lines · Brian Kuschak
I think the
virt_to_phys()function is incorrect for PPC440. It should call iopa for all 4xx, not only the
405. By chance, it happens to work currently if the address is in SDRAM, but is always incorrect for ioremapped addresses.virt_to_bus()does the right thing.Also, to be correct, shouldn't this function return a
phys_addr_trather than an unsigned long, as the physical address is >32 bits on 44x?
Read IO-mapping.txt and DMA-mapping.txt
PPC40x is incorrect. These APIs are valid only for system memory kernel addresses that are staticly mapped.
Anything wanting a generic translation from virt->phys should call iopa() directly until somebody drives a generic translation API into the kernel.
-Matt
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 10 lines
These APIs are valid only for
system
memory kernel addresses that are staticly mapped.Anything wanting a generic translation from
virt->physshould
calliopa()directly until somebody drives a generic translation
API into the kernel.
Thanks, I missed that.
Regards,
Brian
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 5 lines · Brian Kuschak
Quoted 5 lines
These APIs are valid only for
system
memory kernel addresses that are staticly mapped.
Quoted 7 lines
Quoted 5 lines
Anything wanting a generic translation from
virt->physshould
calliopa()directly until somebody drives a generic translation
API into the kernel.Thanks, I missed that.
BTW, it was pointed out to me that the changesets I made to linux-2.4 to merge the 2.6 virt_to_* method have been merged back into current linuxppc-2.4 and linuxppc_2_4_devel.
So, all current devel trees have the API correct implementation now.
Now somebody needs to create a nice device-to-device DMA and bus address translation API. :)
-Matt
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/