]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amd/display: Store gem objects for planes 1-3
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 11 Nov 2020 02:48:38 +0000 (03:48 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Nov 2020 22:29:47 +0000 (17:29 -0500)
Also do the proper validation which was missed.

Besides the missing validation, not storing the objects in the
framebuffer led to wrong results in the getfb2 ioctl.

Note that this should really have been done for multi-plane
formats like NV12 already before modifiers landed.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

index f4de4b41adcfdc23d79b31c9e0355b4006faf133..e80b295f23c4cf3a58f91b40adef66eac5545449 100644 (file)
@@ -687,13 +687,26 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
                                    const struct drm_mode_fb_cmd2 *mode_cmd,
                                    struct drm_gem_object *obj)
 {
-       int ret;
+       int ret, i;
        rfb->base.obj[0] = obj;
        drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
        ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
        if (ret)
                goto fail;
 
+       /*
+        * This needs to happen before modifier conversion as that might change
+        * the number of planes.
+        */
+       for (i = 1; i < rfb->base.format->num_planes; ++i) {
+               if (mode_cmd->handles[i] != mode_cmd->handles[0]) {
+                       dev_err(&dev->pdev->dev, "Plane 0 and %d have different BOs: %u vs. %u\n",
+                               i, mode_cmd->handles[0], mode_cmd->handles[i]);
+                       ret = -EINVAL;
+                       goto fail;
+               }
+       }
+
        ret = amdgpu_display_get_fb_info(rfb, &rfb->tiling_flags, &rfb->tmz_surface);
        if (ret)
                goto fail;
@@ -705,6 +718,11 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
                        goto fail;
        }
 
+       for (i = 1; i < rfb->base.format->num_planes; ++i) {
+               rfb->base.obj[i] = rfb->base.obj[0];
+               drm_gem_object_get(rfb->base.obj[i]);
+       }
+
        return 0;
 
 fail: