From fd00410ea85b8a02e400034eaf93a503edd2033e Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Mon, 5 Oct 2015 11:24:38 -0400 Subject: [PATCH] Add patches to fix qxl locking issues (rhbz 1238803 1249850) --- ...ffer-reservation-in-qxl_crtc_page_fl.patch | 53 +++++++++++++++++++ drm-qxl-avoid-dependency-lock.patch | 42 +++++++++++++++ kernel.spec | 7 +++ 3 files changed, 102 insertions(+) create mode 100644 drm-qxl-avoid-buffer-reservation-in-qxl_crtc_page_fl.patch create mode 100644 drm-qxl-avoid-dependency-lock.patch diff --git a/drm-qxl-avoid-buffer-reservation-in-qxl_crtc_page_fl.patch b/drm-qxl-avoid-buffer-reservation-in-qxl_crtc_page_fl.patch new file mode 100644 index 000000000..34a8b7973 --- /dev/null +++ b/drm-qxl-avoid-buffer-reservation-in-qxl_crtc_page_fl.patch @@ -0,0 +1,53 @@ +From fc6c6a4dde53bf68c519c0079b5957a24b7bad2b Mon Sep 17 00:00:00 2001 +From: Frediano Ziglio +Date: Thu, 24 Sep 2015 14:25:14 +0100 +Subject: [PATCH 1/2] drm/qxl: avoid buffer reservation in qxl_crtc_page_flip + +This avoid a dependency lock error. +According to https://lwn.net/Articles/548909/ users of WW mutex API +should avoid using different context. +When a buffer is reserved with qxl_bo_reserve a ww_mutex_lock without +context is used. However during qxl_draw_dirty_fb different locks +with specific context are used. +This is detected during a machine booting with a debug kernel with lock +dependency checking enabled. +Like many other function in this file to avoid this problem object +pinning is used. Once the object is pinned is not necessary to keep +the lock so it can be released avoiding the locking problem. + +Signed-off-by: Frediano Ziglio +--- + drivers/gpu/drm/qxl/qxl_display.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c +index 4649bd2ed340..183aea1abebc 100644 +--- a/drivers/gpu/drm/qxl/qxl_display.c ++++ b/drivers/gpu/drm/qxl/qxl_display.c +@@ -244,6 +244,10 @@ static int qxl_crtc_page_flip(struct drm_crtc *crtc, + ret = qxl_bo_reserve(bo, false); + if (ret) + return ret; ++ ret = qxl_bo_pin(bo, bo->type, NULL); ++ qxl_bo_unreserve(bo); ++ if (ret) ++ return ret; + + qxl_draw_dirty_fb(qdev, qfb_src, bo, 0, 0, + &norect, one_clip_rect, inc); +@@ -257,7 +261,11 @@ static int qxl_crtc_page_flip(struct drm_crtc *crtc, + } + drm_vblank_put(dev, qcrtc->index); + +- qxl_bo_unreserve(bo); ++ ret = qxl_bo_reserve(bo, false); ++ if (!ret) { ++ qxl_bo_unpin(bo); ++ qxl_bo_unreserve(bo); ++ } + + return 0; + } +-- +2.4.3 + diff --git a/drm-qxl-avoid-dependency-lock.patch b/drm-qxl-avoid-dependency-lock.patch new file mode 100644 index 000000000..27aea6957 --- /dev/null +++ b/drm-qxl-avoid-dependency-lock.patch @@ -0,0 +1,42 @@ +From 364222966c6cb48898b83f9a912bff4cedcda2cd Mon Sep 17 00:00:00 2001 +From: Frediano Ziglio +Date: Thu, 24 Sep 2015 14:25:15 +0100 +Subject: [PATCH 2/2] drm/qxl: avoid dependency lock + +qxl_bo_unref calls drm_gem_object_unreference_unlocked which +locks dev->struct_mutex. However this lock could be already +locked if the call came from qxl_gem_object_free. +As we don't need to call qxl_bo_ref/qxl_bo_unref cause +qxl_release_list_add will hold a reference by itself avoid +to call them and the possible deadlock. + +Signed-off-by: Frediano Ziglio +--- + drivers/gpu/drm/qxl/qxl_release.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c +index b66ec331c17c..4efa8e261baf 100644 +--- a/drivers/gpu/drm/qxl/qxl_release.c ++++ b/drivers/gpu/drm/qxl/qxl_release.c +@@ -307,7 +307,7 @@ int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, + idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release); + if (idr_ret < 0) + return idr_ret; +- bo = qxl_bo_ref(to_qxl_bo(entry->tv.bo)); ++ bo = to_qxl_bo(entry->tv.bo); + + (*release)->release_offset = create_rel->release_offset + 64; + +@@ -316,8 +316,6 @@ int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, + info = qxl_release_map(qdev, *release); + info->id = idr_ret; + qxl_release_unmap(qdev, *release, info); +- +- qxl_bo_unref(&bo); + return 0; + } + +-- +2.4.3 + diff --git a/kernel.spec b/kernel.spec index 87fbe6c4f..84a338c39 100644 --- a/kernel.spec +++ b/kernel.spec @@ -592,6 +592,10 @@ Patch520: ARM-dts-Fix-Makefile-target-for-sun4i-a10-itead-itea.patch #rhbz 1262434 Patch521: Revert-Input-synaptics-fix-handling-of-disabling-ges.patch +#rhbz 1238803 1249850 +Patch522: drm-qxl-avoid-buffer-reservation-in-qxl_crtc_page_fl.patch +Patch523: drm-qxl-avoid-dependency-lock.patch + Patch904: kdbus.patch # END OF PATCH DEFINITIONS @@ -2037,6 +2041,9 @@ fi # # %changelog +* Mon Oct 05 2015 Josh Boyer +- Add patches to fix qxl locking issues (rhbz 1238803 1249850) + * Sun Oct 4 2015 Peter Robinson - Add support for BeagleBone Green