device_pager.c (f0c07fe3d0007a4499f81583a99598cd0a74d45b) | device_pager.c (38e3125d6df98919983ed800471673ff0e5c2337) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 38 unchanged lines hidden (view full) --- 47#include <sys/vmmeter.h> 48 49#include <vm/vm.h> 50#include <vm/vm_param.h> 51#include <vm/vm_object.h> 52#include <vm/vm_page.h> 53#include <vm/vm_pager.h> 54#include <vm/vm_phys.h> | 1/*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 1990 University of Utah. 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by --- 38 unchanged lines hidden (view full) --- 47#include <sys/vmmeter.h> 48 49#include <vm/vm.h> 50#include <vm/vm_param.h> 51#include <vm/vm_object.h> 52#include <vm/vm_page.h> 53#include <vm/vm_pager.h> 54#include <vm/vm_phys.h> |
55#include <vm/vm_radix.h> |
|
55#include <vm/uma.h> 56 57static void dev_pager_init(void); 58static vm_object_t dev_pager_alloc(void *, vm_ooffset_t, vm_prot_t, 59 vm_ooffset_t, struct ucred *); 60static void dev_pager_dealloc(vm_object_t); 61static int dev_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); 62static void dev_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); --- 194 unchanged lines hidden (view full) --- 257 return (cdev_pager_allocate(handle, OBJT_DEVICE, &old_dev_pager_ops, 258 size, prot, foff, cred)); 259} 260 261void 262cdev_pager_free_page(vm_object_t object, vm_page_t m) 263{ 264 | 56#include <vm/uma.h> 57 58static void dev_pager_init(void); 59static vm_object_t dev_pager_alloc(void *, vm_ooffset_t, vm_prot_t, 60 vm_ooffset_t, struct ucred *); 61static void dev_pager_dealloc(vm_object_t); 62static int dev_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); 63static void dev_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); --- 194 unchanged lines hidden (view full) --- 258 return (cdev_pager_allocate(handle, OBJT_DEVICE, &old_dev_pager_ops, 259 size, prot, foff, cred)); 260} 261 262void 263cdev_pager_free_page(vm_object_t object, vm_page_t m) 264{ 265 |
265 if (object->type == OBJT_MGTDEVICE) 266 cdev_mgtdev_pager_free_page(object, m); 267 else if (object->type == OBJT_DEVICE) | 266 if (object->type == OBJT_MGTDEVICE) { 267 struct pctrie_iter pages; 268 269 vm_page_iter_init(&pages, object); 270 vm_page_iter_lookup(&pages, m->pindex); 271 cdev_mgtdev_pager_free_page(&pages); 272 } else if (object->type == OBJT_DEVICE) |
268 dev_pager_free_page(object, m); 269 else 270 KASSERT(false, 271 ("Invalid device type obj %p m %p", object, m)); 272} 273 274void | 273 dev_pager_free_page(object, m); 274 else 275 KASSERT(false, 276 ("Invalid device type obj %p m %p", object, m)); 277} 278 279void |
275cdev_mgtdev_pager_free_page(vm_object_t object, vm_page_t m) | 280cdev_mgtdev_pager_free_page(struct pctrie_iter *pages) |
276{ | 281{ |
282 pmap_remove_all(vm_radix_iter_page(pages)); 283 vm_page_iter_remove(pages); 284} |
|
277 | 285 |
278 VM_OBJECT_ASSERT_WLOCKED(object); 279 KASSERT((object->type == OBJT_MGTDEVICE && 280 (m->oflags & VPO_UNMANAGED) == 0), 281 ("Unmanaged device or page obj %p m %p", object, m)); 282 pmap_remove_all(m); 283 (void)vm_page_remove(m); | 286void 287cdev_mgtdev_pager_free_pages(vm_object_t object) 288{ 289 struct pctrie_iter pages; 290 vm_page_t m; 291 292 vm_page_iter_init(&pages, object); 293 VM_OBJECT_WLOCK(object); 294retry: 295 for (m = vm_page_iter_lookup_ge(&pages, 0); m != NULL; 296 m = vm_radix_iter_step(&pages)) { 297 if (!vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL)) { 298 pctrie_iter_reset(&pages); 299 goto retry; 300 } 301 cdev_mgtdev_pager_free_page(&pages); 302 } 303 VM_OBJECT_WUNLOCK(object); |
284} 285 286static void 287dev_pager_free_page(vm_object_t object, vm_page_t m) 288{ 289 290 VM_OBJECT_ASSERT_WLOCKED(object); 291 KASSERT((object->type == OBJT_DEVICE && --- 223 unchanged lines hidden --- | 304} 305 306static void 307dev_pager_free_page(vm_object_t object, vm_page_t m) 308{ 309 310 VM_OBJECT_ASSERT_WLOCKED(object); 311 KASSERT((object->type == OBJT_DEVICE && --- 223 unchanged lines hidden --- |