All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes
@ 2017-05-31  2:14 ` Caesar Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Caesar Wang @ 2017-05-31  2:14 UTC (permalink / raw)
  To: mark.yao
  Cc: heiko, linux-kernel, airlied, dri-devel, linux-rockchip, tfiga,
	Caesar Wang

As the allocation and free buffer that need to add mutex lock for drm mm,
but it lacks the locking on error path in rockchip_gem_iommu_map().
Also, the trivial changes like The comment should be  placed in the
kerneldoc and unused blank line.

Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---

 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 47905fa..c7e96b8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -45,13 +45,13 @@ struct rockchip_crtc_state {
  *
  * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc.
  * @num_pipe: number of pipes for this device.
+ * @mm_lock: protect drm_mm on multi-threads.
  */
 struct rockchip_drm_private {
 	struct drm_fb_helper fbdev_helper;
 	struct drm_gem_object *fbdev_bo;
 	struct drm_atomic_state *state;
 	struct iommu_domain *domain;
-	/* protect drm_mm on multi-threads */
 	struct mutex mm_lock;
 	struct drm_mm mm;
 	struct list_head psr_list;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index df9e570..b74ac71 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -29,12 +29,11 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
 	ssize_t ret;
 
 	mutex_lock(&private->mm_lock);
-
 	ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
 					 rk_obj->base.size, PAGE_SIZE,
 					 0, 0);
-
 	mutex_unlock(&private->mm_lock);
+
 	if (ret < 0) {
 		DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
 		return ret;
@@ -56,7 +55,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
 	return 0;
 
 err_remove_node:
+	mutex_lock(&private->mm_lock);
 	drm_mm_remove_node(&rk_obj->mm);
+	mutex_unlock(&private->mm_lock);
 
 	return ret;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes
@ 2017-05-31  2:14 ` Caesar Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Caesar Wang @ 2017-05-31  2:14 UTC (permalink / raw)
  To: mark.yao; +Cc: linux-kernel, dri-devel, tfiga, linux-rockchip, Caesar Wang

As the allocation and free buffer that need to add mutex lock for drm mm,
but it lacks the locking on error path in rockchip_gem_iommu_map().
Also, the trivial changes like The comment should be  placed in the
kerneldoc and unused blank line.

Signed-off-by: Caesar Wang <wxt@rock-chips.com>
---

 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +-
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index 47905fa..c7e96b8 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -45,13 +45,13 @@ struct rockchip_crtc_state {
  *
  * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc.
  * @num_pipe: number of pipes for this device.
+ * @mm_lock: protect drm_mm on multi-threads.
  */
 struct rockchip_drm_private {
 	struct drm_fb_helper fbdev_helper;
 	struct drm_gem_object *fbdev_bo;
 	struct drm_atomic_state *state;
 	struct iommu_domain *domain;
-	/* protect drm_mm on multi-threads */
 	struct mutex mm_lock;
 	struct drm_mm mm;
 	struct list_head psr_list;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index df9e570..b74ac71 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -29,12 +29,11 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
 	ssize_t ret;
 
 	mutex_lock(&private->mm_lock);
-
 	ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
 					 rk_obj->base.size, PAGE_SIZE,
 					 0, 0);
-
 	mutex_unlock(&private->mm_lock);
+
 	if (ret < 0) {
 		DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
 		return ret;
@@ -56,7 +55,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
 	return 0;
 
 err_remove_node:
+	mutex_lock(&private->mm_lock);
 	drm_mm_remove_node(&rk_obj->mm);
+	mutex_unlock(&private->mm_lock);
 
 	return ret;
 }
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes
  2017-05-31  2:14 ` Caesar Wang
  (?)
@ 2017-05-31  2:23 ` Mark yao
  -1 siblings, 0 replies; 4+ messages in thread
From: Mark yao @ 2017-05-31  2:23 UTC (permalink / raw)
  To: Caesar Wang
  Cc: heiko, linux-kernel, airlied, dri-devel, linux-rockchip, tfiga

On 2017年05月31日 10:14, Caesar Wang wrote:
> As the allocation and free buffer that need to add mutex lock for drm mm,
> but it lacks the locking on error path in rockchip_gem_iommu_map().
> Also, the trivial changes like The comment should be  placed in the
> kerneldoc and unused blank line.
>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>

Looks good.

Reviewed-by: Mark Yao <mark.yao@rock-chips.com>

> ---
>
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +-
>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++--
>   2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> index 47905fa..c7e96b8 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> @@ -45,13 +45,13 @@ struct rockchip_crtc_state {
>    *
>    * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc.
>    * @num_pipe: number of pipes for this device.
> + * @mm_lock: protect drm_mm on multi-threads.
>    */
>   struct rockchip_drm_private {
>   	struct drm_fb_helper fbdev_helper;
>   	struct drm_gem_object *fbdev_bo;
>   	struct drm_atomic_state *state;
>   	struct iommu_domain *domain;
> -	/* protect drm_mm on multi-threads */
>   	struct mutex mm_lock;
>   	struct drm_mm mm;
>   	struct list_head psr_list;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index df9e570..b74ac71 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -29,12 +29,11 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
>   	ssize_t ret;
>   
>   	mutex_lock(&private->mm_lock);
> -
>   	ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
>   					 rk_obj->base.size, PAGE_SIZE,
>   					 0, 0);
> -
>   	mutex_unlock(&private->mm_lock);
> +
>   	if (ret < 0) {
>   		DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
>   		return ret;
> @@ -56,7 +55,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
>   	return 0;
>   
>   err_remove_node:
> +	mutex_lock(&private->mm_lock);
>   	drm_mm_remove_node(&rk_obj->mm);
> +	mutex_unlock(&private->mm_lock);
>   
>   	return ret;
>   }


-- 
Mark Yao

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes
  2017-05-31  2:14 ` Caesar Wang
  (?)
  (?)
@ 2017-06-01  7:46 ` Mark yao
  -1 siblings, 0 replies; 4+ messages in thread
From: Mark yao @ 2017-06-01  7:46 UTC (permalink / raw)
  To: Caesar Wang
  Cc: heiko, airlied, linux-kernel, dri-devel, tfiga, linux-rockchip

On 2017年05月31日 10:14, Caesar Wang wrote:
> As the allocation and free buffer that need to add mutex lock for drm mm,
> but it lacks the locking on error path in rockchip_gem_iommu_map().
> Also, the trivial changes like The comment should be  placed in the
> kerneldoc and unused blank line.
>
> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> ---

Pushed to drm-misc-next-fixes, Thanks.

>
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 +-
>   drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++--
>   2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> index 47905fa..c7e96b8 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
> @@ -45,13 +45,13 @@ struct rockchip_crtc_state {
>    *
>    * @crtc: array of enabled CRTCs, used to map from "pipe" to drm_crtc.
>    * @num_pipe: number of pipes for this device.
> + * @mm_lock: protect drm_mm on multi-threads.
>    */
>   struct rockchip_drm_private {
>   	struct drm_fb_helper fbdev_helper;
>   	struct drm_gem_object *fbdev_bo;
>   	struct drm_atomic_state *state;
>   	struct iommu_domain *domain;
> -	/* protect drm_mm on multi-threads */
>   	struct mutex mm_lock;
>   	struct drm_mm mm;
>   	struct list_head psr_list;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> index df9e570..b74ac71 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
> @@ -29,12 +29,11 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
>   	ssize_t ret;
>   
>   	mutex_lock(&private->mm_lock);
> -
>   	ret = drm_mm_insert_node_generic(&private->mm, &rk_obj->mm,
>   					 rk_obj->base.size, PAGE_SIZE,
>   					 0, 0);
> -
>   	mutex_unlock(&private->mm_lock);
> +
>   	if (ret < 0) {
>   		DRM_ERROR("out of I/O virtual memory: %zd\n", ret);
>   		return ret;
> @@ -56,7 +55,9 @@ static int rockchip_gem_iommu_map(struct rockchip_gem_object *rk_obj)
>   	return 0;
>   
>   err_remove_node:
> +	mutex_lock(&private->mm_lock);
>   	drm_mm_remove_node(&rk_obj->mm);
> +	mutex_unlock(&private->mm_lock);
>   
>   	return ret;
>   }


-- 
Mark Yao

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-01  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31  2:14 [PATCH] drm/rockchip: gem: add the lacks lock and trivial changes Caesar Wang
2017-05-31  2:14 ` Caesar Wang
2017-05-31  2:23 ` Mark yao
2017-06-01  7:46 ` Mark yao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.