treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / gem / i915_gem_lmem.c
blob70543c83df0630658187b0f96fbdb508bdd1496e
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 .flags = I915_GEM_OBJECT_HAS_IOMEM,
14 .get_pages = i915_gem_object_get_pages_buddy,
15 .put_pages = i915_gem_object_put_pages_buddy,
16 .release = i915_gem_object_release_memory_region,
19 bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
21 return obj->ops == &i915_gem_lmem_obj_ops;
24 struct drm_i915_gem_object *
25 i915_gem_object_create_lmem(struct drm_i915_private *i915,
26 resource_size_t size,
27 unsigned int flags)
29 return i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_LMEM],
30 size, flags);
33 struct drm_i915_gem_object *
34 __i915_gem_lmem_object_create(struct intel_memory_region *mem,
35 resource_size_t size,
36 unsigned int flags)
38 static struct lock_class_key lock_class;
39 struct drm_i915_private *i915 = mem->i915;
40 struct drm_i915_gem_object *obj;
42 obj = i915_gem_object_alloc();
43 if (!obj)
44 return ERR_PTR(-ENOMEM);
46 drm_gem_private_object_init(&i915->drm, &obj->base, size);
47 i915_gem_object_init(obj, &i915_gem_lmem_obj_ops, &lock_class);
49 obj->read_domains = I915_GEM_DOMAIN_WC | I915_GEM_DOMAIN_GTT;
51 i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
53 i915_gem_object_init_memory_region(obj, mem, flags);
55 return obj;