Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 May 2007 06:32:41 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 119399 for review
Message-ID:  <200705070632.l476Wfuw029097@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119399

Change 119399 by kmacy@kmacy_vt-x:opentoe_init on 2007/05/07 06:31:40

	add routine to fault in and pin user pages with EXT_MBUF or kva mapping overhead

Affected files ...

.. //depot/projects/opentoe/sys/dev/cxgb/sys/mvec.h#2 edit
.. //depot/projects/opentoe/sys/dev/cxgb/sys/uipc_mvec.c#3 edit

Differences ...

==== //depot/projects/opentoe/sys/dev/cxgb/sys/mvec.h#2 (text+ko) ====

@@ -193,4 +193,6 @@
 #define bus_dmamap_load_mvec_sg bus_dmamap_load_mbuf_sg
 #endif
 
+int vm_user_page_get(vm_offset_t addr, int npages, vm_page_t *m, vm_paddr_t *paddr, int cow);
+
 #endif

==== //depot/projects/opentoe/sys/dev/cxgb/sys/uipc_mvec.c#3 (text+ko) ====

@@ -35,9 +35,11 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
+#include <sys/mutex.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/ktr.h>
+#include <sys/proc.h>
 #include <sys/sf_buf.h>
 
 #include <machine/bus.h>
@@ -45,8 +47,12 @@
 #include "opt_zero.h"
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+#include <vm/vm_map.h>
 #include <vm/vm_page.h>
-#include <vm/pmap.h>
+#include <vm/vm_object.h>
 
 #ifdef DEBUG
 #define DPRINTF printf
@@ -485,3 +491,44 @@
 	return (error);
 }
 #endif /* !__sparc64__  && !__sun4v__ */
+
+int
+vm_user_page_get(vm_offset_t addr, int npages, vm_page_t *m, vm_paddr_t *paddr, int cow)
+{
+	caddr_t uva;
+	vm_prot_t prot;
+	int i, j;
+	struct pmap *pmap;
+
+	pmap = &curproc->p_vmspace->vm_pmap;
+	uva = (caddr_t)(addr & PG_FRAME);
+	prot = VM_PROT_READ|VM_PROT_WRITE;
+	for (i = 0; i < npages; i++) {
+		if(vm_fault_quick(uva, prot) < 0) {
+			vm_page_lock_queues();
+			for (j = 0; j < i; i++)
+				vm_page_unhold(m[j]);
+			vm_page_unlock_queues();
+			return (EFAULT);
+		}
+		m[i] = pmap_extract_and_hold(pmap, (vm_paddr_t)uva + i*PAGE_SIZE, prot);
+	}
+	
+	vm_page_lock_queues();
+	for (i = 0; i < npages; i++) {
+		if (m[i] == NULL) {
+			paddr[i] = pmap_extract(pmap, (vm_paddr_t)uva + i*PAGE_SIZE);
+			continue;
+		}
+		paddr[i] = VM_PAGE_TO_PHYS(m[i]);
+		if (cow)
+			vm_page_cowsetup(m[i]);
+
+		vm_page_dirty(m[i]);
+		vm_page_wire(m[i]);
+		vm_page_unhold(m[i]);
+	}
+	vm_page_unlock_queues();
+	
+	return(0);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705070632.l476Wfuw029097>