public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: John Fusco <fusco_john@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: [vm 1/4] convert remap_page_range() to remap_pfn_range()
Date: Thu, 23 Sep 2004 19:19:54 -0700	[thread overview]
Message-ID: <20040924021954.GM9106@holomorphy.com> (raw)
In-Reply-To: <20040924021735.GL9106@holomorphy.com>

On Thu, Sep 23, 2004 at 07:17:35PM -0700, William Lee Irwin III wrote:
> Do these patches work for you? Compiletested on sparc64.

Convert remap_page_range() to remap_pfn_range(), with a temporary
remap_page_range() wrapper inline (to be eliminated in the sequel).

Index: mm2-2.6.9-rc2/mm/memory.c
===================================================================
--- mm2-2.6.9-rc2.orig/mm/memory.c	2004-09-22 21:32:52.000000000 -0700
+++ mm2-2.6.9-rc2/mm/memory.c	2004-09-23 17:03:21.296806522 -0700
@@ -945,16 +945,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)))
@@ -966,7 +964,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;
 
@@ -975,12 +973,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++;
@@ -989,7 +987,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_pfn_range(struct vm_area_struct *vma, unsigned long from, unsigned long pfn, unsigned long size, pgprot_t prot)
 {
 	int error = 0;
 	pgd_t * dir;
@@ -997,7 +995,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)
@@ -1009,7 +1007,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;
@@ -1022,8 +1020,7 @@
 	spin_unlock(&mm->page_table_lock);
 	return error;
 }
-
-EXPORT_SYMBOL(remap_page_range);
+EXPORT_SYMBOL(remap_pfn_range);
 
 /*
  * Do pte_mkwrite, but only if the vma says VM_WRITE.  We do this when
Index: mm2-2.6.9-rc2/include/linux/mm.h
===================================================================
--- mm2-2.6.9-rc2.orig/include/linux/mm.h	2004-09-22 21:32:18.000000000 -0700
+++ mm2-2.6.9-rc2/include/linux/mm.h	2004-09-23 16:35:12.546535586 -0700
@@ -764,8 +764,16 @@
 extern struct page * vmalloc_to_page(void *addr);
 extern struct page * follow_page(struct mm_struct *mm, unsigned long address,
 		int write);
-extern int remap_page_range(struct vm_area_struct *vma, unsigned long from,
-		unsigned long to, unsigned long size, pgprot_t prot);
+int remap_pfn_range(struct vm_area_struct *vma, unsigned long uvaddr,
+		unsigned long pfn, unsigned long size, pgprot_t prot);
+
+static inline int remap_page_range(struct vm_area_struct *vma,
+					unsigned long uvaddr,
+					unsigned long paddr,
+					unsigned long size, pgprot_t prot)
+{
+	return remap_pfn_range(vma, uvaddr, paddr >> PAGE_SHIFT, size, prot);
+}
 
 #ifdef CONFIG_PROC_FS
 void __vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
Index: mm2-2.6.9-rc2/mm/nommu.c
===================================================================
--- mm2-2.6.9-rc2.orig/mm/nommu.c	2004-09-22 21:31:17.000000000 -0700
+++ mm2-2.6.9-rc2/mm/nommu.c	2004-09-23 16:38:50.608385146 -0700
@@ -560,8 +560,8 @@
 	return NULL;
 }
 
-int remap_page_range(struct vm_area_struct *vma, unsigned long from,
-		unsigned long to, unsigned long size, pgprot_t prot)
+int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
+		unsigned long pfn, unsigned long size, pgprot_t prot)
 {
 	return -EPERM;
 }
Index: mm2-2.6.9-rc2/Documentation/IO-mapping.txt
===================================================================
--- mm2-2.6.9-rc2.orig/Documentation/IO-mapping.txt	2004-09-12 22:32:00.000000000 -0700
+++ mm2-2.6.9-rc2/Documentation/IO-mapping.txt	2004-09-23 16:40:43.150276178 -0700
@@ -119,9 +119,10 @@
 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). 

  reply	other threads:[~2004-09-24  2:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <41535AAE.6090700@yahoo.com>
2004-09-24  2:17 ` [vm 0/4] replace remap_page_range() with remap_pfn_range() William Lee Irwin III
2004-09-24  2:19   ` William Lee Irwin III [this message]
2004-09-24  2:21     ` [vm 2/4] convert io_remap_page_range() to call remap_pfn_range() William Lee Irwin III
2004-09-24  2:23       ` [vm 3/4] convert direct callers of remap_page_range() William Lee Irwin III
2004-09-24  2:25         ` [vm 4/4] remove remap_page_range() William Lee Irwin III
2004-09-24  2:27         ` [vm 3/4] convert direct callers of remap_page_range() William Lee Irwin III
2004-09-24  3:29   ` [vm 0/4] replace remap_page_range() with remap_pfn_range() William Lee Irwin III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040924021954.GM9106@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=fusco_john@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox