From 75ac49532a3cd44f2b22d88bab888ae92c411650 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 1 Sep 2016 09:41:35 +0200 Subject: [PATCH 1/6] drm/doc: Add a few words on validation with IGT Also provide some pointers for building IGT as some kernel hackers might not be that familiar with building stuff on Linux distros. Signed-off-by: Tomeu Vizoso Cc: Daniel Vetter Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/1472715695-19812-1-git-send-email-tomeu.vizoso@collabora.com --- Documentation/gpu/drm-uapi.rst | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst index 12b47c30fe2e..1ba301cebe16 100644 --- a/Documentation/gpu/drm-uapi.rst +++ b/Documentation/gpu/drm-uapi.rst @@ -156,6 +156,43 @@ other hand, a driver requires shared state between clients which is visible to user-space and accessible beyond open-file boundaries, they cannot support render nodes. +Validating changes with IGT +=========================== + +There's a collection of tests that aims to cover the whole functionality of +DRM drivers and that can be used to check that changes to DRM drivers or the +core don't regress existing functionality. This test suite is called IGT and +its code can be found in https://cgit.freedesktop.org/drm/igt-gpu-tools/. + +To build IGT, start by installing its build dependencies. In Debian-based +systems:: + + # apt-get build-dep intel-gpu-tools + +And in Fedora-based systems:: + + # dnf builddep intel-gpu-tools + +Then clone the repository:: + + $ git clone git://anongit.freedesktop.org/drm/igt-gpu-tools + +Configure the build system and start the build:: + + $ cd igt-gpu-tools && ./autogen.sh && make -j6 + +Download the piglit dependency:: + + $ ./scripts/run-tests.sh -d + +And run the tests:: + + $ ./scripts/run-tests.sh -t kms -t core -s + +run-tests.sh is a wrapper around piglit that will execute the tests matching +the -t options. A report in HTML format will be available in +./results/html/index.html. Results can be compared with piglit. + VBlank event handling ===================== From 4e9951d960932d648197d691aa28a7bc0ced1b56 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Mon, 5 Sep 2016 10:06:13 +0200 Subject: [PATCH 2/6] drm/atomic: Reject properties not part of the object. The legacy setprop ioctl doesn't attempt to set properties that are not enumerated on the object. The atomic ioctl does, fix this by validating first. Signed-off-by: Maarten Lankhorst Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/1473062773-5045-1-git-send-email-maarten.lankhorst@linux.intel.com --- drivers/gpu/drm/drm_atomic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 5cb2e22d5d55..a5126e5c05ee 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -1609,7 +1609,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev, struct drm_crtc_state *crtc_state; unsigned plane_mask; int ret = 0; - unsigned int i, j; + unsigned int i, j, k; /* disallow for drivers not supporting atomic: */ if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) @@ -1691,6 +1691,15 @@ retry: goto out; } + for (k = 0; k < obj->properties->count; k++) + if (obj->properties->properties[k]->base.id == prop_id) + break; + + if (k == obj->properties->count) { + ret = -EINVAL; + goto out; + } + prop = drm_property_find(dev, prop_id); if (!prop) { drm_mode_object_unreference(obj); From ae0119f5f73b1e9cf7177fbbeea68d74c5751def Mon Sep 17 00:00:00 2001 From: Xie XiuQi Date: Tue, 6 Sep 2016 16:55:38 +0800 Subject: [PATCH 3/6] drm: fix signed integer overflow Use 1UL for unsigned long, or we'll meet a overflow issue with UBSAN. [ 15.589489] UBSAN: Undefined behaviour in drivers/gpu/drm/drm_hashtab.c:145:35 [ 15.589500] signed integer overflow: [ 15.589999] -2147483648 - 1 cannot be represented in type 'int' [ 15.590434] CPU: 2 PID: 294 Comm: plymouthd Not tainted 3.10.0-327.28.3.el7.x86_64 #1 [ 15.590653] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 01/07/2011 [ 15.591001] 1ffff1000670fe83 000000000d6b385e ffff88003387f3e0 ffffffff81ee3140 [ 15.591028] ffff88003387f3f8 ffffffff81ee31fd ffffffffa032f460 ffff88003387f560 [ 15.591044] ffffffff81ee46e2 0000002d00000009 0000000000000001 0000000041b58ab3 [ 15.591059] Call Trace: [ 15.591078] [] dump_stack+0x1e/0x20 [ 15.591093] [] ubsan_epilogue+0x12/0x55 [ 15.591109] [] handle_overflow+0x1ba/0x215 [ 15.591126] [] ? __ubsan_handle_negate_overflow+0x162/0x162 [ 15.591146] [] ? print_context_stack+0x9c/0x160 [ 15.591163] [] ? dump_trace+0x252/0x750 [ 15.591181] [] ? __list_add+0x93/0x160 [ 15.591197] [] __ubsan_handle_sub_overflow+0x2a/0x31 [ 15.591261] [] drm_ht_just_insert_please+0x1e0/0x200 [drm] [ 15.591290] [] ttm_base_object_init+0x10a/0x270 [ttm] [ 15.591316] [] ttm_vt_lock+0x28c/0x3a0 [ttm] [ 15.591343] [] ? ttm_write_lock+0x180/0x180 [ttm] [ 15.591362] [] ? kasan_unpoison_shadow+0x36/0x50 [ 15.591379] [] ? kasan_unpoison_shadow+0x36/0x50 [ 15.591396] [] ? kasan_unpoison_shadow+0x36/0x50 [ 15.591413] [] ? kasan_unpoison_shadow+0x36/0x50 [ 15.591442] [] vmw_master_set+0x121/0x470 [vmwgfx] [ 15.591459] [] ? __init_waitqueue_head+0x45/0x70 [ 15.591487] [] ? vmw_master_drop+0x310/0x310 [vmwgfx] [ 15.591535] [] drm_open+0x92a/0xc00 [drm] [ 15.591563] [] ? vmw_driver_open+0x170/0x170 [vmwgfx] [ 15.591610] [] ? drm_poll+0xe0/0xe0 [drm] [ 15.591661] [] drm_stub_open+0x224/0x330 [drm] [ 15.591711] [] ? drm_minor_acquire+0x240/0x240 [drm] [ 15.591727] [] chrdev_open+0x1fa/0x3f0 [ 15.591742] [] ? cdev_put+0x50/0x50 [ 15.591761] [] ? __fsnotify_parent+0x53/0x210 [ 15.591778] [] do_dentry_open+0x351/0x670 [ 15.591792] [] ? cdev_put+0x50/0x50 [ 15.591807] [] vfs_open+0xa2/0x170 [ 15.591824] [] do_last+0xccf/0x2c80 [ 15.591842] [] ? filename_create+0x320/0x320 [ 15.591858] [] ? path_init+0x1b9/0xa90 [ 15.591875] [] ? mountpoint_last+0x9a0/0x9a0 [ 15.591894] [] ? selinux_file_alloc_security+0xcf/0x130 [ 15.591911] [] path_openat+0x1e7/0xcc0 [ 15.591927] [] ? dump_trace+0x252/0x750 [ 15.591943] [] ? do_last+0x2c80/0x2c80 [ 15.591959] [] ? __list_add+0x93/0x160 [ 15.591974] [] ? save_stack_trace+0x7d/0xb0 [ 15.591989] [] do_filp_open+0xa4/0x160 [ 15.592004] [] ? user_path_mountpoint_at+0x50/0x50 [ 15.592022] [] ? __alloc_fd+0x175/0x300 [ 15.592039] [] do_sys_open+0x1b7/0x3f0 [ 15.592054] [] ? filp_open+0x80/0x80 [ 15.592070] [] SyS_open+0x32/0x40 [ 15.592088] [] system_call_fastpath+0x16/0x1b Signed-off-by: Xie XiuQi [seanpaul tweaked subject to remove "gpu/"] Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/1473152138-25335-1-git-send-email-xiexiuqi@huawei.com --- drivers/gpu/drm/drm_hashtab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c index 7b30b307674b..dae18e58e79b 100644 --- a/drivers/gpu/drm/drm_hashtab.c +++ b/drivers/gpu/drm/drm_hashtab.c @@ -142,7 +142,7 @@ int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *it unsigned long add) { int ret; - unsigned long mask = (1 << bits) - 1; + unsigned long mask = (1UL << bits) - 1; unsigned long first, unshifted_key; unshifted_key = hash_long(seed, bits); From 737ba10928061c899b7da45e8580ac5c20ff3593 Mon Sep 17 00:00:00 2001 From: Haixia Shi Date: Tue, 30 Aug 2016 14:50:21 -0700 Subject: [PATCH 4/6] drm/udl: implement usb_driver suspend/resume. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The usb_driver suspend and resume function pointers must be populated to prevent forced unbinding of USB interface driver. See usb/core/driver.c: unbind_no_pm_drivers_interfaces(). Restore mode and damage the entire frame buffer upon resume. TEST=suspend and resume with the same UDL device connected TEST=suspend with UDL, unplug UDL and resume TEST=suspend with UDL, unplug and connect another UDL device then resume Signed-off-by: Haixia Shi Reviewed-by: Stéphane Marchesin [seanpaul fixed checkpatch warnings and gave marcheu his é back] Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/1472593821-38429-2-git-send-email-hshi@chromium.org --- drivers/gpu/drm/udl/udl_drv.c | 16 ++++++++++++++++ drivers/gpu/drm/udl/udl_drv.h | 2 ++ drivers/gpu/drm/udl/udl_modeset.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c index 17d34e0edbdd..f0851db6ba6c 100644 --- a/drivers/gpu/drm/udl/udl_drv.c +++ b/drivers/gpu/drm/udl/udl_drv.c @@ -16,6 +16,20 @@ static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m) return 0; } +static int udl_usb_suspend(struct usb_interface *interface, + pm_message_t message) +{ + return 0; +} + +static int udl_usb_resume(struct usb_interface *interface) +{ + struct drm_device *dev = usb_get_intfdata(interface); + + udl_modeset_restore(dev); + return 0; +} + static const struct vm_operations_struct udl_gem_vm_ops = { .fault = udl_gem_fault, .open = drm_gem_vm_open, @@ -122,6 +136,8 @@ static struct usb_driver udl_driver = { .name = "udl", .probe = udl_usb_probe, .disconnect = udl_usb_disconnect, + .suspend = udl_usb_suspend, + .resume = udl_usb_resume, .id_table = id_table, }; module_usb_driver(udl_driver); diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index 0b03d34ffdee..f338a576efc8 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -52,6 +52,7 @@ struct udl_device { struct device *dev; struct drm_device *ddev; struct usb_device *udev; + struct drm_crtc *crtc; int sku_pixel_limit; @@ -87,6 +88,7 @@ struct udl_framebuffer { /* modeset */ int udl_modeset_init(struct drm_device *dev); +void udl_modeset_restore(struct drm_device *dev); void udl_modeset_cleanup(struct drm_device *dev); int udl_connector_init(struct drm_device *dev, struct drm_encoder *encoder); diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index 73695127c573..f2b2481cad52 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -309,6 +309,8 @@ static int udl_crtc_mode_set(struct drm_crtc *crtc, char *wrptr; int color_depth = 0; + udl->crtc = crtc; + buf = (char *)udl->mode_buf; /* for now we just clip 24 -> 16 - if we fix that fix this */ @@ -450,6 +452,18 @@ int udl_modeset_init(struct drm_device *dev) return 0; } +void udl_modeset_restore(struct drm_device *dev) +{ + struct udl_device *udl = dev->dev_private; + struct udl_framebuffer *ufb; + + if (!udl->crtc || !udl->crtc->primary->fb) + return; + udl_crtc_commit(udl->crtc); + ufb = to_udl_fb(udl->crtc->primary->fb); + udl_handle_damage(ufb, 0, 0, ufb->base.width, ufb->base.height); +} + void udl_modeset_cleanup(struct drm_device *dev) { drm_mode_config_cleanup(dev); From 30c06570cd6716ba392f674c49dee5a69f96e096 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Wed, 7 Sep 2016 11:52:40 +0200 Subject: [PATCH 5/6] Revert "drm: Unify handling of blob and object properties" This reverts commit 77953bd136d2a70bca2dc93b3ccda07a2b37076f. This causes a kernel panic when trying to assign a blob to a property, and has obviously never been tested. Fixes: 77953bd136d2 ("drm: Unify handling of blob and object properties") Signed-off-by: Maarten Lankhorst Tested-by: Liu Ying Acked-by: Daniel Stone Signed-off-by: Jani Nikula Link: http://patchwork.freedesktop.org/patch/msgid/8c0d3482-1bb5-6a15-b105-6bda2b31b5dc@linux.intel.com --- drivers/gpu/drm/drm_property.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index 4139afbcc267..a4d81cf4ffa0 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -870,8 +870,20 @@ bool drm_property_change_valid_get(struct drm_property *property, for (i = 0; i < property->num_values; i++) valid_mask |= (1ULL << property->values[i]); return !(value & ~valid_mask); - } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB) || - drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { + } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) { + struct drm_property_blob *blob; + + if (value == 0) + return true; + + blob = drm_property_lookup_blob(property->dev, value); + if (blob) { + *ref = &blob->base; + return true; + } else { + return false; + } + } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { /* a zero value for an object property translates to null: */ if (value == 0) return true; @@ -888,12 +900,13 @@ bool drm_property_change_valid_get(struct drm_property *property, } void drm_property_change_valid_put(struct drm_property *property, - struct drm_mode_object *ref) + struct drm_mode_object *ref) { if (!ref) return; - if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT) || - drm_property_type_is(property, DRM_MODE_PROP_BLOB)) + if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { drm_mode_object_unreference(ref); + } else if (drm_property_type_is(property, DRM_MODE_PROP_BLOB)) + drm_property_unreference_blob(obj_to_blob(ref)); } From dec90ea1456b5a5d990d94ade2e45a2457cfd149 Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Wed, 7 Sep 2016 20:23:45 +0300 Subject: [PATCH 6/6] drm: Fix error path in drm_mode_page_flip_ioctl() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the error path for platforms that don't define the new page_flip_target() hook. Fixes: c229bfbbd04 ("drm: Add page_flip_target CRTC hook v2") Testcase: igt/kms_flip/basic-flip-vs-dpms CC: Michel Dänzer Signed-off-by: Imre Deak Reviewed-by: Michel Dänzer Signed-off-by: Jani Nikula Link: http://patchwork.freedesktop.org/patch/msgid/1473269025-16148-1-git-send-email-imre.deak@intel.com --- drivers/gpu/drm/drm_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index a33dab27bb0d..631691bae01d 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2044,7 +2044,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev, } out: - if (ret) + if (ret && crtc->funcs->page_flip_target) drm_crtc_vblank_put(crtc); if (fb) drm_framebuffer_unreference(fb);