[PATCH xf86-video-ati] Use pRADEONEnt->fd exclusively for the DRM file descriptor

Deucher, Alexander Alexander.Deucher at amd.com
Fri Jun 30 14:47:01 UTC 2017


> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf
> Of Michel Dänzer
> Sent: Friday, June 30, 2017 5:20 AM
> To: amd-gfx at lists.freedesktop.org
> Subject: [PATCH xf86-video-ati] Use pRADEONEnt->fd exclusively for the
> DRM file descriptor
> 
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> This brings us closer to amdgpu.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/drmmode_display.c  | 151 +++++++++++++++++++++++++----------------
> --------
>  src/drmmode_display.h  |   1 -
>  src/radeon.h           |  14 +++--
>  src/radeon_accel.c     |   4 +-
>  src/radeon_bo_helper.c |   8 ++-
>  src/radeon_dri2.c      |  54 ++++++++++--------
>  src/radeon_dri2.h      |   1 -
>  src/radeon_dri3.c      |   3 +-
>  src/radeon_exa.c       |   4 +-
>  src/radeon_glamor.c    |   3 +-
>  src/radeon_kms.c       |  70 ++++++++++++-----------
>  src/radeon_present.c   |  13 +++--
>  12 files changed, 172 insertions(+), 154 deletions(-)
> 
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index dd394ec1d..4b964b7b9 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -272,7 +272,7 @@ int drmmode_get_current_ust(int drm_fd, CARD64
> *ust)
>  int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64
> *msc)
>  {
>      ScrnInfoPtr scrn = crtc->scrn;
> -    RADEONInfoPtr info = RADEONPTR(scrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      drmVBlank vbl;
>      int ret;
> 
> @@ -280,7 +280,7 @@ int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc,
> CARD64 *ust, CARD64 *msc)
>      vbl.request.type |= radeon_populate_vbl_request_type(crtc);
>      vbl.request.sequence = 0;
> 
> -    ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +    ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>      if (ret) {
>  	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>  		   "get vblank counter failed: %s\n", strerror(errno));
> @@ -298,7 +298,7 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
>  	ScrnInfoPtr scrn = crtc->scrn;
> -	RADEONInfoPtr info = RADEONPTR(scrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>  	CARD64 ust;
>  	int ret;
> 
> @@ -318,7 +318,7 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
>  		vbl.request.type = DRM_VBLANK_RELATIVE;
>  		vbl.request.type |=
> radeon_populate_vbl_request_type(crtc);
>  		vbl.request.sequence = 0;
> -		ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +		ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>  		if (ret)
>  			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
>  				   "%s cannot get last vblank counter\n",
> @@ -345,7 +345,7 @@ drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode)
>  		 * Off->On transition: calculate and accumulate the
>  		 * number of interpolated vblanks while we were in Off state
>  		 */
> -		ret = drmmode_get_current_ust(info->dri2.drm_fd, &ust);
> +		ret = drmmode_get_current_ust(pRADEONEnt->fd, &ust);
>  		if (ret)
>  			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
>  				   "%s cannot get current time\n", __func__);
> @@ -365,7 +365,7 @@ static void
>  drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -	drmmode_ptr drmmode = drmmode_crtc->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
> 
>  	/* Disable unused CRTCs */
>  	if (!crtc->enabled || mode != DPMSModeOn) {
> @@ -373,9 +373,9 @@ drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
>  		if (drmmode_crtc->flip_pending)
>  			return;
> 
> -		drmModeSetCrtc(drmmode->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
> +		drmModeSetCrtc(pRADEONEnt->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
>  			       0, 0, 0, NULL, 0, NULL);
> -		drmmode_fb_reference(drmmode->fd, &drmmode_crtc-
> >fb, NULL);
> +		drmmode_fb_reference(pRADEONEnt->fd,
> &drmmode_crtc->fb, NULL);
>  	} else if (drmmode_crtc->dpms_mode != DPMSModeOn)
>  		crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc-
> >rotation,
>  					    crtc->x, crtc->y);
> @@ -385,6 +385,7 @@ static PixmapPtr
>  create_pixmap_for_fbcon(drmmode_ptr drmmode,
>  			ScrnInfoPtr pScrn, int fbcon_id)
>  {
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>  	RADEONInfoPtr info = RADEONPTR(pScrn);
>  	PixmapPtr pixmap = info->fbcon_pixmap;
>  	struct radeon_bo *bo;
> @@ -394,7 +395,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,
>  	if (pixmap)
>  	    return pixmap;
> 
> -	fbcon = drmModeGetFB(drmmode->fd, fbcon_id);
> +	fbcon = drmModeGetFB(pRADEONEnt->fd, fbcon_id);
>  	if (fbcon == NULL)
>  		return NULL;
> 
> @@ -404,7 +405,7 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode,
>  		goto out_free_fb;
> 
>  	flink.handle = fbcon->handle;
> -	if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
> +	if (ioctl(pRADEONEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
>  		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  			   "Couldn't flink fbcon handle\n");
>  		goto out_free_fb;
> @@ -812,8 +813,9 @@ drmmode_crtc_gamma_do_set(xf86CrtcPtr crtc,
> uint16_t *red, uint16_t *green,
>  			  uint16_t *blue, int size)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
> 
> -	drmModeCrtcSetGamma(drmmode_crtc->drmmode->fd,
> +	drmModeCrtcSetGamma(pRADEONEnt->fd,
>  			    drmmode_crtc->mode_crtc->crtc_id, size, red,
> green,
>  			    blue);
>  }
> @@ -825,6 +827,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc,
> DisplayModePtr mode,
>  	ScrnInfoPtr pScrn = crtc->scrn;
>  	ScreenPtr pScreen = pScrn->pScreen;
>  	RADEONInfoPtr info = RADEONPTR(pScrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>  	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc-
> >scrn);
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
>  	unsigned scanout_id = 0;
> @@ -907,13 +910,13 @@ drmmode_set_mode_major(xf86CrtcPtr crtc,
> DisplayModePtr mode,
>  		if (!fb)
>  			fb = radeon_pixmap_get_fb(pScreen-
> >GetWindowPixmap(pScreen->root));
>  		if (!fb) {
> -			fb = radeon_fb_create(drmmode->fd, pScrn-
> >virtualX,
> +			fb = radeon_fb_create(pRADEONEnt->fd, pScrn-
> >virtualX,
>  					      pScrn->virtualY, pScrn->depth,
>  					      pScrn->bitsPerPixel,
>  					      pScrn->displayWidth * info-
> >pixel_bytes,
>  					      info->front_bo->handle);
>  			/* Prevent refcnt of ad-hoc FBs from reaching 2 */
> -			drmmode_fb_reference(drmmode->fd,
> &drmmode_crtc->fb, NULL);
> +			drmmode_fb_reference(pRADEONEnt->fd,
> &drmmode_crtc->fb, NULL);
>  			drmmode_crtc->fb = fb;
>  		}
>  		if (!fb) {
> @@ -923,10 +926,10 @@ drmmode_set_mode_major(xf86CrtcPtr crtc,
> DisplayModePtr mode,
> 
>  		/* Wait for any pending flip to finish */
>  		do {} while (drmmode_crtc->flip_pending &&
> -			     drmHandleEvent(drmmode->fd,
> +			     drmHandleEvent(pRADEONEnt->fd,
>  					    &drmmode->event_context) > 0);
> 
> -		if (drmModeSetCrtc(drmmode->fd,
> +		if (drmModeSetCrtc(pRADEONEnt->fd,
>  				   drmmode_crtc->mode_crtc->crtc_id,
>  				   fb->handle, x, y, output_ids,
>  				   output_count, &kmode) != 0) {
> @@ -935,7 +938,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc,
> DisplayModePtr mode,
>  			goto done;
>  		} else {
>  			ret = TRUE;
> -			drmmode_fb_reference(drmmode->fd,
> &drmmode_crtc->fb, fb);
> +			drmmode_fb_reference(pRADEONEnt->fd,
> &drmmode_crtc->fb, fb);
>  		}
> 
>  		if (pScreen)
> @@ -1006,7 +1009,7 @@ static void
>  drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -	drmmode_ptr drmmode = drmmode_crtc->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
> 
>  #if XF86_CRTC_VERSION >= 4 && XF86_CRTC_VERSION < 7
>  	if (crtc->driverIsPerformingTransform) {
> @@ -1016,7 +1019,7 @@ drmmode_set_cursor_position (xf86CrtcPtr crtc, int
> x, int y)
>  	}
>  #endif
> 
> -	drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc-
> >crtc_id, x, y);
> +	drmModeMoveCursor(pRADEONEnt->fd, drmmode_crtc-
> >mode_crtc->crtc_id, x, y);
>  }
> 
>  #if XF86_CRTC_VERSION >= 4 && XF86_CRTC_VERSION < 7
> @@ -1138,9 +1141,9 @@ drmmode_hide_cursor (xf86CrtcPtr crtc)
>  	ScrnInfoPtr pScrn = crtc->scrn;
>  	RADEONInfoPtr info = RADEONPTR(pScrn);
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -	drmmode_ptr drmmode = drmmode_crtc->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
> 
> -	drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc-
> >crtc_id, 0,
> +	drmModeSetCursor(pRADEONEnt->fd, drmmode_crtc->mode_crtc-
> >crtc_id, 0,
>  			 info->cursor_w, info->cursor_h);
> 
>  }
> @@ -1151,7 +1154,7 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
>  	ScrnInfoPtr pScrn = crtc->scrn;
>  	RADEONInfoPtr info = RADEONPTR(pScrn);
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -	drmmode_ptr drmmode = drmmode_crtc->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>  	uint32_t handle = drmmode_crtc->cursor_bo->handle;
>  	static Bool use_set_cursor2 = TRUE;
> 
> @@ -1191,7 +1194,7 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
>  	    }
> 
>  	    ret =
> -		drmModeSetCursor2(drmmode->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
> +		drmModeSetCursor2(pRADEONEnt->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
>  				  handle, info->cursor_w, info->cursor_h,
>  				  xhot, yhot);
>  	    if (ret == -EINVAL)
> @@ -1200,7 +1203,7 @@ drmmode_show_cursor (xf86CrtcPtr crtc)
>  		return;
>  	}
> 
> -	drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc-
> >crtc_id, handle,
> +	drmModeSetCursor(pRADEONEnt->fd, drmmode_crtc->mode_crtc-
> >crtc_id, handle,
>  			 info->cursor_w, info->cursor_h);
>  }
> 
> @@ -1347,8 +1350,7 @@ int drmmode_get_crtc_id(xf86CrtcPtr crtc)
>  void drmmode_crtc_hw_id(xf86CrtcPtr crtc)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> -	ScrnInfoPtr pScrn = crtc->scrn;
> -	RADEONInfoPtr info = RADEONPTR(pScrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
>  	struct drm_radeon_info ginfo;
>  	int r;
>  	uint32_t tmp;
> @@ -1357,7 +1359,7 @@ void drmmode_crtc_hw_id(xf86CrtcPtr crtc)
>  	ginfo.request = 0x4;
>  	tmp = drmmode_crtc->mode_crtc->crtc_id;
>  	ginfo.value = (uintptr_t)&tmp;
> -	r = drmCommandWriteRead(info->dri2.drm_fd,
> DRM_RADEON_INFO, &ginfo, sizeof(ginfo));
> +	r = drmCommandWriteRead(pRADEONEnt->fd,
> DRM_RADEON_INFO, &ginfo, sizeof(ginfo));
>  	if (r) {
>  		drmmode_crtc->hw_id = -1;
>  		return;
> @@ -1377,7 +1379,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, drmModeResPtr mode_res
>  		return 0;
> 
>  	drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
> -	drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd,
> mode_res->crtcs[num]);
> +	drmmode_crtc->mode_crtc = drmModeGetCrtc(pRADEONEnt->fd,
> mode_res->crtcs[num]);
>  	drmmode_crtc->drmmode = drmmode;
>  	drmmode_crtc->dpms_mode = DPMSModeOff;
>  	drmmode_crtc->pending_dpms_mode = DPMSModeOff;
> @@ -1397,11 +1399,11 @@ drmmode_output_detect(xf86OutputPtr
> output)
>  {
>  	/* go to the hw and retrieve a new output struct */
>  	drmmode_output_private_ptr drmmode_output = output-
> >driver_private;
> -	drmmode_ptr drmmode = drmmode_output->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
>  	xf86OutputStatus status;
>  	drmModeFreeConnector(drmmode_output->mode_output);
> 
> -	drmmode_output->mode_output =
> drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
> +	drmmode_output->mode_output =
> drmModeGetConnector(pRADEONEnt->fd, drmmode_output->output_id);
>  	if (!drmmode_output->mode_output)
>  		return XF86OutputStatusDisconnected;
> 
> @@ -1431,7 +1433,7 @@ drmmode_output_get_modes(xf86OutputPtr
> output)
>  {
>  	drmmode_output_private_ptr drmmode_output = output-
> >driver_private;
>  	drmModeConnectorPtr koutput = drmmode_output-
> >mode_output;
> -	drmmode_ptr drmmode = drmmode_output->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
>  	int i;
>  	DisplayModePtr Modes = NULL, Mode;
>  	drmModePropertyPtr props;
> @@ -1442,12 +1444,12 @@ drmmode_output_get_modes(xf86OutputPtr
> output)
> 
>  	/* look for an EDID property */
>  	for (i = 0; i < koutput->count_props; i++) {
> -		props = drmModeGetProperty(drmmode->fd, koutput-
> >props[i]);
> +		props = drmModeGetProperty(pRADEONEnt->fd, koutput-
> >props[i]);
>  		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
>  			if (!strcmp(props->name, "EDID")) {
>  				if (drmmode_output->edid_blob)
> 
> 	drmModeFreePropertyBlob(drmmode_output->edid_blob);
> -				drmmode_output->edid_blob =
> drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
> +				drmmode_output->edid_blob =
> drmModeGetPropertyBlob(pRADEONEnt->fd, koutput->prop_values[i]);
>  			}
>  		}
>  		if (props)
> @@ -1501,7 +1503,7 @@ drmmode_output_dpms(xf86OutputPtr output, int
> mode)
>  	drmmode_output_private_ptr drmmode_output = output-
> >driver_private;
>  	xf86CrtcPtr crtc = output->crtc;
>  	drmModeConnectorPtr koutput = drmmode_output-
> >mode_output;
> -	drmmode_ptr drmmode = drmmode_output->drmmode;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
> 
>  	if (!koutput)
>  		return;
> @@ -1516,7 +1518,7 @@ drmmode_output_dpms(xf86OutputPtr output, int
> mode)
>  			return;
>  	}
> 
> -	drmModeConnectorSetProperty(drmmode->fd, koutput-
> >connector_id,
> +	drmModeConnectorSetProperty(pRADEONEnt->fd, koutput-
> >connector_id,
>  				    drmmode_output->dpms_enum_id,
> mode);
> 
>  	if (mode == DPMSModeOn && crtc) {
> @@ -1553,7 +1555,7 @@
> drmmode_output_create_resources(xf86OutputPtr output)
>      RADEONInfoPtr info = RADEONPTR(output->scrn);
>      drmmode_output_private_ptr drmmode_output = output-
> >driver_private;
>      drmModeConnectorPtr mode_output = drmmode_output-
> >mode_output;
> -    drmmode_ptr drmmode = drmmode_output->drmmode;
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
>      drmModePropertyPtr drmmode_prop, tearfree_prop;
>      int i, j, err;
> 
> @@ -1563,7 +1565,7 @@
> drmmode_output_create_resources(xf86OutputPtr output)
> 
>      drmmode_output->num_props = 0;
>      for (i = 0, j = 0; i < mode_output->count_props; i++) {
> -	drmmode_prop = drmModeGetProperty(drmmode->fd,
> mode_output->props[i]);
> +	drmmode_prop = drmModeGetProperty(pRADEONEnt->fd,
> mode_output->props[i]);
>  	if (drmmode_property_ignore(drmmode_prop)) {
>  	    drmModeFreeProperty(drmmode_prop);
>  	    continue;
> @@ -1657,7 +1659,7 @@ drmmode_output_set_property(xf86OutputPtr
> output, Atom property,
>  		RRPropertyValuePtr value)
>  {
>      drmmode_output_private_ptr drmmode_output = output-
> >driver_private;
> -    drmmode_ptr drmmode = drmmode_output->drmmode;
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(output->scrn);
>      int i;
> 
>      for (i = 0; i < drmmode_output->num_props; i++) {
> @@ -1674,7 +1676,7 @@ drmmode_output_set_property(xf86OutputPtr
> output, Atom property,
>  		return FALSE;
>  	    val = *(uint32_t *)value->data;
> 
> -	    drmModeConnectorSetProperty(drmmode->fd,
> drmmode_output->output_id,
> +	    drmModeConnectorSetProperty(pRADEONEnt->fd,
> drmmode_output->output_id,
>  		    p->mode_prop->prop_id, (uint64_t)val);
>  	    return TRUE;
>  	} else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
> @@ -1703,7 +1705,7 @@ drmmode_output_set_property(xf86OutputPtr
> output, Atom property,
>  			    }
>  			}
>  		    } else {
> -			drmModeConnectorSetProperty(drmmode->fd,
> +			drmModeConnectorSetProperty(pRADEONEnt->fd,
>  						    drmmode_output-
> >output_id,
>  						    p->mode_prop->prop_id,
>  						    p->mode_prop-
> >enums[j].value);
> @@ -1876,6 +1878,7 @@ static unsigned int
>  drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
> drmModeResPtr mode_res, int num, int *num_dvi, int *num_hdmi, int
> dynamic)
>  {
>  	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>  	RADEONInfoPtr info = RADEONPTR(pScrn);
>  	xf86OutputPtr output;
>  	drmModeConnectorPtr koutput;
> @@ -1887,15 +1890,15 @@ drmmode_output_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, drmModeResPtr mode_r
>  	int i;
>  	const char *s;
> 
> -	koutput = drmModeGetConnector(drmmode->fd, mode_res-
> >connectors[num]);
> +	koutput = drmModeGetConnector(pRADEONEnt->fd, mode_res-
> >connectors[num]);
>  	if (!koutput)
>  		return 0;
> 
>  	for (i = 0; i < koutput->count_props; i++) {
> -		props = drmModeGetProperty(drmmode->fd, koutput-
> >props[i]);
> +		props = drmModeGetProperty(pRADEONEnt->fd, koutput-
> >props[i]);
>  		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
>  			if (!strcmp(props->name, "PATH")) {
> -				path_blob =
> drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
> +				path_blob =
> drmModeGetPropertyBlob(pRADEONEnt->fd, koutput->prop_values[i]);
>  				drmModeFreeProperty(props);
>  				break;
>  			}
> @@ -1909,7 +1912,7 @@ drmmode_output_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, drmModeResPtr mode_r
>  	}
> 
>  	for (i = 0; i < koutput->count_encoders; i++) {
> -		kencoders[i] = drmModeGetEncoder(drmmode->fd,
> koutput->encoders[i]);
> +		kencoders[i] = drmModeGetEncoder(pRADEONEnt->fd,
> koutput->encoders[i]);
>  		if (!kencoders[i]) {
>  			goto out_free_encoders;
>  		}
> @@ -1982,7 +1985,7 @@ drmmode_output_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, drmModeResPtr mode_r
>  	output->possible_clones = 0;
> 
>  	for (i = 0; i < koutput->count_props; i++) {
> -		props = drmModeGetProperty(drmmode->fd, koutput-
> >props[i]);
> +		props = drmModeGetProperty(pRADEONEnt->fd, koutput-
> >props[i]);
>  		if (props && (props->flags & DRM_MODE_PROP_ENUM)) {
>  			if (!strcmp(props->name, "DPMS")) {
>  				drmmode_output->dpms_enum_id =
> koutput->props[i];
> @@ -2418,6 +2421,7 @@ static void
>  drmmode_flip_handler(xf86CrtcPtr crtc, uint32_t frame, uint64_t usec, void
> *event_data)
>  {
>  	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
>  	drmmode_flipdata_ptr flipdata = event_data;
> 
>  	/* Is this the event whose info shall be delivered to higher level? */
> @@ -2440,7 +2444,7 @@ drmmode_flip_handler(xf86CrtcPtr crtc, uint32_t
> frame, uint64_t usec, void *even
>  		free(flipdata);
>  	}
> 
> -	drmmode_fb_reference(drmmode_crtc->drmmode->fd,
> &drmmode_crtc->fb,
> +	drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->fb,
>  			     drmmode_crtc->flip_pending);
>  	drmmode_clear_pending_flip(crtc);
>  }
> @@ -2454,23 +2458,26 @@ static void
>  drm_wakeup_handler(pointer data, int err, pointer p)
>  #endif
>  {
> -	drmmode_ptr drmmode = data;
> +	ScrnInfoPtr scrn = data;
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
> +	RADEONInfoPtr info = RADEONPTR(scrn);
> +
>  #if !HAVE_NOTIFY_FD
>  	fd_set *read_mask = p;
> 
> -	if (err >= 0 && FD_ISSET(drmmode->fd, read_mask))
> +	if (err >= 0 && FD_ISSET(pRADEONEnt->fd, read_mask))
>  #endif
>  	{
> -		drmHandleEvent(drmmode->fd, &drmmode-
> >event_context);
> +		drmHandleEvent(pRADEONEnt->fd, &info-
> >drmmode.event_context);
>  	}
>  }
> 
> -static Bool drmmode_probe_page_flip_target(drmmode_ptr drmmode)
> +static Bool drmmode_probe_page_flip_target(RADEONEntPtr
> pRADEONEnt)
>  {
>  #ifdef DRM_CAP_PAGE_FLIP_TARGET
>  	uint64_t cap_value;
> 
> -	return drmGetCap(drmmode->fd, DRM_CAP_PAGE_FLIP_TARGET,
> +	return drmGetCap(pRADEONEnt->fd,
> DRM_CAP_PAGE_FLIP_TARGET,
>  			 &cap_value) == 0 && cap_value != 0;
>  #else
>  	return FALSE;
> @@ -2478,13 +2485,12 @@ static Bool
> drmmode_probe_page_flip_target(drmmode_ptr drmmode)
>  }
> 
>  static int
> -drmmode_page_flip(drmmode_crtc_private_ptr drmmode_crtc, int fb_id,
> +drmmode_page_flip(RADEONEntPtr pRADEONEnt,
> +		  drmmode_crtc_private_ptr drmmode_crtc, int fb_id,
>  		  uint32_t flags, uintptr_t drm_queue_seq)
>  {
> -	drmmode_ptr drmmode = drmmode_crtc->drmmode;
> -
>  	flags |= DRM_MODE_PAGE_FLIP_EVENT;
> -	return drmModePageFlip(drmmode->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
> +	return drmModePageFlip(pRADEONEnt->fd, drmmode_crtc-
> >mode_crtc->crtc_id,
>  			       fb_id, flags, (void*)drm_queue_seq);
>  }
> 
> @@ -2496,17 +2502,16 @@
> drmmode_page_flip_target_absolute(RADEONEntPtr pRADEONEnt,
>  {
>  #ifdef DRM_MODE_PAGE_FLIP_TARGET
>  	if (pRADEONEnt->has_page_flip_target) {
> -		drmmode_ptr drmmode = drmmode_crtc->drmmode;
> -
>  		flags |= DRM_MODE_PAGE_FLIP_EVENT |
> DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE;
> -		return drmModePageFlipTarget(drmmode->fd,
> +		return drmModePageFlipTarget(pRADEONEnt->fd,
>  					     drmmode_crtc->mode_crtc-
> >crtc_id,
>  					     fb_id, flags,
> (void*)drm_queue_seq,
>  					     target_msc);
>  	}
>  #endif
> 
> -	return drmmode_page_flip(drmmode_crtc, fb_id, flags,
> drm_queue_seq);
> +	return drmmode_page_flip(pRADEONEnt, drmmode_crtc, fb_id,
> flags,
> +				 drm_queue_seq);
>  }
> 
>  int
> @@ -2517,17 +2522,16 @@
> drmmode_page_flip_target_relative(RADEONEntPtr pRADEONEnt,
>  {
>  #ifdef DRM_MODE_PAGE_FLIP_TARGET
>  	if (pRADEONEnt->has_page_flip_target) {
> -		drmmode_ptr drmmode = drmmode_crtc->drmmode;
> -
>  		flags |= DRM_MODE_PAGE_FLIP_EVENT |
> DRM_MODE_PAGE_FLIP_TARGET_RELATIVE;
> -		return drmModePageFlipTarget(drmmode->fd,
> +		return drmModePageFlipTarget(pRADEONEnt->fd,
>  					     drmmode_crtc->mode_crtc-
> >crtc_id,
>  					     fb_id, flags,
> (void*)drm_queue_seq,
>  					     target_msc);
>  	}
>  #endif
> 
> -	return drmmode_page_flip(drmmode_crtc, fb_id, flags,
> drm_queue_seq);
> +	return drmmode_page_flip(pRADEONEnt, drmmode_crtc, fb_id,
> flags,
> +				 drm_queue_seq);
>  }
> 
>  Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int
> cpp)
> @@ -2544,7 +2548,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, int cpp)
>  	xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
> 
>  	drmmode->scrn = pScrn;
> -	mode_res = drmModeGetResources(drmmode->fd);
> +	mode_res = drmModeGetResources(pRADEONEnt->fd);
>  	if (!mode_res)
>  		return FALSE;
> 
> @@ -2594,7 +2598,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode, int cpp)
>  	drmmode->event_context.vblank_handler =
> radeon_drm_queue_handler;
>  	drmmode->event_context.page_flip_handler =
> radeon_drm_queue_handler;
> 
> -	pRADEONEnt->has_page_flip_target =
> drmmode_probe_page_flip_target(drmmode);
> +	pRADEONEnt->has_page_flip_target =
> drmmode_probe_page_flip_target(pRADEONEnt);
> 
>  	drmModeFreeResources(mode_res);
>  	return TRUE;
> @@ -2611,11 +2615,11 @@ void drmmode_init(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode)
>  	info->drmmode_inited = TRUE;
>  	if (pRADEONEnt->fd_wakeup_registered != serverGeneration) {
>  #if HAVE_NOTIFY_FD
> -		SetNotifyFd(drmmode->fd, drm_notify_fd,
> X_NOTIFY_READ, drmmode);
> +		SetNotifyFd(pRADEONEnt->fd, drm_notify_fd,
> X_NOTIFY_READ, pScrn);
>  #else
> -		AddGeneralSocket(drmmode->fd);
> +		AddGeneralSocket(pRADEONEnt->fd);
> 
> 	RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
> -				drm_wakeup_handler, drmmode);
> +				drm_wakeup_handler, pScrn);
>  #endif
>  		pRADEONEnt->fd_wakeup_registered = serverGeneration;
>  		pRADEONEnt->fd_wakeup_ref = 1;
> @@ -2636,11 +2640,11 @@ void drmmode_fini(ScrnInfoPtr pScrn,
> drmmode_ptr drmmode)
>  	if (pRADEONEnt->fd_wakeup_registered == serverGeneration &&
>  	    !--pRADEONEnt->fd_wakeup_ref) {
>  #if HAVE_NOTIFY_FD
> -		RemoveNotifyFd(drmmode->fd);
> +		RemoveNotifyFd(pRADEONEnt->fd);
>  #else
> -		RemoveGeneralSocket(drmmode->fd);
> +		RemoveGeneralSocket(pRADEONEnt->fd);
> 
> 	RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
> -				drm_wakeup_handler, drmmode);
> +				drm_wakeup_handler, pScrn);
>  #endif
>  	}
> 
> @@ -2682,6 +2686,7 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr
> pScrn, drmmode_ptr drmmode,
>  			       Bool set_hw)
>  {
>  	xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>  	int c;
> 
>  	for (c = 0; c < config->num_crtc; c++) {
> @@ -2694,10 +2699,10 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr
> pScrn, drmmode_ptr drmmode,
>  		if (!crtc->enabled) {
>  			if (set_hw) {
>  				drmmode_do_crtc_dpms(crtc,
> DPMSModeOff);
> -				drmModeSetCrtc(drmmode->fd,
> +				drmModeSetCrtc(pRADEONEnt->fd,
>  					       drmmode_crtc->mode_crtc-
> >crtc_id,
>  					       0, 0, 0, NULL, 0, NULL);
> -				drmmode_fb_reference(drmmode->fd,
> +				drmmode_fb_reference(pRADEONEnt->fd,
>  						     &drmmode_crtc->fb,
> NULL);
>  			}
>  			continue;
> @@ -2812,7 +2817,7 @@ radeon_mode_hotplug(ScrnInfoPtr scrn,
> drmmode_ptr drmmode)
>  	Bool changed = FALSE;
>  	int num_dvi = 0, num_hdmi = 0;
> 
> -	mode_res = drmModeGetResources(drmmode->fd);
> +	mode_res = drmModeGetResources(pRADEONEnt->fd);
>  	if (!mode_res)
>  		goto out;
> 
> diff --git a/src/drmmode_display.h b/src/drmmode_display.h
> index dde27a009..ba1a7bc89 100644
> --- a/src/drmmode_display.h
> +++ b/src/drmmode_display.h
> @@ -40,7 +40,6 @@
>  #endif
> 
>  typedef struct {
> -  int fd;
>    struct radeon_bo_manager *bufmgr;
>    ScrnInfoPtr scrn;
>  #ifdef HAVE_LIBUDEV
> diff --git a/src/radeon.h b/src/radeon.h
> index febe580b6..ca509561a 100644
> --- a/src/radeon.h
> +++ b/src/radeon.h
> @@ -694,7 +694,9 @@ uint32_t radeon_get_pixmap_tiling(PixmapPtr pPix);
>  static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo
> *bo)
>  {
>  #ifdef USE_GLAMOR
> -    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pPix-
> >drawable.pScreen));
> +    ScrnInfoPtr scrn = xf86ScreenToScrn(pPix->drawable.pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
> +    RADEONInfoPtr info = RADEONPTR(scrn);
> 
>      if (info->use_glamor) {
>  	struct radeon_pixmap *priv;
> @@ -711,7 +713,7 @@ static inline Bool radeon_set_pixmap_bo(PixmapPtr
> pPix, struct radeon_bo *bo)
>  		radeon_bo_unref(priv->bo);
>  	    }
> 
> -	    drmmode_fb_reference(info->drmmode.fd, &priv->fb, NULL);
> +	    drmmode_fb_reference(pRADEONEnt->fd, &priv->fb, NULL);
> 
>  	    if (!bo) {
>  		free(priv);
> @@ -831,7 +833,9 @@ radeon_pixmap_create_fb(int drm_fd, PixmapPtr
> pix)
>  static inline struct drmmode_fb*
>  radeon_pixmap_get_fb(PixmapPtr pix)
>  {
> -    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pix-
> >drawable.pScreen));
> +    ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
> +    RADEONInfoPtr info = RADEONPTR(scrn);
> 
>  #ifdef USE_GLAMOR
>      if (info->use_glamor) {
> @@ -841,7 +845,7 @@ radeon_pixmap_get_fb(PixmapPtr pix)
>  	    return NULL;
> 
>  	if (!priv->fb)
> -	    priv->fb = radeon_pixmap_create_fb(info->drmmode.fd, pix);
> +	    priv->fb = radeon_pixmap_create_fb(pRADEONEnt->fd, pix);
> 
>  	return priv->fb;
>      } else
> @@ -855,7 +859,7 @@ radeon_pixmap_get_fb(PixmapPtr pix)
>  	    return NULL;
> 
>  	if (!driver_priv->fb)
> -	    driver_priv->fb = radeon_pixmap_create_fb(info->drmmode.fd,
> pix);
> +	    driver_priv->fb = radeon_pixmap_create_fb(pRADEONEnt->fd,
> pix);
> 
>  	return driver_priv->fb;
>      }
> diff --git a/src/radeon_accel.c b/src/radeon_accel.c
> index 1def2a3fb..fc80ed745 100644
> --- a/src/radeon_accel.c
> +++ b/src/radeon_accel.c
> @@ -94,11 +94,11 @@
> 
>  static int RADEONDRMGetNumPipes(ScrnInfoPtr pScrn, int *num_pipes)
>  {
> -    RADEONInfoPtr info = RADEONPTR(pScrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      struct drm_radeon_info np2;
>      np2.value = (unsigned long)num_pipes;
>      np2.request = RADEON_INFO_NUM_GB_PIPES;
> -    return drmCommandWriteRead(info->dri2.drm_fd, DRM_RADEON_INFO,
> &np2, sizeof(np2));
> +    return drmCommandWriteRead(pRADEONEnt->fd, DRM_RADEON_INFO,
> &np2, sizeof(np2));
>  }
> 
>  /* Initialize the acceleration hardware */
> diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c
> index 933dc7b37..a8ba76185 100644
> --- a/src/radeon_bo_helper.c
> +++ b/src/radeon_bo_helper.c
> @@ -201,7 +201,9 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap,
> uint32_t *handle)
>      struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap);
>  #ifdef USE_GLAMOR
>      ScreenPtr screen = pixmap->drawable.pScreen;
> -    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen));
> +    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
> +    RADEONInfoPtr info = RADEONPTR(scrn);
>  #endif
> 
>      if (bo) {
> @@ -230,7 +232,7 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap,
> uint32_t *handle)
>  	if (fd < 0)
>  	    return FALSE;
> 
> -	r = drmPrimeFDToHandle(info->dri2.drm_fd, fd, &priv->handle);
> +	r = drmPrimeFDToHandle(pRADEONEnt->fd, fd, &priv->handle);
>  	close(fd);
>  	if (r == 0) {
>  	    struct drm_radeon_gem_set_tiling args = { .handle = priv->handle
> };
> @@ -238,7 +240,7 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap,
> uint32_t *handle)
>  	    priv->handle_valid = TRUE;
>  	    *handle = priv->handle;
> 
> -	    if (drmCommandWriteRead(info->dri2.drm_fd,
> +	    if (drmCommandWriteRead(pRADEONEnt->fd,
>  				    DRM_RADEON_GEM_GET_TILING, &args,
>  				    sizeof(args)) == 0)
>  		priv->tiling_flags = args.tiling_flags;
> diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
> index cc72bd52d..435bf5397 100644
> --- a/src/radeon_dri2.c
> +++ b/src/radeon_dri2.c
> @@ -81,7 +81,7 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
> 
>  /* Get GEM flink name for a pixmap */
>  static Bool
> -radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t
> *name)
> +radeon_get_flink_name(RADEONEntPtr pRADEONEnt, PixmapPtr pixmap,
> uint32_t *name)
>  {
>      struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap);
>      struct drm_gem_flink flink;
> @@ -90,7 +90,7 @@ radeon_get_flink_name(RADEONInfoPtr info,
> PixmapPtr pixmap, uint32_t *name)
>  	return radeon_gem_get_kernel_name(bo, name) == 0;
> 
>      if (radeon_get_pixmap_handle(pixmap, &flink.handle)) {
> -	if (drmIoctl(info->dri2.drm_fd, DRM_IOCTL_GEM_FLINK, &flink) != 0)
> +	if (drmIoctl(pRADEONEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) != 0)
>  	    return FALSE;
> 
>  	*name = flink.name;
> @@ -107,6 +107,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
>  			   unsigned int format)
>  {
>      ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr info = RADEONPTR(pScrn);
>      BufferPtr buffers;
>      struct dri2_buffer_priv *privates;
> @@ -253,7 +254,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen,
>  	    pixmap->refcnt++;
>  	}
> 
> -	if (!radeon_get_flink_name(info, pixmap, &buffers->name))
> +	if (!radeon_get_flink_name(pRADEONEnt, pixmap, &buffers-
> >name))
>  	    goto error;
>      }
> 
> @@ -523,13 +524,13 @@ static Bool radeon_dri2_get_crtc_msc(xf86CrtcPtr
> crtc, CARD64 *ust, CARD64 *msc)
>  	 drmmode_crtc_get_ust_msc(crtc, ust, msc) != Success) {
>  	/* CRTC is not running, extrapolate MSC and timestamp */
>  	ScrnInfoPtr scrn = crtc->scrn;
> -	RADEONInfoPtr info = RADEONPTR(scrn);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>  	CARD64 now, delta_t, delta_seq;
> 
>  	if (!drmmode_crtc->dpms_last_ust)
>  	    return FALSE;
> 
> -	if (drmmode_get_current_ust(info->dri2.drm_fd, &now) != 0) {
> +	if (drmmode_get_current_ust(pRADEONEnt->fd, &now) != 0) {
>  	    xf86DrvMsg(scrn->scrnIndex, X_ERROR,
>  		       "%s cannot get current time\n", __func__);
>  	    return FALSE;
> @@ -689,7 +690,9 @@ static Bool
>  update_front(DrawablePtr draw, DRI2BufferPtr front)
>  {
>      PixmapPtr pixmap;
> -    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(draw->pScreen));
> +    ScrnInfoPtr scrn = xf86ScreenToScrn(draw->pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
> +    RADEONInfoPtr info = RADEONPTR(scrn);
>      struct dri2_buffer_priv *priv = front->driverPrivate;
> 
>      pixmap = get_drawable_pixmap(draw);
> @@ -697,7 +700,7 @@ update_front(DrawablePtr draw, DRI2BufferPtr front)
> 
>      if (!info->use_glamor)
>  	exaMoveInPixmap(pixmap);
> -    if (!radeon_get_flink_name(info, pixmap, &front->name)) {
> +    if (!radeon_get_flink_name(pRADEONEnt, pixmap, &front->name)) {
>  	(*draw->pScreen->DestroyPixmap)(pixmap);
>  	return FALSE;
>      }
> @@ -937,7 +940,7 @@ CARD32
> radeon_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 *target_msc,
>  {
>      drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
>      ScrnInfoPtr pScrn = crtc->scrn;
> -    RADEONInfoPtr info = RADEONPTR(pScrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      int nominal_frame_rate = drmmode_crtc->dpms_last_fps;
>      CARD64 last_vblank_ust = drmmode_crtc->dpms_last_ust;
>      uint32_t last_vblank_seq = drmmode_crtc->dpms_last_seq;
> @@ -950,7 +953,7 @@ CARD32
> radeon_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 *target_msc,
>  	*target_msc = 0;
>  	return FALLBACK_SWAP_DELAY;
>      }
> -    ret = drmmode_get_current_ust(info->dri2.drm_fd, &now);
> +    ret = drmmode_get_current_ust(pRADEONEnt->fd, &now);
>      if (ret) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  		   "%s cannot get current time\n", __func__);
> @@ -1028,7 +1031,7 @@ CARD32 radeon_dri2_deferred_event(OsTimerPtr
> timer, CARD32 now, pointer data)
>      DRI2FrameEventPtr event_info = (DRI2FrameEventPtr)data;
>      xf86CrtcPtr crtc = event_info->crtc;
>      ScrnInfoPtr scrn;
> -    RADEONInfoPtr info;
> +    RADEONEntPtr pRADEONEnt;
>      CARD64 drm_now;
>      int ret;
>      CARD64 delta_t, delta_seq, frame;
> @@ -1051,13 +1054,13 @@ CARD32
> radeon_dri2_deferred_event(OsTimerPtr timer, CARD32 now, pointer data)
>      }
> 
>      scrn = crtc->scrn;
> -    info = RADEONPTR(scrn);
> -    ret = drmmode_get_current_ust(info->dri2.drm_fd, &drm_now);
> +    pRADEONEnt = RADEONEntPriv(scrn);
> +    ret = drmmode_get_current_ust(pRADEONEnt->fd, &drm_now);
>      if (ret) {
>  	xf86DrvMsg(scrn->scrnIndex, X_ERROR,
>  		   "%s cannot get current time\n", __func__);
>  	if (event_info->drm_queue_seq)
> -	    radeon_drm_queue_handler(info->dri2.drm_fd, 0, 0, 0,
> +	    radeon_drm_queue_handler(pRADEONEnt->fd, 0, 0, 0,
>  				     (void*)event_info->drm_queue_seq);
>  	else
>  	    radeon_dri2_frame_event_handler(crtc, 0, 0, data);
> @@ -1073,7 +1076,7 @@ CARD32 radeon_dri2_deferred_event(OsTimerPtr
> timer, CARD32 now, pointer data)
>      delta_seq /= 1000000;
>      frame = (CARD64)drmmode_crtc->dpms_last_seq + delta_seq;
>      if (event_info->drm_queue_seq)
> -	radeon_drm_queue_handler(info->dri2.drm_fd, frame, drm_now /
> 1000000,
> +	radeon_drm_queue_handler(pRADEONEnt->fd, frame, drm_now /
> 1000000,
>  				 drm_now % 1000000,
>  				 (void*)event_info->drm_queue_seq);
>      else
> @@ -1104,7 +1107,7 @@ static int
> radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
>  {
>      ScreenPtr screen = draw->pScreen;
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> -    RADEONInfoPtr info = RADEONPTR(scrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      DRI2FrameEventPtr wait_info = NULL;
>      uintptr_t drm_queue_seq = 0;
>      xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
> @@ -1152,7 +1155,7 @@ static int
> radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
>      vbl.request.type = DRM_VBLANK_RELATIVE;
>      vbl.request.type |= radeon_populate_vbl_request_type(crtc);
>      vbl.request.sequence = 0;
> -    ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +    ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>      if (ret) {
>          xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                  "get vblank counter failed: %s\n", strerror(errno));
> @@ -1190,7 +1193,7 @@ static int
> radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
>  	vbl.request.type |= radeon_populate_vbl_request_type(crtc);
>          vbl.request.sequence = target_msc - msc_delta;
>          vbl.request.signal = drm_queue_seq;
> -        ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +        ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>          if (ret) {
>              xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                      "get vblank counter failed: %s\n", strerror(errno));
> @@ -1221,7 +1224,7 @@ static int
> radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
>          vbl.request.sequence += divisor;
> 
>      vbl.request.signal = drm_queue_seq;
> -    ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +    ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>      if (ret) {
>          xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                  "get vblank counter failed: %s\n", strerror(errno));
> @@ -1266,7 +1269,7 @@ static int radeon_dri2_schedule_swap(ClientPtr
> client, DrawablePtr draw,
>  {
>      ScreenPtr screen = draw->pScreen;
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> -    RADEONInfoPtr info = RADEONPTR(scrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
>      uint32_t msc_delta;
>      drmVBlank vbl;
> @@ -1339,7 +1342,7 @@ static int radeon_dri2_schedule_swap(ClientPtr
> client, DrawablePtr draw,
>      vbl.request.type = DRM_VBLANK_RELATIVE;
>      vbl.request.type |= radeon_populate_vbl_request_type(crtc);
>      vbl.request.sequence = 0;
> -    ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +    ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>      if (ret) {
>          xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                  "first get vblank counter failed: %s\n",
> @@ -1387,7 +1390,7 @@ static int radeon_dri2_schedule_swap(ClientPtr
> client, DrawablePtr draw,
> 
>          vbl.request.sequence = *target_msc - msc_delta;
>          vbl.request.signal = drm_queue_seq;
> -        ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +        ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>          if (ret) {
>              xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                      "divisor 0 get vblank counter failed: %s\n",
> @@ -1432,7 +1435,7 @@ static int radeon_dri2_schedule_swap(ClientPtr
> client, DrawablePtr draw,
>      vbl.request.sequence -= flip;
> 
>      vbl.request.signal = drm_queue_seq;
> -    ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +    ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>      if (ret) {
>          xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>                  "final get vblank counter failed: %s\n",
> @@ -1475,6 +1478,7 @@ Bool
>  radeon_dri2_screen_init(ScreenPtr pScreen)
>  {
>      ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr info = RADEONPTR(pScrn);
>      DRI2InfoRec dri2_info = { 0 };
>      const char *driverNames[2];
> @@ -1483,7 +1487,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
>      if (!info->dri2.available)
>          return FALSE;
> 
> -    info->dri2.device_name = drmGetDeviceNameFromFd(info-
> >dri2.drm_fd);
> +    info->dri2.device_name = drmGetDeviceNameFromFd(pRADEONEnt-
> >fd);
> 
>      if ( (info->ChipFamily >= CHIP_FAMILY_TAHITI) ) {
>          dri2_info.driverName = SI_DRIVER_NAME;
> @@ -1496,7 +1500,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
>      } else {
>          dri2_info.driverName = RADEON_DRIVER_NAME;
>      }
> -    dri2_info.fd = info->dri2.drm_fd;
> +    dri2_info.fd = pRADEONEnt->fd;
>      dri2_info.deviceName = info->dri2.device_name;
>      dri2_info.version = DRI2INFOREC_VERSION;
>      dri2_info.CreateBuffer = radeon_dri2_create_buffer;
> @@ -1513,7 +1517,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
>  #ifdef DRM_CAP_VBLANK_HIGH_CRTC
>  	uint64_t cap_value;
> 
> -	if (drmGetCap(info->dri2.drm_fd, DRM_CAP_VBLANK_HIGH_CRTC,
> &cap_value)) {
> +	if (drmGetCap(pRADEONEnt->fd, DRM_CAP_VBLANK_HIGH_CRTC,
> &cap_value)) {
>  	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "You need a newer
> kernel "
>  		       "for VBLANKs on CRTC > 1\n");
>  	    scheduling_works = FALSE;
> diff --git a/src/radeon_dri2.h b/src/radeon_dri2.h
> index 9ba47c78f..4d3f377b4 100644
> --- a/src/radeon_dri2.h
> +++ b/src/radeon_dri2.h
> @@ -31,7 +31,6 @@
> 
>  struct radeon_dri2 {
>      drmVersionPtr     pKernelDRMVersion;
> -    int         drm_fd;
>      Bool        available;
>      Bool        enabled;
>      char	*device_name;
> diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
> index fa24abaee..3e689ffd7 100644
> --- a/src/radeon_dri3.c
> +++ b/src/radeon_dri3.c
> @@ -43,6 +43,7 @@
>  static int open_master_node(ScreenPtr screen, int *out)
>  {
>  	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>  	RADEONInfoPtr info = RADEONPTR(scrn);
>  	drm_magic_t magic;
>  	int fd;
> @@ -76,7 +77,7 @@ static int open_master_node(ScreenPtr screen, int
> *out)
>  		}
>  	}
> 
> -	if (drmAuthMagic(info->dri2.drm_fd, magic) < 0) {
> +	if (drmAuthMagic(pRADEONEnt->fd, magic) < 0) {
>  		close(fd);
>  		return BadMatch;
>  	}
> diff --git a/src/radeon_exa.c b/src/radeon_exa.c
> index d8dd7fdce..d362e5d9b 100644
> --- a/src/radeon_exa.c
> +++ b/src/radeon_exa.c
> @@ -300,7 +300,7 @@ void *RADEONEXACreatePixmap2(ScreenPtr pScreen,
> int width, int height,
> 
>  void RADEONEXADestroyPixmap(ScreenPtr pScreen, void *driverPriv)
>  {
> -    RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pScreen));
> +    RADEONEntPtr pRADEONEnt =
> RADEONEntPriv(xf86ScreenToScrn(pScreen));
>      struct radeon_exa_pixmap_priv *driver_priv = driverPriv;
> 
>      if (!driverPriv)
> @@ -308,7 +308,7 @@ void RADEONEXADestroyPixmap(ScreenPtr pScreen,
> void *driverPriv)
> 
>      if (driver_priv->bo)
>  	radeon_bo_unref(driver_priv->bo);
> -    drmmode_fb_reference(info->drmmode.fd, &driver_priv->fb, NULL);
> +    drmmode_fb_reference(pRADEONEnt->fd, &driver_priv->fb, NULL);
>      free(driverPriv);
>  }
> 
> diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
> index e5e35553a..01ff56094 100644
> --- a/src/radeon_glamor.c
> +++ b/src/radeon_glamor.c
> @@ -74,6 +74,7 @@ radeon_glamor_create_screen_resources(ScreenPtr
> screen)
>  Bool
>  radeon_glamor_pre_init(ScrnInfoPtr scrn)
>  {
> +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>  	RADEONInfoPtr info = RADEONPTR(scrn);
>  	pointer glamor_module;
>  	CARD32 version;
> @@ -135,7 +136,7 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn)
>  			"Incompatible glamor version, required >= 0.3.0.\n");
>  			return FALSE;
>  		} else {
> -			if (glamor_egl_init(scrn, info->dri2.drm_fd)) {
> +			if (glamor_egl_init(scrn, pRADEONEnt->fd)) {
>  				xf86DrvMsg(scrn->scrnIndex, X_INFO,
>  					   "glamor detected, initialising EGL
> layer.\n");
>  			} else {
> diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> index 691fcdf5b..3f14b4620 100644
> --- a/src/radeon_kms.c
> +++ b/src/radeon_kms.c
> @@ -187,6 +187,7 @@ static Bool RADEONGetRec(ScrnInfoPtr pScrn)
>  /* Free our private RADEONInfoRec */
>  static void RADEONFreeRec(ScrnInfoPtr pScrn)
>  {
> +    RADEONEntPtr pRADEONEnt;
>      RADEONInfoPtr  info;
> 
>      if (!pScrn || !pScrn->driverPrivate) return;
> @@ -196,7 +197,9 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn)
>      if (info->fbcon_pixmap)
>  	pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
> 
> -    if (info->dri2.drm_fd > 0) {
> +    pRADEONEnt = RADEONEntPriv(pScrn);
> +
> +    if (pRADEONEnt->fd > 0) {
>          DevUnion *pPriv;
>          RADEONEntPtr pRADEONEnt;
>          pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
> @@ -719,6 +722,7 @@
> radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
>  {
>      ScreenPtr screen = dirty->slave_dst->drawable.pScreen;
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      xf86CrtcPtr xf86_crtc = radeon_prime_dirty_to_crtc(dirty);
>      drmmode_crtc_private_ptr drmmode_crtc;
>      uintptr_t drm_queue_seq;
> @@ -748,7 +752,7 @@
> radeon_prime_scanout_update(PixmapDirtyUpdatePtr dirty)
>      vbl.request.type |= radeon_populate_vbl_request_type(xf86_crtc);
>      vbl.request.sequence = 1;
>      vbl.request.signal = drm_queue_seq;
> -    if (drmWaitVBlank(RADEONPTR(scrn)->dri2.drm_fd, &vbl)) {
> +    if (drmWaitVBlank(pRADEONEnt->fd, &vbl)) {
>  	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>  		   "drmWaitVBlank failed for PRIME update: %s\n",
>  		   strerror(errno));
> @@ -772,9 +776,10 @@ static void
>  radeon_prime_scanout_flip_handler(xf86CrtcPtr crtc, uint32_t msc, uint64_t
> usec,
>  				  void *event_data)
>  {
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(crtc->scrn);
>      drmmode_crtc_private_ptr drmmode_crtc = event_data;
> 
> -    drmmode_fb_reference(drmmode_crtc->drmmode->fd,
> &drmmode_crtc->fb,
> +    drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->fb,
>  			 drmmode_crtc->flip_pending);
>      radeon_prime_scanout_flip_abort(crtc, event_data);
>  }
> @@ -1012,6 +1017,7 @@ static void
>  radeon_scanout_update(xf86CrtcPtr xf86_crtc)
>  {
>      drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc->driver_private;
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(xf86_crtc->scrn);
>      uintptr_t drm_queue_seq;
>      ScrnInfoPtr scrn;
>      drmVBlank vbl;
> @@ -1056,7 +1062,7 @@ radeon_scanout_update(xf86CrtcPtr xf86_crtc)
>      vbl.request.type |= radeon_populate_vbl_request_type(xf86_crtc);
>      vbl.request.sequence = 1;
>      vbl.request.signal = drm_queue_seq;
> -    if (drmWaitVBlank(RADEONPTR(scrn)->dri2.drm_fd, &vbl)) {
> +    if (drmWaitVBlank(pRADEONEnt->fd, &vbl)) {
>  	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
>  		   "drmWaitVBlank failed for scanout update: %s\n",
>  		   strerror(errno));
> @@ -1136,6 +1142,7 @@ static void
> RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
>  {
>      SCREEN_PTR(arg);
>      ScrnInfoPtr    pScrn   = xf86ScreenToScrn(pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr  info    = RADEONPTR(pScrn);
>      xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
>      int c;
> @@ -1151,7 +1158,7 @@ static void
> RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
>  	    drmmode_crtc_private_ptr drmmode_crtc =
>  		xf86_config->crtc[c]->driver_private;
> 
> -	    drmmode_fb_reference(info->drmmode.fd, &drmmode_crtc->fb,
> NULL);
> +	    drmmode_fb_reference(pRADEONEnt->fd, &drmmode_crtc->fb,
> NULL);
>  	}
> 
>  	return;
> @@ -1183,7 +1190,7 @@ static void
> RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL)
> 
>  static Bool RADEONIsFastFBWorking(ScrnInfoPtr pScrn)
>  {
> -    RADEONInfoPtr info = RADEONPTR(pScrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      struct drm_radeon_info ginfo;
>      int r;
>      uint32_t tmp = 0;
> @@ -1191,7 +1198,7 @@ static Bool RADEONIsFastFBWorking(ScrnInfoPtr
> pScrn)
>      memset(&ginfo, 0, sizeof(ginfo));
>      ginfo.request = RADEON_INFO_FASTFB_WORKING;
>      ginfo.value = (uintptr_t)&tmp;
> -    r = drmCommandWriteRead(info->dri2.drm_fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
> +    r = drmCommandWriteRead(pRADEONEnt->fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
>      if (r) {
>  	return FALSE;
>      }
> @@ -1202,7 +1209,7 @@ static Bool RADEONIsFastFBWorking(ScrnInfoPtr
> pScrn)
> 
>  static Bool RADEONIsFusionGARTWorking(ScrnInfoPtr pScrn)
>  {
> -    RADEONInfoPtr info = RADEONPTR(pScrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      struct drm_radeon_info ginfo;
>      int r;
>      uint32_t tmp;
> @@ -1210,7 +1217,7 @@ static Bool
> RADEONIsFusionGARTWorking(ScrnInfoPtr pScrn)
>      memset(&ginfo, 0, sizeof(ginfo));
>      ginfo.request = RADEON_INFO_FUSION_GART_WORKING;
>      ginfo.value = (uintptr_t)&tmp;
> -    r = drmCommandWriteRead(info->dri2.drm_fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
> +    r = drmCommandWriteRead(pRADEONEnt->fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
>      if (r) {
>  	return FALSE;
>      }
> @@ -1221,6 +1228,7 @@ static Bool
> RADEONIsFusionGARTWorking(ScrnInfoPtr pScrn)
> 
>  static Bool RADEONIsAccelWorking(ScrnInfoPtr pScrn)
>  {
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr info = RADEONPTR(pScrn);
>      struct drm_radeon_info ginfo;
>      int r;
> @@ -1232,7 +1240,7 @@ static Bool RADEONIsAccelWorking(ScrnInfoPtr
> pScrn)
>      else
>  	ginfo.request = RADEON_INFO_ACCEL_WORKING;
>      ginfo.value = (uintptr_t)&tmp;
> -    r = drmCommandWriteRead(info->dri2.drm_fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
> +    r = drmCommandWriteRead(pRADEONEnt->fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
>      if (r) {
>          /* If kernel is too old before 2.6.32 than assume accel is working */
>          if (r == -EINVAL) {
> @@ -1470,7 +1478,6 @@ static int radeon_get_drm_master_fd(ScrnInfoPtr
> pScrn)
> 
>  static Bool radeon_open_drm_master(ScrnInfoPtr pScrn)
>  {
> -    RADEONInfoPtr  info   = RADEONPTR(pScrn);
>      RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      drmSetVersion sv;
>      int err;
> @@ -1478,14 +1485,12 @@ static Bool
> radeon_open_drm_master(ScrnInfoPtr pScrn)
>      if (pRADEONEnt->fd) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
>  		   " reusing fd for second head\n");
> -
> -	info->drmmode.fd = info->dri2.drm_fd = pRADEONEnt->fd;
>  	pRADEONEnt->fd_ref++;
>          return TRUE;
>      }
> 
> -    info->dri2.drm_fd = radeon_get_drm_master_fd(pScrn);
> -    if (info->dri2.drm_fd == -1)
> +    pRADEONEnt->fd = radeon_get_drm_master_fd(pScrn);
> +    if (pRADEONEnt->fd == -1)
>  	return FALSE;
> 
>      /* Check that what we opened was a master or a master-capable FD,
> @@ -1496,24 +1501,23 @@ static Bool
> radeon_open_drm_master(ScrnInfoPtr pScrn)
>      sv.drm_di_minor = 1;
>      sv.drm_dd_major = -1;
>      sv.drm_dd_minor = -1;
> -    err = drmSetInterfaceVersion(info->dri2.drm_fd, &sv);
> +    err = drmSetInterfaceVersion(pRADEONEnt->fd, &sv);
>      if (err != 0) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  		   "[drm] failed to set drm interface version.\n");
> -	drmClose(info->dri2.drm_fd);
> -	info->dri2.drm_fd = -1;
> +	drmClose(pRADEONEnt->fd);
> +	pRADEONEnt->fd = -1;
> 
>  	return FALSE;
>      }
> 
> -    pRADEONEnt->fd = info->dri2.drm_fd;
>      pRADEONEnt->fd_ref = 1;
> -    info->drmmode.fd = info->dri2.drm_fd;
>      return TRUE;
>  }
> 
>  static Bool r600_get_tile_config(ScrnInfoPtr pScrn)
>  {
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr  info   = RADEONPTR(pScrn);
>      struct drm_radeon_info ginfo;
>      int r;
> @@ -1525,7 +1529,7 @@ static Bool r600_get_tile_config(ScrnInfoPtr pScrn)
>      memset(&ginfo, 0, sizeof(ginfo));
>      ginfo.request = RADEON_INFO_TILING_CONFIG;
>      ginfo.value = (uintptr_t)&tmp;
> -    r = drmCommandWriteRead(info->dri2.drm_fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
> +    r = drmCommandWriteRead(pRADEONEnt->fd, DRM_RADEON_INFO,
> &ginfo, sizeof(ginfo));
>      if (r)
>  	return FALSE;
> 
> @@ -1622,6 +1626,7 @@ static Bool r600_get_tile_config(ScrnInfoPtr pScrn)
>  static void RADEONSetupCapabilities(ScrnInfoPtr pScrn)
>  {
>  #ifdef RADEON_PIXMAP_SHARING
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr  info = RADEONPTR(pScrn);
>      uint64_t value;
>      int ret;
> @@ -1632,7 +1637,7 @@ static void RADEONSetupCapabilities(ScrnInfoPtr
> pScrn)
>      if (info->r600_shadow_fb)
>  	return;
> 
> -    ret = drmGetCap(info->dri2.drm_fd, DRM_CAP_PRIME, &value);
> +    ret = drmGetCap(pRADEONEnt->fd, DRM_CAP_PRIME, &value);
>      if (ret == 0) {
>  	if (value & DRM_PRIME_CAP_EXPORT)
>  	    pScrn->capabilities |= RR_Capability_SourceOutput |
> RR_Capability_SourceOffload;
> @@ -1770,7 +1775,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int
> flags)
> 
>      info->dri2.available = FALSE;
>      info->dri2.enabled = FALSE;
> -    info->dri2.pKernelDRMVersion = drmGetVersion(info->dri2.drm_fd);
> +    info->dri2.pKernelDRMVersion = drmGetVersion(pRADEONEnt->fd);
>      if (info->dri2.pKernelDRMVersion == NULL) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  		   "RADEONDRIGetVersion failed to get the DRM version\n");
> @@ -1935,7 +1940,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int
> flags)
>      {
>  	struct drm_radeon_gem_info mminfo;
> 
> -	if (!drmCommandWriteRead(info->dri2.drm_fd,
> DRM_RADEON_GEM_INFO, &mminfo, sizeof(mminfo)))
> +	if (!drmCommandWriteRead(pRADEONEnt->fd,
> DRM_RADEON_GEM_INFO, &mminfo, sizeof(mminfo)))
>  	{
>  	    info->vram_size = mminfo.vram_visible;
>  	    info->gart_size = mminfo.gart_size;
> @@ -2075,10 +2080,7 @@ static Bool RADEONSaveScreen_KMS(ScreenPtr
> pScreen, int mode)
> 
>  static Bool radeon_set_drm_master(ScrnInfoPtr pScrn)
>  {
> -    RADEONInfoPtr  info  = RADEONPTR(pScrn);
> -#ifdef XF86_PDEV_SERVER_FD
>      RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
> -#endif
>      int err;
> 
>  #ifdef XF86_PDEV_SERVER_FD
> @@ -2087,7 +2089,7 @@ static Bool radeon_set_drm_master(ScrnInfoPtr
> pScrn)
>          return TRUE;
>  #endif
> 
> -    err = drmSetMaster(info->dri2.drm_fd);
> +    err = drmSetMaster(pRADEONEnt->fd);
>      if (err)
>          ErrorF("Unable to retrieve master\n");
> 
> @@ -2096,16 +2098,15 @@ static Bool radeon_set_drm_master(ScrnInfoPtr
> pScrn)
> 
>  static void radeon_drop_drm_master(ScrnInfoPtr pScrn)
>  {
> -    RADEONInfoPtr  info  = RADEONPTR(pScrn);
> -#ifdef XF86_PDEV_SERVER_FD
>      RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
> 
> +#ifdef XF86_PDEV_SERVER_FD
>      if (pRADEONEnt->platform_dev &&
>              (pRADEONEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
>          return;
>  #endif
> 
> -    drmDropMaster(info->dri2.drm_fd);
> +    drmDropMaster(pRADEONEnt->fd);
>  }
> 
>  /* Called at the end of each server generation.  Restore the original
> @@ -2177,6 +2178,7 @@ void
> RADEONFreeScreen_KMS(FREE_SCREEN_ARGS_DECL)
>  Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
>  {
>      ScrnInfoPtr    pScrn = xf86ScreenToScrn(pScreen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
>      RADEONInfoPtr  info  = RADEONPTR(pScrn);
>      int            subPixelOrder = SubPixelUnknown;
>      MessageType from;
> @@ -2201,9 +2203,9 @@ Bool
> RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
>      if (info->r600_shadow_fb == FALSE)
>          info->directRenderingEnabled = radeon_dri2_screen_init(pScreen);
> 
> -    info->surf_man = radeon_surface_manager_new(info->dri2.drm_fd);
> +    info->surf_man = radeon_surface_manager_new(pRADEONEnt->fd);
>      if (!info->bufmgr)
> -        info->bufmgr = radeon_bo_manager_gem_ctor(info->dri2.drm_fd);
> +        info->bufmgr = radeon_bo_manager_gem_ctor(pRADEONEnt->fd);
>      if (!info->bufmgr) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  		   "failed to initialise GEM buffer manager");
> @@ -2212,7 +2214,7 @@ Bool
> RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL)
>      drmmode_set_bufmgr(pScrn, &info->drmmode, info->bufmgr);
> 
>      if (!info->csm)
> -        info->csm = radeon_cs_manager_gem_ctor(info->dri2.drm_fd);
> +        info->csm = radeon_cs_manager_gem_ctor(pRADEONEnt->fd);
>      if (!info->csm) {
>  	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
>  		   "failed to initialise command submission manager");
> diff --git a/src/radeon_present.c b/src/radeon_present.c
> index 635d10861..e637d7868 100644
> --- a/src/radeon_present.c
> +++ b/src/radeon_present.c
> @@ -105,10 +105,11 @@ static Bool
>  radeon_present_flush_drm_events(ScreenPtr screen)
>  {
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
>      drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[0]-
> >driver_private;
>      drmmode_ptr drmmode = drmmode_crtc->drmmode;
> -    struct pollfd p = { .fd = drmmode->fd, .events = POLLIN };
> +    struct pollfd p = { .fd = pRADEONEnt->fd, .events = POLLIN };
>      int r;
> 
>      do {
> @@ -118,7 +119,7 @@ radeon_present_flush_drm_events(ScreenPtr
> screen)
>      if (r <= 0)
>  	return 0;
> 
> -    return drmHandleEvent(drmmode->fd, &drmmode->event_context) >=
> 0;
> +    return drmHandleEvent(pRADEONEnt->fd, &drmmode->event_context)
> >= 0;
>  }
> 
>  /*
> @@ -155,7 +156,7 @@ radeon_present_queue_vblank(RRCrtcPtr crtc,
> uint64_t event_id, uint64_t msc)
>      xf86CrtcPtr xf86_crtc = crtc->devPrivate;
>      ScreenPtr screen = crtc->pScreen;
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> -    RADEONInfoPtr info = RADEONPTR(scrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      int crtc_id = drmmode_get_crtc_id(xf86_crtc);
>      struct radeon_present_vblank_event *event;
>      uintptr_t drm_queue_seq;
> @@ -180,7 +181,7 @@ radeon_present_queue_vblank(RRCrtcPtr crtc,
> uint64_t event_id, uint64_t msc)
>      vbl.request.sequence = msc;
>      vbl.request.signal = drm_queue_seq;
>      for (;;) {
> -	ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
> +	ret = drmWaitVBlank(pRADEONEnt->fd, &vbl);
>  	if (!ret)
>  	    break;
>  	if (errno != EBUSY || !radeon_present_flush_drm_events(screen)) {
> @@ -435,11 +436,11 @@ radeon_present_has_async_flip(ScreenPtr screen)
>  {
>  #ifdef DRM_CAP_ASYNC_PAGE_FLIP
>      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> -    RADEONInfoPtr info = RADEONPTR(scrn);
> +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
>      int ret;
>      uint64_t value;
> 
> -    ret = drmGetCap(info->dri2.drm_fd, DRM_CAP_ASYNC_PAGE_FLIP,
> &value);
> +    ret = drmGetCap(pRADEONEnt->fd, DRM_CAP_ASYNC_PAGE_FLIP,
> &value);
>      if (ret == 0)
>  	return value == 1;
>  #endif
> --
> 2.13.1
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list