<pre>
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

</pre><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->