drm/mediatek: Add valid modifier check
Subsystems (3)
PATCH v2 1/1 drm/mediatek: Add valid modifier check
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.
---
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(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +7 -0
@@ -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); }
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
Hi, Justin:
Quoted 7 lines · Justin Green
External email : Please do not click links or open attachments until you have verified the sender or the content.
Add a check tomtk_drm_mode_fb_create()that rejects any modifier
that
is not the AFBC mode supported by MT8195's display overlays.
Quoted 5 lines
Tested by booting ChromeOS and verifying the UI works, and by running the ChromeOS
kms_addfb_basicbinary, which has a test called "addfb25-bad-modifier" that attempts to create a framebuffer with the modifierDRM_FORMAT_MOD_INVALIDand verifies the ADDFB2 ioctl returns EINVAL.
Quoted 32 lines
Signed-off-by Justin Green <[email protected]>Tested-by Fei Shao <[email protected]>---
v2:
* Replace zero check with comparison toDRM_FORMAT_MOD_LINEAR.drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -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|
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4
-0+ AFBC_FORMAT_MOD_SPLIT | + AFBC_FORMAT_MOD_SPARSE)) +return ERR_PTR (-EINVAL ); +return drm_gem_fb_create (dev, file, cmd); }Signature · 2 lines
-- 2.41.0.487.g6d72f3e995-goog
Quoted 11 lines · CK Hu (胡俊光)
Hi, Justin:
Quoted 7 lines · Justin Green
External email : Please do not click links or open attachments until you have verified the sender or the content.
Add a check tomtk_drm_mode_fb_create()that rejects any modifier
that
is not the AFBC mode supported by MT8195's display overlays.
Quoted 11 lines
Quoted 5 lines
Tested by booting ChromeOS and verifying the UI works, and by running the ChromeOS
kms_addfb_basicbinary, which has a test called "addfb25-bad-modifier" that attempts to create a framebuffer with the modifierDRM_FORMAT_MOD_INVALIDand verifies the ADDFB2 ioctl returns EINVAL.Reviewed-by CK Hu <[email protected]>Quoted 3 lines
Signed-off-by Justin Green <[email protected]>Tested-by Fei Shao <[email protected]>
with IGT on Hayato with this patch backported to v6.1 downstream kernel.
Quoted 29 lines
Quoted 29 lines
---
v2:
* Replace zero check with comparison toDRM_FORMAT_MOD_LINEAR.drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-0@@ -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|
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4
-1+ 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