···237237 * mapping_gfp_mask(mapping) which conflicts w/ GFP_DMA32.. probably238238 * we actually want CMA memory for it all anyways..239239 */240240- pages = _drm_gem_get_pages(obj, GFP_KERNEL);240240+ pages = drm_gem_get_pages(obj, GFP_KERNEL);241241 if (IS_ERR(pages)) {242242 dev_err(obj->dev->dev, "could not get pages: %ld\n", PTR_ERR(pages));243243 return PTR_ERR(pages);···271271 return 0;272272273273free_pages:274274- _drm_gem_put_pages(obj, pages, true, false);274274+ drm_gem_put_pages(obj, pages, true, false);275275276276 return ret;277277}···295295 kfree(omap_obj->addrs);296296 omap_obj->addrs = NULL;297297298298- _drm_gem_put_pages(obj, omap_obj->pages, true, false);298298+ drm_gem_put_pages(obj, omap_obj->pages, true, false);299299 omap_obj->pages = NULL;300300}301301···316316317317 /* Make it mmapable */318318 size = omap_gem_mmap_size(obj);319319- ret = _drm_gem_create_mmap_offset_size(obj, size);319319+ ret = drm_gem_create_mmap_offset_size(obj, size);320320 if (ret) {321321 dev_err(dev->dev, "could not allocate mmap offset\n");322322 return 0;
-124
drivers/gpu/drm/omapdrm/omap_gem_helpers.c
···11-/*22- * drivers/gpu/drm/omapdrm/omap_gem_helpers.c33- *44- * Copyright (C) 2011 Texas Instruments55- * Author: Rob Clark <rob.clark@linaro.org>66- *77- * This program is free software; you can redistribute it and/or modify it88- * under the terms of the GNU General Public License version 2 as published by99- * the Free Software Foundation.1010- *1111- * This program is distributed in the hope that it will be useful, but WITHOUT1212- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1313- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for1414- * more details.1515- *1616- * You should have received a copy of the GNU General Public License along with1717- * this program. If not, see <http://www.gnu.org/licenses/>.1818- */1919-2020-/* temporary copy of drm_gem_{get,put}_pages() until the2121- * "drm/gem: add functions to get/put pages" patch is merged..2222- */2323-2424-#include <linux/module.h>2525-#include <linux/types.h>2626-#include <linux/shmem_fs.h>2727-2828-#include <drm/drmP.h>2929-3030-/**3131- * drm_gem_get_pages - helper to allocate backing pages for a GEM object3232- * @obj: obj in question3333- * @gfpmask: gfp mask of requested pages3434- */3535-struct page **_drm_gem_get_pages(struct drm_gem_object *obj, gfp_t gfpmask)3636-{3737- struct inode *inode;3838- struct address_space *mapping;3939- struct page *p, **pages;4040- int i, npages;4141-4242- /* This is the shared memory object that backs the GEM resource */4343- inode = file_inode(obj->filp);4444- mapping = inode->i_mapping;4545-4646- npages = obj->size >> PAGE_SHIFT;4747-4848- pages = drm_malloc_ab(npages, sizeof(struct page *));4949- if (pages == NULL)5050- return ERR_PTR(-ENOMEM);5151-5252- gfpmask |= mapping_gfp_mask(mapping);5353-5454- for (i = 0; i < npages; i++) {5555- p = shmem_read_mapping_page_gfp(mapping, i, gfpmask);5656- if (IS_ERR(p))5757- goto fail;5858- pages[i] = p;5959-6060- /* There is a hypothetical issue w/ drivers that require6161- * buffer memory in the low 4GB.. if the pages are un-6262- * pinned, and swapped out, they can end up swapped back6363- * in above 4GB. If pages are already in memory, then6464- * shmem_read_mapping_page_gfp will ignore the gfpmask,6565- * even if the already in-memory page disobeys the mask.6666- *6767- * It is only a theoretical issue today, because none of6868- * the devices with this limitation can be populated with6969- * enough memory to trigger the issue. But this BUG_ON()7070- * is here as a reminder in case the problem with7171- * shmem_read_mapping_page_gfp() isn't solved by the time7272- * it does become a real issue.7373- *7474- * See this thread: http://lkml.org/lkml/2011/7/11/2387575- */7676- BUG_ON((gfpmask & __GFP_DMA32) &&7777- (page_to_pfn(p) >= 0x00100000UL));7878- }7979-8080- return pages;8181-8282-fail:8383- while (i--)8484- page_cache_release(pages[i]);8585-8686- drm_free_large(pages);8787- return ERR_CAST(p);8888-}8989-9090-/**9191- * drm_gem_put_pages - helper to free backing pages for a GEM object9292- * @obj: obj in question9393- * @pages: pages to free9494- */9595-void _drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,9696- bool dirty, bool accessed)9797-{9898- int i, npages;9999-100100- npages = obj->size >> PAGE_SHIFT;101101-102102- for (i = 0; i < npages; i++) {103103- if (dirty)104104- set_page_dirty(pages[i]);105105-106106- if (accessed)107107- mark_page_accessed(pages[i]);108108-109109- /* Undo the reference we took when populating the table */110110- page_cache_release(pages[i]);111111- }112112-113113- drm_free_large(pages);114114-}115115-116116-int117117-_drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size)118118-{119119- struct drm_device *dev = obj->dev;120120- struct drm_gem_mm *mm = dev->mm_private;121121-122122- return drm_vma_offset_add(&mm->vma_manager, &obj->vma_node,123123- size / PAGE_SIZE);124124-}