diff mbox series

[10/25] drm/msm/dpu: maintain hw_mdp in kms

Message ID 1539059262-8326-11-git-send-email-jsanka@codeaurora.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show
Series reserve RM resources in CRTC state | expand

Commit Message

Jeykumar Sankaran Oct. 9, 2018, 4:27 a.m. UTC
hw_mdp block is common for displays. No need
to reserve per display.

Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  7 ++++++-
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 20 --------------------
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  | 10 ----------
 3 files changed, 6 insertions(+), 31 deletions(-)

Comments

Jordan Crouse Oct. 9, 2018, 4:42 p.m. UTC | #1
On Mon, Oct 08, 2018 at 09:27:27PM -0700, Jeykumar Sankaran wrote:
> hw_mdp block is common for displays. No need
> to reserve per display.
> 
> Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  7 ++++++-
>  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 20 --------------------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  | 10 ----------
>  3 files changed, 6 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 8309850..fdc89a8 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -689,6 +689,10 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
>  		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]);
>  	dpu_kms->vbif[VBIF_RT] = NULL;
>  
> +	if (dpu_kms->hw_mdp)
> +		dpu_hw_mdp_destroy(dpu_kms->hw_mdp);
> +	dpu_kms->hw_mdp = NULL;
> +
>  	if (dpu_kms->mmio)
>  		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio);
>  	dpu_kms->mmio = NULL;
> @@ -1083,7 +1087,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
>  
>  	dpu_kms->rm_init = true;
>  
> -	dpu_kms->hw_mdp = dpu_rm_get_mdp(&dpu_kms->rm);
> +	dpu_kms->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, dpu_kms->mmio,
> +					     dpu_kms->catalog);
>  	if (IS_ERR_OR_NULL(dpu_kms->hw_mdp)) {

dpu_hw_mdptop_init() only returns ERR_PTR so you can change this over to
IS_ERR().

>  		rc = PTR_ERR(dpu_kms->hw_mdp);
>  		if (!dpu_kms->hw_mdp)

And then you don't need this and whatever comes along below it.

> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> index 24fc1c7..561120d 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> @@ -63,11 +63,6 @@ struct dpu_rm_hw_iter {
>  	enum dpu_hw_blk_type type;
>  };
>  
> -struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm)
> -{
> -	return rm->hw_mdp;
> -}
> -
>  static void _dpu_rm_init_hw_iter(
>  		struct dpu_rm_hw_iter *iter,
>  		uint32_t enc_id,
> @@ -151,9 +146,6 @@ int dpu_rm_destroy(struct dpu_rm *rm)
>  		}
>  	}
>  
> -	dpu_hw_mdp_destroy(rm->hw_mdp);
> -	rm->hw_mdp = NULL;
> -
>  	mutex_destroy(&rm->rm_lock);
>  
>  	return 0;
> @@ -168,11 +160,8 @@ static int _dpu_rm_hw_blk_create(
>  		void *hw_catalog_info)
>  {
>  	struct dpu_rm_hw_blk *blk;
> -	struct dpu_hw_mdp *hw_mdp;
>  	void *hw;
>  
> -	hw_mdp = rm->hw_mdp;
> -
>  	switch (type) {
>  	case DPU_HW_BLK_LM:
>  		hw = dpu_hw_lm_init(id, mmio, cat);
> @@ -236,15 +225,6 @@ int dpu_rm_init(struct dpu_rm *rm,
>  	for (type = 0; type < DPU_HW_BLK_MAX; type++)
>  		INIT_LIST_HEAD(&rm->hw_blks[type]);
>  
> -	/* Some of the sub-blocks require an mdptop to be created */
> -	rm->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, mmio, cat);
> -	if (IS_ERR_OR_NULL(rm->hw_mdp)) {
> -		rc = PTR_ERR(rm->hw_mdp);
> -		rm->hw_mdp = NULL;
> -		DPU_ERROR("failed: mdp hw not available\n");
> -		goto fail;
> -	}
> -
>  	/* Interrogate HW catalog and create tracking items for hw blocks */
>  	for (i = 0; i < cat->mixer_count; i++) {
>  		struct dpu_lm_cfg *lm = &cat->mixer[i];
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> index c7e3b2b..7ac1553 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> @@ -24,13 +24,11 @@
>   * struct dpu_rm - DPU dynamic hardware resource manager
>   * @hw_blks: array of lists of hardware resources present in the system, one
>   *	list per type of hardware block
> - * @hw_mdp: hardware object for mdp_top
>   * @lm_max_width: cached layer mixer maximum width
>   * @rm_lock: resource manager mutex
>   */
>  struct dpu_rm {
>  	struct list_head hw_blks[DPU_HW_BLK_MAX];
> -	struct dpu_hw_mdp *hw_mdp;
>  	uint32_t lm_max_width;
>  	struct mutex rm_lock;
>  };
> @@ -82,12 +80,4 @@ int dpu_rm_reserve(struct dpu_rm *rm,
>   * @Return: 0 on Success otherwise -ERROR
>   */
>  void dpu_rm_release(struct dpu_rm *rm, struct drm_crtc_state *crtc_state);
> -
> -/**
> - * dpu_rm_get_mdp - Retrieve HW block for MDP TOP.
> - *	This is never reserved, and is usable by any display.
> - * @rm: DPU Resource Manager handle
> - * @Return: Pointer to hw block or NULL
> - */
> -struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm);
>  #endif /* __DPU_RM_H__ */
Sean Paul Oct. 10, 2018, 2:54 p.m. UTC | #2
On Mon, Oct 08, 2018 at 09:27:27PM -0700, Jeykumar Sankaran wrote:
> hw_mdp block is common for displays. No need
> to reserve per display.
> 
> Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>

Reviewed-by: Sean Paul <seanpaul@chromium.org>

> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  7 ++++++-
>  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 20 --------------------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  | 10 ----------
>  3 files changed, 6 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index 8309850..fdc89a8 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -689,6 +689,10 @@ static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
>  		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]);
>  	dpu_kms->vbif[VBIF_RT] = NULL;
>  
> +	if (dpu_kms->hw_mdp)
> +		dpu_hw_mdp_destroy(dpu_kms->hw_mdp);
> +	dpu_kms->hw_mdp = NULL;
> +
>  	if (dpu_kms->mmio)
>  		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio);
>  	dpu_kms->mmio = NULL;
> @@ -1083,7 +1087,8 @@ static int dpu_kms_hw_init(struct msm_kms *kms)
>  
>  	dpu_kms->rm_init = true;
>  
> -	dpu_kms->hw_mdp = dpu_rm_get_mdp(&dpu_kms->rm);
> +	dpu_kms->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, dpu_kms->mmio,
> +					     dpu_kms->catalog);
>  	if (IS_ERR_OR_NULL(dpu_kms->hw_mdp)) {
>  		rc = PTR_ERR(dpu_kms->hw_mdp);
>  		if (!dpu_kms->hw_mdp)
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> index 24fc1c7..561120d 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
> @@ -63,11 +63,6 @@ struct dpu_rm_hw_iter {
>  	enum dpu_hw_blk_type type;
>  };
>  
> -struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm)
> -{
> -	return rm->hw_mdp;
> -}
> -
>  static void _dpu_rm_init_hw_iter(
>  		struct dpu_rm_hw_iter *iter,
>  		uint32_t enc_id,
> @@ -151,9 +146,6 @@ int dpu_rm_destroy(struct dpu_rm *rm)
>  		}
>  	}
>  
> -	dpu_hw_mdp_destroy(rm->hw_mdp);
> -	rm->hw_mdp = NULL;
> -
>  	mutex_destroy(&rm->rm_lock);
>  
>  	return 0;
> @@ -168,11 +160,8 @@ static int _dpu_rm_hw_blk_create(
>  		void *hw_catalog_info)
>  {
>  	struct dpu_rm_hw_blk *blk;
> -	struct dpu_hw_mdp *hw_mdp;
>  	void *hw;
>  
> -	hw_mdp = rm->hw_mdp;
> -
>  	switch (type) {
>  	case DPU_HW_BLK_LM:
>  		hw = dpu_hw_lm_init(id, mmio, cat);
> @@ -236,15 +225,6 @@ int dpu_rm_init(struct dpu_rm *rm,
>  	for (type = 0; type < DPU_HW_BLK_MAX; type++)
>  		INIT_LIST_HEAD(&rm->hw_blks[type]);
>  
> -	/* Some of the sub-blocks require an mdptop to be created */
> -	rm->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, mmio, cat);
> -	if (IS_ERR_OR_NULL(rm->hw_mdp)) {
> -		rc = PTR_ERR(rm->hw_mdp);
> -		rm->hw_mdp = NULL;
> -		DPU_ERROR("failed: mdp hw not available\n");
> -		goto fail;
> -	}
> -
>  	/* Interrogate HW catalog and create tracking items for hw blocks */
>  	for (i = 0; i < cat->mixer_count; i++) {
>  		struct dpu_lm_cfg *lm = &cat->mixer[i];
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> index c7e3b2b..7ac1553 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
> @@ -24,13 +24,11 @@
>   * struct dpu_rm - DPU dynamic hardware resource manager
>   * @hw_blks: array of lists of hardware resources present in the system, one
>   *	list per type of hardware block
> - * @hw_mdp: hardware object for mdp_top
>   * @lm_max_width: cached layer mixer maximum width
>   * @rm_lock: resource manager mutex
>   */
>  struct dpu_rm {
>  	struct list_head hw_blks[DPU_HW_BLK_MAX];
> -	struct dpu_hw_mdp *hw_mdp;
>  	uint32_t lm_max_width;
>  	struct mutex rm_lock;
>  };
> @@ -82,12 +80,4 @@ int dpu_rm_reserve(struct dpu_rm *rm,
>   * @Return: 0 on Success otherwise -ERROR
>   */
>  void dpu_rm_release(struct dpu_rm *rm, struct drm_crtc_state *crtc_state);
> -
> -/**
> - * dpu_rm_get_mdp - Retrieve HW block for MDP TOP.
> - *	This is never reserved, and is usable by any display.
> - * @rm: DPU Resource Manager handle
> - * @Return: Pointer to hw block or NULL
> - */
> -struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm);
>  #endif /* __DPU_RM_H__ */
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 8309850..fdc89a8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -689,6 +689,10 @@  static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
 		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]);
 	dpu_kms->vbif[VBIF_RT] = NULL;
 
+	if (dpu_kms->hw_mdp)
+		dpu_hw_mdp_destroy(dpu_kms->hw_mdp);
+	dpu_kms->hw_mdp = NULL;
+
 	if (dpu_kms->mmio)
 		devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio);
 	dpu_kms->mmio = NULL;
@@ -1083,7 +1087,8 @@  static int dpu_kms_hw_init(struct msm_kms *kms)
 
 	dpu_kms->rm_init = true;
 
-	dpu_kms->hw_mdp = dpu_rm_get_mdp(&dpu_kms->rm);
+	dpu_kms->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, dpu_kms->mmio,
+					     dpu_kms->catalog);
 	if (IS_ERR_OR_NULL(dpu_kms->hw_mdp)) {
 		rc = PTR_ERR(dpu_kms->hw_mdp);
 		if (!dpu_kms->hw_mdp)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
index 24fc1c7..561120d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
@@ -63,11 +63,6 @@  struct dpu_rm_hw_iter {
 	enum dpu_hw_blk_type type;
 };
 
-struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm)
-{
-	return rm->hw_mdp;
-}
-
 static void _dpu_rm_init_hw_iter(
 		struct dpu_rm_hw_iter *iter,
 		uint32_t enc_id,
@@ -151,9 +146,6 @@  int dpu_rm_destroy(struct dpu_rm *rm)
 		}
 	}
 
-	dpu_hw_mdp_destroy(rm->hw_mdp);
-	rm->hw_mdp = NULL;
-
 	mutex_destroy(&rm->rm_lock);
 
 	return 0;
@@ -168,11 +160,8 @@  static int _dpu_rm_hw_blk_create(
 		void *hw_catalog_info)
 {
 	struct dpu_rm_hw_blk *blk;
-	struct dpu_hw_mdp *hw_mdp;
 	void *hw;
 
-	hw_mdp = rm->hw_mdp;
-
 	switch (type) {
 	case DPU_HW_BLK_LM:
 		hw = dpu_hw_lm_init(id, mmio, cat);
@@ -236,15 +225,6 @@  int dpu_rm_init(struct dpu_rm *rm,
 	for (type = 0; type < DPU_HW_BLK_MAX; type++)
 		INIT_LIST_HEAD(&rm->hw_blks[type]);
 
-	/* Some of the sub-blocks require an mdptop to be created */
-	rm->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, mmio, cat);
-	if (IS_ERR_OR_NULL(rm->hw_mdp)) {
-		rc = PTR_ERR(rm->hw_mdp);
-		rm->hw_mdp = NULL;
-		DPU_ERROR("failed: mdp hw not available\n");
-		goto fail;
-	}
-
 	/* Interrogate HW catalog and create tracking items for hw blocks */
 	for (i = 0; i < cat->mixer_count; i++) {
 		struct dpu_lm_cfg *lm = &cat->mixer[i];
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
index c7e3b2b..7ac1553 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
@@ -24,13 +24,11 @@ 
  * struct dpu_rm - DPU dynamic hardware resource manager
  * @hw_blks: array of lists of hardware resources present in the system, one
  *	list per type of hardware block
- * @hw_mdp: hardware object for mdp_top
  * @lm_max_width: cached layer mixer maximum width
  * @rm_lock: resource manager mutex
  */
 struct dpu_rm {
 	struct list_head hw_blks[DPU_HW_BLK_MAX];
-	struct dpu_hw_mdp *hw_mdp;
 	uint32_t lm_max_width;
 	struct mutex rm_lock;
 };
@@ -82,12 +80,4 @@  int dpu_rm_reserve(struct dpu_rm *rm,
  * @Return: 0 on Success otherwise -ERROR
  */
 void dpu_rm_release(struct dpu_rm *rm, struct drm_crtc_state *crtc_state);
-
-/**
- * dpu_rm_get_mdp - Retrieve HW block for MDP TOP.
- *	This is never reserved, and is usable by any display.
- * @rm: DPU Resource Manager handle
- * @Return: Pointer to hw block or NULL
- */
-struct dpu_hw_mdp *dpu_rm_get_mdp(struct dpu_rm *rm);
 #endif /* __DPU_RM_H__ */