[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-ati: Changes to 'debian-unstable'



 ChangeLog                    |  242 +++++++++++++++++++++++++++++++++++++++++++
 configure.ac                 |    2 
 debian/changelog             |    6 -
 src/drmmode_display.c        |  158 ++++++++++++++++++++++------
 src/drmmode_display.h        |    3 
 src/radeon.h                 |   10 -
 src/radeon_bo_helper.h       |   16 ++
 src/radeon_dri2.c            |   78 +------------
 src/radeon_glamor.c          |   79 +++++++++++++-
 src/radeon_glamor.h          |    2 
 src/radeon_glamor_wrappers.c |   19 ---
 src/radeon_kms.c             |   38 +++---
 src/radeon_present.c         |    4 
 src/radeon_video.c           |    2 
 14 files changed, 506 insertions(+), 153 deletions(-)

New commits:
commit cdc39c749dd6508c5b0995d59f45063f80bc3988
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Fri Sep 16 00:44:56 2016 +0300

    upload to sid

diff --git a/debian/changelog b/debian/changelog
index a5cdb2f..4fcaa72 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,8 @@
-xserver-xorg-video-ati (1:7.7.1-1) UNRELEASED; urgency=medium
+xserver-xorg-video-ati (1:7.7.1-1) unstable; urgency=medium
 
   * New upstream release. (Closes: #827984)
 
- -- Timo Aaltonen <tjaalton@debian.org>  Thu, 07 Apr 2016 17:13:47 +0300
+ -- Timo Aaltonen <tjaalton@debian.org>  Fri, 16 Sep 2016 00:44:43 +0300
 
 xserver-xorg-video-ati (1:7.7.0-1) unstable; urgency=medium
 

commit c413c6af87f2fe6dc4d0348deaeaa61425d37e66
Author: Timo Aaltonen <tjaalton@debian.org>
Date:   Fri Sep 16 00:21:22 2016 +0300

    update changelogs

diff --git a/ChangeLog b/ChangeLog
index 5c127cd..b72d789 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,245 @@
+commit d6f89352f64f4eff858b671e49b732f9973f6e11
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 17:44:21 2016 +0900
+
+    Bump version for 7.7.1 release
+
+commit e890402d14ea7c4b22ef7f19d0679fb45d4eac4e
+Author: Qiang Yu <Qiang.Yu@amd.com>
+Date:   Thu Sep 15 16:51:00 2016 +0900
+
+    DRI2: Fix radeon_dri2_exchange_buffers width/height copy'n'paste error
+    
+    Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
+    (Ported from amdgpu commit 73c8dc000ad6b2b53ba3aa7155f5e8f6b55623b7)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 12d30eeb9711bd2b1609d6bbb74c4a1760596f72)
+
+commit b95ddb39c1154b3231cefd4e99046e7fb89f1e99
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:50:24 2016 +0900
+
+    DRI2: Add interpolated_vblanks in radeon_dri2_get_crtc_msc
+    
+    We need that in radeon_dri2_drawable_crtc as well for priv->vblank_delta
+    to work as intended.
+    
+    radeon_dri2_get_msc was already doing this.
+    
+    Fixes hangs in some cases when using VDPAU via DRI2 and moving the
+    window between CRTCs.
+    
+    (Ported from amdgpu commit abd1a7901c95e4bc78415cf1b7923623b9177152)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 11cc6843aa3b745aa1361f1a65e465e16696b914)
+
+commit 6cca7d529c3bb07bc78a49ae5085028ac743fe1d
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:49:48 2016 +0900
+
+    Destroy all dedicated scanout buffers during CloseScreen
+    
+    Fixes leaking active scanout buffers across a server reset, which also
+    fixes server reset with glamor and active scanout buffers.
+    
+    (Ported from amdgpu commit d96dabc71b1b32dc4b422a9633cdd4e0e95da052)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 4a5fa37f74c233c6b9c6a08306688628a8e216e8)
+
+commit 05f3735131e8fa8c2d1adbca70dab7967e3be58c
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:49:10 2016 +0900
+
+    glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME
+    
+    Fixes corruption when using DRI2 PRIME render offloading with the master
+    screen using this driver.
+    
+    (Ported from amdgpu commit 0007c2f018ba663303d91d847e7c085269a23062)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit cc2555835cd4c5fd2ae4f999a4bf7c18cdb1dda4)
+
+commit 6babf4d2205543a61fcd62c75fd88e49d0ed7cf1
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:48:20 2016 +0900
+
+    Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo
+    
+    So it can be used outside of the DRI2 code.
+    
+    (Ported from amdgpu commit 5518bf5d793439b5bab369e5fc18de9a4a3b9dd6)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit b3e5259e60157fdbdf46ee59b1b78995c2b15f72)
+
+commit a3d8e717d5dba8495d6b9934b0804342106e90f5
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:47:54 2016 +0900
+
+    Consolidate get_drawable_pixmap helper
+    
+    There were two static helpers for the same purpose. Consolidate them
+    into a single inline helper which can be used anywhere.
+    
+    (Ported from amdgpu commit 641f4647b7f51dfd2da330376cd10fa9702b6423)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 38632bbd5ff80a9cf8ce584b2bc499d17d15befe)
+
+commit 00a988a811741ee4e4af265deb68b97cc7e5c985
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:47:23 2016 +0900
+
+    glamor: Fix radeon_glamor_share_pixmap_backing for priv->bo == NULL
+    
+    Fixes crash when running a compositor and DRI_PRIME client via DRI2.
+    
+    Reported-by: Qiang Yu <qiang.yu@amd.com>
+    (Ported from amdgpu commit b36c77695ba77b59a0ccd868454e3af4fc04d5ff)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit e91858e435672c32f9c4a854b3dec048199d6f7f)
+
+commit 953b4c2cdf3ea2dcf2d7cc0b1fa0fabefcc49afd
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:46:35 2016 +0900
+
+    Also handle disabled CRTCs in drmmode_clear_pending_flip
+    
+    If disabling a CRTC had to be deferred due to a pending flip in
+    drmmode_crtc_dpms, there may no longer be any outputs associated with
+    the CRTC when we get here. So we have to check for !crtc->enabled and
+    call drmmode_crtc_dpms in that case as well.
+    
+    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
+    off an output or CRTC")
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 4bd2d01552f18153afa03a8947b22eebf3d67c6b)
+
+commit 13f3fe45a4026801f61fb6429ca6e239a1b8c081
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:46:04 2016 +0900
+
+    Don't override crtc parameter value in drmmode_flip_handler/abort
+    
+    When overriding the crtc parameter value of the last pending CRTC,
+    drmmode_clear_pending_flip would work on the wrong CRTC, and the last
+    pending CRTC's flip_pending flag might never get cleared. This would
+    prevent that CRTC from properly turning off and back on again.
+    
+    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
+    off an output or CRTC")
+    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97392
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit a36fdaff40d5b4795a1400c348a80eee94892212)
+
+commit 08672d31a616060d23a2e1543643eafa97bfe236
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Aug 25 18:22:34 2016 +0900
+
+    Also call drmmode_clear_pending_flip from radeon_scanout_flip_abort
+    
+    Not doing so could break DPMS with TearFree.
+    
+    Reported-and-Tested-by: furkan on IRC
+    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
+    off an output or CRTC")
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit e520ce0ec0adf91ddce5c932d4b3f9477fd49304)
+
+commit a12ff1c6aec4453a6f64878cc64961488e803ed1
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:44:13 2016 +0900
+
+    Wait for pending flips to complete before turning off an output or CRTC
+    
+    At least with older kernels, the flip may never complete otherwise,
+    which can result in us hanging in drmmode_set_mode_major.
+    
+    Fixes: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-ati/+bug/1577170
+    
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 9090309e057dc703d1a5bffd88e6cae14108cfc3)
+
+commit 4d377fd007d9a39178e318a8cf8bee5d68415c56
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:42:05 2016 +0900
+
+    Don't enable micro-tiling for scanout buffers on pre-R600
+    
+    The display engine didn't support it.
+    
+    Fixes display corruption with options "TearFree" and "ShadowPrimary"
+    (and rotation or transforms with current xserver) on pre-R600.
+    
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 6d91fb4fc701895473ff675f440a8eef655e80ca)
+
+commit 16135cc8b5d302cf89e174c52e455b64c2c84237
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:41:15 2016 +0900
+
+    Only use RandR APIs if RandR is enabled
+    
+    Fixes crash with Xinerama enabled, which disables RandR.
+    
+    Fixes: https://bugs.debian.org/827984
+    
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 3be841d0ae7d505cef325993205b12d15e98dba9)
+
+commit 948f592259f2f0c0ff331b869fb8f73ce0b29193
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:40:32 2016 +0900
+
+    Explicitly set the fbcon pixmap pitch again
+    
+    The kernel driver returns 0 as the pitch of the fbcon BO via the
+    DRM_RADEON_GEM_GET_TILING ioctl, so we ended up using an incorrect
+    pitch in some cases.
+    
+    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94901
+    
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 040a7b80e1fcbaa93ac17f7113d696d9b853cf8a)
+
+commit d1e74e357278d1227425b12a4a1be2b337a6051d
+Author: Qiang Yu <Qiang.Yu@amd.com>
+Date:   Thu Sep 15 16:39:37 2016 +0900
+
+    Fix radeon_mode_hotplug crash on multi GPU platform.
+    
+    On multi GPU platform, some screen is created by other GPU DDX.
+    
+    Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
+    (Ported from amdgpu commit 978242977e5dc905e1d5a46b1b0d34b356c7af26)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit 380daff43cfefe2a8e4d496eaf65673f2815c878)
+
+commit 3f4cba12b71206aa60271ac435c3709ee335a371
+Author: Michel Dänzer <michel.daenzer@amd.com>
+Date:   Thu Sep 15 16:38:52 2016 +0900
+
+    Handle Zaphod mode correctly in radeon_mode_hotplug
+    
+    We need to scan both screens of the entity for existing connectors, and
+    enumerate DVI & HDMI connectors consistently regardless of which screen
+    they're assigned to.
+    
+    Fixes crash when hot-(un)plugging connectors in Zaphod mode.
+    
+    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93415
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit c801f9f10a5d72d935faf21e72f7e7808fb4f05f)
+
+commit 470538c354977e2ef5256029433d2e28e4a1f7e8
+Author: Qiang Yu <Qiang.Yu@amd.com>
+Date:   Thu Sep 15 16:37:57 2016 +0900
+
+    Remove RR_Capability_SinkOutput for GPU without CRTC
+    
+    Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
+    (Ported from amdgpu commit a0bbb373f902e0ffc14570c85faec7e44134f62e)
+    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
+    (Cherry picked from commit ba8b6288c8e6fc4be5d7144ecbe9a1f241881674)
+
 commit df6662864b56d1aeeea4c67d9b668e64197afb20
 Author: Michel Dänzer <michel.daenzer@amd.com>
 Date:   Thu Apr 7 11:44:05 2016 +0900
diff --git a/debian/changelog b/debian/changelog
index e36f0ee..a5cdb2f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,6 @@
-xserver-xorg-video-ati (1:7.7.0-2) UNRELEASED; urgency=medium
+xserver-xorg-video-ati (1:7.7.1-1) UNRELEASED; urgency=medium
 
-  * Update upstream changelog.
+  * New upstream release. (Closes: #827984)
 
  -- Timo Aaltonen <tjaalton@debian.org>  Thu, 07 Apr 2016 17:13:47 +0300
 

commit d6f89352f64f4eff858b671e49b732f9973f6e11
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 17:44:21 2016 +0900

    Bump version for 7.7.1 release

diff --git a/configure.ac b/configure.ac
index 48e314b..e5c0e67 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-ati],
-        [7.7.0],
+        [7.7.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-ati])
 

commit e890402d14ea7c4b22ef7f19d0679fb45d4eac4e
Author: Qiang Yu <Qiang.Yu@amd.com>
Date:   Thu Sep 15 16:51:00 2016 +0900

    DRI2: Fix radeon_dri2_exchange_buffers width/height copy'n'paste error
    
    Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
    (Ported from amdgpu commit 73c8dc000ad6b2b53ba3aa7155f5e8f6b55623b7)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 12d30eeb9711bd2b1609d6bbb74c4a1760596f72)

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 19c3d6a..0cd6b24 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -775,7 +775,7 @@ radeon_dri2_exchange_buffers(DrawablePtr draw, DRI2BufferPtr front, DRI2BufferPt
 
     region.extents.x1 = region.extents.y1 = 0;
     region.extents.x2 = front_priv->pixmap->drawable.width;
-    region.extents.y2 = front_priv->pixmap->drawable.width;
+    region.extents.y2 = front_priv->pixmap->drawable.height;
     region.data = NULL;
     DamageRegionAppend(&front_priv->pixmap->drawable, &region);
 

commit b95ddb39c1154b3231cefd4e99046e7fb89f1e99
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:50:24 2016 +0900

    DRI2: Add interpolated_vblanks in radeon_dri2_get_crtc_msc
    
    We need that in radeon_dri2_drawable_crtc as well for priv->vblank_delta
    to work as intended.
    
    radeon_dri2_get_msc was already doing this.
    
    Fixes hangs in some cases when using VDPAU via DRI2 and moving the
    window between CRTCs.
    
    (Ported from amdgpu commit abd1a7901c95e4bc78415cf1b7923623b9177152)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 11cc6843aa3b745aa1361f1a65e465e16696b914)

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index bb8d1f8..19c3d6a 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -516,10 +516,11 @@ static uint32_t radeon_get_msc_delta(DrawablePtr pDraw, xf86CrtcPtr crtc)
  */
 static Bool radeon_dri2_get_crtc_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc)
 {
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
     if (!radeon_crtc_is_enabled(crtc) ||
 	 drmmode_crtc_get_ust_msc(crtc, ust, msc) != Success) {
 	/* CRTC is not running, extrapolate MSC and timestamp */
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	ScrnInfoPtr scrn = crtc->scrn;
 	RADEONInfoPtr info = RADEONPTR(scrn);
 	CARD64 now, delta_t, delta_seq;
@@ -544,6 +545,8 @@ static Bool radeon_dri2_get_crtc_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc)
 	*msc += delta_seq;
     }
 
+    *msc += drmmode_crtc->interpolated_vblanks;
+
     return TRUE;
 }
 
@@ -991,7 +994,8 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
     if (!radeon_dri2_get_crtc_msc(crtc, ust, msc))
 	return FALSE;
 
-    *msc += radeon_get_msc_delta(draw, crtc);
+    if (draw && draw->type == DRAWABLE_WINDOW)
+	*msc += get_dri2_window_priv((WindowPtr)draw)->vblank_delta;
     *msc &= 0xffffffff;
     return TRUE;
 }

commit 6cca7d529c3bb07bc78a49ae5085028ac743fe1d
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:49:48 2016 +0900

    Destroy all dedicated scanout buffers during CloseScreen
    
    Fixes leaking active scanout buffers across a server reset, which also
    fixes server reset with glamor and active scanout buffers.
    
    (Ported from amdgpu commit d96dabc71b1b32dc4b422a9633cdd4e0e95da052)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 4a5fa37f74c233c6b9c6a08306688628a8e216e8)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 23723ce..0f57292 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2370,8 +2370,10 @@ void drmmode_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 
 void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 	RADEONInfoPtr info = RADEONPTR(pScrn);
+	int c;
 
 	if (info->dri2.pKernelDRMVersion->version_minor < 4 || !info->drmmode_inited)
 		return;
@@ -2382,6 +2384,14 @@ void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 		RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
 				drm_wakeup_handler, drmmode);
 	}
+
+	for (c = 0; c < config->num_crtc; c++) {
+		xf86CrtcPtr crtc = config->crtc[c];
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		drmmode_crtc_scanout_destroy(&info->drmmode, &drmmode_crtc->scanout[0]);
+		drmmode_crtc_scanout_destroy(&info->drmmode, &drmmode_crtc->scanout[1]);
+	}
 }
 
 

commit 05f3735131e8fa8c2d1adbca70dab7967e3be58c
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:49:10 2016 +0900

    glamor: Reallocate linear pixmap BO if necessary for DRI2 PRIME
    
    Fixes corruption when using DRI2 PRIME render offloading with the master
    screen using this driver.
    
    (Ported from amdgpu commit 0007c2f018ba663303d91d847e7c085269a23062)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit cc2555835cd4c5fd2ae4f999a4bf7c18cdb1dda4)

diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index f46e8ba..7a6bf53 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -342,6 +342,26 @@ radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
 	CARD32 size;
 	int fd;
 
+	if ((radeon_get_pixmap_tiling_flags(pixmap) &
+	     RADEON_TILING_MASK) != RADEON_TILING_LINEAR) {
+		PixmapPtr linear;
+
+		/* We don't want to re-allocate the screen pixmap as
+		 * linear, to avoid trouble with page flipping
+		 */
+		if (screen->GetScreenPixmap(screen) == pixmap)
+			return FALSE;
+
+		linear = screen->CreatePixmap(screen, pixmap->drawable.width,
+					      pixmap->drawable.height,
+					      pixmap->drawable.depth,
+					      CREATE_PIXMAP_USAGE_SHARED);
+		if (!linear)
+			return FALSE;
+
+		radeon_glamor_set_pixmap_bo(&pixmap->drawable, linear);
+	}
+
 	fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
 	if (fd < 0)
 		return FALSE;

commit 6babf4d2205543a61fcd62c75fd88e49d0ed7cf1
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:48:20 2016 +0900

    Move DRI2's local fixup_glamor helper to radeon_glamor_set_pixmap_bo
    
    So it can be used outside of the DRI2 code.
    
    (Ported from amdgpu commit 5518bf5d793439b5bab369e5fc18de9a4a3b9dd6)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit b3e5259e60157fdbdf46ee59b1b78995c2b15f72)

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index dc195ef..bb8d1f8 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -78,60 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
      dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
 
-static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
-{
-	PixmapPtr old = get_drawable_pixmap(drawable);
-#ifdef USE_GLAMOR
-	ScreenPtr screen = drawable->pScreen;
-	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
-	GCPtr gc;
-
-	/* With a glamor pixmap, 2D pixmaps are created in texture
-	 * and without a static BO attached to it. To support DRI,
-	 * we need to create a new textured-drm pixmap and
-	 * need to copy the original content to this new textured-drm
-	 * pixmap, and then convert the old pixmap to a coherent
-	 * textured-drm pixmap which has a valid BO attached to it
-	 * and also has a valid texture, thus both glamor and DRI2
-	 * can access it.
-	 *
-	 */
-
-	/* Copy the current contents of the pixmap to the bo. */
-	gc = GetScratchGC(drawable->depth, screen);
-	if (gc) {
-		ValidateGC(&pixmap->drawable, gc);
-		gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
-				  gc,
-				  0, 0,
-				  old->drawable.width,
-				  old->drawable.height,
-				  0, 0);
-		FreeScratchGC(gc);
-	}
-
-	radeon_set_pixmap_private(pixmap, NULL);
-
-	/* And redirect the pixmap to the new bo (for 3D). */
-	glamor_egl_exchange_buffers(old, pixmap);
-	radeon_set_pixmap_private(old, priv);
-	old->refcnt++;
-
-	screen->ModifyPixmapHeader(old,
-				   old->drawable.width,
-				   old->drawable.height,
-				   0, 0,
-				   pixmap->devKind,
-				   NULL);
-	old->devPrivate.ptr = NULL;
-
-	screen->DestroyPixmap(pixmap);
-
-#endif /* USE_GLAMOR*/
-
-	return old;
-}
-
 /* Get GEM flink name for a pixmap */
 static Bool
 radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t *name)
@@ -301,10 +247,11 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 		/* this happen if pixmap is non accelerable */
 		goto error;
 	    }
+	} else if (is_glamor_pixmap) {
+	    pixmap = radeon_glamor_set_pixmap_bo(drawable, pixmap);
+	    pixmap->refcnt++;
 	}
 
-	if (is_glamor_pixmap)
-	    pixmap = fixup_glamor(drawable, pixmap);
 	if (!radeon_get_flink_name(info, pixmap, &buffers->name))
 	    goto error;
     }
diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index 5c4191b..f46e8ba 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -283,6 +283,54 @@ fallback_pixmap:
 		return fbCreatePixmap(screen, w, h, depth, usage);
 }
 
+PixmapPtr
+radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap)
+{
+	PixmapPtr old = get_drawable_pixmap(drawable);
+	ScreenPtr screen = drawable->pScreen;
+	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
+	GCPtr gc;
+
+	/* With a glamor pixmap, 2D pixmaps are created in texture
+	 * and without a static BO attached to it. To support DRI,
+	 * we need to create a new textured-drm pixmap and
+	 * need to copy the original content to this new textured-drm
+	 * pixmap, and then convert the old pixmap to a coherent
+	 * textured-drm pixmap which has a valid BO attached to it
+	 * and also has a valid texture, thus both glamor and DRI2
+	 * can access it.
+	 *
+	 */
+
+	/* Copy the current contents of the pixmap to the bo. */
+	gc = GetScratchGC(drawable->depth, screen);
+	if (gc) {
+		ValidateGC(&pixmap->drawable, gc);
+		gc->ops->CopyArea(&old->drawable, &pixmap->drawable,
+				  gc,
+				  0, 0,
+				  old->drawable.width,
+				  old->drawable.height, 0, 0);
+		FreeScratchGC(gc);
+	}
+
+	radeon_set_pixmap_private(pixmap, NULL);
+
+	/* And redirect the pixmap to the new bo (for 3D). */
+	glamor_egl_exchange_buffers(old, pixmap);
+	radeon_set_pixmap_private(old, priv);
+
+	screen->ModifyPixmapHeader(old,
+				   old->drawable.width,
+				   old->drawable.height,
+				   0, 0, pixmap->devKind, NULL);
+	old->devPrivate.ptr = NULL;
+
+	screen->DestroyPixmap(pixmap);
+
+	return old;
+}
+
 #ifdef RADEON_PIXMAP_SHARING
 
 static Bool
diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h
index 75129f8..fdc4e57 100644
--- a/src/radeon_glamor.h
+++ b/src/radeon_glamor.h
@@ -71,6 +71,7 @@ void radeon_glamor_free_screen(int scrnIndex, int flags);
 
 Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv);
 void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
+PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
 
 XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
 
@@ -85,6 +86,7 @@ static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { }
 static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { return TRUE; }
 
 static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
+static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; }
 
 static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; }
 

commit a3d8e717d5dba8495d6b9934b0804342106e90f5
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:47:54 2016 +0900

    Consolidate get_drawable_pixmap helper
    
    There were two static helpers for the same purpose. Consolidate them
    into a single inline helper which can be used anywhere.
    
    (Ported from amdgpu commit 641f4647b7f51dfd2da330376cd10fa9702b6423)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 38632bbd5ff80a9cf8ce584b2bc499d17d15befe)

diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h
index d4a4ee0..f1aed55 100644
--- a/src/radeon_bo_helper.h
+++ b/src/radeon_bo_helper.h
@@ -41,4 +41,20 @@ extern Bool
 radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
 				 struct radeon_surface *surface);
 
+/**
+ * get_drawable_pixmap() returns the backing pixmap for a given drawable.
+ *
+ * @param drawable the drawable being requested.
+ *
+ * This function returns the backing pixmap for a drawable, whether it is a
+ * redirected window, unredirected window, or already a pixmap.
+ */
+static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
+{
+    if (drawable->type == DRAWABLE_PIXMAP)
+	return (PixmapPtr)drawable;
+    else
+	return drawable->pScreen->GetWindowPixmap((WindowPtr)drawable);
+}
+
 #endif /* RADEON_BO_HELPER_H */
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 84cd031..dc195ef 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -78,15 +78,6 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
      dixLookupPrivate(&(window)->devPrivates, dri2_window_private_key))
 
 
-static PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
-{
-    if (drawable->type == DRAWABLE_PIXMAP)
-	return (PixmapPtr)drawable;
-    else
-	return (*drawable->pScreen->GetWindowPixmap)((WindowPtr)drawable);
-}
-
-
 static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 {
 	PixmapPtr old = get_drawable_pixmap(drawable);
diff --git a/src/radeon_glamor_wrappers.c b/src/radeon_glamor_wrappers.c
index cd02b06..5f165eb 100644
--- a/src/radeon_glamor_wrappers.c
+++ b/src/radeon_glamor_wrappers.c
@@ -35,27 +35,10 @@
 #ifdef USE_GLAMOR
 
 #include "radeon.h"
+#include "radeon_bo_helper.h"
 #include "radeon_glamor.h"
 
 
-/**
- * get_drawable_pixmap() returns the backing pixmap for a given drawable.
- *
- * @param pDrawable the drawable being requested.
- *
- * This function returns the backing pixmap for a drawable, whether it is a
- * redirected window, unredirected window, or already a pixmap.
- */
-static PixmapPtr
-get_drawable_pixmap(DrawablePtr pDrawable)
-{
-	if (pDrawable->type == DRAWABLE_WINDOW)
-		return pDrawable->pScreen->
-		    GetWindowPixmap((WindowPtr) pDrawable);
-	else
-		return (PixmapPtr) pDrawable;
-}
-
 /* Are there any outstanding GPU operations for this pixmap? */
 static Bool
 radeon_glamor_gpu_pending(uint_fast32_t gpu_synced, uint_fast32_t gpu_access)

commit 00a988a811741ee4e4af265deb68b97cc7e5c985
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:47:23 2016 +0900

    glamor: Fix radeon_glamor_share_pixmap_backing for priv->bo == NULL
    
    Fixes crash when running a compositor and DRI_PRIME client via DRI2.
    
    Reported-by: Qiang Yu <qiang.yu@amd.com>
    (Ported from amdgpu commit b36c77695ba77b59a0ccd868454e3af4fc04d5ff)
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit e91858e435672c32f9c4a854b3dec048199d6f7f)

diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index f94e0fd..5c4191b 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -289,12 +289,17 @@ static Bool
 radeon_glamor_share_pixmap_backing(PixmapPtr pixmap, ScreenPtr slave,
 				   void **handle_p)
 {
-	struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
+	ScreenPtr screen = pixmap->drawable.pScreen;
+	CARD16 stride;
+	CARD32 size;
+	int fd;
 
-	if (!priv)
+	fd = glamor_fd_from_pixmap(screen, pixmap, &stride, &size);
+	if (fd < 0)
 		return FALSE;
 
-	return radeon_share_pixmap_backing(priv->bo, handle_p);
+	*handle_p = (void *)(long)fd;
+	return TRUE;
 }
 
 static Bool

commit 953b4c2cdf3ea2dcf2d7cc0b1fa0fabefcc49afd
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:46:35 2016 +0900

    Also handle disabled CRTCs in drmmode_clear_pending_flip
    
    If disabling a CRTC had to be deferred due to a pending flip in
    drmmode_crtc_dpms, there may no longer be any outputs associated with
    the CRTC when we get here. So we have to check for !crtc->enabled and
    call drmmode_crtc_dpms in that case as well.
    
    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
    off an output or CRTC")
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 4bd2d01552f18153afa03a8947b22eebf3d67c6b)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 65fb0ec..23723ce 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2202,8 +2202,9 @@ drmmode_clear_pending_flip(xf86CrtcPtr crtc)
 
 	drmmode_crtc->flip_pending = FALSE;
 
-	if (drmmode_crtc->pending_dpms_mode != DPMSModeOn &&
-	    drmmode_crtc->dpms_mode != drmmode_crtc->pending_dpms_mode) {
+	if (!crtc->enabled ||
+	    (drmmode_crtc->pending_dpms_mode != DPMSModeOn &&
+	     drmmode_crtc->dpms_mode != drmmode_crtc->pending_dpms_mode)) {
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
 		int o;
 
@@ -2214,8 +2215,9 @@ drmmode_clear_pending_flip(xf86CrtcPtr crtc)
 				continue;
 
 			drmmode_output_dpms(output, drmmode_crtc->pending_dpms_mode);
-			drmmode_crtc_dpms(crtc, drmmode_crtc->pending_dpms_mode);
 		}
+
+		drmmode_crtc_dpms(crtc, drmmode_crtc->pending_dpms_mode);
 	}
 }
 

commit 13f3fe45a4026801f61fb6429ca6e239a1b8c081
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:46:04 2016 +0900

    Don't override crtc parameter value in drmmode_flip_handler/abort
    
    When overriding the crtc parameter value of the last pending CRTC,
    drmmode_clear_pending_flip would work on the wrong CRTC, and the last
    pending CRTC's flip_pending flag might never get cleared. This would
    prevent that CRTC from properly turning off and back on again.
    
    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
    off an output or CRTC")
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97392
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit a36fdaff40d5b4795a1400c348a80eee94892212)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index e79065a..65fb0ec 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2225,9 +2225,9 @@ drmmode_flip_abort(xf86CrtcPtr crtc, void *event_data)
 	drmmode_flipdata_ptr flipdata = event_data;
 
 	if (--flipdata->flip_count == 0) {
-		if (flipdata->fe_crtc)
-			crtc = flipdata->fe_crtc;
-		flipdata->abort(crtc, flipdata->event_data);
+		if (!flipdata->fe_crtc)
+			flipdata->fe_crtc = crtc;
+		flipdata->abort(flipdata->fe_crtc, flipdata->event_data);
 		free(flipdata);
 	}
 
@@ -2248,11 +2248,14 @@ drmmode_flip_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec, void *even
 	}
 
 	if (--flipdata->flip_count == 0) {
-		/* Deliver cached msc, ust from reference crtc to flip event handler */
+		/* Deliver MSC & UST from reference/current CRTC to flip event
+		 * handler
+		 */
 		if (flipdata->fe_crtc)
-			crtc = flipdata->fe_crtc;
-		flipdata->handler(crtc, flipdata->fe_frame, flipdata->fe_usec,
-				  flipdata->event_data);
+			flipdata->handler(flipdata->fe_crtc, flipdata->fe_frame,
+					  flipdata->fe_usec, flipdata->event_data);
+		else
+			flipdata->handler(crtc, frame, usec, flipdata->event_data);
 
 		/* Release framebuffer */
 		drmModeRmFB(info->drmmode.fd, flipdata->old_fb_id);

commit 08672d31a616060d23a2e1543643eafa97bfe236
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Aug 25 18:22:34 2016 +0900

    Also call drmmode_clear_pending_flip from radeon_scanout_flip_abort
    
    Not doing so could break DPMS with TearFree.
    
    Reported-and-Tested-by: furkan on IRC
    Fixes: 9090309e057d ("Wait for pending flips to complete before turning
    off an output or CRTC")
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit e520ce0ec0adf91ddce5c932d4b3f9477fd49304)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 1ee271c..e79065a 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2195,7 +2195,7 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
 	drmmode_xf86crtc_resize
 };
 
-static void
+void
 drmmode_clear_pending_flip(xf86CrtcPtr crtc)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 59b2f9b..bbb827c 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -149,6 +149,7 @@ extern int drmmode_get_crtc_id(xf86CrtcPtr crtc);
 extern int drmmode_get_height_align(ScrnInfoPtr scrn, uint32_t tiling);
 extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
 extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling);
+extern void drmmode_clear_pending_flip(xf86CrtcPtr crtc);
 
 Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 			uint32_t new_front_handle, uint64_t id, void *data,
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 00918a6..f9abc09 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -556,7 +556,7 @@ radeon_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
     drmmode_crtc_private_ptr drmmode_crtc = event_data;
 
     drmmode_crtc->scanout_update_pending = FALSE;
-    drmmode_crtc->flip_pending = FALSE;
+    drmmode_clear_pending_flip(crtc);
 }
 
 static void

commit a12ff1c6aec4453a6f64878cc64961488e803ed1
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Thu Sep 15 16:44:13 2016 +0900

    Wait for pending flips to complete before turning off an output or CRTC
    
    At least with older kernels, the flip may never complete otherwise,
    which can result in us hanging in drmmode_set_mode_major.
    
    Fixes: https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-ati/+bug/1577170
    
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    (Cherry picked from commit 9090309e057dc703d1a5bffd88e6cae14108cfc3)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 823263e..1ee271c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -303,9 +303,15 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
 	CARD64 ust;
 	int ret;
 
+	drmmode_crtc->pending_dpms_mode = mode;
+
 	if (drmmode_crtc->dpms_mode == DPMSModeOn && mode != DPMSModeOn) {
 		drmVBlank vbl;
 
+		/* Wait for any pending flip to finish */
+		if (drmmode_crtc->flip_pending)
+			return;
+
 		/*
 		 * On->Off transition: record the last vblank time,
 		 * sequence number and frame period.
@@ -363,10 +369,14 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
 	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
 	/* Disable unused CRTCs */
-	if (!crtc->enabled || mode != DPMSModeOn)
+	if (!crtc->enabled || mode != DPMSModeOn) {
+		/* Wait for any pending flip to finish */
+		if (drmmode_crtc->flip_pending)
+			return;
+
 		drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
 			       0, 0, 0, NULL, 0, NULL);
-	else if (drmmode_crtc->dpms_mode != DPMSModeOn)
+	} else if (drmmode_crtc->dpms_mode != DPMSModeOn)
 		crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc->rotation,


Reply to: