diff mbox series

[v3,2/8] drm/omap: add omap_gem_unpin_locked()

Message ID 20191007112555.25278-3-jjhiblot@ti.com
State Superseded
Headers show
Series None | expand

Commit Message

Jean-Jacques Hiblot Oct. 7, 2019, 11:25 a.m. UTC
From: Tomi Valkeinen <tomi.valkeinen@ti.com>

Add omap_gem_unpin_locked() which is a version of omap_gem_unpin() that
expects the caller to hold the omap_obj lock.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Comments

Jean-Jacques Hiblot Oct. 8, 2019, 3:54 p.m. UTC | #1
On 07/10/2019 13:25, Jean-Jacques Hiblot wrote:
> From: Tomi Valkeinen <tomi.valkeinen@ti.com>
>
> Add omap_gem_unpin_locked() which is a version of omap_gem_unpin() that
> expects the caller to hold the omap_obj lock.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
>   drivers/gpu/drm/omapdrm/omap_gem.c | 24 +++++++++++++++++-------
>   1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
> index 51ede7777083..9201c21e206f 100644
> --- a/drivers/gpu/drm/omapdrm/omap_gem.c
> +++ b/drivers/gpu/drm/omapdrm/omap_gem.c
> @@ -834,20 +834,16 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
>   }
>   
>   /**
> - * omap_gem_unpin() - Unpin a GEM object from memory
> + * omap_gem_unpin_locked() - Unpin a GEM object from memory
>    * @obj: the GEM object
>    *
> - * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
> - * reference-counted, the actualy unpin will only be performed when the number
> - * of calls to this function matches the number of calls to omap_gem_pin().
> + * omap_gem_unpin() without locking.
>    */
> -void omap_gem_unpin(struct drm_gem_object *obj)
> +static void omap_gem_unpin_locked(struct drm_gem_object *obj)
>   {
>   	struct omap_gem_object *omap_obj = to_omap_bo(obj);
>   	int ret;
>   
> -	mutex_lock(&omap_obj->lock);
> -
>   	if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) {
>   		ret = tiler_unpin(omap_obj->block);
>   		if (ret) {
> @@ -864,6 +860,20 @@ void omap_gem_unpin(struct drm_gem_object *obj)
>   	}
>   }
>   
> +/**
> + * omap_gem_unpin() - Unpin a GEM object from memory
> + * @obj: the GEM object
> + *
> + * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
> + * reference-counted, the actual unpin will only be performed when the number
> + * of calls to this function matches the number of calls to omap_gem_pin().
> + */
> +void omap_gem_unpin(struct drm_gem_object *obj)
> +{
> +	struct omap_gem_object *omap_obj = to_omap_bo(obj);
> +
> +	mutex_lock(&omap_obj->lock);
> +	omap_gem_unpin_locked(obj);
>   	mutex_unlock(&omap_obj->lock);
>   }
>   

Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 51ede7777083..9201c21e206f 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -834,20 +834,16 @@  int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr)
 }
 
 /**
- * omap_gem_unpin() - Unpin a GEM object from memory
+ * omap_gem_unpin_locked() - Unpin a GEM object from memory
  * @obj: the GEM object
  *
- * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
- * reference-counted, the actualy unpin will only be performed when the number
- * of calls to this function matches the number of calls to omap_gem_pin().
+ * omap_gem_unpin() without locking.
  */
-void omap_gem_unpin(struct drm_gem_object *obj)
+static void omap_gem_unpin_locked(struct drm_gem_object *obj)
 {
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 	int ret;
 
-	mutex_lock(&omap_obj->lock);
-
 	if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) {
 		ret = tiler_unpin(omap_obj->block);
 		if (ret) {
@@ -864,6 +860,20 @@  void omap_gem_unpin(struct drm_gem_object *obj)
 	}
 }
 
+/**
+ * omap_gem_unpin() - Unpin a GEM object from memory
+ * @obj: the GEM object
+ *
+ * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are
+ * reference-counted, the actual unpin will only be performed when the number
+ * of calls to this function matches the number of calls to omap_gem_pin().
+ */
+void omap_gem_unpin(struct drm_gem_object *obj)
+{
+	struct omap_gem_object *omap_obj = to_omap_bo(obj);
+
+	mutex_lock(&omap_obj->lock);
+	omap_gem_unpin_locked(obj);
 	mutex_unlock(&omap_obj->lock);
 }