1 // SPDX-License-Identifier: MIT
3 * Copyright © 2019 Intel Corporation
6 #include "intel_memory_region.h"
7 #include "gem/i915_gem_region.h"
8 #include "gem/i915_gem_lmem.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
,
29 return i915_gem_object_create_region(i915
->mm
.regions
[INTEL_REGION_LMEM
],
33 struct drm_i915_gem_object
*
34 __i915_gem_lmem_object_create(struct intel_memory_region
*mem
,
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();
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
);