Deleted Added
full compact
device_pager.c (291446) device_pager.c (292373)
1/*-
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)device_pager.c 8.1 (Berkeley) 6/11/93
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990 University of Utah.
3 * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)device_pager.c 8.1 (Berkeley) 6/11/93
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/vm/device_pager.c 291446 2015-11-29 11:37:25Z kib $");
38__FBSDID("$FreeBSD: head/sys/vm/device_pager.c 292373 2015-12-16 21:30:45Z glebius $");
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/conf.h>
43#include <sys/lock.h>
44#include <sys/proc.h>
45#include <sys/mutex.h>
46#include <sys/mman.h>

--- 7 unchanged lines hidden (view full) ---

54#include <vm/vm_pager.h>
55#include <vm/vm_phys.h>
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);
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/conf.h>
43#include <sys/lock.h>
44#include <sys/proc.h>
45#include <sys/mutex.h>
46#include <sys/mman.h>

--- 7 unchanged lines hidden (view full) ---

54#include <vm/vm_pager.h>
55#include <vm/vm_phys.h>
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);
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 *);
64static boolean_t dev_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
65static void dev_pager_free_page(vm_object_t object, vm_page_t m);
66
67/* list of device pager objects */
68static struct pagerlst dev_pager_object_list;
69/* protect list manipulation */
70static struct mtx dev_pager_mtx;

--- 181 unchanged lines hidden (view full) ---

252 != NULL)
253 dev_pager_free_page(object, m);
254 }
255 object->handle = NULL;
256 object->type = OBJT_DEAD;
257}
258
259static int
63static void dev_pager_putpages(vm_object_t, vm_page_t *, int, int, int *);
64static boolean_t dev_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
65static void dev_pager_free_page(vm_object_t object, vm_page_t m);
66
67/* list of device pager objects */
68static struct pagerlst dev_pager_object_list;
69/* protect list manipulation */
70static struct mtx dev_pager_mtx;

--- 181 unchanged lines hidden (view full) ---

252 != NULL)
253 dev_pager_free_page(object, m);
254 }
255 object->handle = NULL;
256 object->type = OBJT_DEAD;
257}
258
259static int
260dev_pager_getpages(vm_object_t object, vm_page_t *ma, int count, int reqpage)
260dev_pager_getpages(vm_object_t object, vm_page_t *ma, int count, int *rbehind,
261 int *rahead)
261{
262 int error;
263
262{
263 int error;
264
265 /* Since our haspage reports zero after/before, the count is 1. */
266 KASSERT(count == 1, ("%s: count %d", __func__, count));
264 VM_OBJECT_ASSERT_WLOCKED(object);
265 error = object->un_pager.devp.ops->cdev_pg_fault(object,
267 VM_OBJECT_ASSERT_WLOCKED(object);
268 error = object->un_pager.devp.ops->cdev_pg_fault(object,
266 IDX_TO_OFF(ma[reqpage]->pindex), PROT_READ, &ma[reqpage]);
269 IDX_TO_OFF(ma[0]->pindex), PROT_READ, &ma[0]);
267
268 VM_OBJECT_ASSERT_WLOCKED(object);
269
270
271 VM_OBJECT_ASSERT_WLOCKED(object);
272
270 vm_pager_free_nonreq(object, ma, reqpage, count, TRUE);
271
272 if (error == VM_PAGER_OK) {
273 KASSERT((object->type == OBJT_DEVICE &&
273 if (error == VM_PAGER_OK) {
274 KASSERT((object->type == OBJT_DEVICE &&
274 (ma[reqpage]->oflags & VPO_UNMANAGED) != 0) ||
275 (ma[0]->oflags & VPO_UNMANAGED) != 0) ||
275 (object->type == OBJT_MGTDEVICE &&
276 (object->type == OBJT_MGTDEVICE &&
276 (ma[reqpage]->oflags & VPO_UNMANAGED) == 0),
277 ("Wrong page type %p %p", ma[reqpage], object));
277 (ma[0]->oflags & VPO_UNMANAGED) == 0),
278 ("Wrong page type %p %p", ma[0], object));
278 if (object->type == OBJT_DEVICE) {
279 TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist,
279 if (object->type == OBJT_DEVICE) {
280 TAILQ_INSERT_TAIL(&object->un_pager.devp.devp_pglist,
280 ma[reqpage], plinks.q);
281 ma[0], plinks.q);
281 }
282 }
283 if (rbehind)
284 *rbehind = 0;
285 if (rahead)
286 *rahead = 0;
282 }
283
284 return (error);
285}
286
287static int
288old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
289 vm_page_t *mres)

--- 133 unchanged lines hidden ---
287 }
288
289 return (error);
290}
291
292static int
293old_dev_pager_fault(vm_object_t object, vm_ooffset_t offset, int prot,
294 vm_page_t *mres)

--- 133 unchanged lines hidden ---