Give more flexibility to the caller, if they already have an allocated object, in case they wish to apply some transformation to the object prior to handing it over to the region specific initialisation step, like in gem_create_ext where we would like to first apply the extensions to the object. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20210114182402.840247-3-matthew.auld@intel.com
53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2019 Intel Corporation
|
|
*/
|
|
|
|
#include "intel_memory_region.h"
|
|
#include "gem/i915_gem_region.h"
|
|
#include "gem/i915_gem_lmem.h"
|
|
#include "i915_drv.h"
|
|
|
|
const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = {
|
|
.name = "i915_gem_object_lmem",
|
|
.flags = I915_GEM_OBJECT_HAS_IOMEM,
|
|
|
|
.get_pages = i915_gem_object_get_pages_buddy,
|
|
.put_pages = i915_gem_object_put_pages_buddy,
|
|
.release = i915_gem_object_release_memory_region,
|
|
};
|
|
|
|
bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj)
|
|
{
|
|
return obj->ops == &i915_gem_lmem_obj_ops;
|
|
}
|
|
|
|
struct drm_i915_gem_object *
|
|
i915_gem_object_create_lmem(struct drm_i915_private *i915,
|
|
resource_size_t size,
|
|
unsigned int flags)
|
|
{
|
|
return i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_LMEM],
|
|
size, flags);
|
|
}
|
|
|
|
int __i915_gem_lmem_object_init(struct intel_memory_region *mem,
|
|
struct drm_i915_gem_object *obj,
|
|
resource_size_t size,
|
|
unsigned int flags)
|
|
{
|
|
static struct lock_class_key lock_class;
|
|
struct drm_i915_private *i915 = mem->i915;
|
|
|
|
drm_gem_private_object_init(&i915->drm, &obj->base, size);
|
|
i915_gem_object_init(obj, &i915_gem_lmem_obj_ops, &lock_class);
|
|
|
|
obj->read_domains = I915_GEM_DOMAIN_WC | I915_GEM_DOMAIN_GTT;
|
|
|
|
i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE);
|
|
|
|
i915_gem_object_init_memory_region(obj, mem, flags);
|
|
|
|
return 0;
|
|
}
|