Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gem / i915_gem_lmem.c
blob932ee21e6609c61935d94d1e801cf0ef1b92d8f4
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright © 2019 Intel Corporation
4 */
6 #include "intel_memory_region.h"
7 #include "gem/i915_gem_region.h"
8 #include "gem/i915_gem_lmem.h"
9 #include "i915_drv.h"
11 const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
12 .name = "i915_gem_object_lmem",
13 .flags = I915_GEM_OBJECT_HAS_IOMEM,
15 .get_pages = i915_gem_object_get_pages_buddy,
16 .put_pages = i915_gem_object_put_pages_buddy,
17 .release = i915_gem_object_release_memory_region,
20 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
22 return obj->ops == &i915_gem_lmem_obj_ops;
25 struct drm_i915_gem_object *
26 i915_gem_object_create_lmem(struct drm_i915_private *i915,
27 resource_size_t size,
28 unsigned int flags)
30 return i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_LMEM],
31 size, flags);
34 struct drm_i915_gem_object *
35 __i915_gem_lmem_object_create(struct intel_memory_region *mem,
36 resource_size_t size,
37 unsigned int flags)
39 static struct lock_class_key lock_class;
40 struct drm_i915_private *i915 = mem->i915;
41 struct drm_i915_gem_object *obj;
43 obj = i915_gem_object_alloc();
44 if (!obj)
45 return ERR_PTR(-ENOMEM);
47 drm_gem_private_object_init(&i915->drm, &obj->base, size);
48 i915_gem_object_init(obj, &i915_gem_lmem_obj_ops, &lock_class);
50 obj->read_domains = I915_GEM_DOMAIN_WC | I915_GEM_DOMAIN_GTT;
52 i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
54 i915_gem_object_init_memory_region(obj, mem, flags);
56 return obj;