* virt_to_phys() on 440
@ 2003-09-08 21:36 Brian Kuschak
2003-09-08 22:03 ` Dan Malek
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Brian Kuschak @ 2003-09-08 21:36 UTC (permalink / raw)
To: linuxppc-embedded
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
--- include/asm/io.h.new Thu Aug 28 14:30:33 2003
+++ include/asm/io.h Mon Sep 8 14:21:08 2003
@@ -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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virt_to_phys() on 440
2003-09-08 21:36 virt_to_phys() on 440 Brian Kuschak
@ 2003-09-08 22:03 ` Dan Malek
2003-09-08 22:08 ` Eugene Surovegin
2003-09-08 22:14 ` Matt Porter
2 siblings, 0 replies; 6+ messages in thread
From: Dan Malek @ 2003-09-08 22:03 UTC (permalink / raw)
To: Brian Kuschak; +Cc: linuxppc-embedded
Brian Kuschak wrote:
> 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.
> .... 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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virt_to_phys() on 440
2003-09-08 21:36 virt_to_phys() on 440 Brian Kuschak
2003-09-08 22:03 ` Dan Malek
@ 2003-09-08 22:08 ` Eugene Surovegin
2003-09-08 22:14 ` Matt Porter
2 siblings, 0 replies; 6+ messages in thread
From: Eugene Surovegin @ 2003-09-08 22:08 UTC (permalink / raw)
To: Brian Kuschak; +Cc: linuxppc-embedded
At 02:36 PM 9/8/2003, Brian Kuschak wrote:
>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.
>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?
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virt_to_phys() on 440
2003-09-08 21:36 virt_to_phys() on 440 Brian Kuschak
2003-09-08 22:03 ` Dan Malek
2003-09-08 22:08 ` Eugene Surovegin
@ 2003-09-08 22:14 ` Matt Porter
2003-09-08 22:36 ` Brian Kuschak
2 siblings, 1 reply; 6+ messages in thread
From: Matt Porter @ 2003-09-08 22:14 UTC (permalink / raw)
To: Brian Kuschak; +Cc: linuxppc-embedded
On Mon, Sep 08, 2003 at 02:36:38PM -0700, Brian Kuschak wrote:
>
> 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?
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virt_to_phys() on 440
2003-09-08 22:14 ` Matt Porter
@ 2003-09-08 22:36 ` Brian Kuschak
2003-09-08 23:26 ` Matt Porter
0 siblings, 1 reply; 6+ messages in thread
From: Brian Kuschak @ 2003-09-08 22:36 UTC (permalink / raw)
To: Matt Porter; +Cc: linuxppc-embedded
> 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.
Thanks, I missed that.
Regards,
Brian
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: virt_to_phys() on 440
2003-09-08 22:36 ` Brian Kuschak
@ 2003-09-08 23:26 ` Matt Porter
0 siblings, 0 replies; 6+ messages in thread
From: Matt Porter @ 2003-09-08 23:26 UTC (permalink / raw)
To: Brian Kuschak; +Cc: Matt Porter, linuxppc-embedded
On Mon, Sep 08, 2003 at 03:36:49PM -0700, Brian Kuschak wrote:
>
> > 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.
>
> 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/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-09-08 23:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-08 21:36 virt_to_phys() on 440 Brian Kuschak
2003-09-08 22:03 ` Dan Malek
2003-09-08 22:08 ` Eugene Surovegin
2003-09-08 22:14 ` Matt Porter
2003-09-08 22:36 ` Brian Kuschak
2003-09-08 23:26 ` Matt Porter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).