From 87d00696fae85b8d3992a9a8b0d2fabaabde3b43 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 4 May 2015 09:10:53 +0200 Subject: [PATCH] drm: Add alloc_pages and __free_pages() --- sys/dev/drm/include/linux/mm.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sys/dev/drm/include/linux/mm.h b/sys/dev/drm/include/linux/mm.h index e850449ffc..2fe6615d31 100644 --- a/sys/dev/drm/include/linux/mm.h +++ b/sys/dev/drm/include/linux/mm.h @@ -4,6 +4,7 @@ * Copyright (c) 2010 Panasas, Inc. * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. * Copyright (c) 2015 François Tigeot + * Copyright (c) 2015 Matthew Dillon * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -96,4 +97,32 @@ set_page_dirty(struct vm_page *page) vm_page_dirty(page); } +/* + * Allocate multiple contiguous pages. The DragonFly code can only do + * multiple allocations via the free page reserve. Linux does not appear + * to restrict the address space, so neither do we. + */ +static inline struct vm_page * +alloc_pages(int flags, u_int order) +{ + size_t bytes = PAGE_SIZE << order; + struct vm_page *pgs; + + pgs = vm_page_alloc_contig(0LLU, ~0LLU, bytes, bytes, bytes, + VM_MEMATTR_DEFAULT); + kprintf("alloc_pages order %u vm_pages=%p\n", order, pgs); + return pgs; +} + +/* + * Free multiple contiguous pages + */ +static inline void +__free_pages(struct vm_page *pgs, u_int order) +{ + size_t bytes = PAGE_SIZE << order; + + vm_page_free_contig(pgs, bytes); +} + #endif /* _LINUX_MM_H_ */ -- 2.11.4.GIT