* Resolving physical addresses
@ 2001-03-09 5:45 gjohnson
2001-03-09 6:01 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: gjohnson @ 2001-03-09 5:45 UTC (permalink / raw)
To: linux-kernel
Hi Kernel-dudes,
I have used this snippet of code previously in a 2.2 kernel
to get the physical address of the user virtual address 'addr'.
It worked fine under 2.2, but gives me crap under 2.4. I have
looked at bits of code in the 2.4 memory manager that do
similar stuff, and it looks much the same. I call 'mlock' (as root)
on the allocated buffer in the user app before my driver
gets called to run this code.
I have tried this on a dual CPU system with both a UP and MP
kernel.
Is there something that I should be doing different in the
2.4 case, or is maybe 'mlock' broken?
I also used 'map_user_kiobuf' on the same buffer and when I
look at iobuf->locked, it says it ain't.
Any ideas, or is there an easier way to get physical address
of a user allocated buffer. The kiobuf is a bit obscure to
divine from the source.
Regards
Greg.
pgd_t *pgd; /* PaGe Directory */
pmd_t *pmd; /* Page Mid-level Directory */
pte_t *pte; /* Page Table Entry */
unsigned long kern_addr; /* Kernel address of addr. */
unsigned long addr_ofst; /* Offset of addr within a page */
/* Get the page table entry of the page that addr belongs */
pgd = pgd_offset(current->mm, (unsigned long) addr);
pmd = pmd_offset(pgd, (unsigned long) addr);
pte = pte_offset(pmd, (unsigned long) addr);
/* Calculate the offset of addr within a page and add to kern_addr */
kern_addr = (unsigned long) pte_page(*pte);
addr_ofst = addr & (PAGE_SIZE - 1);
kern_addr += addr_ofst;
--
+------------------------------------------------------+
| Do you want to know more? www.geocities.com/worfsom/ |
| ..ooOO Greg Johnson OOoo.. |
| HW/SW Engineer gjohnson@research.canon.com.au |
| Canon Information Systems Research Australia (CISRA) |
| 1 Thomas Holt Dr., North Ryde, NSW, 2113, Australia |
| "I FLEXed my BISON and it went YACC!" - me. |
+------------------------------------------------------+
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Resolving physical addresses
2001-03-09 5:45 Resolving physical addresses gjohnson
@ 2001-03-09 6:01 ` David S. Miller
2001-03-09 6:17 ` gjohnson
0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2001-03-09 6:01 UTC (permalink / raw)
To: gjohnson; +Cc: linux-kernel
In 2.4.x pte_page() gives a pointer to a page struct, not an address
as in 2.2.x.
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Resolving physical addresses
2001-03-09 6:01 ` David S. Miller
@ 2001-03-09 6:17 ` gjohnson
2001-03-09 12:14 ` Martin Frey
0 siblings, 1 reply; 4+ messages in thread
From: gjohnson @ 2001-03-09 6:17 UTC (permalink / raw)
To: David S. Miller; +Cc: gjohnson, linux-kernel
Thank you,
But how do I get the physical address out of the page
structure? It is non-obvious to me. Is there some majic
macro? We are talking about 'struct page' in mm.h, correct?
Greg.
Quoth David S. Miller:
> In 2.4.x pte_page() gives a pointer to a page struct, not an address
> as in 2.2.x.
--
+------------------------------------------------------+
| Do you want to know more? www.geocities.com/worfsom/ |
| ..ooOO Greg Johnson OOoo.. |
| HW/SW Engineer gjohnson@research.canon.com.au |
| Canon Information Systems Research Australia (CISRA) |
| 1 Thomas Holt Dr., North Ryde, NSW, 2113, Australia |
| "I FLEXed my BISON and it went YACC!" - me. |
+------------------------------------------------------+
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Resolving physical addresses
2001-03-09 6:17 ` gjohnson
@ 2001-03-09 12:14 ` Martin Frey
0 siblings, 0 replies; 4+ messages in thread
From: Martin Frey @ 2001-03-09 12:14 UTC (permalink / raw)
To: gjohnson; +Cc: linux-kernel
>But how do I get the physical address out of the page
>structure? It is non-obvious to me. Is there some majic
>macro? We are talking about 'struct page' in mm.h, correct?
>
virt_to_phys(page_address(page))
>Quoth David S. Miller:
>> In 2.4.x pte_page() gives a pointer to a page struct, not an address
>> as in 2.2.x.
--
Supercomputing Systems AG email: frey@scs.ch
Martin Frey web: http://www.scs.ch/~frey/
at Compaq Computer Corporation phone: +1 603 884 4266
ZKO2-3P09, 110 Spit Brook Road, Nashua, NH 03062
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-03-09 12:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-09 5:45 Resolving physical addresses gjohnson
2001-03-09 6:01 ` David S. Miller
2001-03-09 6:17 ` gjohnson
2001-03-09 12:14 ` Martin Frey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox