Fri Feb 11 23:05:55 2011 UTC ()
add optional MD pmap_mmap_flags macro for passing flags between cdev_mmap
and pmap_enter, ok matt@


(jmcneill)
diff -r1.58 -r1.59 src/sys/uvm/uvm_device.c
diff -r1.35 -r1.36 src/sys/uvm/uvm_pmap.h

cvs diff -r1.58 -r1.59 src/sys/uvm/uvm_device.c (expand / switch to unified diff)

--- src/sys/uvm/uvm_device.c 2011/02/02 15:13:34 1.58
+++ src/sys/uvm/uvm_device.c 2011/02/11 23:05:55 1.59
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_device.c,v 1.58 2011/02/02 15:13:34 chuck Exp $ */ 1/* $NetBSD: uvm_device.c,v 1.59 2011/02/11 23:05:55 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Charles D. Cranor and Washington University. 4 * Copyright (c) 1997 Charles D. Cranor and Washington University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp 27 * from: Id: uvm_device.c,v 1.1.2.9 1998/02/06 05:11:47 chs Exp
28 */ 28 */
29 29
30/* 30/*
31 * uvm_device.c: the device pager. 31 * uvm_device.c: the device pager.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.58 2011/02/02 15:13:34 chuck Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: uvm_device.c,v 1.59 2011/02/11 23:05:55 jmcneill Exp $");
36 36
37#include "opt_uvmhist.h" 37#include "opt_uvmhist.h"
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/conf.h> 41#include <sys/conf.h>
42#include <sys/proc.h> 42#include <sys/proc.h>
43#include <sys/malloc.h> 43#include <sys/malloc.h>
44 44
45#include <uvm/uvm.h> 45#include <uvm/uvm.h>
46#include <uvm/uvm_device.h> 46#include <uvm/uvm_device.h>
47 47
48/* 48/*
@@ -345,26 +345,27 @@ again: @@ -345,26 +345,27 @@ again:
345 */ 345 */
346 346
347static int 347static int
348udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, struct vm_page **pps, 348udv_fault(struct uvm_faultinfo *ufi, vaddr_t vaddr, struct vm_page **pps,
349 int npages, int centeridx, vm_prot_t access_type, 349 int npages, int centeridx, vm_prot_t access_type,
350 int flags) 350 int flags)
351{ 351{
352 struct vm_map_entry *entry = ufi->entry; 352 struct vm_map_entry *entry = ufi->entry;
353 struct uvm_object *uobj = entry->object.uvm_obj; 353 struct uvm_object *uobj = entry->object.uvm_obj;
354 struct uvm_device *udv = (struct uvm_device *)uobj; 354 struct uvm_device *udv = (struct uvm_device *)uobj;
355 vaddr_t curr_va; 355 vaddr_t curr_va;
356 off_t curr_offset; 356 off_t curr_offset;
357 paddr_t paddr, mdpgno; 357 paddr_t paddr, mdpgno;
 358 u_int mmapflags;
358 int lcv, retval; 359 int lcv, retval;
359 dev_t device; 360 dev_t device;
360 vm_prot_t mapprot; 361 vm_prot_t mapprot;
361 UVMHIST_FUNC("udv_fault"); UVMHIST_CALLED(maphist); 362 UVMHIST_FUNC("udv_fault"); UVMHIST_CALLED(maphist);
362 UVMHIST_LOG(maphist," flags=%d", flags,0,0,0); 363 UVMHIST_LOG(maphist," flags=%d", flags,0,0,0);
363 364
364 /* 365 /*
365 * we do not allow device mappings to be mapped copy-on-write 366 * we do not allow device mappings to be mapped copy-on-write
366 * so we kill any attempt to do so here. 367 * so we kill any attempt to do so here.
367 */ 368 */
368 369
369 if (UVM_ET_ISCOPYONWRITE(entry)) { 370 if (UVM_ET_ISCOPYONWRITE(entry)) {
370 UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)", 371 UVMHIST_LOG(maphist, "<- failed -- COW entry (etype=0x%x)",
@@ -405,32 +406,33 @@ udv_fault(struct uvm_faultinfo *ufi, vad @@ -405,32 +406,33 @@ udv_fault(struct uvm_faultinfo *ufi, vad
405 curr_va += PAGE_SIZE) { 406 curr_va += PAGE_SIZE) {
406 if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx) 407 if ((flags & PGO_ALLPAGES) == 0 && lcv != centeridx)
407 continue; 408 continue;
408 409
409 if (pps[lcv] == PGO_DONTCARE) 410 if (pps[lcv] == PGO_DONTCARE)
410 continue; 411 continue;
411 412
412 mdpgno = cdev_mmap(device, curr_offset, access_type); 413 mdpgno = cdev_mmap(device, curr_offset, access_type);
413 if (mdpgno == -1) { 414 if (mdpgno == -1) {
414 retval = EIO; 415 retval = EIO;
415 break; 416 break;
416 } 417 }
417 paddr = pmap_phys_address(mdpgno); 418 paddr = pmap_phys_address(mdpgno);
 419 mmapflags = pmap_mmap_flags(mdpgno);
418 mapprot = ufi->entry->protection; 420 mapprot = ufi->entry->protection;
419 UVMHIST_LOG(maphist, 421 UVMHIST_LOG(maphist,
420 " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d", 422 " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d",
421 ufi->orig_map->pmap, curr_va, paddr, mapprot); 423 ufi->orig_map->pmap, curr_va, paddr, mapprot);
422 if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, 424 if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, mapprot,
423 mapprot, PMAP_CANFAIL | mapprot) != 0) { 425 PMAP_CANFAIL | mapprot | mmapflags) != 0) {
424 /* 426 /*
425 * pmap_enter() didn't have the resource to 427 * pmap_enter() didn't have the resource to
426 * enter this mapping. Unlock everything, 428 * enter this mapping. Unlock everything,
427 * wait for the pagedaemon to free up some 429 * wait for the pagedaemon to free up some
428 * pages, and then tell uvm_fault() to start 430 * pages, and then tell uvm_fault() to start
429 * the fault again. 431 * the fault again.
430 * 432 *
431 * XXX Needs some rethinking for the PGO_ALLPAGES 433 * XXX Needs some rethinking for the PGO_ALLPAGES
432 * XXX case. 434 * XXX case.
433 */ 435 */
434 pmap_update(ufi->orig_map->pmap); /* sync what we have so far */ 436 pmap_update(ufi->orig_map->pmap); /* sync what we have so far */
435 uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap, 437 uvmfault_unlockall(ufi, ufi->entry->aref.ar_amap,
436 uobj, NULL); 438 uobj, NULL);

cvs diff -r1.35 -r1.36 src/sys/uvm/uvm_pmap.h (expand / switch to unified diff)

--- src/sys/uvm/uvm_pmap.h 2010/11/29 09:49:33 1.35
+++ src/sys/uvm/uvm_pmap.h 2011/02/11 23:05:55 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_pmap.h,v 1.35 2010/11/29 09:49:33 mrg Exp $ */ 1/* $NetBSD: uvm_pmap.h,v 1.36 2011/02/11 23:05:55 jmcneill Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University. 8 * The Mach Operating System project at Carnegie-Mellon University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -168,26 +168,29 @@ void pmap_kenter_pa(vaddr_t, paddr_t, v @@ -168,26 +168,29 @@ void pmap_kenter_pa(vaddr_t, paddr_t, v
168void pmap_kremove(vaddr_t, vsize_t); 168void pmap_kremove(vaddr_t, vsize_t);
169#if !defined(pmap_is_modified) 169#if !defined(pmap_is_modified)
170bool pmap_is_modified(struct vm_page *); 170bool pmap_is_modified(struct vm_page *);
171#endif 171#endif
172#if !defined(pmap_is_referenced) 172#if !defined(pmap_is_referenced)
173bool pmap_is_referenced(struct vm_page *); 173bool pmap_is_referenced(struct vm_page *);
174#endif 174#endif
175 175
176void pmap_page_protect(struct vm_page *, vm_prot_t); 176void pmap_page_protect(struct vm_page *, vm_prot_t);
177 177
178#if !defined(pmap_phys_address) 178#if !defined(pmap_phys_address)
179paddr_t pmap_phys_address(paddr_t); 179paddr_t pmap_phys_address(paddr_t);
180#endif 180#endif
 181#if !defined(pmap_mmap_flags)
 182#define pmap_mmap_flags(x) 0
 183#endif
181void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t); 184void pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
182#if !defined(pmap_reference) 185#if !defined(pmap_reference)
183void pmap_reference(pmap_t); 186void pmap_reference(pmap_t);
184#endif 187#endif
185#if !defined(pmap_remove) 188#if !defined(pmap_remove)
186void pmap_remove(pmap_t, vaddr_t, vaddr_t); 189void pmap_remove(pmap_t, vaddr_t, vaddr_t);
187#endif 190#endif
188void pmap_remove_all(struct pmap *); 191void pmap_remove_all(struct pmap *);
189#if !defined(pmap_update) 192#if !defined(pmap_update)
190void pmap_update(pmap_t); 193void pmap_update(pmap_t);
191#endif 194#endif
192#if !defined(pmap_resident_count) 195#if !defined(pmap_resident_count)
193long pmap_resident_count(pmap_t); 196long pmap_resident_count(pmap_t);