Skip to contentSkip to conversation

Does io_remap_page_range() take 5 or 6 args?

DISCUSSION Paul Jackson 4 participants 18 messages Aug 18, 2004 – Aug 19, 2004

Subsystems (14)
lore
Share & tools
lore
#0 lore raw

What is up with io_remap_page_range()? Seems like half of its mentions take 5 args, and half 6 args (the 6th arg being 'space').

Grep'ing and eyeballing in 2.6.8.1-mm1 just now shows the following files using 5 args:

        arch/ia64/sn/io/sn2/pcibr/pcibr_dvr.c
        arch/ia64/sn/io/sn2/xbow.c
        arch/sh/kernel/cpu/sh4/sq.c
        drivers/video/acornfb.c
        drivers/video/controlfb.c
        drivers/video/fbmem.c
        include/asm-alpha/pgtable.h
        include/asm-arm/pgtable.h
        include/asm-arm26/pgtable.h
        sound/core/pcm_native.c

and the following files using 6 args:

        arch/sparc/mm/generic.c
        arch/sparc64/kernel/pci.c
        arch/sparc64/kernel/pci.c
        arch/sparc64/kernel/sparc64_ksyms.c
        arch/sparc64/mm/generic.c
        drivers/char/drm/drm_vm.h
        drivers/sbus/char/vfc_dev.c
        drivers/video/fbmem.c
        drivers/video/sbuslib.c
        include/asm-sparc/pgtable.h
        include/asm-sparc64/pgtable.h

I'm noticing this trying to build 2.6.8.1-mm1 sparc64, using crosstool
and 'make defconfig'. It errors out with:

 $ make sound/core/pcm_native.o
 CC [M]  sound/core/pcm_native.o
 sound/core/pcm_native.c: In function `snd_pcm_mmap_data':
 sound/core/pcm_native.c:3088: error: too few arguments to function `io_remap_page_range'

My dimm recollection is that this error has been here a while, but that I've just been commenting CONFIG_SOUND out, since I really didn't care about either sound nor about sparc64 (only that I wasn't contributing further grief to sparc64 with my cpumask and cpuset stuff).

Does anyone know the story behind this odd inconsistency?

Better yet, is anyone signed up to resolve this? No, I'm not volunteering ;).

Signature · 3 lines
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <[email protected]> 1.650.933.1373
#1 lore raw
Quoted 7 lines · Paul Jackson

and the following files using 6 args:
arch/sparc/mm/generic.c
drivers/sbus/char/vfc_dev.c include/asm-sparc/pgtable.h include/asm-sparc64/pgtable.h
I'm noticing this trying to build 2.6.8.1-mm1 sparc64, using crosstool
and 'make defconfig'. It errors out with:

Quoted 11 lines
 $ make sound/core/pcm_native.o
 CC [M]  sound/core/pcm_native.o
 sound/core/pcm_native.c: In function `snd_pcm_mmap_data':
 sound/core/pcm_native.c:3088: error: too few arguments to function `io_remap_page_range'
My dimm recollection is that this error has been here a while, but that
I've just been commenting CONFIG_SOUND out, since I really didn't care
about either sound nor about sparc64 (only that I wasn't contributing
further grief to sparc64 with my cpumask and cpuset stuff).
Does anyone know the story behind this odd inconsistency?
Better yet, is anyone signed up to resolve this?  No, I'm not
volunteering ;).

Once it's decided how many it really takes, I'll fix up sparc32 as-needed.

-- wli

#2 lore raw
Quoted 1 line · On Wed, 18 Aug 2004 13:53:38 -0700 William Lee Irwin III <[email protected]>…

Once it's decided how many it really takes, I'll fix up sparc32 as-needed.

#3 lore raw
In reply to William Lee Irwin III
Quoted 1 line · On Wed, 18 Aug 2004 13:53:38 -0700 William Lee Irwin III <[email protected]>…

Once it's decided how many it really takes, I'll fix up sparc32 as-needed.

(sorry for the emply reply previously)

It needs 6 unless we start passing in a 64-bit value to io_remap_page_range() for the 'offset' parameter.

Physical I/O addresses are 36-bits or so on sparc32 systems, which is why we need to pass in "offset" and "space".

#4 lore raw
Quoted 1 line · On Wed, 18 Aug 2004 13:53:38 -0700 William Lee Irwin III wrote:
Quoted 1 line

Once it's decided how many it really takes, I'll fix up sparc32 as-needed.

Quoted 5 lines · David S. Miller

(sorry for the emply reply previously)
It needs 6 unless we start passing in a 64-bit value to io_remap_page_range() for the 'offset' parameter.
Physical I/O addresses are 36-bits or so on sparc32 systems, which is why we need to pass in "offset" and "space".

We should pass 64-bit values to remap_page_range() also, then. Or perhaps passing pfn's to both suffices, as it all has to be page aligned anyway.

-- wli

#5 lore raw
Quoted 3 lines · On Wed, 18 Aug 2004 14:05:03 -0700 William Lee Irwin III <[email protected]>…

We should pass 64-bit values to remap_page_range() also, then. Or perhaps passing pfn's to both suffices, as it all has to be page aligned anyway.

Does not work on a system who has more physical address bits than 32 + PAGE_SHIFT

Sparc32 does not fall into this category... but some other might.

#6 lore raw
Quoted 3 lines · On Wed, 18 Aug 2004 14:05:03 -0700 William Lee Irwin III wrote:
Quoted 3 lines

We should pass 64-bit values to remap_page_range() also, then. Or perhaps passing pfn's to both suffices, as it all has to be page aligned anyway.

Quoted 4 lines · David S. Miller

Does not work on a system who has more physical address bits than 32 + PAGE_SHIFT
Sparc32 does not fall into this category... but some other might.

All extant systems of this category I'm aware of are 32-bit kernels on 64-bit machines, which we don't really support. Also, the assumption that physical addresses are bounded by 1ULL << (BITS_PER_LONG + PAGE_SHIFT) is made broadly elsewhere, particularly in pfn_to_page() and the like. Making this assumption in remap_page_range() and io_remap_page_range() would save the overhead of passing additional arguments and/or passing 64-bit arguments on 32-bit machines. Using pgoff_t for pfn's may prove useful for such systems, but it's highly doubtful the kernel will ever be made clean for such or that they'll ever be brought to a usable state.

-- wli

#7 lore raw
Quoted 4 lines · David S. Miller
Quoted 4 lines

Does not work on a system who has more physical address bits than 32 + PAGE_SHIFT
Sparc32 does not fall into this category... but some other might.

Quoted 9 lines · William Lee Irwin III

All extant systems of this category I'm aware of are 32-bit kernels on 64-bit machines, which we don't really support. Also, the assumption that physical addresses are bounded by 1ULL << (BITS_PER_LONG + PAGE_SHIFT) is made broadly elsewhere, particularly in pfn_to_page() and the like. Making this assumption in remap_page_range() and io_remap_page_range() would save the overhead of passing additional arguments and/or passing 64-bit arguments on 32-bit machines. Using pgoff_t for pfn's may prove useful for such systems, but it's highly doubtful the kernel will ever be made clean for such or that they'll ever be brought to a usable state.

Or, if not pgoff_t, introduce a pfn_t for this purpose, an unsigned arithmetic type of architecture-dependent width (such systems may not want 64-bit page indices and the like for various reasons). But exhibiting a system with the need for such is yet to be done, and in fact, even with a 32B struct page, 16TB RAM (the minimum required to trigger more physical address bits >= BITS_PER_LONG + PAGE_SHIFT) has a 128GB mem_map[] with 4KB pages, an 8GB mem_map[] with 64KB pages, and so will have far, far deeper support issues than pfn overflows. Even supposing a kernel could be made to boot and the like, the massive internal fragmentation from using a large enough emulated PAGE_SIZE to get mem_map[] to fit within virtualspace will surely render such a machine completely useless, likely to the point of being unable to run userspace, or panicking much earlier from boot-time allocation failures.

-- wli

#8 lore raw
Quoted 5 lines · William Lee Irwin III

Or, if not pgoff_t, introduce a pfn_t for this purpose, an unsigned arithmetic type of architecture-dependent width (such systems may not want 64-bit page indices and the like for various reasons). But exhibiting a system with the need for such is yet to be done, and in fact, even with a 32B struct page, 16TB RAM (the minimum required to

Quoted 8 lines

trigger more physical address bits >= BITS_PER_LONG + PAGE_SHIFT) has a 128GB mem_map[] with 4KB pages, an 8GB mem_map[] with 64KB pages, and so will have far, far deeper support issues than pfn overflows. Even supposing a kernel could be made to boot and the like, the massive internal fragmentation from using a large enough emulated PAGE_SIZE to get mem_map[] to fit within virtualspace will surely render such a machine completely useless, likely to the point of being unable to run userspace, or panicking much earlier from boot-time allocation failures.

Given this, will a pfn suffice?

-- wli

#9 lore raw
Quoted 15 lines · On Wed, 18 Aug 2004 15:59:15 -0700 William Lee Irwin III <[email protected]>…
Quoted 5 lines · William Lee Irwin III

Or, if not pgoff_t, introduce a pfn_t for this purpose, an unsigned arithmetic type of architecture-dependent width (such systems may not want 64-bit page indices and the like for various reasons). But exhibiting a system with the need for such is yet to be done, and in fact, even with a 32B struct page, 16TB RAM (the minimum required to

Quoted 8 lines

trigger more physical address bits >= BITS_PER_LONG + PAGE_SHIFT) has a 128GB mem_map[] with 4KB pages, an 8GB mem_map[] with 64KB pages, and so will have far, far deeper support issues than pfn overflows. Even supposing a kernel could be made to boot and the like, the massive internal fragmentation from using a large enough emulated PAGE_SIZE to get mem_map[] to fit within virtualspace will surely render such a machine completely useless, likely to the point of being unable to run userspace, or panicking much earlier from boot-time allocation failures.

Quoted 1 line

Given this, will a pfn suffice?

There is an error in the calculations. 16TB "RAM", means "RAM". On many systems, a large chunk of the physical address space is taken up by I/O areas, not real memory.

Such areas do not take up mem_map[] array space.

Regardless, I think an "unsigned long" page frame number is sufficient for now. Don't even make the new type.

#10 lore raw

On Wed, 18 Aug 2004 15:59:15 -0700

Quoted 1 line
Quoted 1 line

Given this, will a pfn suffice?

Quoted 6 lines · David S. Miller

There is an error in the calculations. 16TB "RAM", means "RAM". On many systems, a large chunk of the physical address space is taken up by I/O areas, not real memory.
Such areas do not take up mem_map[] array space. Regardless, I think an "unsigned long" page frame number is sufficient for now. Don't even make the new type.

Oh, virtualspace footprint of IO areas is far worse, as the convention is to direct map them into a single address space if they're ever used. Of course this convention is much more loosely established than e.g. struct page is for RAM. Some analogue of kmap_atomic() for such machines to multiplex virtualspace in interrupt context would help, but is unrelated to physical address passing issues.

-- wli

#11 lore raw
Quoted 6 lines · David S. Miller
Quoted 6 lines

There is an error in the calculations. 16TB "RAM", means "RAM". On many systems, a large chunk of the physical address space is taken up by I/O areas, not real memory.
Such areas do not take up mem_map[] array space. Regardless, I think an "unsigned long" page frame number is sufficient for now. Don't even make the new type.

Quoted 6 lines · William Lee Irwin III

Oh, virtualspace footprint of IO areas is far worse, as the convention is to direct map them into a single address space if they're ever used. Of course this convention is much more loosely established than e.g. struct page is for RAM. Some analogue of kmap_atomic() for such machines to multiplex virtualspace in interrupt context would help, but is unrelated to physical address passing issues.

remap_page_range() is the easier of the two. Here is something approximating a patch to make that accept pfn's (untested/uncompiled). Oddly, the sparc64 case seems to be the most difficult one for the io_remap_page_range() sweep...

 arch/arm/kernel/bios32.c           |    2 +-
 arch/i386/pci/i386.c               |    2 +-
 arch/ia64/kernel/perfmon.c         |    2 +-
 arch/ia64/pci/pci.c                |    2 +-
 arch/ppc/kernel/pci.c              |    2 +-
 arch/ppc64/kernel/pci.c            |    2 +-
 arch/ppc64/kernel/proc_ppc64.c     |    2 +-
 arch/um/drivers/mmapper_kern.c     |    2 +-
 drivers/char/agp/frontend.c        |    4 ++--
 drivers/char/drm/drm_vm.h          |    2 +-
 drivers/char/drm/i810_dma.c        |    2 +-
 drivers/char/drm/i830_dma.c        |    2 +-
 drivers/char/hpet.c                |    2 +-
 drivers/char/mem.c                 |    2 +-
 drivers/media/video/cpia.c         |   15 +--------------
 drivers/media/video/meye.c         |   14 +-------------
 drivers/media/video/planb.c        |    2 +-
 drivers/media/video/zoran_driver.c |   15 +++++----------
 drivers/media/video/zr36120.c      |    2 +-
 drivers/perfctr/virtual.c          |    2 +-
 drivers/sbus/char/flash.c          |    2 +-
 drivers/usb/class/audio.c          |    2 +-
 drivers/usb/media/ov511.c          |   16 +---------------
 drivers/usb/media/pwc-if.c         |   15 +--------------
 drivers/usb/media/se401.c          |   15 +--------------
 drivers/usb/media/stv680.c         |   15 +--------------
 drivers/usb/media/usbvideo.c       |   16 +---------------
 drivers/usb/media/vicam.c          |   12 +-----------
 drivers/usb/media/w9968cf.c        |   16 +---------------
 drivers/video/aty/atyfb_base.c     |    4 ++--
 drivers/video/gbefb.c              |    2 +-
 drivers/video/igafb.c              |    2 +-
 drivers/video/sgivwfb.c            |    2 +-
 include/asm-alpha/pgtable.h        |    2 +-
 include/asm-arm/pgtable.h          |    2 +-
 include/asm-arm26/pgtable.h        |    2 +-
 include/asm-h8300/pgtable.h        |    3 ++-
 include/asm-i386/pgtable.h         |    3 ++-
 include/asm-ia64/pgtable.h         |    3 ++-
 include/asm-m68k/pgtable.h         |    3 ++-
 include/asm-m68knommu/pgtable.h    |    3 ++-
 include/asm-mips/pgtable.h         |    3 ++-
 include/asm-parisc/pgtable.h       |    3 ++-
 include/asm-ppc/pgtable.h          |    3 ++-
 include/asm-ppc64/pgtable.h        |    3 ++-
 include/asm-sh/pgtable.h           |    3 ++-
 include/asm-sh64/pgtable.h         |    3 ++-
 include/asm-x86_64/pgtable.h       |    3 ++-
 mm/memory.c                        |   16 +++++++---------
 net/packet/af_packet.c             |    3 ++-
 sound/oss/ali5455.c                |    2 +-
 sound/oss/au1000.c                 |    2 +-
 sound/oss/cmpci.c                  |    2 +-
 sound/oss/cs4281/cs4281m.c         |    2 +-
 sound/oss/cs46xx.c                 |    4 ++--
 sound/oss/es1370.c                 |    4 ++--
 sound/oss/es1371.c                 |    4 ++--
 sound/oss/esssolo1.c               |    2 +-
 sound/oss/forte.c                  |    2 +-
 sound/oss/i810_audio.c             |    2 +-
 sound/oss/ite8172.c                |    2 +-
 sound/oss/maestro.c                |    2 +-
 sound/oss/maestro3.c               |    2 +-
 sound/oss/rme96xx.c                |    4 ++--
 sound/oss/sonicvibes.c             |    2 +-
 sound/oss/trident.c                |    2 +-
 sound/oss/ymfpci.c                 |    2 +-
 67 files changed, 96 insertions(+), 206 deletions(-)

-- wli

arch/arm/kernel/bios32.c +1 -1
Index: mm1-2.6.8.1/arch/arm/kernel/bios32.c
===================================================================
@@ -684,7 +684,7 @@
 	vma->vm_flags |= VM_SHM | VM_LOCKED | VM_IO;
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	if (remap_page_range(vma, vma->vm_start, phys,
+	if (remap_page_range(vma, vma->vm_start, phys >> PAGE_SHIFT,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot))
 		return -EAGAIN;
arch/i386/pci/i386.c +1 -1
Index: mm1-2.6.8.1/arch/i386/pci/i386.c
===================================================================
@@ -291,7 +291,7 @@
 	/* Write-combine setting is ignored, it is changed via the mtrr
 	 * interfaces on this platform.
 	 */
-	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot))
 		return -EAGAIN;
arch/ia64/kernel/perfmon.c +1 -1
Index: mm1-2.6.8.1/arch/ia64/kernel/perfmon.c
===================================================================
@@ -575,7 +575,7 @@
 static inline int
 pfm_remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
 {
-	return remap_page_range(vma, from, phys_addr, size, prot);
+	return remap_page_range(vma, from, phys_addr >> PAGE_SHIFT, size, prot);
 }
 
 static inline unsigned long
arch/ia64/pci/pci.c +1 -1
Index: mm1-2.6.8.1/arch/ia64/pci/pci.c
===================================================================
@@ -487,7 +487,7 @@
 	else
 		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
-	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start, vma->vm_page_prot))
 		return -EAGAIN;
 
arch/ppc/kernel/pci.c +1 -1
Index: mm1-2.6.8.1/arch/ppc/kernel/pci.c
===================================================================
@@ -1601,7 +1601,7 @@
 	__pci_mmap_set_flags(dev, vma, mmap_state);
 	__pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine);
 
-	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff,
 			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
 
 	return ret;
arch/ppc64/kernel/pci.c +1 -1
Index: mm1-2.6.8.1/arch/ppc64/kernel/pci.c
===================================================================
@@ -500,7 +500,7 @@
 	__pci_mmap_set_flags(dev, vma, mmap_state);
 	__pci_mmap_set_pgprot(dev, vma, mmap_state, write_combine);
 
-	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff << PAGE_SHIFT,
+	ret = remap_page_range(vma, vma->vm_start, vma->vm_pgoff,
 			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
 
 	return ret;
arch/ppc64/kernel/proc_ppc64.c +1 -1
Index: mm1-2.6.8.1/arch/ppc64/kernel/proc_ppc64.c
===================================================================
@@ -176,7 +176,7 @@
 	if ((vma->vm_end - vma->vm_start) > dp->size)
 		return -EINVAL;
 
-	remap_page_range( vma, vma->vm_start, __pa(dp->data), dp->size, vma->vm_page_prot );
+	remap_page_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT, dp->size, vma->vm_page_prot );
 	return 0;
 }
 
arch/um/drivers/mmapper_kern.c +1 -1
Index: mm1-2.6.8.1/arch/um/drivers/mmapper_kern.c
===================================================================
@@ -84,7 +84,7 @@
 	/* XXX A comment above remap_page_range says it should only be
 	 * called when the mm semaphore is held
 	 */
-	if (remap_page_range(vma, vma->vm_start, p_buf, size, 
+	if (remap_page_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size, 
 			     vma->vm_page_prot))
 		goto out;
 	ret = 0;
drivers/char/agp/frontend.c +2 -2
Index: mm1-2.6.8.1/drivers/char/agp/frontend.c
===================================================================
@@ -628,7 +628,7 @@
 		if (kerninfo.vm_ops) {
 			vma->vm_ops = kerninfo.vm_ops;
 		} else if (remap_page_range(vma, vma->vm_start, 
-					    (kerninfo.aper_base + offset),
+				(kerninfo.aper_base + offset) >> PAGE_SHIFT,
 					    size, vma->vm_page_prot)) {
 			goto out_again;
 		}
@@ -644,7 +644,7 @@
 		if (kerninfo.vm_ops) {
 			vma->vm_ops = kerninfo.vm_ops;
 		} else if (remap_page_range(vma, vma->vm_start, 
-					    kerninfo.aper_base,
+					    kerninfo.aper_base >> PAGE_SHIFT,
 					    size, vma->vm_page_prot)) {
 			goto out_again;
 		}
drivers/char/drm/drm_vm.h +1 -1
Index: mm1-2.6.8.1/drivers/char/drm/drm_vm.h
===================================================================
@@ -617,7 +617,7 @@
 					vma->vm_page_prot, 0))
 #else
 		if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-				     VM_OFFSET(vma) + offset,
+				     vma->vm_pgoff + (offset >> PAGE_SHIFT),
 				     vma->vm_end - vma->vm_start,
 				     vma->vm_page_prot))
 #endif
drivers/char/drm/i810_dma.c +1 -1
Index: mm1-2.6.8.1/drivers/char/drm/i810_dma.c
===================================================================
@@ -139,7 +139,7 @@
 	unlock_kernel();
 
 	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-			     VM_OFFSET(vma),
+			     vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot)) return -EAGAIN;
 	return 0;
drivers/char/drm/i830_dma.c +1 -1
Index: mm1-2.6.8.1/drivers/char/drm/i830_dma.c
===================================================================
@@ -140,7 +140,7 @@
 	unlock_kernel();
 
 	if (remap_page_range(DRM_RPR_ARG(vma) vma->vm_start,
-			     VM_OFFSET(vma),
+			     vma->vm_pgoff,
 			     vma->vm_end - vma->vm_start,
 			     vma->vm_page_prot)) return -EAGAIN;
 	return 0;
drivers/char/hpet.c +1 -1
Index: mm1-2.6.8.1/drivers/char/hpet.c
===================================================================
@@ -271,7 +271,7 @@
 
 	vma->vm_flags |= VM_IO;
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-	addr = __pa(addr);
+	addr = __pa(addr) >> PAGE_SHIFT;
 
 	if (remap_page_range
 	    (vma, vma->vm_start, addr, PAGE_SIZE, vma->vm_page_prot)) {
drivers/char/mem.c +1 -1
Index: mm1-2.6.8.1/drivers/char/mem.c
===================================================================
@@ -236,7 +236,7 @@
 		cursor++;
 	}
 
-	if (remap_page_range(vma, vma->vm_start, offset,
+	if (remap_page_range(vma, vma->vm_start, vma->vm_pgoff,
 			vma->vm_end-vma->vm_start, vma->vm_page_prot))
 		return -EAGAIN;
 	return 0;
drivers/media/video/cpia.c +1 -14
Index: mm1-2.6.8.1/drivers/media/video/cpia.c
===================================================================
@@ -206,19 +206,6 @@
  *
  **********************************************************************/
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -3785,7 +3772,7 @@
 
 	pos = (unsigned long)(cam->frame_buf);
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&cam->busy_lock);
 			return -EAGAIN;
drivers/media/video/meye.c +1 -13
Index: mm1-2.6.8.1/drivers/media/video/meye.c
===================================================================
@@ -116,18 +116,6 @@
 /* Memory allocation routines (stolen from bttv-driver.c)                   */
 /****************************************************************************/
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr) {
-        unsigned long kva, ret;
-
-        kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-        return ret;
-}
-
 static void *rvmalloc(unsigned long size) {
 	void *mem;
 	unsigned long adr;
@@ -1201,7 +1189,7 @@
 	pos = (unsigned long)meye.grab_fbuffer;
 
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&meye.lock);
 			return -EAGAIN;
drivers/media/video/planb.c +1 -1
Index: mm1-2.6.8.1/drivers/media/video/planb.c
===================================================================
@@ -1996,7 +1996,7 @@
 			return err;
 	}
 	for (i = 0; i < pb->rawbuf_size; i++) {
-		if (remap_page_range(vma, start, virt_to_phys((void *)pb->rawbuf[i]),
+		if (remap_page_range(vma, start, __pa((void *)pb->rawbuf[i]) >> PAGE_SHIFT,
 						PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 		start += PAGE_SIZE;
drivers/media/video/zoran_driver.c +5 -10
Index: mm1-2.6.8.1/drivers/media/video/zoran_driver.c
===================================================================
@@ -4450,12 +4450,6 @@
 	.close = zoran_vm_close,
 };
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
-#define zr_remap_page_range(a,b,c,d,e) remap_page_range(b,c,d,e)
-#else
-#define zr_remap_page_range(a,b,c,d,e) remap_page_range(a,b,c,d,e)
-#endif
-
 static int
 zoran_mmap (struct file           *file,
 	    struct vm_area_struct *vma)
@@ -4555,8 +4549,9 @@
 				pos =
 				    (unsigned long) fh->jpg_buffers.
 				    buffer[i].frag_tab[2 * j];
-				page = virt_to_phys(bus_to_virt(pos));	/* should just be pos on i386 */
-				if (zr_remap_page_range
+				page = __pa(bus_to_virt(pos)) >> PAGE_SHIFT;
+				/* should just be pos on i386 */
+				if (remap_page_range
 				    (vma, start, page, todo, PAGE_SHARED)) {
 					dprintk(1,
 						KERN_ERR
@@ -4640,8 +4635,8 @@
 			todo = size;
 			if (todo > fh->v4l_buffers.buffer_size)
 				todo = fh->v4l_buffers.buffer_size;
-			page = fh->v4l_buffers.buffer[i].fbuffer_phys;
-			if (zr_remap_page_range
+			page = fh->v4l_buffers.buffer[i].fbuffer_phys >> PAGE_SHIFT;
+			if (remap_page_range
 			    (vma, start, page, todo, PAGE_SHARED)) {
 				dprintk(1,
 					KERN_ERR
drivers/media/video/zr36120.c +1 -1
Index: mm1-2.6.8.1/drivers/media/video/zr36120.c
===================================================================
@@ -1475,7 +1475,7 @@
 	/* start mapping the whole shabang to user memory */
 	pos = (unsigned long)ztv->fbuffer;
 	while (size>0) {
-		unsigned long page = virt_to_phys((void*)pos);
+		unsigned long page = __pa(pos) >> PAGE_SHIFT;
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 		start += PAGE_SIZE;
drivers/perfctr/virtual.c +1 -1
Index: mm1-2.6.8.1/drivers/perfctr/virtual.c
===================================================================
@@ -720,7 +720,7 @@
 	perfctr = filp->private_data;
 	if (!perfctr)
 		return -EPERM;
-	return remap_page_range(vma, vma->vm_start, virt_to_phys(perfctr),
+	return remap_page_range(vma, vma->vm_start, __pa(perfctr) >> PAGE_SHIFT,
 				PAGE_SIZE, vma->vm_page_prot);
 }
 
drivers/sbus/char/flash.c +1 -1
Index: mm1-2.6.8.1/drivers/sbus/char/flash.c
===================================================================
@@ -65,7 +65,7 @@
 
 	if ((vma->vm_pgoff << PAGE_SHIFT) > size)
 		return -ENXIO;
-	addr += (vma->vm_pgoff << PAGE_SHIFT);
+	addr = (addr >> PAGE_SHIFT) + vma->vm_pgoff;
 
 	if (vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT)) > size)
 		size = vma->vm_end - (vma->vm_start + (vma->vm_pgoff << PAGE_SHIFT));
drivers/usb/class/audio.c +1 -1
Index: mm1-2.6.8.1/drivers/usb/class/audio.c
===================================================================
@@ -509,7 +509,7 @@
 			return -EINVAL;
 	db->mapped = 1;
 	for(nr = 0; nr < size; nr++) {
-		if (remap_page_range(vma, start, virt_to_phys(db->sgbuf[nr]), PAGE_SIZE, prot))
+		if (remap_page_range(vma, start, __pa(db->sgbuf[nr]) >> PAGE_SHIFT, PAGE_SIZE, prot))
 			return -EAGAIN;
 		start += PAGE_SIZE;
 	}
drivers/usb/media/ov511.c +1 -15
Index: mm1-2.6.8.1/drivers/usb/media/ov511.c
===================================================================
@@ -325,20 +325,6 @@
  * Memory management
  **********************************************************************/
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long
-kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *
 rvmalloc(unsigned long size)
 {
@@ -4771,7 +4757,7 @@
 
 	pos = (unsigned long)ov->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE,
 				     PAGE_SHARED)) {
 			up(&ov->lock);
drivers/usb/media/pwc-if.c +1 -14
Index: mm1-2.6.8.1/drivers/usb/media/pwc-if.c
===================================================================
@@ -191,19 +191,6 @@
 /***************************************************************************/
 /* Private functions */
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr) 
-{
-        unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-        return ret;
-}
-
 static void * rvmalloc(unsigned long size)
 {
 	void * mem;
@@ -1588,7 +1575,7 @@
 
 	pos = (unsigned long)pdev->image_data;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 
drivers/usb/media/se401.c +1 -14
Index: mm1-2.6.8.1/drivers/usb/media/se401.c
===================================================================
@@ -66,19 +66,6 @@
  *
  **********************************************************************/
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -1182,7 +1169,7 @@
 	}
 	pos = (unsigned long)se401->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up(&se401->lock);
 			return -EAGAIN;
drivers/usb/media/stv680.c +1 -14
Index: mm1-2.6.8.1/drivers/usb/media/stv680.c
===================================================================
@@ -119,19 +119,6 @@
  * And the STV0680 driver - Kevin
  ********************************************************************/
 
-/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-static inline unsigned long kvirt_to_pa (unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *rvmalloc (unsigned long size)
 {
 	void *mem;
@@ -1292,7 +1279,7 @@
 	}
 	pos = (unsigned long) stv680->fbuf;
 	while (size > 0) {
-		page = kvirt_to_pa (pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range (vma, start, page, PAGE_SIZE, PAGE_SHARED)) {
 			up (&stv680->lock);
 			return -EAGAIN;
drivers/usb/media/usbvideo.c +1 -15
Index: mm1-2.6.8.1/drivers/usb/media/usbvideo.c
===================================================================
@@ -61,20 +61,6 @@
 /* Memory management functions */
 /*******************************/
 
-/*
- * Here we want the physical address of the memory.
- * This is used when initializing the contents of the area.
- */
-unsigned long usbvideo_kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 static void *usbvideo_rvmalloc(unsigned long size)
 {
 	void *mem;
@@ -1168,7 +1154,7 @@
 
 	pos = (unsigned long) uvd->fbuf;
 	while (size > 0) {
-		page = usbvideo_kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 
drivers/usb/media/vicam.c +1 -11
Index: mm1-2.6.8.1/drivers/usb/media/vicam.c
===================================================================
@@ -351,16 +351,6 @@
 	0x46, 0x05, 0x6C, 0x05, 0x00, 0x00
 };
 
-static unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
 /* rvmalloc / rvfree copied from usbvideo.c
  *
  * Not sure why these are not yet non-statics which I can reference through
@@ -1055,7 +1045,7 @@
 
 	pos = (unsigned long)cam->framebuf;
 	while (size > 0) {
-		page = kvirt_to_pa(pos);
+		page = page_to_pfn(vmalloc_to_page((void *)pos));
 		if (remap_page_range(vma, start, page, PAGE_SIZE, PAGE_SHARED))
 			return -EAGAIN;
 
drivers/usb/media/w9968cf.c +1 -15
Index: mm1-2.6.8.1/drivers/usb/media/w9968cf.c
===================================================================
@@ -457,7 +457,6 @@
                                unsigned long arg);
 
 /* Memory management */
-static inline unsigned long kvirt_to_pa(unsigned long adr);
 static void* rvmalloc(unsigned long size);
 static void rvfree(void *mem, unsigned long size);
 static void w9968cf_deallocate_memory(struct w9968cf_device*);
@@ -612,19 +611,6 @@
  * Memory management functions                                              *
  ****************************************************************************/
 
-/* Here we want the physical address of the memory.
-   This is used when initializing the contents of the area. */
-static inline unsigned long kvirt_to_pa(unsigned long adr)
-{
-	unsigned long kva, ret;
-
-	kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
-	kva |= adr & (PAGE_SIZE-1); /* restore the offset */
-	ret = __pa(kva);
-	return ret;
-}
-
-
 static void* rvmalloc(unsigned long size)
 {
 	void* mem;
@@ -2919,7 +2905,7 @@
 		return -EINVAL;
 
 	while (vsize > 0) {
-		page = kvirt_to_pa(pos) + vma->vm_pgoff;
+		page = page_to_pfn(vmalloc_to_page((void *)pos))+vma->vm_pgoff;
 		if (remap_page_range(vma, start, page, PAGE_SIZE, 
 		                     vma->vm_page_prot))
 			return -EAGAIN;
drivers/video/aty/atyfb_base.c +2 -2
Index: mm1-2.6.8.1/drivers/video/aty/atyfb_base.c
===================================================================
@@ -1174,8 +1174,8 @@
 		    ~(par->mmap_map[i].prot_mask);
 		pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag;
 
-		if (remap_page_range(vma, vma->vm_start + page, map_offset,
-				     map_size, vma->vm_page_prot))
+		if (remap_page_range(vma, vma->vm_start + page,
+			map_offset >> PAGE_SHIFT, map_size, vma->vm_page_prot))
 			return -EAGAIN;
 
 		page += map_size;
drivers/video/gbefb.c +1 -1
Index: mm1-2.6.8.1/drivers/video/gbefb.c
===================================================================
@@ -1019,7 +1019,7 @@
 			phys_size = TILE_SIZE - offset;
 
 		if (remap_page_range
-		    (vma, addr, phys_addr, phys_size, vma->vm_page_prot))
+		    (vma, addr, phys_addr >> PAGE_SHIFT, phys_size, vma->vm_page_prot))
 			return -EAGAIN;
 
 		offset = 0;
drivers/video/igafb.c +1 -1
Index: mm1-2.6.8.1/drivers/video/igafb.c
===================================================================
@@ -262,7 +262,7 @@
 		pgprot_val(vma->vm_page_prot) &= ~(par->mmap_map[i].prot_mask);
 		pgprot_val(vma->vm_page_prot) |= par->mmap_map[i].prot_flag;
 
-		if (remap_page_range(vma, vma->vm_start + page, map_offset,
+		if (remap_page_range(vma, vma->vm_start + page, map_offset >> PAGE_SHIFT,
 				     map_size, vma->vm_page_prot))
 			return -EAGAIN;
 
drivers/video/sgivwfb.c +1 -1
Index: mm1-2.6.8.1/drivers/video/sgivwfb.c
===================================================================
@@ -723,7 +723,7 @@
 	    pgprot_val(vma->vm_page_prot) | _PAGE_PCD;
 	vma->vm_flags |= VM_IO;
 	if (remap_page_range
-	    (vma, vma->vm_start, offset, size, vma->vm_page_prot))
+	    (vma, vma->vm_start, offset >> PAGE_SHIFT, size, vma->vm_page_prot))
 		return -EAGAIN;
 	vma->vm_file = file;
 	printk(KERN_DEBUG "sgivwfb: mmap framebuffer P(%lx)->V(%lx)\n",
include/asm-alpha/pgtable.h +1 -1
Index: mm1-2.6.8.1/include/asm-alpha/pgtable.h
===================================================================
@@ -328,7 +328,7 @@
 #endif
 
 #define io_remap_page_range(vma, start, busaddr, size, prot) \
-    remap_page_range(vma, start, virt_to_phys(__ioremap(busaddr, size)), size, prot)
+    remap_page_range(vma, start, virt_to_phys(__ioremap(busaddr, size)) >> PAGE_SHIFT, size, prot)
 
 #define pte_ERROR(e) \
 	printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
include/asm-arm/pgtable.h +1 -1
Index: mm1-2.6.8.1/include/asm-arm/pgtable.h
===================================================================
@@ -412,7 +412,7 @@
  * into virtual address `from'
  */
 #define io_remap_page_range(vma,from,phys,size,prot) \
-		remap_page_range(vma,from,phys,size,prot)
+		remap_page_range(vma,from,(phys) >> PAGE_SHIFT,size,prot)
 
 #define pgtable_cache_init() do { } while (0)
 
include/asm-arm26/pgtable.h +1 -1
Index: mm1-2.6.8.1/include/asm-arm26/pgtable.h
===================================================================
@@ -288,7 +288,7 @@
  * into virtual address `from'
  */
 #define io_remap_page_range(vma,from,phys,size,prot) \
-		remap_page_range(vma,from,phys,size,prot)
+		remap_page_range(vma, from, (phys) >> PAGE_SHIFT, size, prot)
 
 #endif /* !__ASSEMBLY__ */
 
include/asm-h8300/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-h8300/pgtable.h
===================================================================
@@ -50,7 +50,8 @@
  * No page table caches to initialise
  */
 #define pgtable_cache_init()   do { } while (0)
-#define io_remap_page_range	remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * All 32bit addresses are effectively valid for vmalloc...
include/asm-i386/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-i386/pgtable.h
===================================================================
@@ -404,7 +404,8 @@
 #define kern_addr_valid(addr)	(1)
 #endif /* !CONFIG_DISCONTIGMEM */
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
 #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
include/asm-ia64/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-ia64/pgtable.h
===================================================================
@@ -452,7 +452,8 @@
 #define pte_to_pgoff(pte)		((pte_val(pte) << 1) >> 3)
 #define pgoff_to_pte(off)		((pte_t) { ((off) << 2) | _PAGE_FILE })
 
-#define io_remap_page_range remap_page_range	/* XXX is this right? */
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * ZERO_PAGE is a global shared page that is always zero: used
include/asm-m68k/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-m68k/pgtable.h
===================================================================
@@ -138,7 +138,8 @@
 
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /* MMU-specific headers */
 
include/asm-m68knommu/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-m68knommu/pgtable.h
===================================================================
@@ -54,7 +54,8 @@
  * No page table caches to initialise.
  */
 #define pgtable_cache_init()	do { } while (0)
-#define io_remap_page_range	remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * All 32bit addresses are effectively valid for vmalloc...
include/asm-mips/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-mips/pgtable.h
===================================================================
@@ -245,7 +245,8 @@
  */
 #define HAVE_ARCH_UNMAPPED_AREA
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * No page table caches to initialise
include/asm-parisc/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-parisc/pgtable.h
===================================================================
@@ -505,7 +505,8 @@
 
 #endif /* !__ASSEMBLY__ */
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /* We provide our own get_unmapped_area to provide cache coherency */
 
include/asm-ppc/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-ppc/pgtable.h
===================================================================
@@ -714,7 +714,8 @@
 /* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * No page table caches to initialise
include/asm-ppc64/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-ppc64/pgtable.h
===================================================================
@@ -485,7 +485,8 @@
  */
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range 
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		 remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 void pgtable_cache_init(void);
 
include/asm-sh/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-sh/pgtable.h
===================================================================
@@ -274,7 +274,8 @@
 
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 /*
  * No page table caches to initialise
include/asm-sh64/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-sh64/pgtable.h
===================================================================
@@ -479,7 +479,8 @@
 #define PageSkip(page)		(0)
 #define kern_addr_valid(addr)	(1)
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 #endif /* !__ASSEMBLY__ */
 
 /*
include/asm-x86_64/pgtable.h +2 -1
Index: mm1-2.6.8.1/include/asm-x86_64/pgtable.h
===================================================================
@@ -421,7 +421,8 @@
 
 extern int kern_addr_valid(unsigned long addr); 
 
-#define io_remap_page_range remap_page_range
+#define io_remap_page_range(vma, vaddr, phys, size, prot) \
+		 remap_page_range(vma, vaddr, (phys) >> PAGE_SHIFT, size, prot)
 
 #define HAVE_ARCH_UNMAPPED_AREA
 
mm/memory.c +7 -9
Index: mm1-2.6.8.1/mm/memory.c
===================================================================
@@ -931,16 +931,14 @@
  * in null mappings (currently treated as "copy-on-access")
  */
 static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
-	unsigned long phys_addr, pgprot_t prot)
+	unsigned long pfn, pgprot_t prot)
 {
 	unsigned long end;
-	unsigned long pfn;
 
 	address &= ~PMD_MASK;
 	end = address + size;
 	if (end > PMD_SIZE)
 		end = PMD_SIZE;
-	pfn = phys_addr >> PAGE_SHIFT;
 	do {
 		BUG_ON(!pte_none(*pte));
 		if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
@@ -952,7 +950,7 @@
 }
 
 static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
-	unsigned long phys_addr, pgprot_t prot)
+	unsigned long pfn, pgprot_t prot)
 {
 	unsigned long base, end;
 
@@ -961,12 +959,12 @@
 	end = address + size;
 	if (end > PGDIR_SIZE)
 		end = PGDIR_SIZE;
-	phys_addr -= address;
+	pfn -= address >> PAGE_SHIFT;
 	do {
 		pte_t * pte = pte_alloc_map(mm, pmd, base + address);
 		if (!pte)
 			return -ENOMEM;
-		remap_pte_range(pte, base + address, end - address, address + phys_addr, prot);
+		remap_pte_range(pte, base + address, end - address, pfn + (address >> PAGE_SHIFT), prot);
 		pte_unmap(pte);
 		address = (address + PMD_SIZE) & PMD_MASK;
 		pmd++;
@@ -975,7 +973,7 @@
 }
 
 /*  Note: this is only safe if the mm semaphore is held when called. */
-int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long phys_addr, unsigned long size, pgprot_t prot)
+int remap_page_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot)
 {
 	int error = 0;
 	pgd_t * dir;
@@ -983,7 +981,7 @@
 	unsigned long end = from + size;
 	struct mm_struct *mm = vma->vm_mm;
 
-	phys_addr -= from;
+	pfn -= from >> PAGE_SHIFT;
 	dir = pgd_offset(mm, from);
 	flush_cache_range(vma, beg, end);
 	if (from >= end)
@@ -995,7 +993,7 @@
 		error = -ENOMEM;
 		if (!pmd)
 			break;
-		error = remap_pmd_range(mm, pmd, from, end - from, phys_addr + from, prot);
+		error = remap_pmd_range(mm, pmd, from, end - from, pfn + (from >> PAGE_SHIFT), prot);
 		if (error)
 			break;
 		from = (from + PGDIR_SIZE) & PGDIR_MASK;
net/packet/af_packet.c +2 -1
Index: mm1-2.6.8.1/net/packet/af_packet.c
===================================================================
@@ -1720,7 +1720,8 @@
 	start = vma->vm_start;
 	err = -EAGAIN;
 	for (i=0; i<po->pg_vec_len; i++) {
-		if (remap_page_range(vma, start, __pa(po->pg_vec[i]),
+		if (remap_page_range(vma, start,
+				     __pa(po->pg_vec[i]) >> PAGE_SHIFT,
 				     po->pg_vec_pages*PAGE_SIZE,
 				     vma->vm_page_prot))
 			goto out;
sound/oss/ali5455.c +1 -1
Index: mm1-2.6.8.1/sound/oss/ali5455.c
===================================================================
@@ -1956,7 +1956,7 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(dmabuf->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
 	dmabuf->trigger = 0;
sound/oss/au1000.c +1 -1
Index: mm1-2.6.8.1/sound/oss/au1000.c
===================================================================
@@ -1338,7 +1338,7 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma->vm_start, virt_to_phys(db->rawbuf),
+	if (remap_page_range(vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
sound/oss/cmpci.c +1 -1
Index: mm1-2.6.8.1/sound/oss/cmpci.c
===================================================================
@@ -2301,7 +2301,7 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EINVAL;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
sound/oss/cs4281/cs4281m.c +1 -1
Index: mm1-2.6.8.1/sound/oss/cs4281/cs4281m.c
===================================================================
@@ -3136,7 +3136,7 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		return -EINVAL;
 	if (remap_page_range
-	    (vma, vma->vm_start, virt_to_phys(db->rawbuf), size,
+	    (vma, vma->vm_start, virt_to_phys(db->rawbuf) >> PAGE_SHIFT, size,
 	     vma->vm_page_prot)) return -EAGAIN;
 	db->mapped = 1;
 
sound/oss/cs46xx.c +2 -2
Index: mm1-2.6.8.1/sound/oss/cs46xx.c
===================================================================
@@ -2453,8 +2453,8 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
-			     size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start,
+		__pa(dmabuf->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 	{
 		ret = -EAGAIN;
 		goto out;
sound/oss/es1370.c +2 -2
Index: mm1-2.6.8.1/sound/oss/es1370.c
===================================================================
@@ -1364,7 +1364,7 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
 	}
@@ -1940,7 +1940,7 @@
 	if (size > (PAGE_SIZE << s->dma_dac1.buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(s->dma_dac1.rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	s->dma_dac1.mapped = 1;
 	ret = 0;
sound/oss/es1371.c +2 -2
Index: mm1-2.6.8.1/sound/oss/es1371.c
===================================================================
@@ -1555,7 +1555,7 @@
 		ret = -EINVAL;
 		goto out;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 		ret = -EAGAIN;
 		goto out;
 	}
@@ -2128,7 +2128,7 @@
 	if (size > (PAGE_SIZE << s->dma_dac1.buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(s->dma_dac1.rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	s->dma_dac1.mapped = 1;
 	ret = 0;
sound/oss/esssolo1.c +1 -1
Index: mm1-2.6.8.1/sound/oss/esssolo1.c
===================================================================
@@ -1242,7 +1242,7 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
sound/oss/forte.c +1 -1
Index: mm1-2.6.8.1/sound/oss/forte.c
===================================================================
@@ -1410,7 +1410,7 @@
                 goto out;
 	}
 
-        if (remap_page_range (vma, vma->vm_start, virt_to_phys (channel->buf),
+        if (remap_page_range (vma, vma->vm_start, __pa(channel->buf) >> PAGE_SHIFT,
 			      size, vma->vm_page_prot)) {
 		DPRINTK ("%s: remap el a no worko\n", __FUNCTION__);
 		ret = -EAGAIN;
sound/oss/i810_audio.c +1 -1
Index: mm1-2.6.8.1/sound/oss/i810_audio.c
===================================================================
@@ -1751,7 +1751,7 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_page_range(vma, vma->vm_start, __pa(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
sound/oss/ite8172.c +1 -1
Index: mm1-2.6.8.1/sound/oss/ite8172.c
===================================================================
@@ -1311,7 +1311,7 @@
 		unlock_kernel();
 		return -EINVAL;
 	}
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf),
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot)) {
 		unlock_kernel();
 		return -EAGAIN;
sound/oss/maestro.c +1 -1
Index: mm1-2.6.8.1/sound/oss/maestro.c
===================================================================
@@ -2520,7 +2520,7 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
sound/oss/maestro3.c +1 -1
Index: mm1-2.6.8.1/sound/oss/maestro3.c
===================================================================
@@ -1557,7 +1557,7 @@
      * ask Jeff what the hell I'm doing wrong.
      */
     ret = -EAGAIN;
-    if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+    if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
         goto out;
 
     db->mapped = 1;
sound/oss/rme96xx.c +2 -2
Index: mm1-2.6.8.1/sound/oss/rme96xx.c
===================================================================
@@ -1685,14 +1685,14 @@
 	if (vma->vm_flags & VM_WRITE) {
 		if (!s->started) rme96xx_startcard(s,1);
 
-		if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->outoffset*RME96xx_DMA_MAX_SIZE), size, vma->vm_page_prot)) {
+		if (remap_page_range(vma, vma->vm_start, __pa(s->playbuf + dma->outoffset*RME96xx_DMA_MAX_SIZE) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 			unlock_kernel();
 			return -EAGAIN;
 		}
 	} 
 	else if (vma->vm_flags & VM_READ) {
 		if (!s->started) rme96xx_startcard(s,1);
-		if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->playbuf + dma->inoffset*RME96xx_DMA_MAX_SIZE), size, vma->vm_page_prot)) {
+		if (remap_page_range(vma, vma->vm_start, __pa(s->playbuf + dma->inoffset*RME96xx_DMA_MAX_SIZE) >> PAGE_SHIFT, size, vma->vm_page_prot)) {
 			unlock_kernel();
 			return -EAGAIN;
 		}
sound/oss/sonicvibes.c +1 -1
Index: mm1-2.6.8.1/sound/oss/sonicvibes.c
===================================================================
@@ -1549,7 +1549,7 @@
 	if (size > (PAGE_SIZE << db->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot))
+	if (remap_page_range(vma, vma->vm_start, __pa(db->rawbuf) >> PAGE_SHIFT, size, vma->vm_page_prot))
 		goto out;
 	db->mapped = 1;
 	ret = 0;
sound/oss/trident.c +1 -1
Index: mm1-2.6.8.1/sound/oss/trident.c
===================================================================
@@ -2224,7 +2224,7 @@
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), 
+	if (remap_page_range(vma, vma->vm_start, __pa(dmabuf->rawbuf) >> PAGE_SHIFT, 
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
sound/oss/ymfpci.c +1 -1
Index: mm1-2.6.8.1/sound/oss/ymfpci.c
===================================================================
@@ -1545,7 +1545,7 @@
 	size = vma->vm_end - vma->vm_start;
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		return -EINVAL;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_page_range(vma, vma->vm_start, __pa(dmabuf->rawbuf) >> PAGE_SHIFT,
 			     size, vma->vm_page_prot))
 		return -EAGAIN;
 	dmabuf->mapped = 1;
#12 lore raw
Quoted 2 lines · On Wed, 18 Aug 2004 19:38:48 -0700 William Lee Irwin III <[email protected]>…

Oddly, the sparc64 case seems to be the most difficult one for the io_remap_page_range() sweep...

Oh yeah, that's due to the large TLB mapping support isn't it?

#13 lore raw
Quoted 2 lines · On Wed, 18 Aug 2004 19:38:48 -0700 William Lee Irwin III wrote:
Quoted 2 lines

Oddly, the sparc64 case seems to be the most difficult one for the io_remap_page_range() sweep...

Quoted 2 lines · David S. Miller

Oh yeah, that's due to the large TLB mapping support isn't it?

It could be ... most of the pain was centered around testing bits inside of offset & ~PAGE_MASK, which, when the physical address offset corresponds to is recovered from a pfn, are necessarily all zero.

-- wli

#14 lore raw
In reply to William Lee Irwin III
Quoted 11 lines · William Lee Irwin III
Quoted 1 line · On Wed, 18 Aug 2004 13:53:38 -0700 William Lee Irwin III wrote:
Quoted 1 line

Once it's decided how many it really takes, I'll fix up sparc32 as-needed.

Quoted 6 lines · David S. Miller

(sorry for the emply reply previously)
It needs 6 unless we start passing in a 64-bit value to io_remap_page_range()
for the 'offset' parameter.
Physical I/O addresses are 36-bits or so on sparc32 systems, which is why we need to pass in "offset" and "space".

Maybe a pointer?

Quoted 6 lines

We should pass 64-bit values to remap_page_range() also, then. Or perhaps passing pfn's to both suffices, as it all has to be page aligned anyway.

-- wli

With a pointer to some kind of descriptor (structure), the arch-dependent pointer size is handled by the compiler/linker and the arch-dependent content is handled with the arch-dependent header defining the structure. You get to keep both pieces and they don't break when porting to a new box.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.

#15 lore raw
In reply to Paul Jackson
Quoted 1 line · On Wed, 18 Aug 2004 13:33:48 -0700 Paul Jackson <[email protected]> wrote:

Does anyone know the story behind this odd inconsistency?

Each platform needs different args, unfortunately.

Sparc needs the extra arg because the device space is described with a base 32-bit address, then an upper 32-bit base to form the full 64-bit address. This upper 32-bit part is called the "io_space" and thus is what gets passed into that 6-th argument.

#16 lore raw
Quoted 1 line · Dave Miller

Each platform needs different args, unfortunately.

Doesn't that make it kinda rough on the folks trying to write arch-independent code, such as sound/core/pcm_native.c that I am tripping over?

I can imagine a possible 'solution' something like (1) always passing six args, and (2) providing arch-dependent macros to generate those last two args, from some arch-generic value.

Just brainstorming ...

Signature · 3 lines
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <[email protected]> 1.650.933.1373
#17 lore raw
Quoted 1 line · Dave Miller
Quoted 1 line

Each platform needs different args, unfortunately.

Quoted 7 lines · Paul Jackson

Doesn't that make it kinda rough on the folks trying to write arch-independent code, such as sound/core/pcm_native.c that I am tripping over?
I can imagine a possible 'solution' something like (1) always passing six args, and (2) providing arch-dependent macros to generate those last two args, from some arch-generic value.
Just brainstorming ...

This would not be useful. The extra argument is so that 64-bit values don't have to be passed. Keeping the minimal number of arguments and changing its meaning to be a pfn will suffice for the purposes here.

-- wli