Timo Aaltonen pushed to branch upstream-unstable at X Strike Force / driver / xserver-xorg-video-ati
Commits:
- 
d1d8e3c8
by Michel Dänzer at 2019-04-24T10:25:39Z
- 
f758908d
by Michel Dänzer at 2019-05-09T10:35:37Z
- 
d5f5bc58
by Flora Cui at 2019-06-14T09:20:12Z
- 
2a3f2d20
by Michel Dänzer at 2019-06-14T14:03:38Z
- 
fee737e8
by Michel Dänzer at 2019-06-14T14:03:45Z
- 
33803c85
by Michel Dänzer at 2019-06-25T15:46:23Z
- 
c7ed12cb
by Michel Dänzer at 2019-07-18T16:14:48Z
- 
2cbbd864
by Michel Dänzer at 2019-09-20T16:47:02Z
- 
2faaecc6
by Michel Dänzer at 2019-09-25T07:23:25Z
- 
b9bd8097
by Michel Dänzer at 2019-10-15T15:54:12Z
6 changed files:
Changes:
| ... | ... | @@ -23,7 +23,7 @@ | 
| 23 | 23 |  # Initialize Autoconf
 | 
| 24 | 24 |  AC_PREREQ([2.60])
 | 
| 25 | 25 |  AC_INIT([xf86-video-ati],
 | 
| 26 | -        [19.0.1],
 | |
| 26 | +        [19.1.0],
 | |
| 27 | 27 |          [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=Driver/Radeon],
 | 
| 28 | 28 |          [xf86-video-ati])
 | 
| 29 | 29 |  | 
| ... | ... | @@ -309,6 +309,7 @@ struct radeon_pixmap { | 
| 309 | 309 |  | 
| 310 | 310 |  	struct radeon_buffer *bo;
 | 
| 311 | 311 |  	struct drmmode_fb *fb;
 | 
| 312 | +	Bool fb_failed;
 | |
| 312 | 313 |  | 
| 313 | 314 |  	uint32_t tiling_flags;
 | 
| 314 | 315 |  | 
| ... | ... | @@ -877,21 +878,22 @@ static inline struct drmmode_fb* | 
| 877 | 878 |  radeon_pixmap_get_fb(PixmapPtr pix)
 | 
| 878 | 879 |  {
 | 
| 879 | 880 |      struct drmmode_fb **fb_ptr = radeon_pixmap_get_fb_ptr(pix);
 | 
| 880 | - | |
| 881 | -    if (!fb_ptr)
 | |
| 882 | -	return NULL;
 | |
| 883 | - | |
| 884 | -    if (!*fb_ptr) {
 | |
| 885 | -	uint32_t handle;
 | |
| 886 | - | |
| 887 | -	if (radeon_get_pixmap_handle(pix, &handle)) {
 | |
| 888 | -	    ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
 | |
| 889 | -	    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
 | |
| 890 | - | |
| 891 | -	    *fb_ptr = radeon_fb_create(scrn, pRADEONEnt->fd, pix->drawable.width,
 | |
| 892 | -				       pix->drawable.height, pix->devKind,
 | |
| 893 | -				       handle);
 | |
| 894 | -	}
 | |
| 881 | +    uint32_t handle;
 | |
| 882 | + | |
| 883 | +    if (fb_ptr && *fb_ptr)
 | |
| 884 | +	return *fb_ptr;
 | |
| 885 | +	
 | |
| 886 | +    if (radeon_get_pixmap_handle(pix, &handle)) {
 | |
| 887 | +	ScrnInfoPtr scrn = xf86ScreenToScrn(pix->drawable.pScreen);
 | |
| 888 | +	RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
 | |
| 889 | + | |
| 890 | +	if (!fb_ptr)
 | |
| 891 | +	    fb_ptr = radeon_pixmap_get_fb_ptr(pix);
 | |
| 892 | + | |
| 893 | +	*fb_ptr = radeon_fb_create(scrn, pRADEONEnt->fd,
 | |
| 894 | +				   pix->drawable.width,
 | |
| 895 | +				   pix->drawable.height, pix->devKind,
 | |
| 896 | +				   handle);
 | |
| 895 | 897 |      }
 | 
| 896 | 898 |  | 
| 897 | 899 |      return *fb_ptr;
 | 
| ... | ... | @@ -509,18 +509,20 @@ static Bool radeon_dri2_get_crtc_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc) | 
| 509 | 509 |  }
 | 
| 510 | 510 |  | 
| 511 | 511 |  static
 | 
| 512 | -xf86CrtcPtr radeon_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled)
 | |
| 512 | +xf86CrtcPtr radeon_dri2_drawable_crtc(DrawablePtr pDraw)
 | |
| 513 | 513 |  {
 | 
| 514 | 514 |      ScreenPtr pScreen = pDraw->pScreen;
 | 
| 515 | 515 |      ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 | 
| 516 | -    xf86CrtcPtr crtc = radeon_pick_best_crtc(pScrn, consider_disabled,
 | |
| 516 | +    xf86CrtcPtr crtc = radeon_pick_best_crtc(pScrn, TRUE,
 | |
| 517 | 517 |  					      pDraw->x, pDraw->x + pDraw->width,
 | 
| 518 | 518 |  					      pDraw->y, pDraw->y + pDraw->height);
 | 
| 519 | 519 |  | 
| 520 | -    if (crtc && pDraw->type == DRAWABLE_WINDOW) {
 | |
| 520 | +    if (pDraw->type == DRAWABLE_WINDOW) {
 | |
| 521 | 521 |  	struct dri2_window_priv *priv = get_dri2_window_priv((WindowPtr)pDraw);
 | 
| 522 | 522 |  | 
| 523 | -	if (priv->crtc && priv->crtc != crtc) {
 | |
| 523 | +	if (!crtc) {
 | |
| 524 | +	    crtc = priv->crtc;
 | |
| 525 | +	} else if (priv->crtc && priv->crtc != crtc) {
 | |
| 524 | 526 |  	    CARD64 ust, mscold, mscnew;
 | 
| 525 | 527 |  | 
| 526 | 528 |  	    if (radeon_dri2_get_crtc_msc(priv->crtc, &ust, &mscold) &&
 | 
| ... | ... | @@ -926,7 +928,7 @@ CARD32 radeon_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 *target_msc, | 
| 926 | 928 |   */
 | 
| 927 | 929 |  static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
 | 
| 928 | 930 |  {
 | 
| 929 | -    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
 | |
| 931 | +    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw);
 | |
| 930 | 932 |  | 
| 931 | 933 |      /* Drawable not displayed, make up a value */
 | 
| 932 | 934 |      if (!crtc) {
 | 
| ... | ... | @@ -1041,7 +1043,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, | 
| 1041 | 1043 |      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 | 
| 1042 | 1044 |      DRI2FrameEventPtr wait_info = NULL;
 | 
| 1043 | 1045 |      uintptr_t drm_queue_seq = 0;
 | 
| 1044 | -    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
 | |
| 1046 | +    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw);
 | |
| 1045 | 1047 |      uint32_t msc_delta;
 | 
| 1046 | 1048 |      uint32_t seq;
 | 
| 1047 | 1049 |      CARD64 current_msc;
 | 
| ... | ... | @@ -1156,6 +1158,9 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, | 
| 1156 | 1158 |  out_complete:
 | 
| 1157 | 1159 |      if (wait_info)
 | 
| 1158 | 1160 |  	radeon_dri2_deferred_event(NULL, 0, wait_info);
 | 
| 1161 | +    else
 | |
| 1162 | +	DRI2WaitMSCComplete(client, draw, 0, 0, 0);
 | |
| 1163 | + | |
| 1159 | 1164 |      return TRUE;
 | 
| 1160 | 1165 |  }
 | 
| 1161 | 1166 |  | 
| ... | ... | @@ -1187,7 +1192,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, | 
| 1187 | 1192 |  {
 | 
| 1188 | 1193 |      ScreenPtr screen = draw->pScreen;
 | 
| 1189 | 1194 |      ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 | 
| 1190 | -    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE);
 | |
| 1195 | +    xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw);
 | |
| 1191 | 1196 |      uint32_t msc_delta;
 | 
| 1192 | 1197 |      drmVBlankSeqType type;
 | 
| 1193 | 1198 |      uint32_t seq;
 | 
| ... | ... | @@ -220,29 +220,13 @@ static int radeon_dri3_fd_from_pixmap(ScreenPtr screen, | 
| 220 | 220 |  	RADEONInfoPtr info = RADEONPTR(scrn);
 | 
| 221 | 221 |  | 
| 222 | 222 |  	if (info->use_glamor) {
 | 
| 223 | -		Bool need_flush = TRUE;
 | |
| 224 | -		int ret = -1;
 | |
| 225 | -#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,19,99,904,0)
 | |
| 226 | -		struct gbm_bo *gbm_bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
 | |
| 223 | +		int ret = glamor_fd_from_pixmap(screen, pixmap, stride, size);
 | |
| 227 | 224 |  | 
| 228 | -		if (gbm_bo) {
 | |
| 229 | -			ret = gbm_bo_get_fd(gbm_bo);
 | |
| 230 | -			gbm_bo_destroy(gbm_bo);
 | |
| 231 | - | |
| 232 | -			if (ret >= 0)
 | |
| 233 | -				need_flush = FALSE;
 | |
| 234 | -		}
 | |
| 235 | -#endif
 | |
| 236 | - | |
| 237 | -		if (ret < 0)
 | |
| 238 | -			ret = glamor_fd_from_pixmap(screen, pixmap, stride, size);
 | |
| 239 | - | |
| 240 | -		/* glamor might have needed to reallocate the pixmap storage and
 | |
| 241 | -		 * copy the pixmap contents to the new storage. The copy
 | |
| 242 | -		 * operation needs to be flushed to the kernel driver before the
 | |
| 243 | -		 * client starts using the pixmap storage for direct rendering.
 | |
| 225 | +		/* Any pending drawing operations need to be flushed to the
 | |
| 226 | +		 * kernel driver before the client starts using the pixmap
 | |
| 227 | +		 * storage for direct rendering.
 | |
| 244 | 228 |  		 */
 | 
| 245 | -		if (ret >= 0 && need_flush)
 | |
| 229 | +		if (ret >= 0)
 | |
| 246 | 230 |  			radeon_cs_flush_indirect(scrn);
 | 
| 247 | 231 |  | 
| 248 | 232 |  		return ret;
 | 
| ... | ... | @@ -1917,19 +1917,15 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags) | 
| 1917 | 1917 |  | 
| 1918 | 1918 |      if (!pScrn->is_gpu) {
 | 
| 1919 | 1919 |  	if (info->dri2.pKernelDRMVersion->version_minor >= 8) {
 | 
| 1920 | -	    Bool sw_cursor = xf86ReturnOptValBool(info->Options,
 | |
| 1921 | -						  OPTION_SW_CURSOR, FALSE);
 | |
| 1922 | - | |
| 1923 | 1920 |  	    info->allowPageFlip = xf86ReturnOptValBool(info->Options,
 | 
| 1924 | 1921 |  						       OPTION_PAGE_FLIP, TRUE);
 | 
| 1925 | 1922 |  | 
| 1926 | -	    if (sw_cursor || info->shadow_primary) {
 | |
| 1923 | +	    if (info->shadow_primary) {
 | |
| 1927 | 1924 |  		xf86DrvMsg(pScrn->scrnIndex,
 | 
| 1928 | 1925 |  			   info->allowPageFlip ? X_WARNING : X_DEFAULT,
 | 
| 1929 | 1926 |  			   "KMS Pageflipping: disabled%s\n",
 | 
| 1930 | 1927 |  			   info->allowPageFlip ?
 | 
| 1931 | -			   (sw_cursor ? " because of SWcursor" :
 | |
| 1932 | -			    " because of ShadowPrimary") : "");
 | |
| 1928 | +			   " because of ShadowPrimary" : "");
 | |
| 1933 | 1929 |  		info->allowPageFlip = FALSE;
 | 
| 1934 | 1930 |  	    } else {
 | 
| 1935 | 1931 |  		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 | 
| ... | ... | @@ -2606,16 +2602,25 @@ CARD32 cleanup_black_fb(OsTimerPtr timer, CARD32 now, pointer data) | 
| 2606 | 2602 |  }
 | 
| 2607 | 2603 |  | 
| 2608 | 2604 |  static void
 | 
| 2609 | -pixmap_unref_fb(void *value, XID id, void *cdata)
 | |
| 2605 | +pixmap_unref_fb(PixmapPtr pixmap)
 | |
| 2610 | 2606 |  {
 | 
| 2611 | -    PixmapPtr pixmap = value;
 | |
| 2612 | -    RADEONEntPtr pRADEONEnt = cdata;
 | |
| 2607 | +    ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 | |
| 2613 | 2608 |      struct drmmode_fb **fb_ptr = radeon_pixmap_get_fb_ptr(pixmap);
 | 
| 2609 | +    RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
 | |
| 2614 | 2610 |  | 
| 2615 | 2611 |      if (fb_ptr)
 | 
| 2616 | 2612 |  	drmmode_fb_reference(pRADEONEnt->fd, fb_ptr, NULL);
 | 
| 2617 | 2613 |  }
 | 
| 2618 | 2614 |  | 
| 2615 | +static void
 | |
| 2616 | +client_pixmap_unref_fb(void *value, XID id, void *pScreen)
 | |
| 2617 | +{
 | |
| 2618 | +    PixmapPtr pixmap = value;
 | |
| 2619 | + | |
| 2620 | +    if (pixmap->drawable.pScreen == pScreen)
 | |
| 2621 | +	pixmap_unref_fb(pixmap);
 | |
| 2622 | +}
 | |
| 2623 | + | |
| 2619 | 2624 |  void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn)
 | 
| 2620 | 2625 |  {
 | 
| 2621 | 2626 |      RADEONInfoPtr  info  = RADEONPTR(pScrn);
 | 
| ... | ... | @@ -2633,6 +2638,12 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn) | 
| 2633 | 2638 |  	unsigned w = 0, h = 0;
 | 
| 2634 | 2639 |  	int i;
 | 
| 2635 | 2640 |  | 
| 2641 | +	/* If we're called from CloseScreen, trying to clear the black
 | |
| 2642 | +	 * scanout BO will likely crash and burn
 | |
| 2643 | +	 */
 | |
| 2644 | +	if (!pScreen->GCperDepth[0])
 | |
| 2645 | +	    goto hide_cursors;
 | |
| 2646 | + | |
| 2636 | 2647 |  	/* Compute maximum scanout dimensions of active CRTCs */
 | 
| 2637 | 2648 |  	for (i = 0; i < xf86_config->num_crtc; i++) {
 | 
| 2638 | 2649 |  	    crtc = xf86_config->crtc[i];
 | 
| ... | ... | @@ -2671,11 +2682,9 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn) | 
| 2671 | 2682 |  | 
| 2672 | 2683 |  			if (pScrn->is_gpu) {
 | 
| 2673 | 2684 |  			    if (drmmode_crtc->scanout[0].pixmap)
 | 
| 2674 | -				pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap,
 | |
| 2675 | -						None, pRADEONEnt);
 | |
| 2685 | +				pixmap_unref_fb(drmmode_crtc->scanout[0].pixmap);
 | |
| 2676 | 2686 |  			    if (drmmode_crtc->scanout[1].pixmap)
 | 
| 2677 | -				pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap,
 | |
| 2678 | -						None, pRADEONEnt);
 | |
| 2687 | +				pixmap_unref_fb(drmmode_crtc->scanout[1].pixmap);
 | |
| 2679 | 2688 |  			} else {
 | 
| 2680 | 2689 |  			    drmmode_crtc_scanout_free(crtc);
 | 
| 2681 | 2690 |  			}
 | 
| ... | ... | @@ -2695,18 +2704,20 @@ void RADEONLeaveVT_KMS(ScrnInfoPtr pScrn) | 
| 2695 | 2704 |  		(!clients[i] || clients[i]->clientState != ClientStateRunning))
 | 
| 2696 | 2705 |  		continue;
 | 
| 2697 | 2706 |  | 
| 2698 | -	    FindClientResourcesByType(clients[i], RT_PIXMAP, pixmap_unref_fb,
 | |
| 2699 | -				      pRADEONEnt);
 | |
| 2707 | +	    FindClientResourcesByType(clients[i], RT_PIXMAP,
 | |
| 2708 | +				      client_pixmap_unref_fb, pScreen);
 | |
| 2700 | 2709 |  	}
 | 
| 2701 | 2710 |  | 
| 2702 | -	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen), None, pRADEONEnt);
 | |
| 2711 | +	pixmap_unref_fb(pScreen->GetScreenPixmap(pScreen));
 | |
| 2703 | 2712 |      } else {
 | 
| 2704 | 2713 |  	memset(info->front_buffer->bo.radeon->ptr, 0,
 | 
| 2705 | 2714 |  	       pScrn->displayWidth * info->pixel_bytes * pScrn->virtualY);
 | 
| 2706 | 2715 |      }
 | 
| 2707 | 2716 |  | 
| 2708 | -    TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
 | |
| 2717 | +    if (pScreen->GCperDepth[0])
 | |
| 2718 | +	TimerSet(NULL, 0, 1000, cleanup_black_fb, pScreen);
 | |
| 2709 | 2719 |  | 
| 2720 | + hide_cursors:
 | |
| 2710 | 2721 |      xf86_hide_cursors (pScrn);
 | 
| 2711 | 2722 |  | 
| 2712 | 2723 |      radeon_drop_drm_master(pScrn);
 | 
| ... | ... | @@ -254,6 +254,7 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, | 
| 254 | 254 |      xf86CrtcPtr xf86_crtc = crtc->devPrivate;
 | 
| 255 | 255 |      ScreenPtr screen = window->drawable.pScreen;
 | 
| 256 | 256 |      ScrnInfoPtr scrn = xf86_crtc->scrn;
 | 
| 257 | +    struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap);
 | |
| 257 | 258 |      xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 | 
| 258 | 259 |      RADEONInfoPtr info = RADEONPTR(scrn);
 | 
| 259 | 260 |      PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
 | 
| ... | ... | @@ -277,6 +278,23 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, | 
| 277 | 278 |  	return FALSE;
 | 
| 278 | 279 |  #endif
 | 
| 279 | 280 |  | 
| 281 | +    if (priv && priv->fb_failed)
 | |
| 282 | +	return FALSE;
 | |
| 283 | + | |
| 284 | +    if (!radeon_pixmap_get_fb(pixmap)) {
 | |
| 285 | +	if (!priv)
 | |
| 286 | +	    priv = radeon_get_pixmap_private(pixmap);
 | |
| 287 | + | |
| 288 | +	if (priv && !priv->fb_failed) {
 | |
| 289 | +	    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 | |
| 290 | +		       "Cannot get FB for Present flip (may be "
 | |
| 291 | +		       "normal if using PRIME render offloading)\n");
 | |
| 292 | +	    priv->fb_failed = TRUE;
 | |
| 293 | +	}
 | |
| 294 | + | |
| 295 | +	return FALSE;
 | |
| 296 | +    }
 | |
| 297 | + | |
| 280 | 298 |      /* The kernel driver doesn't handle flipping between BOs with different
 | 
| 281 | 299 |       * tiling parameters correctly yet
 | 
| 282 | 300 |       */
 |