* [PATCH v2] drm/mediatek: Add valid modifier check
@ 2023-07-26 19:52 Justin Green
2023-07-27 3:04 ` CK Hu (胡俊光)
0 siblings, 1 reply; 3+ messages in thread
From: Justin Green @ 2023-07-26 19:52 UTC (permalink / raw)
To: linux-mediatek, dri-devel
Cc: chunkuang.hu, Justin Green, fshao, jason-jh.lin, justin.yeh,
wenst, angelogioacchino.delregno
Add a check to mtk_drm_mode_fb_create() that rejects any modifier that
is not the AFBC mode supported by MT8195's display overlays.
Tested by booting ChromeOS and verifying the UI works, and by running
the ChromeOS kms_addfb_basic binary, which has a test called
"addfb25-bad-modifier" that attempts to create a framebuffer with the
modifier DRM_FORMAT_MOD_INVALID and verifies the ADDFB2 ioctl returns
EINVAL.
Signed-off-by: Justin Green <greenjustin@chromium.org>
Tested-by: Fei Shao <fshao@chromium.org>
---
v2:
* Replace zero check with comparison to DRM_FORMAT_MOD_LINEAR.
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index cd5b18ef7951..2719a1e3163a 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -51,6 +51,13 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
if (info->num_planes != 1)
return ERR_PTR(-EINVAL);
+ if (cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR &&
+ cmd->modifier[0] != DRM_FORMAT_MOD_ARM_AFBC(
+ AFBC_FORMAT_MOD_BLOCK_SIZE_32x8 |
+ AFBC_FORMAT_MOD_SPLIT |
+ AFBC_FORMAT_MOD_SPARSE))
+ return ERR_PTR(-EINVAL);
+
return drm_gem_fb_create(dev, file, cmd);
}
--
2.41.0.487.g6d72f3e995-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/mediatek: Add valid modifier check
2023-07-26 19:52 [PATCH v2] drm/mediatek: Add valid modifier check Justin Green
@ 2023-07-27 3:04 ` CK Hu (胡俊光)
2023-07-31 7:45 ` Chen-Yu Tsai
0 siblings, 1 reply; 3+ messages in thread
From: CK Hu (胡俊光) @ 2023-07-27 3:04 UTC (permalink / raw)
To: dri-devel, linux-mediatek, greenjustin
Cc: chunkuang.hu, fshao, Jason-JH Lin (林睿祥),
Justin Yeh (葉英茂),
wenst, angelogioacchino.delregno
[-- Attachment #1: Type: text/html, Size: 3529 bytes --]
[-- Attachment #2: Type: text/plain, Size: 1697 bytes --]
Hi, Justin:
On Wed, 2023-07-26 at 15:52 -0400, Justin Green wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Add a check to mtk_drm_mode_fb_create() that rejects any modifier
> that
> is not the AFBC mode supported by MT8195's display overlays.
>
> Tested by booting ChromeOS and verifying the UI works, and by running
> the ChromeOS kms_addfb_basic binary, which has a test called
> "addfb25-bad-modifier" that attempts to create a framebuffer with the
> modifier DRM_FORMAT_MOD_INVALID and verifies the ADDFB2 ioctl returns
> EINVAL.
Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> Signed-off-by: Justin Green <greenjustin@chromium.org>
> Tested-by: Fei Shao <fshao@chromium.org>
> ---
> v2:
> * Replace zero check with comparison to DRM_FORMAT_MOD_LINEAR.
>
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cd5b18ef7951..2719a1e3163a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -51,6 +51,13 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
> if (info->num_planes != 1)
> return ERR_PTR(-EINVAL);
>
> + if (cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR &&
> + cmd->modifier[0] != DRM_FORMAT_MOD_ARM_AFBC(
> + AFBC_FORMAT_MOD_BLOCK_SIZE_32x8
> |
> + AFBC_FORMAT_MOD_SPLIT |
> + AFBC_FORMAT_MOD_SPARSE))
> + return ERR_PTR(-EINVAL);
> +
> return drm_gem_fb_create(dev, file, cmd);
> }
>
> --
> 2.41.0.487.g6d72f3e995-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/mediatek: Add valid modifier check
2023-07-27 3:04 ` CK Hu (胡俊光)
@ 2023-07-31 7:45 ` Chen-Yu Tsai
0 siblings, 0 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2023-07-31 7:45 UTC (permalink / raw)
To: CK Hu (胡俊光)
Cc: chunkuang.hu, greenjustin, fshao,
Jason-JH Lin (林睿祥),
Justin Yeh (葉英茂),
dri-devel, linux-mediatek, angelogioacchino.delregno
On Thu, Jul 27, 2023 at 11:04 AM CK Hu (胡俊光) <ck.hu@mediatek.com> wrote:
>
> Hi, Justin:
>
> On Wed, 2023-07-26 at 15:52 -0400, Justin Green wrote:
> >
> > External email : Please do not click links or open attachments until
> > you have verified the sender or the content.
> > Add a check to mtk_drm_mode_fb_create() that rejects any modifier
> > that
> > is not the AFBC mode supported by MT8195's display overlays.
> >
> > Tested by booting ChromeOS and verifying the UI works, and by running
> > the ChromeOS kms_addfb_basic binary, which has a test called
> > "addfb25-bad-modifier" that attempts to create a framebuffer with the
> > modifier DRM_FORMAT_MOD_INVALID and verifies the ADDFB2 ioctl returns
> > EINVAL.
>
> Reviewed-by: CK Hu <ck.hu@mediatek.com>
>
> >
> > Signed-off-by: Justin Green <greenjustin@chromium.org>
> > Tested-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
with IGT on Hayato with this patch backported to v6.1 downstream kernel.
> > ---
> > v2:
> > * Replace zero check with comparison to DRM_FORMAT_MOD_LINEAR.
> >
> > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > index cd5b18ef7951..2719a1e3163a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > @@ -51,6 +51,13 @@ mtk_drm_mode_fb_create(struct drm_device *dev,
> > if (info->num_planes != 1)
> > return ERR_PTR(-EINVAL);
> >
> > + if (cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR &&
> > + cmd->modifier[0] != DRM_FORMAT_MOD_ARM_AFBC(
> > + AFBC_FORMAT_MOD_BLOCK_SIZE_32x8
> > |
> > + AFBC_FORMAT_MOD_SPLIT |
> > + AFBC_FORMAT_MOD_SPARSE))
> > + return ERR_PTR(-EINVAL);
> > +
> > return drm_gem_fb_create(dev, file, cmd);
> > }
> >
> > --
> > 2.41.0.487.g6d72f3e995-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-31 7:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 19:52 [PATCH v2] drm/mediatek: Add valid modifier check Justin Green
2023-07-27 3:04 ` CK Hu (胡俊光)
2023-07-31 7:45 ` Chen-Yu Tsai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).