summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/selftests/mock_region.c
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2021-01-14 19:24:02 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2021-01-15 09:00:03 +0100
commit97d5539632501af59290ead8f832e0ca6b6f69e7 (patch)
tree0f45daa182d7e392d8cf63e4359728f1e7eaf36c /drivers/gpu/drm/i915/selftests/mock_region.c
parentdrm/i915/gem: sanity check object size in gem_create (diff)
downloadlinux-97d5539632501af59290ead8f832e0ca6b6f69e7.tar.xz
linux-97d5539632501af59290ead8f832e0ca6b6f69e7.zip
drm/i915/region: convert object_create into object_init
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
Diffstat (limited to 'drivers/gpu/drm/i915/selftests/mock_region.c')
-rw-r--r--drivers/gpu/drm/i915/selftests/mock_region.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/gpu/drm/i915/selftests/mock_region.c b/drivers/gpu/drm/i915/selftests/mock_region.c
index 979d96f27c43..3c6021415274 100644
--- a/drivers/gpu/drm/i915/selftests/mock_region.c
+++ b/drivers/gpu/drm/i915/selftests/mock_region.c
@@ -15,21 +15,16 @@ static const struct drm_i915_gem_object_ops mock_region_obj_ops = {
.release = i915_gem_object_release_memory_region,
};
-static struct drm_i915_gem_object *
-mock_object_create(struct intel_memory_region *mem,
- resource_size_t size,
- unsigned int flags)
+static int mock_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;
- struct drm_i915_gem_object *obj;
if (size > mem->mm.size)
- return ERR_PTR(-E2BIG);
-
- obj = i915_gem_object_alloc();
- if (!obj)
- return ERR_PTR(-ENOMEM);
+ return -E2BIG;
drm_gem_private_object_init(&i915->drm, &obj->base, size);
i915_gem_object_init(obj, &mock_region_obj_ops, &lock_class);
@@ -40,13 +35,13 @@ mock_object_create(struct intel_memory_region *mem,
i915_gem_object_init_memory_region(obj, mem, flags);
- return obj;
+ return 0;
}
static const struct intel_memory_region_ops mock_region_ops = {
.init = intel_memory_region_init_buddy,
.release = intel_memory_region_release_buddy,
- .create_object = mock_object_create,
+ .init_object = mock_object_init,
};
struct intel_memory_region *