[PATCH RFC 042/111] staging: etnaviv: clean up etnaviv_gem_{get, put}_pages()

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


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

Move the locking into etnaviv_gem_prime.c and pass an etnaviv_gem_object
rather than drm_gem_object.  As this becomes an internal gem function,
move the prototype into etnaviv_gem.h.

Signed-off-by: Russell King <rmk+kernel at arm.linux.org.uk>
---
 drivers/staging/etnaviv/etnaviv_drv.h       |  2 --
 drivers/staging/etnaviv/etnaviv_gem.c       | 13 +++----------
 drivers/staging/etnaviv/etnaviv_gem.h       |  2 ++
 drivers/staging/etnaviv/etnaviv_gem_prime.c | 18 ++++++++++++++----
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/etnaviv/etnaviv_drv.h b/drivers/staging/etnaviv/etnaviv_drv.h
index bdf6685ef6cc..79f22d15fc63 100644
--- a/drivers/staging/etnaviv/etnaviv_drv.h
+++ b/drivers/staging/etnaviv/etnaviv_drv.h
@@ -81,8 +81,6 @@ int etnaviv_gem_get_iova_locked(struct etnaviv_gpu *gpu,
 	struct drm_gem_object *obj, uint32_t *iova);
 int etnaviv_gem_get_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
 	int id, uint32_t *iova);
-struct page **etnaviv_gem_get_pages(struct drm_gem_object *obj);
-void msm_gem_put_pages(struct drm_gem_object *obj);
 void etnaviv_gem_put_iova(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 		struct drm_mode_create_dumb *args);
diff --git a/drivers/staging/etnaviv/etnaviv_gem.c b/drivers/staging/etnaviv/etnaviv_gem.c
index 493ffc025569..2120cd378d86 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.c
+++ b/drivers/staging/etnaviv/etnaviv_gem.c
@@ -81,19 +81,12 @@ static void put_pages(struct etnaviv_gem_object *etnaviv_obj)
 	}
 }
 
-struct page **etnaviv_gem_get_pages(struct drm_gem_object *obj)
+struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *etnaviv_obj)
 {
-	struct drm_device *dev = obj->dev;
-	struct page **p;
-
-	mutex_lock(&dev->struct_mutex);
-	p = get_pages(to_etnaviv_bo(obj));
-	mutex_unlock(&dev->struct_mutex);
-
-	return p;
+	return get_pages(etnaviv_obj);
 }
 
-void msm_gem_put_pages(struct drm_gem_object *obj)
+void etnaviv_gem_put_pages(struct etnaviv_gem_object *etnaviv_obj)
 {
 	/* when we start tracking the pin count, then do something here */
 }
diff --git a/drivers/staging/etnaviv/etnaviv_gem.h b/drivers/staging/etnaviv/etnaviv_gem.h
index 65c9740542da..569a407cbd35 100644
--- a/drivers/staging/etnaviv/etnaviv_gem.h
+++ b/drivers/staging/etnaviv/etnaviv_gem.h
@@ -107,5 +107,7 @@ struct etnaviv_gem_submit {
 
 int etnaviv_gem_new_private(struct drm_device *dev, size_t size, uint32_t flags,
 	struct etnaviv_gem_object **res);
+struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj);
+void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);
 
 #endif /* __ETNAVIV_GEM_H__ */
diff --git a/drivers/staging/etnaviv/etnaviv_gem_prime.c b/drivers/staging/etnaviv/etnaviv_gem_prime.c
index d9742ae1fad1..3a986ae9b00b 100644
--- a/drivers/staging/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/staging/etnaviv/etnaviv_gem_prime.c
@@ -41,15 +41,25 @@ void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
 
 int msm_gem_prime_pin(struct drm_gem_object *obj)
 {
-	if (!obj->import_attach)
-		etnaviv_gem_get_pages(obj);
+	if (!obj->import_attach) {
+		struct drm_device *dev = obj->dev;
+
+		mutex_lock(&dev->struct_mutex);
+		etnaviv_gem_get_pages(to_etnaviv_bo(obj));
+		mutex_unlock(&dev->struct_mutex);
+	}
 	return 0;
 }
 
 void msm_gem_prime_unpin(struct drm_gem_object *obj)
 {
-	if (!obj->import_attach)
-		msm_gem_put_pages(obj);
+	if (!obj->import_attach) {
+		struct drm_device *dev = obj->dev;
+
+		mutex_lock(&dev->struct_mutex);
+		etnaviv_gem_put_pages(to_etnaviv_bo(obj));
+		mutex_unlock(&dev->struct_mutex);
+	}
 }
 
 static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
-- 
2.1.4



More information about the dri-devel mailing list