[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211027163433.2017401-1-markyacoub@chromium.org>
Date: Wed, 27 Oct 2021 12:34:31 -0400
From: Mark Yacoub <markyacoub@...omium.org>
To: unlisted-recipients:; (no To-header on input)
Cc: seanpaul@...omium.org, Mark Yacoub <markyacoub@...gle.com>,
Mark Yacoub <markyacoub@...omium.org>,
Chun-Kuang Hu <chunkuang.hu@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Matthias Brugger <matthias.bgg@...il.com>,
dri-devel@...ts.freedesktop.org,
linux-mediatek@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/mediatek: Do not overwrite user state rotation value.
From: Mark Yacoub <markyacoub@...gle.com>
[Why]
The rotation property must have a valid bitmask value. 0 isn't a valid
value.
The state should not be overwritten when performing an overlay value
check.
[How]
Do not overwrite state during the check.
Resolves: IGT@..._properties@..._properties-sanity-{atomic,non-atomic}
Signed-off-by: Mark Yacoub <markyacoub@...omium.org>
---
drivers/gpu/drm/mediatek/mtk_disp_drv.h | 2 +-
drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 20 +++++++-------------
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 5 ++---
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
index 86c3068894b11..2fc566964f68e 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
@@ -64,7 +64,7 @@ void mtk_ovl_config(struct device *dev, unsigned int w,
unsigned int h, unsigned int vrefresh,
unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
int mtk_ovl_layer_check(struct device *dev, unsigned int idx,
- struct mtk_plane_state *mtk_state);
+ const struct mtk_plane_state *mtk_state);
void mtk_ovl_layer_config(struct device *dev, unsigned int idx,
struct mtk_plane_state *state,
struct cmdq_pkt *cmdq_pkt);
diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
index ea5760f856ec6..13999564304bc 100644
--- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
+++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
@@ -190,19 +190,15 @@ unsigned int mtk_ovl_supported_rotations(struct device *dev)
}
int mtk_ovl_layer_check(struct device *dev, unsigned int idx,
- struct mtk_plane_state *mtk_state)
+ const struct mtk_plane_state *mtk_state)
{
- struct drm_plane_state *state = &mtk_state->base;
- unsigned int rotation = 0;
+ const struct drm_plane_state *state = &mtk_state->base;
+ unsigned int rotation = drm_rotation_simplify(
+ state->rotation,
+ DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y);
- rotation = drm_rotation_simplify(state->rotation,
- DRM_MODE_ROTATE_0 |
- DRM_MODE_REFLECT_X |
- DRM_MODE_REFLECT_Y);
- rotation &= ~DRM_MODE_ROTATE_0;
-
- /* We can only do reflection, not rotation */
- if ((rotation & DRM_MODE_ROTATE_MASK) != 0)
+ /* We can only do reflection, not non-zero rotation */
+ if (((rotation & ~DRM_MODE_ROTATE_0) & DRM_MODE_ROTATE_MASK) != 0)
return -EINVAL;
/*
@@ -212,8 +208,6 @@ int mtk_ovl_layer_check(struct device *dev, unsigned int idx,
if (state->fb->format->is_yuv && rotation != 0)
return -EINVAL;
- state->rotation = rotation;
-
return 0;
}
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
index 1b582262b682b..530bdd031933f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h
@@ -53,9 +53,8 @@ struct mtk_ddp_comp_funcs {
void (*disable_vblank)(struct device *dev);
unsigned int (*supported_rotations)(struct device *dev);
unsigned int (*layer_nr)(struct device *dev);
- int (*layer_check)(struct device *dev,
- unsigned int idx,
- struct mtk_plane_state *state);
+ int (*layer_check)(struct device *dev, unsigned int idx,
+ const struct mtk_plane_state *state);
void (*layer_config)(struct device *dev, unsigned int idx,
struct mtk_plane_state *state,
struct cmdq_pkt *cmdq_pkt);
--
2.33.0.1079.g6e70778dc9-goog
Powered by blists - more mailing lists