@@ -231,7 +231,10 @@ intel_memory_region_create(struct drm_i915_private *i915,
struct intel_memory_region *mem;
int err;
- mem = kzalloc(sizeof(*mem), GFP_KERNEL);
+ if (ops->alloc)
+ mem = ops->alloc();
+ else
+ mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem)
return ERR_PTR(-ENOMEM);
@@ -265,7 +268,10 @@ intel_memory_region_create(struct drm_i915_private *i915,
if (mem->ops->release)
mem->ops->release(mem);
err_free:
- kfree(mem);
+ if (mem->ops->free)
+ mem->ops->free(mem);
+ else
+ kfree(mem);
return ERR_PTR(err);
}
@@ -288,7 +294,11 @@ void intel_memory_region_destroy(struct intel_memory_region *mem)
GEM_WARN_ON(!list_empty_careful(&mem->objects.list));
mutex_destroy(&mem->objects.lock);
- if (!ret)
+ if (ret)
+ return;
+ if (mem->ops->free)
+ mem->ops->free(mem);
+ else
kfree(mem);
}
@@ -61,6 +61,8 @@ struct intel_memory_region_ops {
resource_size_t size,
resource_size_t page_size,
unsigned int flags);
+ struct intel_memory_region *(*alloc)(void);
+ void (*free)(struct intel_memory_region *mem);
};
struct intel_memory_region {
add callbacks for alloc and free. this allows region creators to allocate any extra storage they may require. Signed-off-by: Robert Beckett <bob.beckett@collabora.com> --- drivers/gpu/drm/i915/intel_memory_region.c | 16 +++++++++++++--- drivers/gpu/drm/i915/intel_memory_region.h | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-)