Skip to contentSkip to conversation

drm/msm/mdp5: handle non-fullscreen base plane case

PATCH In review Rob Clark 5 participants 9 messages Oct 13, 2016 – Oct 15, 2016 4 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH 1/1 drm/msm/mdp5: handle non-fullscreen base plane case

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44 ++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +27 -17
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
 		plane_cnt++;
 	}
 
-	/*
-	* If there is no base layer, enable border color.
-	* Although it's not possbile in current blend logic,
-	* put it here as a reminder.
-	*/
 	if (!pstates[STAGE_BASE] && plane_cnt) {
 		ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
 		DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
 	return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+		struct drm_plane_state *pstate)
+{
+	return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+		(pstate->crtc_w == cstate->mode.hdisplay) &&
+		(pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 		struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	struct plane_state pstates[STAGE_MAX + 1];
 	const struct mdp5_cfg_hw *hw_cfg;
 	const struct drm_plane_state *pstate;
-	int cnt = 0, i;
+	int cnt = 0, base = 0, i;
 
 	DBG("%s: check", mdp5_crtc->name);
 
-	/* verify that there are not too many planes attached to crtc
-	 * and that we don't have conflicting mixer stages:
-	 */
-	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-		if (cnt >= (hw_cfg->lm.nb_stages)) {
-			dev_err(dev->dev, "too many planes!\n");
-			return -EINVAL;
-		}
-
-
 		pstates[cnt].plane = plane;
 		pstates[cnt].state = to_mdp5_plane_state(pstate);
 
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	/* assign a stage based on sorted zpos property */
 	sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+	/* if the bottom-most layer is not fullscreen, we need to use
+	 * it for solid-color:
+	 */
+	if (!is_fullscreen(state, &pstates[0].state->base))
+		base++;
+
+	/* verify that there are not too many planes attached to crtc
+	 * and that we don't have conflicting mixer stages:
+	 */
+	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+	if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+		dev_err(dev->dev, "too many planes!\n");
+		return -EINVAL;
+	}
+
 	for (i = 0; i < cnt; i++) {
-		pstates[i].state->stage = STAGE_BASE + i;
+		pstates[i].state->stage = STAGE_BASE + i + base;
 		DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 				pipe2name(mdp5_plane_pipe(pstates[i].plane)),
 				pstates[i].state->stage);
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 1476377326-17877-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 4 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

The patch looks good. I couldn't test the problematic scenario since I don't have an easy way to reproduce it, but it doesn't break regular usage (where base layer is full screen).

Quoted 90 lines

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44 ++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +27 -17
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
 		plane_cnt++;
 	}
 
-	/*
-	* If there is no base layer, enable border color.
-	* Although it's not possbile in current blend logic,
-	* put it here as a reminder.
-	*/
 	if (!pstates[STAGE_BASE] && plane_cnt) {
 		ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
 		DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
 	return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+		struct drm_plane_state *pstate)
+{
+	return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+		(pstate->crtc_w == cstate->mode.hdisplay) &&
+		(pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 		struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	struct plane_state pstates[STAGE_MAX + 1];
 	const struct mdp5_cfg_hw *hw_cfg;
 	const struct drm_plane_state *pstate;
-	int cnt = 0, i;
+	int cnt = 0, base = 0, i;
 
 	DBG("%s: check", mdp5_crtc->name);
 
-	/* verify that there are not too many planes attached to crtc
-	 * and that we don't have conflicting mixer stages:
-	 */
-	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-		if (cnt >= (hw_cfg->lm.nb_stages)) {
-			dev_err(dev->dev, "too many planes!\n");
-			return -EINVAL;
-		}
-
-
 		pstates[cnt].plane = plane;
 		pstates[cnt].state = to_mdp5_plane_state(pstate);
 
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	/* assign a stage based on sorted zpos property */
 	sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+	/* if the bottom-most layer is not fullscreen, we need to use
+	 * it for solid-color:
+	 */
+	if (!is_fullscreen(state, &pstates[0].state->base))
+		base++;
+
+	/* verify that there are not too many planes attached to crtc
+	 * and that we don't have conflicting mixer stages:
+	 */
+	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+	if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+		dev_err(dev->dev, "too many planes!\n");
+		return -EINVAL;
+	}
+
 	for (i = 0; i < cnt; i++) {
-		pstates[i].state->stage = STAGE_BASE + i;
+		pstates[i].state->stage = STAGE_BASE + i + base;
 		DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 				pipe2name(mdp5_plane_pipe(pstates[i].plane)),
 				pstates[i].state->stage);
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#3 lore raw
In reply to a message not in the archive
Quoted 30 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44 ++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +0 -5
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
 		plane_cnt++;
 	}
 
-	/*
-	* If there is no base layer, enable border color.
-	* Although it's not possbile in current blend logic,
-	* put it here as a reminder.
-	*/
 	if (!pstates[STAGE_BASE] && plane_cnt) {
 		ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
 		DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
 	return pa->state->zpos - pb->state->zpos;

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int pstate_cmp(const void *a, const void *b) · line 370

Quoted 10 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +8 -0
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+		struct drm_plane_state *pstate)
+{
+	return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+		(pstate->crtc_w == cstate->mode.hdisplay) &&
+		(pstate->crtc_h == cstate->mode.vdisplay);
+}

And what if the plane is larger than the screen size while covering it fully?

Quoted 60 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +19 -12
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 		struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	struct plane_state pstates[STAGE_MAX + 1];
 	const struct mdp5_cfg_hw *hw_cfg;
 	const struct drm_plane_state *pstate;
-	int cnt = 0, i;
+	int cnt = 0, base = 0, i;
 
 	DBG("%s: check", mdp5_crtc->name);
 
-	/* verify that there are not too many planes attached to crtc
-	 * and that we don't have conflicting mixer stages:
-	 */
-	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-		if (cnt >= (hw_cfg->lm.nb_stages)) {
-			dev_err(dev->dev, "too many planes!\n");
-			return -EINVAL;
-		}
-
-
 		pstates[cnt].plane = plane;
 		pstates[cnt].state = to_mdp5_plane_state(pstate);
 
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	/* assign a stage based on sorted zpos property */
 	sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+	/* if the bottom-most layer is not fullscreen, we need to use
+	 * it for solid-color:
+	 */
+	if (!is_fullscreen(state, &pstates[0].state->base))
+		base++;
+
+	/* verify that there are not too many planes attached to crtc
+	 * and that we don't have conflicting mixer stages:
+	 */
+	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+	if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+		dev_err(dev->dev, "too many planes!\n");
+		return -EINVAL;
+	}
+
 	for (i = 0; i < cnt; i++) {
-		pstates[i].state->stage = STAGE_BASE + i;
+		pstates[i].state->stage = STAGE_BASE + i + base;
 		DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 				pipe2name(mdp5_plane_pipe(pstates[i].plane)),
 				pstates[i].state->stage);
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 33 lines · Ville Syrjälä
Quoted 32 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44 ++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +0 -5
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
              plane_cnt++;
      }
 
-     /*
-     * If there is no base layer, enable border color.
-     * Although it's not possbile in current blend logic,
-     * put it here as a reminder.
-     */
      if (!pstates[STAGE_BASE] && plane_cnt) {
              ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
              DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
      return pa->state->zpos - pb->state->zpos;
 }
 
Quoted 11 lines

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int pstate_cmp(const void *a, const void *b) · line 370

Quoted 8 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +8 -0
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+             struct drm_plane_state *pstate)
+{
+     return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+             (pstate->crtc_w == cstate->mode.hdisplay) &&
+             (pstate->crtc_h == cstate->mode.vdisplay);
+}

And what if the plane is larger than the screen size while covering it fully?

good question.. if things aren't clipped elsewhere we probably end up programming hw badly..

fwiw, it doesn't seem to hurt anything to turn on the solid-fill layer but we'd be burning an extra mixer stage. I guess I can make this cover that case easily enough, but probably doesn't mean that case works

BR,
-R

Quoted 56 lines
Quoted 56 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +19 -13
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
              struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
      struct plane_state pstates[STAGE_MAX + 1];
      const struct mdp5_cfg_hw *hw_cfg;
      const struct drm_plane_state *pstate;
-     int cnt = 0, i;
+     int cnt = 0, base = 0, i;
 
      DBG("%s: check", mdp5_crtc->name);
 
-     /* verify that there are not too many planes attached to crtc
-      * and that we don't have conflicting mixer stages:
-      */
-     hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
      drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-             if (cnt >= (hw_cfg->lm.nb_stages)) {
-                     dev_err(dev->dev, "too many planes!\n");
-                     return -EINVAL;
-             }
-
-
              pstates[cnt].plane = plane;
              pstates[cnt].state = to_mdp5_plane_state(pstate);
 
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
      /* assign a stage based on sorted zpos property */
      sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+     /* if the bottom-most layer is not fullscreen, we need to use
+      * it for solid-color:
+      */
+     if (!is_fullscreen(state, &pstates[0].state->base))
+             base++;
+
+     /* verify that there are not too many planes attached to crtc
+      * and that we don't have conflicting mixer stages:
+      */
+     hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+     if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+             dev_err(dev->dev, "too many planes!\n");
+             return -EINVAL;
+     }
+
      for (i = 0; i < cnt; i++) {
-             pstates[i].state->stage = STAGE_BASE + i;
+             pstates[i].state->stage = STAGE_BASE + i + base;
              DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
                              pipe2name(mdp5_plane_pipe(pstates[i].plane)),
                              pstates[i].state->stage);
--

2.7.4

Quoted 8 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel OTC

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

#6 lore raw
In reply to Rob Clark
Quoted 68 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44 ++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +10 -16
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
 		plane_cnt++;
 	}
 
-	/*
-	* If there is no base layer, enable border color.
-	* Although it's not possbile in current blend logic,
-	* put it here as a reminder.
-	*/
 	if (!pstates[STAGE_BASE] && plane_cnt) {
 		ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
 		DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
 	return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+		struct drm_plane_state *pstate)
+{
+	return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+		(pstate->crtc_w == cstate->mode.hdisplay) &&
+		(pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 		struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	struct plane_state pstates[STAGE_MAX + 1];
 	const struct mdp5_cfg_hw *hw_cfg;
 	const struct drm_plane_state *pstate;
-	int cnt = 0, i;
+	int cnt = 0, base = 0, i;
 
 	DBG("%s: check", mdp5_crtc->name);
 
-	/* verify that there are not too many planes attached to crtc
-	 * and that we don't have conflicting mixer stages:
-	 */
-	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
 	drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-		if (cnt >= (hw_cfg->lm.nb_stages)) {
-			dev_err(dev->dev, "too many planes!\n");
-			return -EINVAL;
-		}
-
-
 		pstates[cnt].plane = plane;
 		pstates[cnt].state = to_mdp5_plane_state(pstate);
 

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int mdp5_crtc_atomic_check(struct drm_crtc *crtc, · line 401

Quoted 9 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +6 -0
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 	/* assign a stage based on sorted zpos property */
 	sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+	/* if the bottom-most layer is not fullscreen, we need to use
+	 * it for solid-color:
+	 */
+	if (!is_fullscreen(state, &pstates[0].state->base))
+		base++;
+

I get a crash here when fbcon is enabled and there are no connectors connected. We're trying to refer pstates[0] when there is no plane connected to the crtc. I guess we could bail out much earlier if cnt is 0.

Archit

Quoted 17 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +11 -1
+	/* verify that there are not too many planes attached to crtc
+	 * and that we don't have conflicting mixer stages:
+	 */
+	hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+	if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+		dev_err(dev->dev, "too many planes!\n");
+		return -EINVAL;
+	}
+
 	for (i = 0; i < cnt; i++) {
-		pstates[i].state->stage = STAGE_BASE + i;
+		pstates[i].state->stage = STAGE_BASE + i + base;
 		DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 				pipe2name(mdp5_plane_pipe(pstates[i].plane)),
 				pstates[i].state->stage);
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): f57272cf-4e42-741d-e4b7-c201f50130ec-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#8 lore raw
Quoted 78 lines · Archit Taneja
Quoted 76 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44
++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +10 -16
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
                plane_cnt++;
        }
 
-       /*
-       * If there is no base layer, enable border color.
-       * Although it's not possbile in current blend logic,
-       * put it here as a reminder.
-       */
        if (!pstates[STAGE_BASE] && plane_cnt) {
                ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
                DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
        return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+               struct drm_plane_state *pstate)
+{
+       return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+               (pstate->crtc_w == cstate->mode.hdisplay) &&
+               (pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
                struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        struct plane_state pstates[STAGE_MAX + 1];
        const struct mdp5_cfg_hw *hw_cfg;
        const struct drm_plane_state *pstate;
-       int cnt = 0, i;
+       int cnt = 0, base = 0, i;
 
        DBG("%s: check", mdp5_crtc->name);
 
-       /* verify that there are not too many planes attached to crtc
-        * and that we don't have conflicting mixer stages:
-        */
-       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
        drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-               if (cnt >= (hw_cfg->lm.nb_stages)) {
-                       dev_err(dev->dev, "too many planes!\n");
-                       return -EINVAL;
-               }
-
-
                pstates[cnt].plane = plane;
                pstates[cnt].state = to_mdp5_plane_state(pstate);
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        /* assign a stage based on sorted zpos property */
        sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
Quoted 12 lines

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int mdp5_crtc_atomic_check(struct drm_crtc *crtc, · line 401

Quoted 6 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +6 -0
+       /* if the bottom-most layer is not fullscreen, we need to use
+        * it for solid-color:
+        */
+       if (!is_fullscreen(state, &pstates[0].state->base))
+               base++;
+

I get a crash here when fbcon is enabled and there are no connectors connected. We're trying to refer pstates[0] when there is no plane connected to the crtc. I guess we could bail out much earlier if cnt is 0.

yeah, I hit that last night with no fbcon and killing the UI.. I've already fixed it up locally with an 'if (pstates[0].state && !is_fullscreen())'

BR,
-R

Quoted 17 lines

Archit

Quoted 15 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +11 -1
+       /* verify that there are not too many planes attached to crtc
+        * and that we don't have conflicting mixer stages:
+        */
+       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+       if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+               dev_err(dev->dev, "too many planes!\n");
+               return -EINVAL;
+       }
+
        for (i = 0; i < cnt; i++) {
-               pstates[i].state->stage = STAGE_BASE + i;
+               pstates[i].state->stage = STAGE_BASE + i + base;
                DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 
Quoted 7 lines
Quoted 3 lines

pipe2name(mdp5_plane_pipe(pstates[i].plane)),

                                pstates[i].state->stage);

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

#9 lore raw
Quoted 92 lines · Rob Clark
Quoted 78 lines · Archit Taneja
Quoted 76 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44
++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +10 -16
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
                plane_cnt++;
        }
 
-       /*
-       * If there is no base layer, enable border color.
-       * Although it's not possbile in current blend logic,
-       * put it here as a reminder.
-       */
        if (!pstates[STAGE_BASE] && plane_cnt) {
                ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
                DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
        return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+               struct drm_plane_state *pstate)
+{
+       return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+               (pstate->crtc_w == cstate->mode.hdisplay) &&
+               (pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
                struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        struct plane_state pstates[STAGE_MAX + 1];
        const struct mdp5_cfg_hw *hw_cfg;
        const struct drm_plane_state *pstate;
-       int cnt = 0, i;
+       int cnt = 0, base = 0, i;
 
        DBG("%s: check", mdp5_crtc->name);
 
-       /* verify that there are not too many planes attached to crtc
-        * and that we don't have conflicting mixer stages:
-        */
-       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
        drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
-               if (cnt >= (hw_cfg->lm.nb_stages)) {
-                       dev_err(dev->dev, "too many planes!\n");
-                       return -EINVAL;
-               }
-
-
                pstates[cnt].plane = plane;
                pstates[cnt].state = to_mdp5_plane_state(pstate);
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        /* assign a stage based on sorted zpos property */
        sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
Quoted 12 lines

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int mdp5_crtc_atomic_check(struct drm_crtc *crtc, · line 401

Quoted 6 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +6 -0
+       /* if the bottom-most layer is not fullscreen, we need to use
+        * it for solid-color:
+        */
+       if (!is_fullscreen(state, &pstates[0].state->base))
+               base++;
+

I get a crash here when fbcon is enabled and there are no connectors connected. We're trying to refer pstates[0] when there is no plane connected to the crtc. I guess we could bail out much earlier if cnt is 0.

Quoted 3 lines

yeah, I hit that last night with no fbcon and killing the UI.. I've already fixed it up locally with an 'if (pstates[0].state && !is_fullscreen())'

Okay, I guess we should probably memset pstates array to 0 in case the stack memory has some older non NULL stuff in it.

Thanks,
Archit

Quoted 28 lines

BR,
-R

Quoted 24 lines

Archit

Quoted 16 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +11 -1
+       /* verify that there are not too many planes attached to crtc
+        * and that we don't have conflicting mixer stages:
+        */
+       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+       if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+               dev_err(dev->dev, "too many planes!\n");
+               return -EINVAL;
+       }
+
        for (i = 0; i < cnt; i++) {
-               pstates[i].state->stage = STAGE_BASE + i;
+               pstates[i].state->stage = STAGE_BASE + i + base;
                DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 

pipe2name(mdp5_plane_pipe(pstates[i].plane)),

Quoted 2 lines
                                pstates[i].state->stage);

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author
#10 lore raw
Quoted 102 lines · Archit Taneja
Quoted 99 lines · Rob Clark
Quoted 94 lines · Archit Taneja
Quoted 74 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44
++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +10 -16
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
                plane_cnt++;
        }
 
-       /*
-       * If there is no base layer, enable border color.
-       * Although it's not possbile in current blend logic,
-       * put it here as a reminder.
-       */
        if (!pstates[STAGE_BASE] && plane_cnt) {
                ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
                DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
        return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+               struct drm_plane_state *pstate)
+{
+       return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+               (pstate->crtc_w == cstate->mode.hdisplay) &&
+               (pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
                struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        struct plane_state pstates[STAGE_MAX + 1];
        const struct mdp5_cfg_hw *hw_cfg;
        const struct drm_plane_state *pstate;
-       int cnt = 0, i;
+       int cnt = 0, base = 0, i;
 
        DBG("%s: check", mdp5_crtc->name);
 
-       /* verify that there are not too many planes attached to crtc
-        * and that we don't have conflicting mixer stages:
-        */
-       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
        drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state)
 {
-               if (cnt >= (hw_cfg->lm.nb_stages)) {
-                       dev_err(dev->dev, "too many planes!\n");
-                       return -EINVAL;
-               }
-
-
                pstates[cnt].plane = plane;
                pstates[cnt].state = to_mdp5_plane_state(pstate);

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int mdp5_crtc_atomic_check(struct drm_crtc · line 402

Quoted 10 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +6 -0
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        /* assign a stage based on sorted zpos property */
        sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+       /* if the bottom-most layer is not fullscreen, we need to use
+        * it for solid-color:
+        */
+       if (!is_fullscreen(state, &pstates[0].state->base))
+               base++;
+

I get a crash here when fbcon is enabled and there are no connectors connected. We're trying to refer pstates[0] when there is no plane connected to the crtc. I guess we could bail out much earlier if cnt is 0.

Quoted 7 lines
Quoted 3 lines

yeah, I hit that last night with no fbcon and killing the UI.. I've already fixed it up locally with an 'if (pstates[0].state && !is_fullscreen())'

Okay, I guess we should probably memset pstates array to 0 in case the stack memory has some older non NULL stuff in it.

hmm, yeah, you are right.. I wonder how that wasn't already a problem.. I guess we at least always have an outgoing plane? I guess changing the check to '(cnt > 0)' instead of 'pstates[0].state' would do the trick..

fwiw, I pushed current version of this and the other patches to:

https://github.com/freedreno/kernel-msm/commits/integration-linux-qcomlt-fences-2

BR,
-R

Quoted 34 lines

Thanks,
Archit

Quoted 28 lines

BR,
-R

Quoted 24 lines

Archit

Quoted 16 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +11 -1
+       /* verify that there are not too many planes attached to crtc
+        * and that we don't have conflicting mixer stages:
+        */
+       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+       if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+               dev_err(dev->dev, "too many planes!\n");
+               return -EINVAL;
+       }
+
        for (i = 0; i < cnt; i++) {
-               pstates[i].state->stage = STAGE_BASE + i;
+               pstates[i].state->stage = STAGE_BASE + i + base;
                DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 

pipe2name(mdp5_plane_pipe(pstates[i].plane)),

Quoted 2 lines
                                pstates[i].state->stage);

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

Quoted 3 lines

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): CAF6AEGuukfacj7G+j3496tLSBMJA44Yt14NTxpT9kCX5kJftPw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#12 lore raw
Quoted 111 lines · Rob Clark
Quoted 102 lines · Archit Taneja
Quoted 99 lines · Rob Clark
Quoted 94 lines · Archit Taneja
Quoted 74 lines · Rob Clark

If the bottom-most layer is not fullscreen, we need to use the BASE mixer stage for solid fill (ie. MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT). The blend_setup() code pretty much handled this already, we just had to figure this out in _atomic_check() and assign the stages appropriately.

---
TODO mdp4 might need similar treatment?

 drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c | 44
++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +10 -16
index fa2be7c..e42f62d 100644
@@ -223,11 +223,6 @@ static void blend_setup(struct drm_crtc *crtc)
                plane_cnt++;
        }
 
-       /*
-       * If there is no base layer, enable border color.
-       * Although it's not possbile in current blend logic,
-       * put it here as a reminder.
-       */
        if (!pstates[STAGE_BASE] && plane_cnt) {
                ctl_blend_flags |= MDP5_CTL_BLEND_OP_FLAG_BORDER_OUT;
                DBG("Border Color is enabled");
@@ -365,6 +360,15 @@ static int pstate_cmp(const void *a, const void *b)
        return pa->state->zpos - pb->state->zpos;
 }
 
+/* is there a helper for this? */
+static bool is_fullscreen(struct drm_crtc_state *cstate,
+               struct drm_plane_state *pstate)
+{
+       return (pstate->crtc_x == 0) && (pstate->crtc_y == 0) &&
+               (pstate->crtc_w == cstate->mode.hdisplay) &&
+               (pstate->crtc_h == cstate->mode.vdisplay);
+}
+
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
                struct drm_crtc_state *state)
 {
@@ -375,21 +379,11 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        struct plane_state pstates[STAGE_MAX + 1];
        const struct mdp5_cfg_hw *hw_cfg;
        const struct drm_plane_state *pstate;
-       int cnt = 0, i;
+       int cnt = 0, base = 0, i;
 
        DBG("%s: check", mdp5_crtc->name);
 
-       /* verify that there are not too many planes attached to crtc
-        * and that we don't have conflicting mixer stages:
-        */
-       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
        drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state)
 {
-               if (cnt >= (hw_cfg->lm.nb_stages)) {
-                       dev_err(dev->dev, "too many planes!\n");
-                       return -EINVAL;
-               }
-
-
                pstates[cnt].plane = plane;
                pstates[cnt].state = to_mdp5_plane_state(pstate);

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c static int mdp5_crtc_atomic_check(struct drm_crtc · line 402

Quoted 10 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +6 -0
@@ -399,8 +393,24 @@ static int mdp5_crtc_atomic_check(struct drm_crtc
 *crtc,
        /* assign a stage based on sorted zpos property */
        sort(pstates, cnt, sizeof(pstates[0]), pstate_cmp, NULL);
 
+       /* if the bottom-most layer is not fullscreen, we need to use
+        * it for solid-color:
+        */
+       if (!is_fullscreen(state, &pstates[0].state->base))
+               base++;
+

I get a crash here when fbcon is enabled and there are no connectors connected. We're trying to refer pstates[0] when there is no plane connected to the crtc. I guess we could bail out much earlier if cnt is 0.

Quoted 7 lines
Quoted 3 lines

yeah, I hit that last night with no fbcon and killing the UI.. I've already fixed it up locally with an 'if (pstates[0].state && !is_fullscreen())'

Okay, I guess we should probably memset pstates array to 0 in case the stack memory has some older non NULL stuff in it.

Quoted 8 lines

hmm, yeah, you are right.. I wonder how that wasn't already a problem.. I guess we at least always have an outgoing plane? I guess changing the check to '(cnt > 0)' instead of 'pstates[0].state' would do the trick..

fwiw, I pushed current version of this and the other patches to:

https://github.com/freedreno/kernel-msm/commits/integration-linux-qcomlt-fences-2

thanks! I'll start using these patches too.

Archit

Quoted 41 lines

BR,
-R

Quoted 37 lines

Thanks,
Archit

Quoted 28 lines

BR,
-R

Quoted 24 lines

Archit

Quoted 16 lines
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c +11 -1
+       /* verify that there are not too many planes attached to crtc
+        * and that we don't have conflicting mixer stages:
+        */
+       hw_cfg = mdp5_cfg_get_hw_config(mdp5_kms->cfg);
+
+       if ((cnt + base) >= hw_cfg->lm.nb_stages) {
+               dev_err(dev->dev, "too many planes!\n");
+               return -EINVAL;
+       }
+
        for (i = 0; i < cnt; i++) {
-               pstates[i].state->stage = STAGE_BASE + i;
+               pstates[i].state->stage = STAGE_BASE + i + base;
                DBG("%s: assign pipe %s on stage=%d", mdp5_crtc->name,
 

pipe2name(mdp5_plane_pipe(pstates[i].plane)),

Quoted 2 lines
                                pstates[i].state->stage);

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno