All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeykumar Sankaran <jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: hoegsberg-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	Jeykumar Sankaran
	<jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: [PATCH 17/25] drm/msm/dpu: remove RM HW block list iterator
Date: Mon,  8 Oct 2018 21:27:34 -0700	[thread overview]
Message-ID: <1539059262-8326-18-git-send-email-jsanka@codeaurora.org> (raw)
In-Reply-To: <1539059262-8326-1-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>

Replacing with simpler linked list helper iterators.

Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 120 +++++++++++++--------------------
 1 file changed, 46 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
index 1234991..a79456c 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c
@@ -45,49 +45,6 @@ struct dpu_rm_hw_blk {
 	struct dpu_hw_blk *hw;
 };
 
-/**
- * struct dpu_rm_hw_iter - iterator for use with dpu_rm
- * @blk: dpu_rm internal block representation. Clients ignore. Used as iterator.
- * @type: Hardware Block Type client wishes to search for.
- */
-struct dpu_rm_hw_iter {
-	struct dpu_rm_hw_blk *blk;
-	enum dpu_hw_blk_type type;
-};
-
-static void _dpu_rm_init_hw_iter(
-		struct dpu_rm_hw_iter *iter,
-		enum dpu_hw_blk_type type)
-{
-	memset(iter, 0, sizeof(*iter));
-	iter->type = type;
-}
-
-static bool _dpu_rm_get_hw_locked(struct dpu_rm *rm, struct dpu_rm_hw_iter *i)
-{
-	struct list_head *blk_list;
-
-	if (!rm || !i || i->type >= DPU_HW_BLK_MAX) {
-		DPU_ERROR("invalid rm\n");
-		return false;
-	}
-
-	blk_list = &rm->hw_blks[i->type];
-
-	if (i->blk && (&i->blk->list == blk_list)) {
-		DPU_DEBUG("attempt resume iteration past last\n");
-		return false;
-	}
-
-	i->blk = list_prepare_entry(i->blk, blk_list, list);
-
-	list_for_each_entry_continue(i->blk, blk_list, list)
-		if (!i->blk->in_use)
-			return true;
-
-	return false;
-}
-
 static void _dpu_rm_hw_destroy(enum dpu_hw_blk_type type, void *hw)
 {
 	switch (type) {
@@ -301,7 +258,8 @@ static bool _dpu_rm_check_lm_and_get_connected_blks(
 		struct dpu_rm_hw_blk *primary_lm)
 {
 	const struct dpu_lm_cfg *lm_cfg = to_dpu_hw_mixer(lm->hw)->cap;
-	struct dpu_rm_hw_iter iter;
+	struct dpu_rm_hw_blk *iter;
+	struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_PINGPONG];
 
 	*pp = NULL;
 
@@ -320,10 +278,12 @@ static bool _dpu_rm_check_lm_and_get_connected_blks(
 		}
 	}
 
-	_dpu_rm_init_hw_iter(&iter, DPU_HW_BLK_PINGPONG);
-	while (_dpu_rm_get_hw_locked(rm, &iter)) {
-		if (iter.blk->hw->id == lm_cfg->pingpong) {
-			*pp = iter.blk;
+	list_for_each_entry(iter, blk_list, list) {
+		if (iter->in_use)
+			continue;
+
+		if (iter->hw->id == lm_cfg->pingpong) {
+			*pp = iter;
 			break;
 		}
 	}
@@ -343,7 +303,8 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm,
 {
 	struct dpu_rm_hw_blk *lm[MAX_BLOCKS];
 	struct dpu_rm_hw_blk *pp[MAX_BLOCKS];
-	struct dpu_rm_hw_iter iter_i, iter_j;
+	struct dpu_rm_hw_blk *iter_i, *iter_j;
+	struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_LM];
 	int lm_count = 0;
 	int i, rc = 0;
 
@@ -353,14 +314,18 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm,
 	}
 
 	/* Find a primary mixer */
-	_dpu_rm_init_hw_iter(&iter_i, DPU_HW_BLK_LM);
-	while (lm_count != reqs->topology.num_lm &&
-			_dpu_rm_get_hw_locked(rm, &iter_i)) {
+	list_for_each_entry(iter_i, blk_list, list) {
+		if (iter_i->in_use)
+			continue;
+
+		if (lm_count == reqs->topology.num_lm)
+			break;
+
 		memset(&lm, 0, sizeof(lm));
 		memset(&pp, 0, sizeof(pp));
 
 		lm_count = 0;
-		lm[lm_count] = iter_i.blk;
+		lm[lm_count] = iter_i;
 
 		if (!_dpu_rm_check_lm_and_get_connected_blks(
 				rm, reqs, lm[lm_count],
@@ -370,19 +335,22 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm,
 		++lm_count;
 
 		/* Valid primary mixer found, find matching peers */
-		_dpu_rm_init_hw_iter(&iter_j, DPU_HW_BLK_LM);
+		list_for_each_entry(iter_j, blk_list, list) {
+			if (iter_j->in_use)
+				continue;
 
-		while (lm_count != reqs->topology.num_lm &&
-				_dpu_rm_get_hw_locked(rm, &iter_j)) {
-			if (iter_i.blk == iter_j.blk)
+			if (lm_count == reqs->topology.num_lm)
+				break;
+
+			if (iter_i == iter_j)
 				continue;
 
 			if (!_dpu_rm_check_lm_and_get_connected_blks(
-					rm, reqs, iter_j.blk,
-					&pp[lm_count], iter_i.blk))
+					rm, reqs, iter_j,
+					&pp[lm_count], iter_i))
 				continue;
 
-			lm[lm_count] = iter_j.blk;
+			lm[lm_count] = iter_j;
 			++lm_count;
 		}
 	}
@@ -417,7 +385,9 @@ static int _dpu_rm_reserve_ctls(
 		const struct msm_display_topology *top)
 {
 	struct dpu_rm_hw_blk *ctls[MAX_BLOCKS];
-	struct dpu_rm_hw_iter iter;
+	struct dpu_rm_hw_blk *iter;
+	struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_CTL];
+
 	int i = 0, num_ctls = 0;
 	bool needs_split_display = false;
 
@@ -428,21 +398,23 @@ static int _dpu_rm_reserve_ctls(
 
 	needs_split_display = _dpu_rm_needs_split_display(top);
 
-	_dpu_rm_init_hw_iter(&iter, DPU_HW_BLK_CTL);
-	while (_dpu_rm_get_hw_locked(rm, &iter)) {
-		const struct dpu_hw_ctl *ctl = to_dpu_hw_ctl(iter.blk->hw);
+	list_for_each_entry(iter, blk_list, list)  {
+		const struct dpu_hw_ctl *ctl = to_dpu_hw_ctl(iter->hw);
 		unsigned long features = ctl->caps->features;
 		bool has_split_display;
 
+		if (iter->in_use)
+			continue;
+
 		has_split_display = BIT(DPU_CTL_SPLIT_DISPLAY) & features;
 
-		DPU_DEBUG("ctl %d caps 0x%lX\n", iter.blk->hw->id, features);
+		DPU_DEBUG("ctl %d caps 0x%lX\n", iter->hw->id, features);
 
 		if (needs_split_display != has_split_display)
 			continue;
 
-		ctls[i] = iter.blk;
-		DPU_DEBUG("ctl %d match\n", iter.blk->hw->id);
+		ctls[i] = iter;
+		DPU_DEBUG("ctl %d match\n", iter->hw->id);
 
 		if (++i == num_ctls)
 			break;
@@ -468,26 +440,26 @@ static struct dpu_rm_hw_blk *_dpu_rm_reserve_intf(
 		uint32_t id,
 		enum dpu_hw_blk_type type)
 {
-	struct dpu_rm_hw_iter iter;
+	struct dpu_rm_hw_blk *iter;
+	struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_INTF];
 
 	/* Find the block entry in the rm, and note the reservation */
-	_dpu_rm_init_hw_iter(&iter, type);
-	while (_dpu_rm_get_hw_locked(rm, &iter)) {
-		if (iter.blk->hw->id != id)
+	list_for_each_entry(iter, blk_list, list)  {
+		if (iter->hw->id != id || iter->in_use)
 			continue;
 
-		trace_dpu_rm_reserve_intf(iter.blk->hw->id, DPU_HW_BLK_INTF);
+		trace_dpu_rm_reserve_intf(iter->hw->id, DPU_HW_BLK_INTF);
 
 		break;
 	}
 
 	/* Shouldn't happen since intfs are fixed at probe */
-	if (!iter.blk) {
+	if (!iter) {
 		DPU_ERROR("couldn't find type %d id %d\n", type, id);
 		return NULL;
 	}
 
-	return iter.blk;
+	return iter;
 }
 
 static int _dpu_rm_reserve_intf_related_hw(
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

  parent reply	other threads:[~2018-10-09  4:27 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09  4:27 [PATCH 00/25] reserve RM resources in CRTC state Jeykumar Sankaran
     [not found] ` <1539059262-8326-1-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09  4:27   ` [PATCH 01/25] drm/msm/dpu: fix hw ctl retrieval for mixer muxing Jeykumar Sankaran
     [not found]     ` <1539059262-8326-2-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 16:05       ` Jordan Crouse
2018-10-09 18:07     ` [Freedreno] " Sean Paul
2018-10-10  5:46       ` Jeykumar Sankaran
2018-10-10 14:29         ` [Freedreno] " Sean Paul
2018-10-10 18:35           ` Jeykumar Sankaran
     [not found]             ` <126041ab035da0674d0e5a6d2ce151da-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-11 14:51               ` Sean Paul
2018-10-09  4:27   ` [PATCH 02/25] drm/msm/dpu: avoid tracking reservations in RM Jeykumar Sankaran
     [not found]     ` <1539059262-8326-3-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 19:57       ` Sean Paul
2018-10-09  4:27   ` [PATCH 03/25] drm/msm/dpu: remove dev from RM Jeykumar Sankaran
     [not found]     ` <1539059262-8326-4-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 19:58       ` Sean Paul
2018-10-09  4:27   ` [PATCH 04/25] drm/msm/dpu: clean up dpu_rm_check_property_topctl declaration Jeykumar Sankaran
     [not found]     ` <1539059262-8326-5-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 19:59       ` Sean Paul
2018-10-09  4:27   ` [PATCH 05/25] drm/msm/dpu: remove encoder from crtc mixer struct Jeykumar Sankaran
     [not found]     ` <1539059262-8326-6-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 20:03       ` Sean Paul
2018-10-09  4:27   ` [PATCH 06/25] drm/msm/dpu: clean up redundant hw type Jeykumar Sankaran
     [not found]     ` <1539059262-8326-7-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 20:32       ` Sean Paul
2018-10-10  0:40       ` kbuild test robot
2018-10-09  4:27   ` [PATCH 07/25] drm/msm/dpu: reserve using crtc state Jeykumar Sankaran
     [not found]     ` <1539059262-8326-8-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 21:06       ` Sean Paul
2018-10-10  6:28         ` Jeykumar Sankaran
     [not found]           ` <eabacae428bee1041fc7f9bafec144f7-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-12 22:19             ` Jeykumar Sankaran
2018-10-09 21:53     ` kbuild test robot
2018-10-09  4:27   ` [PATCH 08/25] drm/msm/dpu: release reservation " Jeykumar Sankaran
2018-10-10 14:50     ` Sean Paul
2018-10-09  4:27   ` [PATCH 09/25] drm/msm/dpu: make RM iterator static Jeykumar Sankaran
     [not found]     ` <1539059262-8326-10-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-10 14:51       ` Sean Paul
2018-10-09  4:27   ` [PATCH 10/25] drm/msm/dpu: maintain hw_mdp in kms Jeykumar Sankaran
     [not found]     ` <1539059262-8326-11-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 16:42       ` Jordan Crouse
2018-10-10 14:54       ` Sean Paul
2018-10-09  4:27   ` [PATCH 11/25] drm/msm/dpu: remove reserve in encoder mode_set Jeykumar Sankaran
     [not found]     ` <1539059262-8326-12-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-10 14:57       ` Sean Paul
2018-10-09  4:27   ` [PATCH 12/25] drm/msm/dpu: remove mode_set_complete Jeykumar Sankaran
2018-10-10 14:59     ` Sean Paul
2018-10-09  4:27   ` [PATCH 13/25] drm/msm/dpu: make RM iterator hw type specific Jeykumar Sankaran
     [not found]     ` <1539059262-8326-14-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-10 15:00       ` Sean Paul
2018-10-09  4:27   ` [PATCH 14/25] drm/msm/dpu: remove enc_id tagging for hw blocks Jeykumar Sankaran
2018-10-10 15:06     ` Sean Paul
2018-10-10 18:41       ` Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 15/25] drm/msm/dpu: avoid redundant hw blk reference Jeykumar Sankaran
     [not found]     ` <1539059262-8326-16-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-10 15:07       ` Sean Paul
2018-10-09  4:27   ` [PATCH 16/25] drm/msm/dpu: clean up test_only flag for RM reservation Jeykumar Sankaran
2018-10-10 15:10     ` Sean Paul
2018-10-09  4:27   ` Jeykumar Sankaran [this message]
2018-10-09  4:27   ` [PATCH 18/25] drm/msm/dpu: merge RM interface reservation helpers Jeykumar Sankaran
     [not found]     ` <1539059262-8326-19-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 16:50       ` Jordan Crouse
     [not found]         ` <20181009165022.GD3130-9PYrDHPZ2Orvke4nUoYGnHL1okKdlPRT@public.gmane.org>
2018-10-09 18:20           ` Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 19/25] drm/msm/dpu: remove msm_display_topology Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 20/25] drm/msm/dpu: refine layer mixer reservations Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 21/25] drm/msm/dpu: merge RM reservation helpers Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 22/25] drm/msm/dpu: make crtc and encoder specific HW reservation Jeykumar Sankaran
     [not found]     ` <1539059262-8326-23-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 20:41       ` Sean Paul
2018-10-10  6:15         ` Jeykumar Sankaran
2018-10-10 14:33           ` [Freedreno] " Sean Paul
2018-10-09  4:27   ` [PATCH 23/25] drm/msm/dpu: remove max_width from RM Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 24/25] drm/msm/dpu: remove mutex locking for RM interfaces Jeykumar Sankaran
     [not found]     ` <1539059262-8326-25-git-send-email-jsanka-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-09 19:57       ` Sean Paul
2018-10-10  6:03         ` Jeykumar Sankaran
     [not found]           ` <0c506d6b3edbfec7519a2bffa9bdaedc-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2018-10-10 14:36             ` Sean Paul
2018-10-10 18:40               ` [Freedreno] " Jeykumar Sankaran
2018-10-09  4:27   ` [PATCH 25/25] drm/msm/dpu: maintain RM init check internally Jeykumar Sankaran
2018-10-09 19:29   ` [PATCH 00/25] reserve RM resources in CRTC state Sean Paul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539059262-8326-18-git-send-email-jsanka@codeaurora.org \
    --to=jsanka-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=hoegsberg-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=seanpaul-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.