public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 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

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