The sprd_prime_import() creates gem object always even though there is
existing gem object that refers memory of imported dma-buf. This patch
will make to reuse existing gem object on this case.
Change-Id: I4aa31bd2a41a511774b9e1aaf150ddbf45728c22
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
goto err;
}
+ obj = ion_get_gem(ion_handle);
+ if (obj) {
+ sprd_gem_obj = to_sprd_gem_obj(obj);
+ if (sprd_gem_obj->buffer->ion_handle != ion_handle) {
+ DRM_ERROR("Unable get GEM object from ion\n");
+ ret = -EINVAL;
+ goto err;
+ }
+
+ drm_gem_object_reference(obj);
+ ion_free(private->sprd_drm_ion_client, ion_handle);
+
+ return obj;
+ }
+
buf = sprd_drm_init_buf(dev, size);
if (!buf) {
DRM_ERROR("Unable to allocate the GEM buffer\n");
return handle;
}
EXPORT_SYMBOL(ion_alloc_with_gem);
+
+struct drm_gem_object *ion_get_gem(struct ion_handle *handle)
+{
+ if (handle && handle->buffer)
+ return handle->buffer->obj;
+
+ return NULL;
+}
+EXPORT_SYMBOL(ion_get_gem);
#endif
void ion_free(struct ion_client *client, struct ion_handle *handle)
ion_buffer_put(buffer);
#ifdef CONFIG_DRM_SPRD
- if (buffer->obj)
+ if (buffer->obj) {
drm_gem_object_unreference_unlocked(buffer->obj);
+ buffer->obj = NULL;
+ }
#endif
}
size_t align, unsigned int heap_id_mask,
unsigned int flags,
struct drm_gem_object *obj);
+struct drm_gem_object *ion_get_gem(struct ion_handle *handle);
#endif
/**
* ion_free - free a handle