[PATCH RFC 038/111] staging: etnaviv: provide etnaviv_gem_new_private()

Lucas Stach l.stach at pengutronix.de
Thu Apr 2 08:29:40 PDT 2015


From: Russell King <rmk+kernel at arm.linux.org.uk>

etnaviv_gem_new_private() creates a private non-shmem gem object which
can be used to create these kinds of objects.  Fix up msm_gem_import()
to use it.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_gem.c | 32 ++++++++++++++++++++++----------
 drivers/staging/etnaviv/etnaviv_gem.h |  3 +++
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 0a0cf92ff13f..185cd1702b2e 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -686,6 +686,23 @@ fail:
 	return ERR_PTR(ret);
 }
 
+int etnaviv_gem_new_private(struct drm_device *dev, size_t size, uint32_t flags,
+	struct etnaviv_gem_object **res)
+{
+	struct drm_gem_object *obj;
+	int ret;
+
+	ret = etnaviv_gem_new_impl(dev, size, flags, &obj);
+	if (ret)
+		return ret;
+
+	drm_gem_private_object_init(dev, obj, size);
+
+	*res = to_etnaviv_bo(obj);
+
+	return 0;
+}
+
 static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
 {
 	if (etnaviv_obj->vaddr)
@@ -709,20 +726,16 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
 		uint32_t size, struct sg_table *sgt)
 {
 	struct etnaviv_gem_object *etnaviv_obj;
-	struct drm_gem_object *obj;
 	int ret, npages;
 
 	size = PAGE_ALIGN(size);
 
-	ret = etnaviv_gem_new_impl(dev, size, ETNA_BO_WC, &obj);
-	if (ret)
-		goto fail;
-
-	drm_gem_private_object_init(dev, obj, size);
+	ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, &etnaviv_obj);
+	if (ret < 0)
+		return ERR_PTR(ret);
 
 	npages = size / PAGE_SIZE;
 
-	etnaviv_obj = to_etnaviv_bo(obj);
 	etnaviv_obj->ops = &etnaviv_gem_prime_ops;
 	etnaviv_obj->sgt = sgt;
 	etnaviv_obj->pages = drm_malloc_ab(npages, sizeof(struct page *));
@@ -736,11 +749,10 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
 	if (ret)
 		goto fail;
 
-	return obj;
+	return &etnaviv_obj->base;
 
 fail:
-	if (obj)
-		drm_gem_object_unreference_unlocked(obj);
+	drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
 
 	return ERR_PTR(ret);
 }
diff --git a/drivers/staging/etnaviv/etnaviv_gem.h b/drivers/staging/etnaviv/etnaviv_gem.h
index 676cbd46c600..65c9740542da 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.h
+++ b/drivers/staging/etnaviv/etnaviv_gem.h
@@ -105,4 +105,7 @@ struct etnaviv_gem_submit {
 	} bos[0];
 };
 
+int etnaviv_gem_new_private(struct drm_device *dev, size_t size, uint32_t flags,
+	struct etnaviv_gem_object **res);
+
 #endif /* __ETNAVIV_GEM_H__ */
-- 
2.1.4



More information about the dri-devel mailing list