diff mbox series

drm/mediatek: Fix can't get component for external display plane.

Message ID 20191127100419.130300-1-pihsun@chromium.org (mailing list archive)
State Mainlined
Commit 92c17f6043647652e1f4a772636e4288d4ecea3e
Headers show
Series drm/mediatek: Fix can't get component for external display plane. | expand

Commit Message

Pi-Hsun Shih Nov. 27, 2019, 10:04 a.m. UTC
From: Yongqiang Niu <yongqiang.niu@mediatek.com>

The original logic is ok for primary display, but will not find out
component for external display.

For example, plane->index is 6 for external display, but there are only
2 layer nr in external display, and this condition will never happen:
if (plane->index < (count + mtk_ddp_comp_layer_nr(comp)))

Fix this by using the offset of the plane to mtk_crtc->planes as index,
instead of plane->index.

Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a plane")
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


base-commit: 1875ff320f14afe21731a6e4c7b46dd33e45dfaa

Comments

CK Hu (胡俊光) Dec. 2, 2019, 5:24 a.m. UTC | #1
Hi, Pi-Hsun:


On Wed, 2019-11-27 at 18:04 +0800, Pi-Hsun Shih wrote:
> From: Yongqiang Niu <yongqiang.niu@mediatek.com>
> 
> The original logic is ok for primary display, but will not find out
> component for external display.
> 
> For example, plane->index is 6 for external display, but there are only
> 2 layer nr in external display, and this condition will never happen:
> if (plane->index < (count + mtk_ddp_comp_layer_nr(comp)))
> 
> Fix this by using the offset of the plane to mtk_crtc->planes as index,
> instead of plane->index.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

Regards,
CK

> 
> Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a plane")
> Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index f80a8ba75977..b34e7d70702a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -215,11 +215,12 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
>  	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>  	struct mtk_ddp_comp *comp;
>  	int i, count = 0;
> +	unsigned int local_index = plane - mtk_crtc->planes;
>  
>  	for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>  		comp = mtk_crtc->ddp_comp[i];
> -		if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) {
> -			*local_layer = plane->index - count;
> +		if (local_index < (count + mtk_ddp_comp_layer_nr(comp))) {
> +			*local_layer = local_index - count;
>  			return comp;
>  		}
>  		count += mtk_ddp_comp_layer_nr(comp);
> 
> base-commit: 1875ff320f14afe21731a6e4c7b46dd33e45dfaa
CK Hu (胡俊光) Dec. 12, 2019, 4:49 a.m. UTC | #2
Hi, Pi-Hsun:

On Mon, 2019-12-02 at 13:24 +0800, CK Hu wrote:
> Hi, Pi-Hsun:
> 
> 
> On Wed, 2019-11-27 at 18:04 +0800, Pi-Hsun Shih wrote:
> > From: Yongqiang Niu <yongqiang.niu@mediatek.com>
> > 
> > The original logic is ok for primary display, but will not find out
> > component for external display.
> > 
> > For example, plane->index is 6 for external display, but there are only
> > 2 layer nr in external display, and this condition will never happen:
> > if (plane->index < (count + mtk_ddp_comp_layer_nr(comp)))
> > 
> > Fix this by using the offset of the plane to mtk_crtc->planes as index,
> > instead of plane->index.
> 
> Reviewed-by: CK Hu <ck.hu@mediatek.com>
> 

Applied to mediatek-drm-fixes-5.5 [1], thanks.

[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.5


Regards,
CK

> Regards,
> CK
> 
> > 
> > Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a plane")
> > Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
> > Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index f80a8ba75977..b34e7d70702a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -215,11 +215,12 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
> >  	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
> >  	struct mtk_ddp_comp *comp;
> >  	int i, count = 0;
> > +	unsigned int local_index = plane - mtk_crtc->planes;
> >  
> >  	for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> >  		comp = mtk_crtc->ddp_comp[i];
> > -		if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) {
> > -			*local_layer = plane->index - count;
> > +		if (local_index < (count + mtk_ddp_comp_layer_nr(comp))) {
> > +			*local_layer = local_index - count;
> >  			return comp;
> >  		}
> >  		count += mtk_ddp_comp_layer_nr(comp);
> > 
> > base-commit: 1875ff320f14afe21731a6e4c7b46dd33e45dfaa
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index f80a8ba75977..b34e7d70702a 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -215,11 +215,12 @@  struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
 	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	struct mtk_ddp_comp *comp;
 	int i, count = 0;
+	unsigned int local_index = plane - mtk_crtc->planes;
 
 	for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
 		comp = mtk_crtc->ddp_comp[i];
-		if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) {
-			*local_layer = plane->index - count;
+		if (local_index < (count + mtk_ddp_comp_layer_nr(comp))) {
+			*local_layer = local_index - count;
 			return comp;
 		}
 		count += mtk_ddp_comp_layer_nr(comp);