]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/vkms: Avoid assigning 0 for possible_crtc
authorRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Wed, 26 Jun 2019 01:36:18 +0000 (22:36 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Oct 2019 16:58:30 +0000 (18:58 +0200)
[ Upstream commit e9d85f731de06a35d2ae6cdcf7d0e037c98ef41a ]

When vkms invoke drm_universal_plane_init(), it sets 0 for
possible_crtcs parameter which means that planes can't be attached to
any CRTC. It currently works due to some safeguard in the drm_crtc file;
however, it is possible to identify the problem by trying to append a
second connector. This patch fixes this issue by modifying
vkms_plane_init() to accept an index parameter which makes the code a
little bit more flexible and avoid set zero to possible_crtcs.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/d67849c62a8d8ace1a0af455998b588798a4c45f.1561491964.git.rodrigosiqueiramelo@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/vkms/vkms_drv.c
drivers/gpu/drm/vkms/vkms_drv.h
drivers/gpu/drm/vkms/vkms_output.c
drivers/gpu/drm/vkms/vkms_plane.c

index 738dd6206d85b0793d4a0c34057837500069baae..92296bd8f6233ac091ab4f33824ba69fed9f28c7 100644 (file)
@@ -92,7 +92,7 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)
        dev->mode_config.max_height = YRES_MAX;
        dev->mode_config.preferred_depth = 24;
 
-       return vkms_output_init(vkmsdev);
+       return vkms_output_init(vkmsdev, 0);
 }
 
 static int __init vkms_init(void)
index 3c7e06b19efd565610cf35e9ee433355a5e5f146..a0adcc86079f55d115845ca695f66873066210df 100644 (file)
@@ -115,10 +115,10 @@ bool vkms_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
                               int *max_error, ktime_t *vblank_time,
                               bool in_vblank_irq);
 
-int vkms_output_init(struct vkms_device *vkmsdev);
+int vkms_output_init(struct vkms_device *vkmsdev, int index);
 
 struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
-                                 enum drm_plane_type type);
+                                 enum drm_plane_type type, int index);
 
 /* Gem stuff */
 struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
index 3b162b25312ece5932e0e1befcbbc968925815a1..1442b447c7070fb54e193e358564e9eecbfdd2de 100644 (file)
@@ -36,7 +36,7 @@ static const struct drm_connector_helper_funcs vkms_conn_helper_funcs = {
        .get_modes    = vkms_conn_get_modes,
 };
 
-int vkms_output_init(struct vkms_device *vkmsdev)
+int vkms_output_init(struct vkms_device *vkmsdev, int index)
 {
        struct vkms_output *output = &vkmsdev->output;
        struct drm_device *dev = &vkmsdev->drm;
@@ -46,12 +46,12 @@ int vkms_output_init(struct vkms_device *vkmsdev)
        struct drm_plane *primary, *cursor = NULL;
        int ret;
 
-       primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY);
+       primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index);
        if (IS_ERR(primary))
                return PTR_ERR(primary);
 
        if (enable_cursor) {
-               cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR);
+               cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index);
                if (IS_ERR(cursor)) {
                        ret = PTR_ERR(cursor);
                        goto err_cursor;
index 0e67d2d42f0cc4014fe88b263237fa347af07116..20ffc52f9194055ec41289e194b54ff24fd42681 100644 (file)
@@ -168,7 +168,7 @@ static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = {
 };
 
 struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
-                                 enum drm_plane_type type)
+                                 enum drm_plane_type type, int index)
 {
        struct drm_device *dev = &vkmsdev->drm;
        const struct drm_plane_helper_funcs *funcs;
@@ -190,7 +190,7 @@ struct drm_plane *vkms_plane_init(struct vkms_device *vkmsdev,
                funcs = &vkms_primary_helper_funcs;
        }
 
-       ret = drm_universal_plane_init(dev, plane, 0,
+       ret = drm_universal_plane_init(dev, plane, 1 << index,
                                       &vkms_plane_funcs,
                                       formats, nformats,
                                       NULL, type, NULL);