Module Name:    src
Committed By:   uebayasi
Date:           Thu Nov 18 16:16:37 UTC 2010

Modified Files:
        src/sys/miscfs/genfs [uebayasi-xip]: genfs_io.c
        src/sys/uvm [uebayasi-xip]: uvm_extern.h uvm_vnode.c

Log Message:
Make XIP pager use cdev_mmap() instead of struct vm_physseg.


To generate a diff of this commit:
cvs rdiff -u -r1.36.2.33 -r1.36.2.34 src/sys/miscfs/genfs/genfs_io.c
cvs rdiff -u -r1.161.2.12 -r1.161.2.13 src/sys/uvm/uvm_extern.h
cvs rdiff -u -r1.93.2.3 -r1.93.2.4 src/sys/uvm/uvm_vnode.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/miscfs/genfs/genfs_io.c
diff -u src/sys/miscfs/genfs/genfs_io.c:1.36.2.33 src/sys/miscfs/genfs/genfs_io.c:1.36.2.34
--- src/sys/miscfs/genfs/genfs_io.c:1.36.2.33	Thu Nov 18 01:53:04 2010
+++ src/sys/miscfs/genfs/genfs_io.c	Thu Nov 18 16:16:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_io.c,v 1.36.2.33 2010/11/18 01:53:04 uebayasi Exp $	*/
+/*	$NetBSD: genfs_io.c,v 1.36.2.34 2010/11/18 16:16:36 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.33 2010/11/18 01:53:04 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.36.2.34 2010/11/18 16:16:36 uebayasi Exp $");
 
 #include "opt_xip.h"
 
@@ -880,7 +880,7 @@
 			blk_off = blkno << dev_bshift;
 			fs_off = off - (lbn << fs_bshift);
 
-			pps[i] = uvn_findpage_xip(&devvp->v_uobj,
+			pps[i] = uvn_findpage_xip(devvp, &vp->v_uobj,
 			    blk_off + fs_off);
 			KASSERT(pps[i] != NULL);
 		}

Index: src/sys/uvm/uvm_extern.h
diff -u src/sys/uvm/uvm_extern.h:1.161.2.12 src/sys/uvm/uvm_extern.h:1.161.2.13
--- src/sys/uvm/uvm_extern.h:1.161.2.12	Tue Nov 16 07:44:24 2010
+++ src/sys/uvm/uvm_extern.h	Thu Nov 18 16:16:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_extern.h,v 1.161.2.12 2010/11/16 07:44:24 uebayasi Exp $	*/
+/*	$NetBSD: uvm_extern.h,v 1.161.2.13 2010/11/18 16:16:36 uebayasi Exp $	*/
 
 /*
  *
@@ -763,7 +763,8 @@
 bool			uvn_text_p(struct uvm_object *);
 bool			uvn_clean_p(struct uvm_object *);
 bool			uvn_needs_writefault_p(struct uvm_object *);
-struct vm_page		*uvn_findpage_xip(struct uvm_object *, off_t);
+struct vm_page		*uvn_findpage_xip(struct vnode *,
+			    struct uvm_object *, off_t);
 
 /* kern_malloc.c */
 void			kmeminit_nkmempages(void);

Index: src/sys/uvm/uvm_vnode.c
diff -u src/sys/uvm/uvm_vnode.c:1.93.2.3 src/sys/uvm/uvm_vnode.c:1.93.2.4
--- src/sys/uvm/uvm_vnode.c:1.93.2.3	Tue Nov 16 07:44:25 2010
+++ src/sys/uvm/uvm_vnode.c	Thu Nov 18 16:16:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_vnode.c,v 1.93.2.3 2010/11/16 07:44:25 uebayasi Exp $	*/
+/*	$NetBSD: uvm_vnode.c,v 1.93.2.4 2010/11/18 16:16:36 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.93.2.3 2010/11/16 07:44:25 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_vnode.c,v 1.93.2.4 2010/11/18 16:16:36 uebayasi Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_xip.h"
@@ -412,12 +412,16 @@
  *	given offset.
  */
 struct vm_page *
-uvn_findpage_xip(struct uvm_object *uobj, off_t off)
+uvn_findpage_xip(struct vnode *devvp, struct uvm_object *uobj, off_t off)
 {
+#if defined(DIAGNOSTIC)
 	struct vnode *vp = (struct vnode *)uobj;
+#endif
 	struct vm_physseg *seg;
 	struct vm_page *pg;
 
+#if defined(XIP)
+#if !defined(XIP_CDEV_MMAP)
 	KASSERT((vp->v_vflag & VV_XIP) != 0);
 	KASSERT((off & PAGE_MASK) == 0);
 
@@ -431,10 +435,41 @@
 	 * uvm_object *, and this will call cdev_page(uobj, off).
 	 */
 
-	seg = vp->v_physseg;
+	seg = devvp->v_physseg;
 	KASSERT(seg != NULL);
 
 	pg = seg->pgs + (off >> PAGE_SHIFT);
+#else
+	dev_t dev;
+	paddr_t mdpgno, pa, pfn;
+	int segno, segidx;
+
+	KASSERT(vp != NULL);
+	KASSERT((vp->v_vflag & VV_XIP) != 0);
+	KASSERT((off & PAGE_MASK) == 0);
+
+	/*
+	 * Get an "mmap cookie" from device.
+	 */
+	dev = devsw_blk2chr(devvp->v_rdev);
+	mdpgno = cdev_mmap(dev, off, 0);
+	KASSERT(mdpgno != -1);
+
+	/*
+	 * Index the matching vm_page and return it the vnode pager
+	 * (genfs_getpages).
+	 */
+	pa = pmap_phys_address(mdpgno);
+	pfn = atop(pa);
+	segno = vm_physseg_find_device(pfn, &segidx);
+	seg = VM_PHYSDEV_PTR(segno);
+	KASSERT(seg != NULL);
+	KASSERT(segidx == pfn - seg->start);
+	KASSERT(seg->pgs != NULL);
+
+	pg = seg->pgs + segidx;
+#endif
+#endif
 
 	KASSERT(pg->phys_addr == (seg->start << PAGE_SHIFT) + off);
 

Reply via email to