diff mbox series

[25/25] drm/msm/dpu: maintain RM init check internally

Message ID 1539059262-8326-26-git-send-email-jsanka@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series reserve RM resources in CRTC state | expand

Commit Message

Jeykumar Sankaran Oct. 9, 2018, 4:27 a.m. UTC
Move and maintain RM initialization flag checks
from KMS to RM.

Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c |  6 +-----
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h |  1 -
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c  | 12 ++++++++++++
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h  |  3 +++
 4 files changed, 16 insertions(+), 6 deletions(-)
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 fdc89a8..59ccc46 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -668,9 +668,7 @@  static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
 		}
 	}
 
-	if (dpu_kms->rm_init)
-		dpu_rm_destroy(&dpu_kms->rm);
-	dpu_kms->rm_init = false;
+	dpu_rm_destroy(&dpu_kms->rm);
 
 	if (dpu_kms->catalog)
 		dpu_hw_catalog_deinit(dpu_kms->catalog);
@@ -1085,8 +1083,6 @@  static int dpu_kms_hw_init(struct msm_kms *kms)
 		goto power_error;
 	}
 
-	dpu_kms->rm_init = true;
-
 	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)) {
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
index 66d4666..1fff795 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h
@@ -140,7 +140,6 @@  struct dpu_kms {
 	bool suspend_block;
 
 	struct dpu_rm rm;
-	bool rm_init;
 
 	struct dpu_hw_vbif *hw_vbif[VBIF_MAX];
 	struct dpu_hw_mdp *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 9a63128..3452fb9 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
@@ -65,6 +65,9 @@  int dpu_rm_destroy(struct dpu_rm *rm)
 	struct dpu_rm_hw_blk *hw_cur, *hw_nxt;
 	enum dpu_hw_blk_type type;
 
+	if (!rm->initialized)
+		return 0;
+
 	for (type = 0; type < DPU_HW_BLK_MAX; type++) {
 		list_for_each_entry_safe(hw_cur, hw_nxt, &rm->hw_blks[type],
 				list) {
@@ -74,6 +77,8 @@  int dpu_rm_destroy(struct dpu_rm *rm)
 		}
 	}
 
+	rm->initialized = false;
+
 	return 0;
 }
 
@@ -141,6 +146,11 @@  int dpu_rm_init(struct dpu_rm *rm,
 		return -EINVAL;
 	}
 
+	if (rm->initialized) {
+		DPU_DEBUG("RM is already initialized\n");
+		return 0;
+	}
+
 	/* Clear, setup lists */
 	memset(rm, 0, sizeof(*rm));
 
@@ -196,6 +206,8 @@  int dpu_rm_init(struct dpu_rm *rm,
 		}
 	}
 
+	rm->initialized = true;
+
 	return 0;
 
 fail:
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
index 9acbeba..74e5d58 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h
@@ -24,9 +24,12 @@ 
  * 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
+ * @initialized: True, when RM is initialized with hw block list.
+ *               False, otherwise
  */
 struct dpu_rm {
 	struct list_head hw_blks[DPU_HW_BLK_MAX];
+	bool initialized;
 };
 
 /**