<div dir="ltr">"friendly ping"</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 10, 2021 at 11:14 AM Mark Yacoub <<a href="mailto:markyacoub@chromium.org">markyacoub@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Mark Yacoub <<a href="mailto:markyacoub@google.com" target="_blank">markyacoub@google.com</a>><br>
<br>
On initializing the framebuffer, call drm_any_plane_has_format to do a<br>
check if the modifier is supported. drm_any_plane_has_format calls<br>
dm_plane_format_mod_supported which is extended to validate that the<br>
modifier is on the list of the plane's supported modifiers.<br>
<br>
The bug was caught using igt-gpu-tools test: kms_addfb_basic.addfb25-bad-modifier<br>
<br>
Tested on ChromeOS Zork by turning on the display, running an overlay<br>
test, and running a YT video.<br>
<br>
Cc: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" target="_blank">alexander.deucher@amd.com</a>><br>
Cc: Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>><br>
Signed-off-by: default avatarMark Yacoub <<a href="mailto:markyacoub@chromium.org" target="_blank">markyacoub@chromium.org</a>><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       | 13 +++++++++++++<br>
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  9 +++++++++<br>
 2 files changed, 22 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
index afa5f8ad0f563..a947b5aa420d2 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c<br>
@@ -908,6 +908,19 @@ int amdgpu_display_gem_fb_verify_and_init(<br>
                                         &amdgpu_fb_funcs);<br>
        if (ret)<br>
                goto err;<br>
+       /* Verify that the modifier is supported. */<br>
+       if (!drm_any_plane_has_format(dev, mode_cmd->pixel_format,<br>
+                                     mode_cmd->modifier[0])) {<br>
+               struct drm_format_name_buf format_name;<br>
+               drm_dbg_kms(dev,<br>
+                           "unsupported pixel format %s / modifier 0x%llx\n",<br>
+                           drm_get_format_name(mode_cmd->pixel_format,<br>
+                                               &format_name),<br>
+                           mode_cmd->modifier[0]);<br>
+<br>
+               ret = -EINVAL;<br>
+               goto err;<br>
+       }<br>
<br>
        ret = amdgpu_display_framebuffer_init(dev, rfb, mode_cmd, obj);<br>
        if (ret)<br>
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
index 961abf1cf040c..21314024a83ce 100644<br>
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c<br>
@@ -3939,6 +3939,7 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,<br>
 {<br>
        struct amdgpu_device *adev = drm_to_adev(plane->dev);<br>
        const struct drm_format_info *info = drm_format_info(format);<br>
+       int i;<br>
<br>
        enum dm_micro_swizzle microtile = modifier_gfx9_swizzle_mode(modifier) & 3;<br>
<br>
@@ -3952,6 +3953,14 @@ static bool dm_plane_format_mod_supported(struct drm_plane *plane,<br>
        if (modifier == DRM_FORMAT_MOD_LINEAR)<br>
                return true;<br>
<br>
+       /* Check that the modifier is on the list of the plane's supported modifiers. */<br>
+       for (i = 0; i < plane->modifier_count; i++) {<br>
+               if (modifier == plane->modifiers[i])<br>
+                       break;<br>
+       }<br>
+       if (i == plane->modifier_count)<br>
+               return false;<br>
+<br>
        /*<br>
         * The arbitrary tiling support for multiplane formats has not been hooked<br>
         * up.<br>
-- <br>
2.30.1.766.gb4fecdf3b7-goog<br>
<br>
</blockquote></div>