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 .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
,
30 return i915_gem_object_create_region(i915
->mm
.regions
[INTEL_REGION_LMEM
],
34 struct drm_i915_gem_object
*
35 __i915_gem_lmem_object_create(struct intel_memory_region
*mem
,
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();
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
);