xf86-video-ati: Branch 'master' - 21 commits

Michel Dänzer daenzer at kemper.freedesktop.org
Thu Jul 12 16:16:33 UTC 2018


 configure.ac                 |    4 
 src/ati.c                    |    4 
 src/drmmode_display.c        |  344 ++++++++++++++++++++++++++++++++++---------
 src/drmmode_display.h        |    8 -
 src/evergreen_exa.c          |   10 -
 src/r600_exa.c               |   10 -
 src/radeon.h                 |    2 
 src/radeon_dri2.c            |   12 -
 src/radeon_drm_queue.c       |    3 
 src/radeon_exa.c             |    2 
 src/radeon_exa_funcs.c       |    8 -
 src/radeon_exa_render.c      |    6 
 src/radeon_glamor.c          |    2 
 src/radeon_glamor_wrappers.c |    4 
 src/radeon_kms.c             |   45 +++--
 src/radeon_probe.c           |    2 
 src/radeon_textured_video.c  |   10 -
 src/radeon_video.c           |    6 
 18 files changed, 352 insertions(+), 130 deletions(-)

New commits:
commit f533b1f654952cee794de49d28d01947a6571daf
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 11 19:13:28 2018 +0200

    Add RandR leases support
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (Ported from xserver commit e4e3447603b5fd3a38a92c3f972396d1f81168ad)
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    (Ported from amdgpu commit 61040bdfa360975614fb47aa7ea1b3a1abac3427)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/configure.ac b/configure.ac
index 65206e7f..15c7b212 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,7 +70,7 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
 XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 
 # Checks for libraries.
-PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.78])
+PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.89])
 PKG_CHECK_MODULES(LIBDRM_RADEON, [libdrm_radeon])
 
 # Obtain compiler/linker options for the driver dependencies
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index d4bd76e1..2af64e3f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2400,8 +2400,159 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 	return FALSE;
 }
 
+static void
+drmmode_validate_leases(ScrnInfoPtr scrn)
+{
+#ifdef XF86_LEASE_VERSION
+	ScreenPtr screen = scrn->pScreen;
+	rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+	drmModeLesseeListPtr lessees;
+	RRLeasePtr lease, next;
+	int l;
+
+	/* We can't talk to the kernel about leases when VT switched */
+	if (!scrn->vtSema)
+		return;
+
+	lessees = drmModeListLessees(pRADEONEnt->fd);
+	if (!lessees)
+		return;
+
+	xorg_list_for_each_entry_safe(lease, next, &scr_priv->leases, list) {
+		drmmode_lease_private_ptr lease_private = lease->devPrivate;
+
+		for (l = 0; l < lessees->count; l++) {
+			if (lessees->lessees[l] == lease_private->lessee_id)
+				break;
+		}
+
+		/* check to see if the lease has gone away */
+		if (l == lessees->count) {
+			free(lease_private);
+			lease->devPrivate = NULL;
+			xf86CrtcLeaseTerminated(lease);
+		}
+	}
+
+	free(lessees);
+#endif
+}
+
+#ifdef XF86_LEASE_VERSION
+
+static int
+drmmode_create_lease(RRLeasePtr lease, int *fd)
+{
+	ScreenPtr screen = lease->screen;
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+	drmmode_lease_private_ptr lease_private;
+	int noutput = lease->numOutputs;
+	int ncrtc = lease->numCrtcs;
+	uint32_t *objects;
+	size_t nobjects;
+	int lease_fd;
+	int c, o;
+	int i;
+
+	nobjects = ncrtc + noutput;
+	if (nobjects == 0 || nobjects > (SIZE_MAX / 4) ||
+	    ncrtc > (SIZE_MAX - noutput))
+		return BadValue;
+
+	lease_private = calloc(1, sizeof (drmmode_lease_private_rec));
+	if (!lease_private)
+		return BadAlloc;
+
+	objects = malloc(nobjects * 4);
+	if (!objects) {
+		free(lease_private);
+		return BadAlloc;
+	}
+
+	i = 0;
+
+	/* Add CRTC ids */
+	for (c = 0; c < ncrtc; c++) {
+		xf86CrtcPtr crtc = lease->crtcs[c]->devPrivate;
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		objects[i++] = drmmode_crtc->mode_crtc->crtc_id;
+	}
+
+	/* Add connector ids */
+	for (o = 0; o < noutput; o++) {
+		xf86OutputPtr   output = lease->outputs[o]->devPrivate;
+		drmmode_output_private_ptr drmmode_output = output->driver_private;
+
+		objects[i++] = drmmode_output->mode_output->connector_id;
+	}
+
+	/* call kernel to create lease */
+	assert (i == nobjects);
+
+	lease_fd = drmModeCreateLease(pRADEONEnt->fd, objects, nobjects, 0,
+				      &lease_private->lessee_id);
+
+	free(objects);
+
+	if (lease_fd < 0) {
+		free(lease_private);
+		return BadMatch;
+	}
+
+	lease->devPrivate = lease_private;
+
+	xf86CrtcLeaseStarted(lease);
+
+	*fd = lease_fd;
+	return Success;
+}
+
+static void
+drmmode_terminate_lease(RRLeasePtr lease)
+{
+	drmmode_lease_private_ptr lease_private = lease->devPrivate;
+	ScreenPtr screen = lease->screen;
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
+
+	if (drmModeRevokeLease(pRADEONEnt->fd, lease_private->lessee_id) == 0) {
+		free(lease_private);
+		lease->devPrivate = NULL;
+		xf86CrtcLeaseTerminated(lease);
+	}
+}
+
+#endif // XF86_LEASE_VERSION
+
+void
+drmmode_terminate_leases(ScrnInfoPtr pScrn)
+{
+#ifdef XF86_LEASE_VERSION
+	ScreenPtr screen = xf86ScrnToScreen(pScrn);
+	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+	rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+	RRLeasePtr lease, next;
+
+	xorg_list_for_each_entry_safe(lease, next, &scr_priv->leases, list) {
+		drmmode_lease_private_ptr lease_private = lease->devPrivate;
+		drmModeRevokeLease(pRADEONEnt->fd, lease_private->lessee_id);
+		free(lease_private);
+		lease->devPrivate = NULL;
+		RRLeaseTerminated(lease);
+		RRLeaseFree(lease);
+	}
+#endif
+}
+
 static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
-	drmmode_xf86crtc_resize
+	.resize = drmmode_xf86crtc_resize,
+#ifdef XF86_LEASE_VERSION
+	.create_lease = drmmode_create_lease,
+	.terminate_lease = drmmode_terminate_lease
+#endif
 };
 
 static void
@@ -2888,6 +3039,9 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 		return FALSE;
 	}
 
+	/* Validate leases on VT re-entry */
+	drmmode_validate_leases(pScrn);
+
 	return TRUE;
 }
 
@@ -3055,6 +3209,9 @@ restart_destroy:
 			changed = TRUE;
 	}
 
+	/* Check to see if a lessee has disappeared */
+	drmmode_validate_leases(scrn);
+
 	if (changed && dixPrivateKeyRegistered(rrPrivKey)) {
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0)
 		RRSetChanged(xf86ScrnToScreen(scrn));
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 27c23c1a..4551e0c7 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -139,6 +139,10 @@ typedef struct {
     int tear_free;
 } drmmode_output_private_rec, *drmmode_output_private_ptr;
 
+typedef struct {
+    uint32_t lessee_id;
+} drmmode_lease_private_rec, *drmmode_lease_private_ptr;
+
 
 enum drmmode_flip_sync {
     FLIP_VSYNC,
@@ -223,6 +227,8 @@ PixmapPtr drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
 
+extern void drmmode_terminate_leases(ScrnInfoPtr scrn);
+
 Bool drmmode_set_mode(xf86CrtcPtr crtc, struct drmmode_fb *fb,
 		      DisplayModePtr mode, int x, int y);
 
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 36840ad3..c8a5726a 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -2154,6 +2154,7 @@ static Bool RADEONCloseScreen_KMS(ScreenPtr pScreen)
     /* Clear mask of assigned crtc's in this generation */
     pRADEONEnt->assigned_crtcs = 0;
 
+    drmmode_terminate_leases(pScrn);
     drmmode_uevent_fini(pScrn, &info->drmmode);
     radeon_drm_queue_close(pScrn);
     radeon_cs_flush_indirect(pScrn);
commit b4f0f44a9f67f2eafd4a2b5ab919e6ea7fa2acf7
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 11 19:10:20 2018 +0200

    modesetting: Create CONNECTOR_ID properties for outputs [v2]
    
    This lets a DRM client map between X outputs and kernel connectors.
    
    v2:
            Change CONNECTOR_ID to enum -- Adam Jackson <ajax at nwnk.net>
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (Ported from xserver commit 023d4aba8d45e9e3630b944ecfb650c081799b96)
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    (Ported from amdgpu commit ab7e39c5a03e24c3ce3ee2f22ada7572bc2d9aa7)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 27aa5a6c..d4bd76e1 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1643,6 +1643,33 @@ drmmode_output_create_resources(xf86OutputPtr output)
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
     drmModePropertyPtr drmmode_prop, tearfree_prop;
     int i, j, err;
+    Atom name;
+
+    /* Create CONNECTOR_ID property */
+    name = MakeAtom("CONNECTOR_ID", 12, TRUE);
+    if (name != BAD_RESOURCE) {
+	INT32 value = mode_output->connector_id;
+
+	err = RRConfigureOutputProperty(output->randr_output, name,
+					FALSE, FALSE, TRUE, 1, &value);
+	if (err != Success) {
+	    xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+		       "RRConfigureOutputProperty error, %d\n", err);
+	}
+
+	err = RRChangeOutputProperty(output->randr_output, name,
+				     XA_INTEGER, 32, PropModeReplace, 1,
+				     &value, FALSE, FALSE);
+	if (err != Success) {
+	    xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+		       "RRChangeOutputProperty error, %d\n", err);
+	}
+    }
+
+    drmmode_output->props =
+	calloc(mode_output->count_props + 1, sizeof(drmmode_prop_rec));
+    if (!drmmode_output->props)
+	return;
 
     drmmode_output->props = calloc(mode_output->count_props + 1, sizeof(drmmode_prop_rec));
     if (!drmmode_output->props)
commit 612bda0a5e769f23478b364cf89620222cfac349
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jul 11 19:07:59 2018 +0200

    modesetting: Record non-desktop kernel property at PreInit time
    
    Save any value of the kernel non-desktop property in the xf86Output
    structure to avoid non-desktop outputs in the default configuration.
    
    [Also bump randrproto requirement to a version that defines
    RR_PROPERTY_NON_DESKTOP - ajax]
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (Ported from xserver commit b91c787c4cd2d20685db69426c539938c556128a)
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    (Ported from amdgpu commit 14db71a606128c4a207f43298809af279b77e2a8)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/configure.ac b/configure.ac
index f5614749..65206e7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,7 +64,7 @@ AC_ARG_WITH(xorg-module-dir,
             [moduledir="$libdir/xorg/modules"])
 
 # Store the list of server defined optional extensions in REQUIRED_MODULES
-XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+XORG_DRIVER_CHECK_EXT(RANDR, [randrproto >= 1.6.0])
 XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
 XORG_DRIVER_CHECK_EXT(XV, videoproto)
 XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 03c850f8..27aa5a6c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1975,6 +1975,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	drmModeEncoderPtr *kencoders = NULL;
 	drmmode_output_private_ptr drmmode_output;
 	drmModePropertyBlobPtr path_blob = NULL;
+#if XF86_CRTC_VERSION >= 8
+	Bool nonDesktop = FALSE;
+#endif
 	char name[32];
 	int i;
 	const char *s;
@@ -1985,6 +1988,13 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 
 	path_blob = koutput_get_prop_blob(pRADEONEnt->fd, koutput, "PATH");
 
+#if XF86_CRTC_VERSION >= 8
+	i = koutput_get_prop_idx(pRADEONEnt->fd, koutput, DRM_MODE_PROP_RANGE,
+				 RR_PROPERTY_NON_DESKTOP);
+	if (i >= 0)
+		nonDesktop = koutput->prop_values[i] != 0;
+#endif
+
 	kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
 	if (!kencoders) {
 		goto out_free_encoders;
@@ -2014,6 +2024,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 			drmmode_output = output->driver_private;
 			drmmode_output->output_id = mode_res->connectors[num];
 			drmmode_output->mode_output = koutput;
+#if XF86_CRTC_VERSION >= 8
+			output->non_desktop = nonDesktop;
+#endif
 			for (i = 0; i < koutput->count_encoders; i++)
 				drmModeFreeEncoder(kencoders[i]);
 			free(kencoders);
@@ -2055,6 +2068,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	output->interlaceAllowed = TRUE;
 	output->doubleScanAllowed = TRUE;
 	output->driver_private = drmmode_output;
+#if XF86_CRTC_VERSION >= 8
+	output->non_desktop = nonDesktop;
+#endif
 	
 	output->possible_crtcs = 0xffffffff;
 	for (i = 0; i < koutput->count_encoders; i++) {
commit 4b3e5f81c6032003237bb05c3ab96423c39524fc
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 19:04:26 2018 +0200

    Call drmmode_crtc_gamma_do_set from drmmode_setup_colormap
    
    Instead of from drmmode_set_mode_major. There's no need to re-set the
    gamma LUT on every modeset, the kernel should preserve it.
    
    (Ported from amdgpu commit baea4fa492f635cdfe746a84be2e337d9aeae8a9)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index e301c0e6..03c850f8 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -887,9 +887,6 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		else
 			drmmode_crtc->scanout_id = 0;
 
-		drmmode_crtc_gamma_do_set(crtc, crtc->gamma_red, crtc->gamma_green,
-					  crtc->gamma_blue, crtc->gamma_size);
-
 		if (drmmode_crtc->prime_scanout_pixmap) {
 			drmmode_crtc_prime_scanout_update(crtc, mode, scanout_id,
 							  &fb, &x, &y);
@@ -2854,6 +2851,7 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i;
 
     if (xf86_config->num_crtc) {
 	xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
@@ -2862,13 +2860,23 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 	    return FALSE;
 
 	/* All radeons support 10 bit CLUTs. They get bypassed at depth 30. */
-	if (pScrn->depth != 30 &&
-	    !xf86HandleColormaps(pScreen, 256, 10,
-				 NULL, NULL,
-				 CMAP_PALETTED_TRUECOLOR
-				 | CMAP_RELOAD_ON_MODE_SWITCH))
-	    return FALSE;
+	if (pScrn->depth != 30) {
+	    if (!xf86HandleColormaps(pScreen, 256, 10, NULL, NULL,
+				     CMAP_PALETTED_TRUECOLOR
+				     | CMAP_RELOAD_ON_MODE_SWITCH))
+		return FALSE;
+
+	    for (i = 0; i < xf86_config->num_crtc; i++) {
+		xf86CrtcPtr crtc = xf86_config->crtc[i];
+
+		drmmode_crtc_gamma_do_set(crtc, crtc->gamma_red,
+					  crtc->gamma_green,
+					  crtc->gamma_blue,
+					  crtc->gamma_size);
+	    }
+	}
     }
+
     return TRUE;
 }
 
commit 16ddc109660dbe813c457765eda66422fb745a3e
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 19:03:12 2018 +0200

    Remove #if 0'd code
    
    This has always been disabled, no need to keep it.
    
    (Ported from amdgpu commit 19a40758be04e1d451a030f452efb49e8aaad541)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 4b5f9f45..e301c0e6 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1835,15 +1835,6 @@ static const xf86OutputFuncsRec drmmode_output_funcs = {
     .create_resources = drmmode_output_create_resources,
     .set_property = drmmode_output_set_property,
     .get_property = drmmode_output_get_property,
-#if 0
-
-    .save = drmmode_crt_save,
-    .restore = drmmode_crt_restore,
-    .mode_fixup = drmmode_crt_mode_fixup,
-    .prepare = drmmode_output_prepare,
-    .mode_set = drmmode_crt_mode_set,
-    .commit = drmmode_output_commit,
-#endif
     .detect = drmmode_output_detect,
     .mode_valid = drmmode_output_mode_valid,
 
@@ -2875,9 +2866,6 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 	    !xf86HandleColormaps(pScreen, 256, 10,
 				 NULL, NULL,
 				 CMAP_PALETTED_TRUECOLOR
-#if 0 /* This option messes up text mode! (eich at suse.de) */
-				 | CMAP_LOAD_EVEN_IF_OFFSCREEN
-#endif
 				 | CMAP_RELOAD_ON_MODE_SWITCH))
 	    return FALSE;
     }
commit 447ef0458fac047919d021f2ba1753a647f5c503
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 19:01:31 2018 +0200

    Check dimensions passed to drmmode_xf86crtc_resize
    
    When enabling a secondary GPU output, Xorg can try resizing the screen
    beyond the limit advertised by the driver, leading to drmModeAddFB
    failing and primary GPU outputs turning off. Check for this and bail
    instead.
    
    (Ported from amdgpu commit 940c8b39f79789d4d5ddb8ab8d25a8ae05932756)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 25fcabfa..4b5f9f45 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2260,6 +2260,14 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
 
+	if (width > xf86_config->maxWidth || height > xf86_config->maxHeight) {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "Xorg tried resizing screen to %dx%d, but maximum "
+			   "supported is %dx%d\n", width, height,
+			   xf86_config->maxWidth, xf86_config->maxHeight);
+		return FALSE;
+	}
+
 	if (info->allowColorTiling && !info->shadow_primary) {
 		if (info->ChipFamily < CHIP_FAMILY_R600 || info->allowColorTiling2D)
 			usage |= RADEON_CREATE_PIXMAP_TILING_MACRO;
commit 6a0c01bbd4ed48c696c38952ee33ce21afec9f91
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 18:59:58 2018 +0200

    Use drmmode_crtc_dpms in drmmode_set_desired_modes
    
    Simplifies the latter slightly.
    
    (Ported from amdgpu commit 74124f2c17dbb4b752707bb7eee398ae099e8a2c)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index cf1f6e80..25fcabfa 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2763,7 +2763,6 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 			       Bool set_hw)
 {
 	xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
-	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
 	unsigned num_desired = 0, num_on = 0;
 	int c;
 
@@ -2771,18 +2770,12 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 	if (set_hw) {
 		for (c = 0; c < config->num_crtc; c++) {
 			xf86CrtcPtr crtc = config->crtc[c];
-			drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
 			/* Skip disabled CRTCs */
 			if (crtc->enabled)
 				continue;
 
-			drmmode_do_crtc_dpms(crtc, DPMSModeOff);
-			drmModeSetCrtc(pRADEONEnt->fd,
-				       drmmode_crtc->mode_crtc->crtc_id,
-				       0, 0, 0, NULL, 0, NULL);
-			drmmode_fb_reference(pRADEONEnt->fd,
-					     &drmmode_crtc->fb, NULL);
+			drmmode_crtc_dpms(crtc, DPMSModeOff);
 		}
 	}
 
commit 59441ee3dae15e0e81ed20688b0ba6dba12d7917
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 18:58:20 2018 +0200

    Call drmmode_do_crtc_dpms from drmmode_crtc_dpms as well
    
    Leo pointed out that drmmode_do_crtc_dpms wasn't getting called when
    turning off an output with
    
     xrandr --output <output> --off
    
    This meant that the vblank sequence number and timestamp wouldn't be
    saved before turning off the CRTC in this case.
    
    Reported-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
    (Ported from amdgpu commit ceeacb455cd058492a493aac954deab8455804b5)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3117b8f1..cf1f6e80 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -361,8 +361,7 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
 
 	/* Disable unused CRTCs */
 	if (!crtc->enabled || mode != DPMSModeOn) {
-		drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
-						drmmode_crtc->flip_pending);
+		drmmode_do_crtc_dpms(crtc, DPMSModeOff);
 		drmModeSetCrtc(pRADEONEnt->fd, drmmode_crtc->mode_crtc->crtc_id,
 			       0, 0, 0, NULL, 0, NULL);
 		drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->fb, NULL);
commit 4050b0ad51b1c65945c6474981d1228888738cd4
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Jul 11 18:42:58 2018 +0200

    Replace 'foo == NULL' with '!foo'
    
    Shorter and sweeter. :)
    
    (Ported from amdgpu commit e8e688f3852fb06b0c34ed5bce47c9493bcd1613)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/ati.c b/src/ati.c
index 6fd21567..837b0094 100644
--- a/src/ati.c
+++ b/src/ati.c
@@ -109,7 +109,7 @@ ati_device_get_primary(void)
 
     device_iter = pci_slot_match_iterator_create(NULL);
 
-    while ((device = pci_device_next(device_iter)) != NULL) {
+    while ((device = pci_device_next(device_iter))) {
         if (xf86IsPrimaryPci(device))
             break;
     }
@@ -128,7 +128,7 @@ ati_device_get_indexed(int index)
 
     device_iter = pci_slot_match_iterator_create(NULL);
 
-    while ((device = pci_device_next(device_iter)) != NULL) {
+    while ((device = pci_device_next(device_iter))) {
         if (device->vendor_id == PCI_VENDOR_ATI) {
             if (count == index)
                 return device;
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 003fe51e..3117b8f1 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -386,7 +386,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,
 	    return pixmap;
 
 	fbcon = drmModeGetFB(pRADEONEnt->fd, fbcon_id);
-	if (fbcon == NULL)
+	if (!fbcon)
 		return NULL;
 
 	if (fbcon->depth != pScrn->depth ||
@@ -410,7 +410,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,
 	bo->ref_count = 1;
 
 	bo->bo.radeon = radeon_bo_open(drmmode->bufmgr, flink.name, 0, 0, 0, 0);
-	if (bo == NULL) {
+	if (!bo) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 			   "Couldn't open BO for fbcon handle\n");
 		goto out_free_fb;
@@ -1365,7 +1365,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res
 	RADEONInfoPtr info = RADEONPTR(pScrn);
 
 	crtc = xf86CrtcCreate(pScrn, &info->drmmode_crtc_funcs);
-	if (crtc == NULL)
+	if (!crtc)
 		return 0;
 
 	drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
@@ -2317,7 +2317,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 		if (radeon_bo_map(info->front_buffer->bo.radeon, 1))
 			goto fail;
 		fb_shadow = calloc(1, pitch * scrn->virtualY);
-		if (fb_shadow == NULL)
+		if (!fb_shadow)
 			goto fail;
 		free(info->fb_shadow);
 		info->fb_shadow = fb_shadow;
diff --git a/src/evergreen_exa.c b/src/evergreen_exa.c
index dae8b6a1..447ed217 100644
--- a/src/evergreen_exa.c
+++ b/src/evergreen_exa.c
@@ -511,7 +511,7 @@ EVERGREENPrepareCopy(PixmapPtr pSrc,   PixmapPtr pDst,
 	accel_state->copy_area_bo = radeon_bo_open(info->bufmgr, 0, size, 0,
 						   RADEON_GEM_DOMAIN_VRAM,
 						   0);
-	if (accel_state->copy_area_bo == NULL)
+	if (!accel_state->copy_area_bo)
 	    RADEON_FALLBACK(("temp copy surface alloc failed\n"));
 
 	radeon_cs_space_add_persistent_bo(info->cs, accel_state->copy_area_bo,
@@ -1693,7 +1693,7 @@ EVERGREENUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
     base_align = drmmode_get_base_align(pScrn, (bpp / 8), 0);
     size = scratch_pitch * height * (bpp / 8);
     scratch = radeon_bo_open(info->bufmgr, 0, size, base_align, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
 
@@ -1821,7 +1821,7 @@ EVERGREENDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w,
     base_align = drmmode_get_base_align(pScrn, (bpp / 8), 0);
     size = scratch_pitch * height * (bpp / 8);
     scratch = radeon_bo_open(info->bufmgr, 0, size, base_align, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
     radeon_cs_space_reset_bos(info->cs);
@@ -1927,7 +1927,7 @@ EVERGREENAllocShaders(ScrnInfoPtr pScrn, ScreenPtr pScreen)
 
     accel_state->shaders_bo = radeon_bo_open(info->bufmgr, 0, size, 0,
 					     RADEON_GEM_DOMAIN_VRAM, 0);
-    if (accel_state->shaders_bo == NULL) {
+    if (!accel_state->shaders_bo) {
 	ErrorF("Allocating shader failed\n");
 	return FALSE;
     }
@@ -2046,7 +2046,7 @@ EVERGREENDrawInit(ScreenPtr pScreen)
     ScrnInfoPtr pScrn =  xf86ScreenToScrn(pScreen);
     RADEONInfoPtr info   = RADEONPTR(pScrn);
 
-    if (info->accel_state->exa == NULL) {
+    if (!info->accel_state->exa) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR, "Memory map not set up\n");
 	return FALSE;
     }
diff --git a/src/r600_exa.c b/src/r600_exa.c
index bd824c87..99db0c40 100644
--- a/src/r600_exa.c
+++ b/src/r600_exa.c
@@ -575,7 +575,7 @@ R600PrepareCopy(PixmapPtr pSrc,   PixmapPtr pDst,
 	accel_state->copy_area_bo = radeon_bo_open(info->bufmgr, 0, size, align,
 						   RADEON_GEM_DOMAIN_VRAM,
 						   0);
-	if (accel_state->copy_area_bo == NULL)
+	if (!accel_state->copy_area_bo)
 	    RADEON_FALLBACK(("temp copy surface alloc failed\n"));
 	
 	radeon_cs_space_add_persistent_bo(info->cs, accel_state->copy_area_bo,
@@ -1723,7 +1723,7 @@ R600UploadToScreenCS(PixmapPtr pDst, int x, int y, int w, int h,
     base_align = drmmode_get_base_align(pScrn, (bpp / 8), 0);
     size = scratch_pitch * height * (bpp / 8);
     scratch = radeon_bo_open(info->bufmgr, 0, size, base_align, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
 
@@ -1847,7 +1847,7 @@ R600DownloadFromScreenCS(PixmapPtr pSrc, int x, int y, int w,
     base_align = drmmode_get_base_align(pScrn, (bpp / 8), 0);
     size = scratch_pitch * height * (bpp / 8);
     scratch = radeon_bo_open(info->bufmgr, 0, size, base_align, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
     radeon_cs_space_reset_bos(info->cs);
@@ -1960,7 +1960,7 @@ R600AllocShaders(ScrnInfoPtr pScrn, ScreenPtr pScreen)
 
     accel_state->shaders_bo = radeon_bo_open(info->bufmgr, 0, size, 0,
 					     RADEON_GEM_DOMAIN_VRAM, 0);
-    if (accel_state->shaders_bo == NULL) {
+    if (!accel_state->shaders_bo) {
         ErrorF("Allocating shader failed\n");
 	return FALSE;
     }
@@ -2025,7 +2025,7 @@ R600DrawInit(ScreenPtr pScreen)
     ScrnInfoPtr pScrn =  xf86ScreenToScrn(pScreen);
     RADEONInfoPtr info   = RADEONPTR(pScrn);
 
-    if (info->accel_state->exa == NULL) {
+    if (!info->accel_state->exa) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR, "Memory map not set up\n");
 	return FALSE;
     }
diff --git a/src/radeon.h b/src/radeon.h
index 2bcfa41b..450c69aa 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -726,7 +726,7 @@ static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_buffer *bo
 	struct radeon_pixmap *priv;
 
 	priv = radeon_get_pixmap_private(pPix);
-	if (priv == NULL && bo == NULL)
+	if (!priv && !bo)
 	    return TRUE;
 
 	if (priv) {
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 70ad1d92..c36e06f2 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -238,14 +238,14 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 	return NULL;
 
     buffers = calloc(1, sizeof *buffers);
-    if (buffers == NULL)
+    if (!buffers)
         goto error;
 
     if (!info->use_glamor) {
 	info->exa_force_create = TRUE;
 	exaMoveInPixmap(pixmap);
 	info->exa_force_create = FALSE;
-	if (exaGetPixmapDriverPrivate(pixmap) == NULL) {
+	if (!exaGetPixmapDriverPrivate(pixmap)) {
 	    /* this happen if pixmap is non accelerable */
 	    goto error;
 	}
@@ -258,7 +258,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
 	goto error;
 
     privates = calloc(1, sizeof(struct dri2_buffer_priv));
-    if (privates == NULL)
+    if (!privates)
         goto error;
 
     buffers->attachment = attachment;
@@ -923,7 +923,7 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
     xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
 
     /* Drawable not displayed, make up a value */
-    if (crtc == NULL) {
+    if (!crtc) {
         *ust = 0;
         *msc = 0;
         return TRUE;
@@ -1034,7 +1034,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
     remainder &= 0xffffffff;
 
     /* Drawable not visible, return immediately */
-    if (crtc == NULL)
+    if (!crtc)
         goto out_complete;
 
     msc_delta = radeon_get_msc_delta(draw, crtc);
@@ -1193,7 +1193,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
     radeon_dri2_ref_buffer(back);
 
     /* either off-screen or CRTC not usable... just complete the swap */
-    if (crtc == NULL)
+    if (!crtc)
         goto blit_fallback;
 
     msc_delta = radeon_get_msc_delta(draw, crtc);
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 90d92d7b..93c2f056 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -150,7 +150,7 @@ Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset)
  */
 Bool radeon_transform_is_affine_or_scaled(PictTransformPtr t)
 {
-	if (t == NULL)
+	if (!t)
 		return TRUE;
 	/* the shaders don't handle scaling either */
 	return t->matrix[2][0] == 0 && t->matrix[2][1] == 0 && t->matrix[2][2] == IntToxFixed(1);
diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c
index 819b4258..b3200cc9 100644
--- a/src/radeon_exa_funcs.c
+++ b/src/radeon_exa_funcs.c
@@ -331,7 +331,7 @@ RADEONBlitChunk(ScrnInfoPtr pScrn, struct radeon_bo *src_bo,
 
     if (src_bo && dst_bo) {
         BEGIN_ACCEL_RELOC(6, 2);
-    } else if (src_bo && dst_bo == NULL) {
+    } else if (src_bo && !dst_bo) {
         BEGIN_ACCEL_RELOC(6, 1);
     } else {
         BEGIN_RING(2*6);
@@ -423,7 +423,7 @@ RADEONUploadToScreenCS(PixmapPtr pDst, int x, int y, int w, int h,
 
     size = scratch_pitch * h;
     scratch = radeon_bo_open(info->bufmgr, 0, size, 0, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
     radeon_cs_space_reset_bos(info->cs);
@@ -531,7 +531,7 @@ RADEONDownloadFromScreenCS(PixmapPtr pSrc, int x, int y, int w,
     }
     size = scratch_pitch * h;
     scratch = radeon_bo_open(info->bufmgr, 0, size, 0, RADEON_GEM_DOMAIN_GTT, 0);
-    if (scratch == NULL) {
+    if (!scratch) {
 	goto copy;
     }
     radeon_cs_space_reset_bos(info->cs);
@@ -584,7 +584,7 @@ Bool RADEONDrawInit(ScreenPtr pScreen)
 {
     RINFO_FROM_SCREEN(pScreen);
 
-    if (info->accel_state->exa == NULL) {
+    if (!info->accel_state->exa) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR, "Memory map not set up\n");
 	return FALSE;
     }
diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c
index 9510f7f4..c61d83f4 100644
--- a/src/radeon_exa_render.c
+++ b/src/radeon_exa_render.c
@@ -630,7 +630,7 @@ static Bool R100PrepareComposite(int op,
 	return FALSE;
     pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
 
-    if (pMask != NULL) {
+    if (pMask) {
 	if (!R100TextureSetup(pMaskPicture, pMask, 1))
 	    return FALSE;
 	pp_cntl |= RADEON_TEX_1_ENABLE;
@@ -992,7 +992,7 @@ static Bool R200PrepareComposite(int op, PicturePtr pSrcPicture,
 	return FALSE;
     pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
 
-    if (pMask != NULL) {
+    if (pMask) {
 	if (!R200TextureSetup(pMaskPicture, pMask, 1))
 	    return FALSE;
 	pp_cntl |= RADEON_TEX_1_ENABLE;
@@ -1484,7 +1484,7 @@ static Bool R300PrepareComposite(int op, PicturePtr pSrcPicture,
 	return FALSE;
     txenable = R300_TEX_0_ENABLE;
 
-    if (pMask != NULL) {
+    if (pMask) {
 	if (!R300TextureSetup(pMaskPicture, pMask, 1))
 	    return FALSE;
 	txenable |= R300_TEX_1_ENABLE;
diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
index fa634947..b649bd18 100644
--- a/src/radeon_glamor.c
+++ b/src/radeon_glamor.c
@@ -261,7 +261,7 @@ radeon_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		int stride;
 
 		priv = calloc(1, sizeof (struct radeon_pixmap));
-		if (priv == NULL)
+		if (!priv)
 			goto fallback_pixmap;
 
 		priv->bo = radeon_alloc_pixmap_bo(scrn, w, h, depth, usage,
diff --git a/src/radeon_glamor_wrappers.c b/src/radeon_glamor_wrappers.c
index 79d98cc7..edffd9ad 100644
--- a/src/radeon_glamor_wrappers.c
+++ b/src/radeon_glamor_wrappers.c
@@ -132,7 +132,7 @@ radeon_glamor_finish_access_cpu(PixmapPtr pixmap)
 static Bool
 radeon_glamor_prepare_access_gpu(struct radeon_pixmap *priv)
 {
-	return priv != NULL;
+	return !!priv;
 }
 
 static void
@@ -201,7 +201,7 @@ radeon_glamor_picture_prepare_access_cpu_ro(ScrnInfoPtr scrn,
 	PixmapPtr pixmap;
 	struct radeon_pixmap *priv;
 
-	if (picture->pDrawable == NULL)
+	if (!picture->pDrawable)
 		return TRUE;
 
 	pixmap = get_drawable_pixmap(picture->pDrawable);
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 15dca0de..36840ad3 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -639,7 +639,7 @@ master_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
 {
     ScreenPtr master_screen = radeon_dirty_master(dirty);
 
-    return master_screen->SyncSharedPixmap != NULL;
+    return !!master_screen->SyncSharedPixmap;
 }
 
 static Bool
@@ -647,7 +647,7 @@ slave_has_sync_shared_pixmap(ScrnInfoPtr scrn, PixmapDirtyUpdatePtr dirty)
 {
     ScreenPtr slave_screen = dirty->slave_dst->drawable.pScreen;
 
-    return slave_screen->SyncSharedPixmap != NULL;
+    return !!slave_screen->SyncSharedPixmap;
 }
 
 static void
@@ -1769,7 +1769,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
     info->dri2.available = FALSE;
     info->dri2.enabled = FALSE;
     info->dri2.pKernelDRMVersion = drmGetVersion(pRADEONEnt->fd);
-    if (info->dri2.pKernelDRMVersion == NULL) {
+    if (!info->dri2.pKernelDRMVersion) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		   "RADEONDRIGetVersion failed to get the DRM version\n");
 	return FALSE;
@@ -1924,7 +1924,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	    xf86OutputPtr output = xf86_config->output[i];
 
 	    /* XXX: double check crtc mode */
-	    if ((output->probed_modes != NULL) && (output->crtc == NULL))
+	    if (output->probed_modes && !output->crtc)
 		output->crtc = xf86_config->crtc[0];
 	}
     }
@@ -1987,7 +1987,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	if (!xf86LoadSubModule(pScrn, "ramdac")) return FALSE;
     }
 
-    if (pScrn->modes == NULL
+    if (!pScrn->modes
 #ifdef XSERVER_PLATFORM_BUS
         && !pScrn->is_gpu
 #endif
@@ -2098,7 +2098,7 @@ static Bool RADEONSaveScreen_KMS(ScreenPtr pScreen, int mode)
     unblank = xf86IsUnblank(mode);
     if (unblank) SetTimeSinceLastInputEvent();
 
-    if ((pScrn != NULL) && pScrn->vtSema) {
+    if (pScrn && pScrn->vtSema) {
 	if (unblank)
 	    RADEONUnblank(pScrn);
 	else
@@ -2287,7 +2287,7 @@ Bool RADEONScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)
 	info->fb_shadow = calloc(1,
 				 pScrn->displayWidth * pScrn->virtualY *
 				 ((pScrn->bitsPerPixel + 7) >> 3));
-	if (info->fb_shadow == NULL) {
+	if (!info->fb_shadow) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "Failed to allocate shadow framebuffer\n");
 	    return FALSE;
@@ -2689,13 +2689,13 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen)
     int pitch;
     uint32_t tiling_flags = 0;
 
-    if (info->accel_state->exa != NULL) {
+    if (info->accel_state->exa) {
 	xf86DrvMsg(pScreen->myNum, X_ERROR, "Memory map already initialized\n");
 	return FALSE;
     }
     if (!info->use_glamor && info->r600_shadow_fb == FALSE) {
         info->accel_state->exa = exaDriverAlloc();
-        if (info->accel_state->exa == NULL) {
+        if (!info->accel_state->exa) {
 	    xf86DrvMsg(pScreen->myNum, X_ERROR, "exaDriverAlloc failed\n");
 	    return FALSE;
 	}
@@ -2709,7 +2709,7 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen)
 	cursor_size = RADEON_ALIGN(cursor_size, RADEON_GPU_PAGE_SIZE);
 	for (c = 0; c < xf86_config->num_crtc; c++) {
 	    /* cursor objects */
-            if (info->cursor_bo[c] == NULL) {
+            if (!info->cursor_bo[c]) {
                 info->cursor_bo[c] = radeon_bo_open(info->bufmgr, 0,
                                                     cursor_size, 0,
                                                     RADEON_GEM_DOMAIN_VRAM, 0);
@@ -2727,7 +2727,7 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen)
         }
     }
 
-    if (info->front_buffer == NULL) {
+    if (!info->front_buffer) {
 	int usage = CREATE_PIXMAP_USAGE_BACKING_PIXMAP;
 
 	if (info->allowColorTiling && !info->shadow_primary) {
@@ -2787,9 +2787,8 @@ void radeon_kms_update_vram_limit(ScrnInfoPtr pScrn, uint32_t new_fb_size)
     int c;
 
     for (c = 0; c < xf86_config->num_crtc; c++) {
-	if (info->cursor_bo[c] != NULL) {
+	if (info->cursor_bo[c])
 	    new_fb_size += (64 * 4 * 64);
-	}
     }
 
     remain_size_bytes = info->vram_size - new_fb_size;
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 23bdfd1d..be71e408 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -153,7 +153,7 @@ radeon_allocate_video_bo(ScrnInfoPtr pScrn,
 static void
 RADEONFreeVideoMemory(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 {
-    if (pPriv->video_memory != NULL) {
+    if (pPriv->video_memory) {
 	radeon_bo_unref(pPriv->video_memory);
 	pPriv->video_memory = NULL;
 
@@ -312,7 +312,7 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
 	RADEONFreeVideoMemory(pScrn, pPriv);
     }
 
-    if (pPriv->video_memory == NULL) {
+    if (!pPriv->video_memory) {
       Bool ret;
       ret = radeon_allocate_video_bo(pScrn,
 				     &pPriv->video_memory,
@@ -329,7 +329,7 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
 
     /* Bicubic filter loading */
     if (pPriv->bicubic_enabled) {
-	if (info->bicubic_bo == NULL)
+	if (!info->bicubic_bo)
 	    pPriv->bicubic_enabled = FALSE;
     }
 
@@ -725,7 +725,7 @@ static void radeon_unload_bicubic_texture(ScrnInfoPtr pScrn)
 {
     RADEONInfoPtr    info = RADEONPTR(pScrn);
 
-    if (info->bicubic_memory != NULL) {
+    if (info->bicubic_memory) {
 	radeon_bo_unref(info->bicubic_memory);
 	info->bicubic_memory = NULL;
     }
@@ -827,7 +827,7 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen)
 
     adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + num_texture_ports *
 		   (sizeof(RADEONPortPrivRec) + sizeof(DevUnion)));
-    if (adapt == NULL)
+    if (!adapt)
 	return NULL;
 
     xvBicubic         = MAKE_ATOM("XV_BICUBIC");
diff --git a/src/radeon_video.c b/src/radeon_video.c
index e08d8e00..fc321184 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -144,7 +144,7 @@ void RADEONInitVideo(ScreenPtr pScreen)
 
     num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
     newAdaptors = malloc((num_adaptors + 2) * sizeof(*newAdaptors));
-    if (newAdaptors == NULL)
+    if (!newAdaptors)
 	return;
 
     memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr));
@@ -152,7 +152,7 @@ void RADEONInitVideo(ScreenPtr pScreen)
 
     if (info->use_glamor) {
         texturedAdaptor = radeon_glamor_xv_init(pScreen, 16);
-	if (texturedAdaptor != NULL) {
+	if (texturedAdaptor) {
 	    adaptors[num_adaptors++] = texturedAdaptor;
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Set up textured video (glamor)\n");
 	} else
@@ -161,7 +161,7 @@ void RADEONInitVideo(ScreenPtr pScreen)
 	|| (info->directRenderingEnabled)
 	) {
 	texturedAdaptor = RADEONSetupImageTexturedVideo(pScreen);
-	if (texturedAdaptor != NULL) {
+	if (texturedAdaptor) {
 	    adaptors[num_adaptors++] = texturedAdaptor;
 	    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Set up textured video\n");
 	} else
commit cf8bc72e3473cef2b511e2c938eb00aca82de909
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:57:49 2018 +0200

    Wait for pending flips in drmmode_output_set_tear_free
    
    This prevents a nested call to drmHandleEvent, which would hang.
    
    Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is
    page flipping.
    
    (Ported from amdgpu commit 04947b83cce3a7782e59dece2c7797cc396c1e05)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index ae605eda..003fe51e 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1754,6 +1754,14 @@ drmmode_output_set_tear_free(RADEONEntPtr pRADEONEnt,
 	drmmode_output->tear_free = tear_free;
 
 	if (crtc) {
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		/* Wait for pending flips before drmmode_set_mode_major calls
+		 * drmmode_crtc_update_tear_free, to prevent a nested
+		 * drmHandleEvent call, which would hang
+		 */
+		drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
+						drmmode_crtc->flip_pending);
 		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
 				       crtc->x, crtc->y);
 	}
commit f01d8cf2bd9681b8f5f0e2eddec0a79614389771
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:53:54 2018 +0200

    Refactor drmmode_output_set_tear_free helper
    
    Preparation for the following fix, no functional change intended.
    
    (Ported from amdgpu commit fa30f4601de7a44edfb4a95873bd648946fd4292)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index df8ef320..ae605eda 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1743,6 +1743,22 @@ drmmode_output_create_resources(xf86OutputPtr output)
     }
 }
 
+static void
+drmmode_output_set_tear_free(RADEONEntPtr pRADEONEnt,
+			     drmmode_output_private_ptr drmmode_output,
+			     xf86CrtcPtr crtc, int tear_free)
+{
+	if (drmmode_output->tear_free == tear_free)
+		return;
+
+	drmmode_output->tear_free = tear_free;
+
+	if (crtc) {
+		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+				       crtc->x, crtc->y);
+	}
+}
+
 static Bool
 drmmode_output_set_property(xf86OutputPtr output, Atom property,
 		RRPropertyValuePtr value)
@@ -1783,16 +1799,8 @@ drmmode_output_set_property(xf86OutputPtr output, Atom property,
 	    for (j = 0; j < p->mode_prop->count_enums; j++) {
 		if (!strcmp(p->mode_prop->enums[j].name, name)) {
 		    if (i == (drmmode_output->num_props - 1)) {
-			if (drmmode_output->tear_free != j) {
-			    xf86CrtcPtr crtc = output->crtc;
-
-			    drmmode_output->tear_free = j;
-			    if (crtc) {
-				drmmode_set_mode_major(crtc, &crtc->mode,
-						       crtc->rotation,
-						       crtc->x, crtc->y);
-			    }
-			}
+			drmmode_output_set_tear_free(pRADEONEnt, drmmode_output,
+						     output->crtc, j);
 		    } else {
 			drmModeConnectorSetProperty(pRADEONEnt->fd,
 						    drmmode_output->output_id,
commit ee7e15746148122abf6728fb0f59d6c8ae329e4e
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:53:06 2018 +0200

    Set drmmode_crtc->scanout_id = 0 when TearFree is disabled
    
    When disabling TearFree, drmmode_crtc->scanout_id could remain as 1,
    but drmmode_set_mode_major would destroy drmmode_crtc->scanout[1], so
    scanout_do_update() would keep bailing, and the scanout buffer would
    stop being updated.
    
    Fixes freeze after disabling TearFree on a CRTC with active RandR
    rotation or other transform.
    
    (Ported from amdgpu commit 7db0c8e9d7586cff4312d4b93684d35de3e6376f)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index fce8723e..df8ef320 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -885,6 +885,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		drmmode_crtc_update_tear_free(crtc);
 		if (drmmode_crtc->tear_free)
 			scanout_id = drmmode_crtc->scanout_id;
+		else
+			drmmode_crtc->scanout_id = 0;
 
 		drmmode_crtc_gamma_do_set(crtc, crtc->gamma_red, crtc->gamma_green,
 					  crtc->gamma_blue, crtc->gamma_size);
commit e9d2d149481e2a9c7cba50d43c6a5146124be3f2
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:52:08 2018 +0200

    Simplify drmmode_handle_transform
    
    Set crtc->driverIsPerformingTransform for any case we can handle before
    calling xf86CrtcRotate. We already clear it afterwards when the latter
    clears crtc->transform_in_use.
    
    This should allow our separate scanout buffer mechanism to be used in
    more cases.
    
    (Cherry picked from amdgpu commit 8e544b4a0de6717feb4abf00052d57c5b726b5ce)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index b3b37f56..fce8723e 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -669,13 +669,9 @@ drmmode_handle_transform(xf86CrtcPtr crtc)
 	Bool ret;
 
 #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,903,0)
-	if (crtc->transformPresent || crtc->rotation != RR_Rotate_0)
-	    crtc->driverIsPerformingTransform = XF86DriverTransformOutput;
-	else
-	    crtc->driverIsPerformingTransform = XF86DriverTransformNone;
+	crtc->driverIsPerformingTransform = XF86DriverTransformOutput;
 #else
 	crtc->driverIsPerformingTransform = !crtc->transformPresent &&
-		crtc->rotation != RR_Rotate_0 &&
 		(crtc->rotation & 0xf) == RR_Rotate_0;
 #endif
 
commit 89d38e976fd6ba6e026cda7c5d05971f1f177f13
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:51:00 2018 +0200

    Don't call scanout_flip/update with a legacy RandR scanout buffer
    
    It means we are not using our own scanout buffers.
    
    Fixes crash when TearFree is supposed to be enabled, but
    drmmode_handle_transform doesn't set crtc->driverIsPerformingTransform.
    
    Bugzilla: https://bugs.freedesktop.org/105736
    (Ported from amdgpu commit 463477661c88cab3a87746499e5838c5b9f9a13b)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index cdda8962..15dca0de 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -1167,6 +1167,9 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
 	    xf86CrtcPtr crtc = xf86_config->crtc[c];
 	    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
+	    if (drmmode_crtc->rotate.pixmap)
+		continue;
+
 	    if (drmmode_crtc->tear_free)
 		radeon_scanout_flip(pScreen, info, crtc);
 	    else if (drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
commit 9f2409c4d3a9ecad8e769783e307e57a75b1255e
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:49:05 2018 +0200

    Simplify drmmode_crtc_scanout_update
    
    Use our own BoxRec for the extents, and RegionEmpty for clearing the
    scanout damage region.
    
    (Ported from amdgpu commit 72c3e9c7308fbcdf85708b72f9be14a5f2f8e7b5)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index fa05cda4..b3b37f56 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -765,8 +765,8 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 	if (drmmode_crtc->scanout[scanout_id].pixmap &&
 	    (!drmmode_crtc->tear_free ||
 	     drmmode_crtc->scanout[scanout_id ^ 1].pixmap)) {
-		RegionPtr region;
-		BoxPtr box;
+		BoxRec extents = { .x1 = 0, .y1 = 0,
+				   .x2 = scrn->virtualX, .y2 = scrn->virtualY };
 
 		if (!drmmode_crtc->scanout_damage) {
 			drmmode_crtc->scanout_damage =
@@ -778,21 +778,13 @@ drmmode_crtc_scanout_update(xf86CrtcPtr crtc, DisplayModePtr mode,
 				       drmmode_crtc->scanout_damage);
 		}
 
-		region = DamageRegion(drmmode_crtc->scanout_damage);
-		RegionUninit(region);
-		region->data = NULL;
-		box = RegionExtents(region);
-		box->x1 = 0;
-		box->y1 = 0;
-		box->x2 = max(box->x2, scrn->virtualX);
-		box->y2 = max(box->y2, scrn->virtualY);
-
 		*fb = radeon_pixmap_get_fb(drmmode_crtc->scanout[scanout_id].pixmap);
 		*x = *y = 0;
 
 		radeon_scanout_do_update(crtc, scanout_id,
 					 screen->GetWindowPixmap(screen->root),
-					 *box);
+					 extents);
+		RegionEmpty(DamageRegion(drmmode_crtc->scanout_damage));
 		radeon_finish(scrn, drmmode_crtc->scanout[scanout_id].bo);
 	}
 }
commit e07c38649280b3f4361005bc4c256f2145a72537
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:48:16 2018 +0200

    Update RandR CRTC state if set_mode_major fails in set_desired_modes
    
    Without this, RandR would report the CRTC and its outputs as enabled,
    even though they were actually off due to the failure.
    
    (Cherry picked from amdgpu commit 4dcda0b48d62944c841cd9540f4ad4c7ac8dee47)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 64dab316..fa05cda4 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2833,6 +2833,8 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
 			} else {
 				xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 					   "Failed to set mode on CRTC %d\n", c);
+				RRCrtcSet(crtc->randr_crtc, NULL, crtc->x, crtc->y,
+					  crtc->rotation, 0, NULL);
 			}
 		} else {
 			crtc->mode = crtc->desiredMode;
commit 05390ae36a0abb19f1d533ff95a3fceaafdf79c8
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:45:51 2018 +0200

    Abort scanout_update_pending event when possible
    
    We don't need to wait for a non-TearFree scanout update before scanning
    out from the screen pixmap or before flipping, as the scanout update
    won't be visible anyway. Instead, just abort it.
    
    (Ported from amdgpu commit 36d01989cd842588f12fdae5b2cba5fdcf9c91dd)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index b3e5cc99..64dab316 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -986,8 +986,8 @@ done:
 		if (drmmode_crtc->scanout[scanout_id].pixmap &&
 		    fb != radeon_pixmap_get_fb(drmmode_crtc->
 					       scanout[scanout_id].pixmap)) {
-			drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
-							drmmode_crtc->scanout_update_pending);
+			radeon_drm_abort_entry(drmmode_crtc->scanout_update_pending);
+			drmmode_crtc->scanout_update_pending = 0;
 			drmmode_crtc_scanout_free(drmmode_crtc);
 		} else if (!drmmode_crtc->tear_free) {
 			drmmode_crtc_scanout_destroy(drmmode,
@@ -3190,8 +3190,12 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
 						 extents);
 			radeon_cs_flush_indirect(crtc->scrn);
 
-			drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
-							drmmode_crtc->scanout_update_pending);
+			if (drmmode_crtc->scanout_update_pending) {
+				drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
+								drmmode_crtc->flip_pending);
+				radeon_drm_abort_entry(drmmode_crtc->scanout_update_pending);
+				drmmode_crtc->scanout_update_pending = 0;
+			}
 		}
 
 		if (crtc == ref_crtc) {
commit 290291a11598ba9aa594417998502b0e0ac96970
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:43:28 2018 +0200

    Track DRM event queue sequence number in scanout_update_pending
    
    Preparation for next change, no behaviour change intended.
    (Ported from amdgpu commit 04a5c5f7cfacad8d9ccffe81e388cc3da2036cb5)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 23460fdc..27c23c1a 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -88,7 +88,7 @@ typedef struct {
     Bool ignore_damage;
     RegionRec scanout_last_region;
     unsigned scanout_id;
-    Bool scanout_update_pending;
+    uintptr_t scanout_update_pending;
     Bool tear_free;
 
     PixmapPtr prime_scanout_pixmap;
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 72e60831..cdda8962 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -526,7 +526,7 @@ radeon_scanout_flip_abort(xf86CrtcPtr crtc, void *event_data)
     RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
     drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->flip_pending,
 			 NULL);
 }
@@ -611,7 +611,7 @@ radeon_prime_scanout_update_abort(xf86CrtcPtr crtc, void *event_data)
 {
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 void
@@ -752,7 +752,7 @@ radeon_prime_scanout_update_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t u
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
     radeon_prime_scanout_do_update(crtc, 0);
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 static void
@@ -793,7 +793,7 @@ radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
 	return;
     }
 
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -851,7 +851,7 @@ radeon_prime_scanout_flip(PixmapDirtyUpdatePtr ent)
     }
 
     drmmode_crtc->scanout_id = scanout_id;
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -1000,7 +1000,7 @@ radeon_scanout_update_abort(xf86CrtcPtr crtc, void *event_data)
 {
     drmmode_crtc_private_ptr drmmode_crtc = event_data;
 
-    drmmode_crtc->scanout_update_pending = FALSE;
+    drmmode_crtc->scanout_update_pending = 0;
 }
 
 static void
@@ -1077,7 +1077,7 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)
 	return;
     }
 
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void
@@ -1144,7 +1144,7 @@ radeon_scanout_flip(ScreenPtr pScreen, RADEONInfoPtr info,
     }
 
     drmmode_crtc->scanout_id = scanout_id;
-    drmmode_crtc->scanout_update_pending = TRUE;
+    drmmode_crtc->scanout_update_pending = drm_queue_seq;
 }
 
 static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
commit d14ff6b77824d0e32728869907e88d6866243101
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Tue Jul 10 18:41:43 2018 +0200

    Ignore RADEON_DRM_QUEUE_ERROR (0) in radeon_drm_abort_entry
    
    This allows a following change to be slightly simpler.
    (Ported from amdgpu commit 8fcc3a9b43d3907052a83a96e5a2423afab5ad3f)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c
index 869f95c3..ac775f86 100644
--- a/src/radeon_drm_queue.c
+++ b/src/radeon_drm_queue.c
@@ -150,6 +150,9 @@ radeon_drm_abort_entry(uintptr_t seq)
 {
     struct radeon_drm_queue_entry *e, *tmp;
 
+    if (seq == RADEON_DRM_QUEUE_ERROR)
+	return;
+
     xorg_list_for_each_entry_safe(e, tmp, &radeon_drm_queue, list) {
 	if (e->seq == seq) {
 	    radeon_drm_abort_one(e);
commit 731d4b386a55cdb468e37b69d41284150952cf8c
Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Tue Jul 10 18:39:31 2018 +0200

    Do not export the DriverRec RADEON
    
    Unused externally and should not be exported.
    
    Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
    (Ported from amdgpu commit 7fb8b49895e225b3908c8bd186539de23afe91d1)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 19295f00..04f9e559 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -278,7 +278,7 @@ radeon_platform_probe(DriverPtr pDriver,
 }
 #endif
 
-_X_EXPORT DriverRec RADEON =
+DriverRec RADEON =
 {
     RADEON_VERSION_CURRENT,
     RADEON_DRIVER_NAME,
commit cc1d0824a8a7ef29f8911b95695f7cb1b4abe9b8
Author: Jim Qu <Jim.Qu at amd.com>
Date:   Tue Jul 10 18:36:42 2018 +0200

    Wait for pending scanout update before calling drmmode_crtc_scanout_free
    
    There is a case that when set screen from reverse to normal, the old
    scanout damage is freed in modesetting before scanout update handler,
    so it causes segment fault issue.
    
    Signed-off-by: Jim Qu <Jim.Qu at amd.com>
    
    [ Michel Dänzer: Only call drmmode_crtc_wait_pending_event before
      drmmode_crtc_scanout_free is actually called, slightly tweak commit
      message ]
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    (Ported from amdgpu commit 9f6a8905611b5b1d8fcd31bebbc9af7ca1355cc3)
    Acked-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2773ce67..b3e5cc99 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -985,9 +985,11 @@ done:
 
 		if (drmmode_crtc->scanout[scanout_id].pixmap &&
 		    fb != radeon_pixmap_get_fb(drmmode_crtc->
-					       scanout[scanout_id].pixmap))
+					       scanout[scanout_id].pixmap)) {
+			drmmode_crtc_wait_pending_event(drmmode_crtc, pRADEONEnt->fd,
+							drmmode_crtc->scanout_update_pending);
 			drmmode_crtc_scanout_free(drmmode_crtc);
-		else if (!drmmode_crtc->tear_free) {
+		} else if (!drmmode_crtc->tear_free) {
 			drmmode_crtc_scanout_destroy(drmmode,
 						     &drmmode_crtc->scanout[1]);
 		}


More information about the xorg-commit mailing list