diff mbox

drm/tegra: Use drm_gem_object_reference_unlocked

Message ID 1445414791-20977-1-git-send-email-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Vetter Oct. 21, 2015, 8:06 a.m. UTC
This only grabs the mutex when really needed, but still has a
might-acquire lockdep check to make sure that's always possible.
With this patch tegra is officially struct_mutex free, yay!

Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/tegra/drm.c | 4 +---
 drivers/gpu/drm/tegra/gem.c | 8 ++------
 2 files changed, 3 insertions(+), 9 deletions(-)

Comments

Daniel Vetter Oct. 21, 2015, 8:20 a.m. UTC | #1
On Wed, Oct 21, 2015 at 10:06:31AM +0200, Daniel Vetter wrote:
> This only grabs the mutex when really needed, but still has a
> might-acquire lockdep check to make sure that's always possible.
> With this patch tegra is officially struct_mutex free, yay!
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

Please disregard this, wrong patch.
-Daniel

> ---
>  drivers/gpu/drm/tegra/drm.c | 4 +---
>  drivers/gpu/drm/tegra/gem.c | 8 ++------
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 159ef515cab1..5de9a4ead463 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -277,9 +277,7 @@ host1x_bo_lookup(struct drm_device *drm, struct drm_file *file, u32 handle)
>  	if (!gem)
>  		return NULL;
>  
> -	mutex_lock(&drm->struct_mutex);
> -	drm_gem_object_unreference(gem);
> -	mutex_unlock(&drm->struct_mutex);
> +	drm_gem_object_unreference_unlocked(gem);
>  
>  	bo = to_tegra_bo(gem);
>  	return &bo->base;
> diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
> index fb712316c522..1146fbe523d5 100644
> --- a/drivers/gpu/drm/tegra/gem.c
> +++ b/drivers/gpu/drm/tegra/gem.c
> @@ -30,9 +30,7 @@ static void tegra_bo_put(struct host1x_bo *bo)
>  	struct tegra_bo *obj = host1x_to_tegra_bo(bo);
>  	struct drm_device *drm = obj->gem.dev;
>  
> -	mutex_lock(&drm->struct_mutex);
> -	drm_gem_object_unreference(&obj->gem);
> -	mutex_unlock(&drm->struct_mutex);
> +	drm_gem_object_unreference_unlocked(&obj->gem);
>  }
>  
>  static dma_addr_t tegra_bo_pin(struct host1x_bo *bo, struct sg_table **sgt)
> @@ -74,9 +72,7 @@ static struct host1x_bo *tegra_bo_get(struct host1x_bo *bo)
>  	struct tegra_bo *obj = host1x_to_tegra_bo(bo);
>  	struct drm_device *drm = obj->gem.dev;
>  
> -	mutex_lock(&drm->struct_mutex);
> -	drm_gem_object_reference(&obj->gem);
> -	mutex_unlock(&drm->struct_mutex);
> +	drm_gem_object_reference_unlocked(&obj->gem);
>  
>  	return bo;
>  }
> -- 
> 2.5.1
>
kernel test robot Oct. 21, 2015, 1:03 p.m. UTC | #2
Hi Daniel,

[auto build test ERROR on drm-intel/for-linux-next -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Daniel-Vetter/drm-tegra-Use-drm_gem_object_reference_unlocked/20151021-160838
config: arm-tegra_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/tegra/gem.c: In function 'tegra_bo_put':
   drivers/gpu/drm/tegra/gem.c:31:21: warning: unused variable 'drm' [-Wunused-variable]
     struct drm_device *drm = obj->gem.dev;
                        ^
   drivers/gpu/drm/tegra/gem.c: In function 'tegra_bo_get':
>> drivers/gpu/drm/tegra/gem.c:75:2: error: implicit declaration of function 'drm_gem_object_reference_unlocked' [-Werror=implicit-function-declaration]
     drm_gem_object_reference_unlocked(&obj->gem);
     ^
   drivers/gpu/drm/tegra/gem.c:73:21: warning: unused variable 'drm' [-Wunused-variable]
     struct drm_device *drm = obj->gem.dev;
                        ^
   cc1: some warnings being treated as errors

vim +/drm_gem_object_reference_unlocked +75 drivers/gpu/drm/tegra/gem.c

    25		return container_of(bo, struct tegra_bo, base);
    26	}
    27	
    28	static void tegra_bo_put(struct host1x_bo *bo)
    29	{
    30		struct tegra_bo *obj = host1x_to_tegra_bo(bo);
  > 31		struct drm_device *drm = obj->gem.dev;
    32	
    33		drm_gem_object_unreference_unlocked(&obj->gem);
    34	}
    35	
    36	static dma_addr_t tegra_bo_pin(struct host1x_bo *bo, struct sg_table **sgt)
    37	{
    38		struct tegra_bo *obj = host1x_to_tegra_bo(bo);
    39	
    40		return obj->paddr;
    41	}
    42	
    43	static void tegra_bo_unpin(struct host1x_bo *bo, struct sg_table *sgt)
    44	{
    45	}
    46	
    47	static void *tegra_bo_mmap(struct host1x_bo *bo)
    48	{
    49		struct tegra_bo *obj = host1x_to_tegra_bo(bo);
    50	
    51		return obj->vaddr;
    52	}
    53	
    54	static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
    55	{
    56	}
    57	
    58	static void *tegra_bo_kmap(struct host1x_bo *bo, unsigned int page)
    59	{
    60		struct tegra_bo *obj = host1x_to_tegra_bo(bo);
    61	
    62		return obj->vaddr + page * PAGE_SIZE;
    63	}
    64	
    65	static void tegra_bo_kunmap(struct host1x_bo *bo, unsigned int page,
    66				    void *addr)
    67	{
    68	}
    69	
    70	static struct host1x_bo *tegra_bo_get(struct host1x_bo *bo)
    71	{
    72		struct tegra_bo *obj = host1x_to_tegra_bo(bo);
    73		struct drm_device *drm = obj->gem.dev;
    74	
  > 75		drm_gem_object_reference_unlocked(&obj->gem);
    76	
    77		return bo;
    78	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 159ef515cab1..5de9a4ead463 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -277,9 +277,7 @@  host1x_bo_lookup(struct drm_device *drm, struct drm_file *file, u32 handle)
 	if (!gem)
 		return NULL;
 
-	mutex_lock(&drm->struct_mutex);
-	drm_gem_object_unreference(gem);
-	mutex_unlock(&drm->struct_mutex);
+	drm_gem_object_unreference_unlocked(gem);
 
 	bo = to_tegra_bo(gem);
 	return &bo->base;
diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index fb712316c522..1146fbe523d5 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -30,9 +30,7 @@  static void tegra_bo_put(struct host1x_bo *bo)
 	struct tegra_bo *obj = host1x_to_tegra_bo(bo);
 	struct drm_device *drm = obj->gem.dev;
 
-	mutex_lock(&drm->struct_mutex);
-	drm_gem_object_unreference(&obj->gem);
-	mutex_unlock(&drm->struct_mutex);
+	drm_gem_object_unreference_unlocked(&obj->gem);
 }
 
 static dma_addr_t tegra_bo_pin(struct host1x_bo *bo, struct sg_table **sgt)
@@ -74,9 +72,7 @@  static struct host1x_bo *tegra_bo_get(struct host1x_bo *bo)
 	struct tegra_bo *obj = host1x_to_tegra_bo(bo);
 	struct drm_device *drm = obj->gem.dev;
 
-	mutex_lock(&drm->struct_mutex);
-	drm_gem_object_reference(&obj->gem);
-	mutex_unlock(&drm->struct_mutex);
+	drm_gem_object_reference_unlocked(&obj->gem);
 
 	return bo;
 }