mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* remap_page_range
@ 2004-11-17 20:43 Thiago Robert dos Santos
  2004-11-18  2:02 ` remap_page_range William Lee Irwin III
  0 siblings, 1 reply; 2+ messages in thread
From: Thiago Robert dos Santos @ 2004-11-17 20:43 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]

All,

  I'm having a problem with remap_page_range in the 2.6 kernel series. I
use remap_page_range inside the mmap function of a module I wrote in
order to map a given device's memory into user space.

  Apparently, everything works fine but I just can't access the device's
memory (even tough I get a valid point from the mmap system call). This
is the mmap function I wrote:


static int
pcimap_mmap (struct file *filp, struct vm_area_struct *vma)
{

    int unit, reg;
    unsigned long size, phy_addr;

    unit = MINOR(filp->f_dentry->d_inode->i_rdev) >> 4;
    reg = MINOR(filp->f_dentry->d_inode->i_rdev) & 0x0f;

    size = vma->vm_end - vma->vm_start;

    /* Mapping must be page aligned and not larger than the region size */
    if ((size + vma->vm_pgoff * PAGE_SIZE) > pcidevs[unit].reg[reg].size)
    {
        return -EINVAL;
    }

    /* Get device's memory physical address for mapping */
    phy_addr = pcidevs[unit].reg[reg].phy_addr + vma->vm_pgoff * PAGE_SIZE;

    /* Map device's memory in the requested address space range */
    if (remap_page_range (vma, phy_addr, 0, size, vma->vm_page_prot))
    {
        return -EAGAIN;
    }

    filp->f_dentry->d_inode->i_count.counter++;

    return 0;
}



    Can anyone help me?


Thanks in advance.


Thiago Robert

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pcimap.c --]
[-- Type: text/x-csrc; name="pcimap.c", Size: 0 bytes --]



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: pcimap.h --]
[-- Type: text/x-chdr; name="pcimap.h", Size: 0 bytes --]



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: debug.h --]
[-- Type: text/x-chdr; name="debug.h", Size: 0 bytes --]



[-- Attachment #5: Makefile --]
[-- Type: application/octet-stream, Size: 0 bytes --]



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: pcimap_test.c --]
[-- Type: text/x-csrc; name="pcimap_test.c", Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: remap_page_range
  2004-11-17 20:43 remap_page_range Thiago Robert dos Santos
@ 2004-11-18  2:02 ` William Lee Irwin III
  0 siblings, 0 replies; 2+ messages in thread
From: William Lee Irwin III @ 2004-11-18  2:02 UTC (permalink / raw)
  To: Thiago Robert dos Santos; +Cc: linux-kernel

On Wed, Nov 17, 2004 at 06:43:46PM -0200, Thiago Robert dos Santos wrote:
>   I'm having a problem with remap_page_range in the 2.6 kernel series. I
> use remap_page_range inside the mmap function of a module I wrote in
> order to map a given device's memory into user space.
>   Apparently, everything works fine but I just can't access the device's
> memory (even tough I get a valid point from the mmap system call). This
> is the mmap function I wrote:
> static int
> pcimap_mmap (struct file *filp, struct vm_area_struct *vma)
> {

(1) set PG_reserved on all struct pages covering the physical region
(2) set VM_RESERVED|VM_IO in vma->vm_flags


-- wli

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-18  2:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-17 20:43 remap_page_range Thiago Robert dos Santos
2004-11-18  2:02 ` remap_page_range William Lee Irwin III

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome