Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/uebayasi-xip]: src/sys/uvm Teach device page handling.



details:   https://anonhg.NetBSD.org/src/rev/f2941ff49b23
branches:  uebayasi-xip
changeset: 751574:f2941ff49b23
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Feb 12 13:38:41 2010 +0000

description:
Teach device page handling.

diffstat:

 sys/uvm/uvm_bio.c    |  35 +++++++++++++++++++++++++++++------
 sys/uvm/uvm_loan.c   |  11 ++++++++---
 sys/uvm/uvm_object.c |   7 +++++--
 3 files changed, 42 insertions(+), 11 deletions(-)

diffs (171 lines):

diff -r bd56d4f89642 -r f2941ff49b23 sys/uvm/uvm_bio.c
--- a/sys/uvm/uvm_bio.c Fri Feb 12 04:33:05 2010 +0000
+++ b/sys/uvm/uvm_bio.c Fri Feb 12 13:38:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_bio.c,v 1.68 2009/11/07 07:27:49 cegger Exp $      */
+/*     $NetBSD: uvm_bio.c,v 1.68.2.1 2010/02/12 13:38:41 uebayasi Exp $        */
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,10 +34,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68 2009/11/07 07:27:49 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.68.2.1 2010/02/12 13:38:41 uebayasi Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
+#include "opt_xip.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -335,7 +336,13 @@
                        continue;
                }
 
-               uobj = pg->uobject;
+               if (uvm_pageisdevice_p(pg)) {
+                       UVMHIST_LOG(ubchist, "pg is device", i, 0,0,0);
+                       goto ubc_fault_enter;
+               }
+
+               KASSERT(uobj == pg->uobject);
+                       
                mutex_enter(&uobj->vmobjlock);
                if (pg->flags & PG_WANTED) {
                        wakeup(pg);
@@ -371,26 +378,37 @@
                        }
                }
 
+ubc_fault_enter:
                /*
                 * note that a page whose backing store is partially allocated
                 * is marked as PG_RDONLY.
                 */
 
-               rdonly = ((access_type & VM_PROT_WRITE) == 0 &&
-                   (pg->flags & PG_RDONLY) != 0) ||
+               /* XXXUEBS device pages are always read-only for now */
+               rdonly = uvm_pageisdevice_p(pg) ||
+                   ((access_type & VM_PROT_WRITE) == 0 &&
+                    (pg->flags & PG_RDONLY) != 0) ||
                    UVM_OBJ_NEEDS_WRITEFAULT(uobj);
-               KASSERT((pg->flags & PG_RDONLY) == 0 ||
+               KASSERT(uvm_pageisdevice_p(pg) ||
+                   (pg->flags & PG_RDONLY) == 0 ||
                    (access_type & VM_PROT_WRITE) == 0 ||
                    pg->offset < umap->writeoff ||
                    pg->offset + PAGE_SIZE > umap->writeoff + umap->writelen);
                mask = rdonly ? ~VM_PROT_WRITE : VM_PROT_ALL;
+
                error = pmap_enter(ufi->orig_map->pmap, va, VM_PAGE_TO_PHYS(pg),
                    prot & mask, PMAP_CANFAIL | (access_type & mask));
+
+               if (uvm_pageisdevice_p(pg))
+                       goto ubc_fault_done;
+
                mutex_enter(&uvm_pageqlock);
                uvm_pageactivate(pg);
                mutex_exit(&uvm_pageqlock);
                pg->flags &= ~(PG_BUSY|PG_WANTED);
                UVM_PAGE_OWN(pg, NULL);
+
+ubc_fault_done:
                mutex_exit(&uobj->vmobjlock);
                if (error) {
                        UVMHIST_LOG(ubchist, "pmap_enter fail %d",
@@ -532,6 +550,9 @@
                for (i = 0; i < npages; i++) {
                        struct vm_page *pg = pgs[i];
 
+                       if (uvm_pageisdevice_p(pg))
+                               goto uvm_alloc_enter;
+
                        KASSERT(pg->uobject == uobj);
                        if (pg->loan_count != 0) {
                                mutex_enter(&uobj->vmobjlock);
@@ -550,6 +571,8 @@
                                }
                                pgs[i] = pg;
                        }
+
+uvm_alloc_enter:
                        pmap_kenter_pa(va + slot_offset + (i << PAGE_SHIFT),
                            VM_PAGE_TO_PHYS(pg),
                            VM_PROT_READ | VM_PROT_WRITE, 0);
diff -r bd56d4f89642 -r f2941ff49b23 sys/uvm/uvm_loan.c
--- a/sys/uvm/uvm_loan.c        Fri Feb 12 04:33:05 2010 +0000
+++ b/sys/uvm/uvm_loan.c        Fri Feb 12 13:38:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_loan.c,v 1.77 2010/02/03 14:02:49 uebayasi Exp $   */
+/*     $NetBSD: uvm_loan.c,v 1.77.2.1 2010/02/12 13:39:10 uebayasi Exp $       */
 
 /*
  *
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.77 2010/02/03 14:02:49 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_loan.c,v 1.77.2.1 2010/02/12 13:39:10 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -540,6 +540,10 @@
                }
                if (error)
                        goto fail;
+               if (uvm_pageisdevice_p(pgpp[0])) {
+                       error = EBUSY;
+                       goto fail2;
+               }
 
                KASSERT(npages > 0);
 
@@ -606,6 +610,7 @@
 fail:
        uvm_unloan(origpgpp, ndone, UVM_LOAN_TOPAGE);
 
+fail2:
        return error;
 }
 
@@ -657,7 +662,7 @@
         * then we fail the loan.
         */
 
-       if (error && error != EBUSY) {
+       if ((error && error != EBUSY) || uvm_pageisdevice_p(pg)) {
                uvmfault_unlockall(ufi, amap, uobj, NULL);
                return (-1);
        }
diff -r bd56d4f89642 -r f2941ff49b23 sys/uvm/uvm_object.c
--- a/sys/uvm/uvm_object.c      Fri Feb 12 04:33:05 2010 +0000
+++ b/sys/uvm/uvm_object.c      Fri Feb 12 13:38:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_object.c,v 1.7 2009/08/18 19:16:09 thorpej Exp $   */
+/*     $NetBSD: uvm_object.c,v 1.7.2.1 2010/02/12 13:39:26 uebayasi Exp $      */
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.7 2009/08/18 19:16:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_object.c,v 1.7.2.1 2010/02/12 13:39:26 uebayasi Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvmhist.h"
@@ -85,6 +85,9 @@
                mutex_enter(&uobj->vmobjlock);
                for (i = 0; i < npages; i++) {
 
+                       if (uvm_pageisdevice_p(pgs[i]))
+                               continue;
+
                        KASSERT(pgs[i] != NULL);
                        KASSERT(!(pgs[i]->flags & PG_RELEASED));
 



Home | Main Index | Thread Index | Old Index