// SPDX-License-Identifier: GPL-2.0-only /* * psb GEM interface * * Copyright (c) 2011, Intel Corporation. * * Authors: Alan Cox * * TODO: * - we need to work out if the MMU is relevant (eg for * accelerated operations on a GEM object) */ #include <linux/pagemap.h> #include <asm/set_memory.h> #include <drm/drm.h> #include <drm/drm_vma_manager.h> #include "gem.h" #include "psb_drv.h" /* * PSB GEM object */ int psb_gem_pin(struct psb_gem_object *pobj) { … } void psb_gem_unpin(struct psb_gem_object *pobj) { … } static vm_fault_t psb_gem_fault(struct vm_fault *vmf); static void psb_gem_free_object(struct drm_gem_object *obj) { … } static const struct vm_operations_struct psb_gem_vm_ops = …; static const struct drm_gem_object_funcs psb_gem_object_funcs = …; struct psb_gem_object * psb_gem_create(struct drm_device *dev, u64 size, const char *name, bool stolen, u32 align) { … } /** * psb_gem_dumb_create - create a dumb buffer * @file: our client file * @dev: our device * @args: the requested arguments copied from userspace * * Allocate a buffer suitable for use for a frame buffer of the * form described by user space. Give userspace a handle by which * to reference it. */ int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { … } /** * psb_gem_fault - pagefault handler for GEM objects * @vmf: fault detail * * Invoked when a fault occurs on an mmap of a GEM managed area. GEM * does most of the work for us including the actual map/unmap calls * but we need to do the actual page work. * * This code eventually needs to handle faulting objects in and out * of the GTT and repacking it when we run out of space. We can put * that off for now and for our simple uses * * The VMA was set up by GEM. In doing so it also ensured that the * vma->vm_private_data points to the GEM object that is backing this * mapping. */ static vm_fault_t psb_gem_fault(struct vm_fault *vmf) { … } /* * Memory management */ /* Insert vram stolen pages into the GTT. */ static void psb_gem_mm_populate_stolen(struct drm_psb_private *pdev) { … } int psb_gem_mm_init(struct drm_device *dev) { … } void psb_gem_mm_fini(struct drm_device *dev) { … } /* Re-insert all pinned GEM objects into GTT. */ static void psb_gem_mm_populate_resources(struct drm_psb_private *pdev) { … } int psb_gem_mm_resume(struct drm_device *dev) { … }