From 9455b56ea676720d1c1595a98ce71583c9ed193e Mon Sep 17 00:00:00 2001 From: William Lee Irwin III Date: Tue, 19 Oct 2004 18:28:15 -0700 Subject: [PATCH] [PATCH] vm: convert references to remap_page_range() under arch/ and Documentation/ to remap_pfn_range() This patch converts all callers of remap_page_range() under arch/ and all references in Documentation/ to use remap_pfn_range(). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/IO-mapping.txt | 7 ++++--- arch/arm/kernel/bios32.c | 4 ++-- arch/i386/pci/i386.c | 2 +- arch/ia64/kernel/perfmon.c | 26 ++++---------------------- arch/ia64/pci/pci.c | 2 +- arch/ppc/kernel/pci.c | 2 +- arch/ppc64/kernel/pci.c | 2 +- arch/ppc64/kernel/proc_ppc64.c | 3 ++- arch/sparc/mm/generic.c | 2 +- arch/sparc64/mm/generic.c | 2 +- arch/um/drivers/mmapper_kern.c | 4 ++-- 11 files changed, 20 insertions(+), 36 deletions(-) diff --git a/Documentation/IO-mapping.txt b/Documentation/IO-mapping.txt index ddc8173465e91..86edb61bdee62 100644 --- a/Documentation/IO-mapping.txt +++ b/Documentation/IO-mapping.txt @@ -119,9 +119,10 @@ you can't use it from the bus master. So why do we care about the physical address at all? We do need the physical address in some cases, it's just not very often in normal code. The physical address is needed if you use memory mappings, for example, because the -"remap_page_range()" mm function wants the physical address of the memory to -be remapped (the memory management layer doesn't know about devices outside -the CPU, so it shouldn't need to know about "bus addresses" etc). +"remap_pfn_range()" mm function wants the physical address of the memory to +be remapped as measured in units of pages, a.k.a. the pfn (the memory +management layer doesn't know about devices outside the CPU, so it +shouldn't need to know about "bus addresses" etc). NOTE NOTE NOTE! The above is only one part of the whole equation. The above only talks about "real memory", that is, CPU memory (RAM). diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index ab29858771db8..6b2a9bb9f16db 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -681,7 +681,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, if (mmap_state == pci_mmap_io) { return -EINVAL; } else { - phys = root->mem_offset + (vma->vm_pgoff << PAGE_SHIFT); + phys = vma->vm_pgoff + (root->mem_offset >> PAGE_SHIFT); } /* @@ -690,7 +690,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 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_pfn_range(vma, vma->vm_start, phys, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c index c1363f879201c..7a7b35a375d8d 100644 --- a/arch/i386/pci/i386.c +++ b/arch/i386/pci/i386.c @@ -295,7 +295,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, /* 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_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 2685e6ea8bbd2..8561f8dcffba9 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -572,12 +572,6 @@ pfm_unreserve_page(unsigned long a) ClearPageReserved(vmalloc_to_page((void*)a)); } -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); -} - static inline unsigned long pfm_protect_ctx_ctxsw(pfm_context_t *x) { @@ -805,18 +799,6 @@ pfm_reset_msgq(pfm_context_t *ctx) DPRINT(("ctx=%p msgq reset\n", ctx)); } - -/* Here we want the physical address of the memory. - * This is used when initializing the contents of the - * area and marking the pages as reserved. - */ -static inline unsigned long -pfm_kvirt_to_pa(unsigned long adr) -{ - __u64 pa = ia64_tpa(adr); - return pa; -} - static void * pfm_rvmalloc(unsigned long size) { @@ -2244,14 +2226,14 @@ pfm_free_fd(int fd, struct file *file) static int pfm_remap_buffer(struct vm_area_struct *vma, unsigned long buf, unsigned long addr, unsigned long size) { - unsigned long page; - DPRINT(("CPU%d buf=0x%lx addr=0x%lx size=%ld\n", smp_processor_id(), buf, addr, size)); while (size > 0) { - page = pfm_kvirt_to_pa(buf); + unsigned long pfn = ia64_tpa(buf) >> PAGE_SHIFT; + - if (pfm_remap_page_range(vma, addr, page, PAGE_SIZE, PAGE_READONLY)) return -ENOMEM; + if (remap_pfn_range(vma, addr, pfn, PAGE_SIZE, PAGE_READONLY)) + return -ENOMEM; addr += PAGE_SIZE; buf += PAGE_SIZE; diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 65950d60c344e..e05cb70172bef 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -474,7 +474,7 @@ pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, 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_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c index 746983d91307a..0f1eee33cb877 100644 --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -1591,7 +1591,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, __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_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot); return ret; diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c index 9c5e823aaa0cc..0dd1459d13f99 100644 --- a/arch/ppc64/kernel/pci.c +++ b/arch/ppc64/kernel/pci.c @@ -534,7 +534,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, __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_pfn_range(vma, vma->vm_start, vma->vm_pgoff, vma->vm_end - vma->vm_start, vma->vm_page_prot); return ret; diff --git a/arch/ppc64/kernel/proc_ppc64.c b/arch/ppc64/kernel/proc_ppc64.c index ed172cd78344d..3cff4fd0152e3 100644 --- a/arch/ppc64/kernel/proc_ppc64.c +++ b/arch/ppc64/kernel/proc_ppc64.c @@ -176,7 +176,8 @@ static int page_map_mmap( struct file *file, struct vm_area_struct *vma ) 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_pfn_range(vma, vma->vm_start, __pa(dp->data) >> PAGE_SHIFT, + dp->size, vma->vm_page_prot); return 0; } diff --git a/arch/sparc/mm/generic.c b/arch/sparc/mm/generic.c index 6d2febb040b02..f4c6851b5c1a0 100644 --- a/arch/sparc/mm/generic.c +++ b/arch/sparc/mm/generic.c @@ -41,7 +41,7 @@ static inline void forget_pte(pte_t page) #endif } -/* Remap IO memory, the same way as remap_page_range(), but use +/* Remap IO memory, the same way as remap_pfn_range(), but use * the obio memory space. * * They use a pgprot that sets PAGE_IO and does not check the diff --git a/arch/sparc64/mm/generic.c b/arch/sparc64/mm/generic.c index 149dc1b4c4846..4d3ed8b9ae05a 100644 --- a/arch/sparc64/mm/generic.c +++ b/arch/sparc64/mm/generic.c @@ -23,7 +23,7 @@ static inline void forget_pte(pte_t page) } } -/* Remap IO memory, the same way as remap_page_range(), but use +/* Remap IO memory, the same way as remap_pfn_range(), but use * the obio memory space. * * They use a pgprot that sets PAGE_IO and does not check the diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c index 1862691b91469..3138464344c33 100644 --- a/arch/um/drivers/mmapper_kern.c +++ b/arch/um/drivers/mmapper_kern.c @@ -81,10 +81,10 @@ mmapper_mmap(struct file *file, struct vm_area_struct * vma) size = vma->vm_end - vma->vm_start; if(size > mmapper_size) return(-EFAULT); - /* XXX A comment above remap_page_range says it should only be + /* XXX A comment above remap_pfn_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_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size, vma->vm_page_prot)) goto out; ret = 0; -- 2.53.0