Ticket #11051: ati-upstream-fixes

File ati-upstream-fixes, 19.5 KB (added by ken@…, 6 years ago)

Upstream commits 3c4c0213c11d 499d2f9d5d30

Line 
1commit 3c4c0213c11d623cba7adbc28dde652694f2f758
2Author: Michel Dänzer <michel.daenzer@amd.com>
3Date: Fri Jun 29 17:57:03 2018 +0200
4
5 glamor: Use GBM for BO allocation when possible
6
7 Inspired by amdgpu. This avoids various issues due to a GEM handle
8 lifetime conflict between us and Mesa with current glamor.
9
10 Bugzilla: https://bugs.freedesktop.org/105381
11 Tested-by: Konstantin Kharlamov <hi-angel@yandex.ru>
12 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
13
14diff --git a/configure.ac b/configure.ac
15index 11efdf0a..f5614749 100644
16--- a/configure.ac
17+++ b/configure.ac
18@@ -138,12 +138,22 @@ if test "x$GLAMOR" != "xno"; then
19 [Have glamor_egl_destroy_textured_pixmap API])], [],
20 [#include "xorg-server.h"
21 #include "glamor.h"])
22+
23+ AC_CHECK_DECL(glamor_finish,
24+ [AC_DEFINE(HAVE_GLAMOR_FINISH, 1,
25+ [Have glamor_finish API])],
26+ [PKG_CHECK_MODULES(LIBGL, [gl])],
27+ [#include "xorg-server.h"
28+ #include "glamor.h"])
29 fi
30
31 if test "x$GLAMOR_XSERVER" != xyes; then
32 PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.6.0])
33 PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
34 fi
35+
36+ PKG_CHECK_MODULES(GBM, [gbm >= 10.6])
37+
38 AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
39 else
40 AC_MSG_RESULT([$GLAMOR])
41diff --git a/src/Makefile.am b/src/Makefile.am
42index ed1bfa9e..df4a95e4 100644
43--- a/src/Makefile.am
44+++ b/src/Makefile.am
45@@ -62,8 +62,8 @@ radeon_drv_la_SOURCES = \
46 $(RADEON_KMS_SRCS)
47
48 if GLAMOR
49-AM_CFLAGS += @LIBGLAMOR_CFLAGS@
50-radeon_drv_la_LIBADD += @LIBGLAMOR_LIBS@
51+AM_CFLAGS += @LIBGLAMOR_CFLAGS@ @GBM_CFLAGS@
52+radeon_drv_la_LIBADD += @LIBGLAMOR_LIBS@ @GBM_LIBS@
53 radeon_drv_la_SOURCES += \
54 radeon_glamor_wrappers.c \
55 radeon_glamor.c
56diff --git a/src/drmmode_display.c b/src/drmmode_display.c
57index c91f5bb2..2773ce67 100644
58--- a/src/drmmode_display.c
59+++ b/src/drmmode_display.c
60@@ -142,8 +142,7 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
61 }
62
63 if (!info->use_glamor ||
64- radeon_glamor_create_textured_pixmap(pixmap,
65- radeon_get_pixmap_private(pixmap)))
66+ radeon_glamor_create_textured_pixmap(pixmap, bo))
67 return pixmap;
68
69 fail:
70@@ -435,8 +434,14 @@ destroy_pixmap_for_fbcon(ScrnInfoPtr pScrn)
71 /* XXX: The current GPUVM support in the kernel doesn't allow removing
72 * the virtual address range for this BO, so we need to keep around
73 * the pixmap to avoid breaking glamor with GPUVM
74+ *
75+ * Similarly, need to keep around the pixmap with current glamor, to
76+ * avoid issues due to a GEM handle lifetime conflict between us and
77+ * Mesa
78 */
79- if (info->use_glamor && info->ChipFamily >= CHIP_FAMILY_CAYMAN)
80+ if (info->use_glamor &&
81+ (info->ChipFamily >= CHIP_FAMILY_CAYMAN ||
82+ xorgGetVersion() >= XORG_VERSION_NUMERIC(1,19,99,1,0)))
83 return;
84
85 if (info->fbcon_pixmap)
86@@ -2277,21 +2282,23 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
87
88 scrn->displayWidth = pitch / cpp;
89
90+ if (!info->use_glamor) {
91 #if X_BYTE_ORDER == X_BIG_ENDIAN
92- switch (cpp) {
93- case 4:
94- tiling_flags |= RADEON_TILING_SWAP_32BIT;
95- break;
96- case 2:
97- tiling_flags |= RADEON_TILING_SWAP_16BIT;
98- break;
99- }
100- if (info->ChipFamily < CHIP_FAMILY_R600 &&
101- info->r600_shadow_fb && tiling_flags)
102- tiling_flags |= RADEON_TILING_SURFACE;
103+ switch (cpp) {
104+ case 4:
105+ tiling_flags |= RADEON_TILING_SWAP_32BIT;
106+ break;
107+ case 2:
108+ tiling_flags |= RADEON_TILING_SWAP_16BIT;
109+ break;
110+ }
111+ if (info->ChipFamily < CHIP_FAMILY_R600 &&
112+ info->r600_shadow_fb && tiling_flags)
113+ tiling_flags |= RADEON_TILING_SURFACE;
114 #endif
115- if (tiling_flags)
116- radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
117+ if (tiling_flags)
118+ radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
119+ }
120
121 if (!info->r600_shadow_fb) {
122 if (info->surf_man && !info->use_glamor)
123diff --git a/src/radeon.h b/src/radeon.h
124index 648fd98a..2bcfa41b 100644
125--- a/src/radeon.h
126+++ b/src/radeon.h
127@@ -606,6 +606,8 @@ typedef struct {
128 unsigned hwcursor_disabled;
129
130 #ifdef USE_GLAMOR
131+ struct gbm_device *gbm;
132+
133 struct {
134 CreateGCProcPtr SavedCreateGC;
135 RegionPtr (*SavedCopyArea)(DrawablePtr, DrawablePtr, GCPtr, int, int,
136@@ -744,8 +746,6 @@ static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_buffer *bo
137 }
138
139 if (bo) {
140- uint32_t pitch;
141-
142 if (!priv) {
143 priv = calloc(1, sizeof (struct radeon_pixmap));
144 if (!priv)
145@@ -754,11 +754,10 @@ static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_buffer *bo
146
147 radeon_buffer_ref(bo);
148 priv->bo = bo;
149-
150- radeon_bo_get_tiling(bo->bo.radeon, &priv->tiling_flags, &pitch);
151 }
152
153 radeon_set_pixmap_private(pPix, priv);
154+ radeon_get_pixmap_tiling_flags(pPix);
155 return TRUE;
156 } else
157 #endif /* USE_GLAMOR */
158diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c
159index 2b836bbf..79e8ff1b 100644
160--- a/src/radeon_bo_helper.c
161+++ b/src/radeon_bo_helper.c
162@@ -28,6 +28,37 @@
163 #include "radeon_glamor.h"
164 #include "radeon_bo_gem.h"
165
166+
167+#ifdef USE_GLAMOR
168+
169+static uint32_t
170+radeon_get_gbm_format(int depth, int bitsPerPixel)
171+{
172+ switch (depth) {
173+#ifdef GBM_FORMAT_R8
174+ case 8:
175+ return GBM_FORMAT_R8;
176+#endif
177+ case 16:
178+ return GBM_FORMAT_RGB565;
179+ case 32:
180+ return GBM_FORMAT_ARGB8888;
181+ case 30:
182+ return GBM_FORMAT_XRGB2101010;
183+ case 24:
184+ if (bitsPerPixel == 32)
185+ return GBM_FORMAT_XRGB8888;
186+ /* fall through */
187+ default:
188+ ErrorF("%s: Unsupported depth/bpp %d/%d\n", __func__, depth,
189+ bitsPerPixel);
190+ return ~0U;
191+ }
192+}
193+
194+#endif /* USE_GLAMOR */
195+
196+
197 static const unsigned MicroBlockTable[5][3][2] = {
198 /*linear tiled square-tiled */
199 {{32, 1}, {8, 4}, {0, 0}}, /* 8 bits per pixel */
200@@ -158,6 +189,46 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
201 struct radeon_surface surface;
202 struct radeon_buffer *bo;
203 int domain = RADEON_GEM_DOMAIN_VRAM;
204+
205+#ifdef USE_GLAMOR
206+ if (info->use_glamor &&
207+ !(usage_hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP &&
208+ info->shadow_primary)) {
209+ uint32_t bo_use = GBM_BO_USE_RENDERING;
210+ uint32_t gbm_format = radeon_get_gbm_format(depth, bitsPerPixel);
211+
212+ if (gbm_format == ~0U)
213+ return NULL;
214+
215+ bo = calloc(1, sizeof(struct radeon_buffer));
216+ if (!bo)
217+ return NULL;
218+
219+ bo->ref_count = 1;
220+
221+ if (bitsPerPixel == pScrn->bitsPerPixel)
222+ bo_use |= GBM_BO_USE_SCANOUT;
223+
224+ if ((usage_hint == CREATE_PIXMAP_USAGE_BACKING_PIXMAP &&
225+ info->shadow_primary) ||
226+ (usage_hint & 0xffff) == CREATE_PIXMAP_USAGE_SHARED)
227+ bo_use |= GBM_BO_USE_LINEAR;
228+
229+ bo->bo.gbm = gbm_bo_create(info->gbm, width, height, gbm_format, bo_use);
230+ if (!bo->bo.gbm) {
231+ free(bo);
232+ return NULL;
233+ }
234+
235+ bo->flags |= RADEON_BO_FLAGS_GBM;
236+
237+ if (new_pitch)
238+ *new_pitch = gbm_bo_get_stride(bo->bo.gbm);
239+
240+ return bo;
241+ }
242+#endif
243+
244 if (usage_hint) {
245 if (info->allowColorTiling) {
246 if (usage_hint & RADEON_CREATE_PIXMAP_TILING_MACRO)
247@@ -245,6 +316,13 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth,
248 void
249 radeon_finish(ScrnInfoPtr scrn, struct radeon_buffer *bo)
250 {
251+ RADEONInfoPtr info = RADEONPTR(scrn);
252+
253+ if (info->use_glamor) {
254+ radeon_glamor_finish(scrn);
255+ return;
256+ }
257+
258 radeon_cs_flush_indirect(scrn);
259 radeon_bo_wait(bo->bo.radeon);
260 }
261@@ -282,7 +360,7 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle)
262 RADEONInfoPtr info = RADEONPTR(scrn);
263 #endif
264
265- if (bo) {
266+ if (bo && !(bo->flags & RADEON_BO_FLAGS_GBM)) {
267 *handle = bo->bo.radeon->handle;
268 return TRUE;
269 }
270@@ -380,6 +458,44 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
271 if (!bo)
272 goto error;
273
274+#ifdef USE_GLAMOR
275+ if (info->use_glamor) {
276+ struct gbm_import_fd_data data;
277+ uint32_t bo_use = GBM_BO_USE_RENDERING;
278+
279+ data.format = radeon_get_gbm_format(ppix->drawable.depth,
280+ ppix->drawable.bitsPerPixel);
281+ if (data.format == ~0U)
282+ goto error;
283+
284+ bo->ref_count = 1;
285+
286+ data.fd = ihandle;
287+ data.width = ppix->drawable.width;
288+ data.height = ppix->drawable.height;
289+ data.stride = ppix->devKind;
290+
291+ if (ppix->drawable.bitsPerPixel == pScrn->bitsPerPixel)
292+ bo_use |= GBM_BO_USE_SCANOUT;
293+
294+ bo->bo.gbm = gbm_bo_import(info->gbm, GBM_BO_IMPORT_FD, &data, bo_use);
295+ if (!bo->bo.gbm)
296+ goto error;
297+
298+ bo->flags |= RADEON_BO_FLAGS_GBM;
299+
300+ if (!radeon_glamor_create_textured_pixmap(ppix, bo)) {
301+ radeon_buffer_unref(&bo);
302+ return FALSE;
303+ }
304+
305+ ret = radeon_set_pixmap_bo(ppix, bo);
306+ /* radeon_set_pixmap_bo increments ref_count if it succeeds */
307+ radeon_buffer_unref(&bo);
308+ return ret;
309+ }
310+#endif
311+
312 bo->bo.radeon = radeon_gem_bo_open_prime(info->bufmgr, ihandle, size);
313 if (!bo)
314 goto error;
315diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h
316index 53af87c3..cc3d1d3b 100644
317--- a/src/radeon_bo_helper.h
318+++ b/src/radeon_bo_helper.h
319@@ -23,13 +23,21 @@
320 #ifndef RADEON_BO_HELPER_H
321 #define RADEON_BO_HELPER_H 1
322
323+#ifdef USE_GLAMOR
324+#include <gbm.h>
325+#endif
326+
327 #define RADEON_BO_FLAGS_GBM 0x1
328
329 struct radeon_buffer {
330 union {
331+#ifdef USE_GLAMOR
332+ struct gbm_bo *gbm;
333+#endif
334 struct radeon_bo *radeon;
335 } bo;
336 uint32_t ref_count;
337+ uint32_t flags;
338 };
339
340 extern struct radeon_buffer *
341@@ -88,8 +96,16 @@ radeon_buffer_unref(struct radeon_buffer **buffer)
342 return;
343 }
344
345- radeon_bo_unmap(buf->bo.radeon);
346- radeon_bo_unref(buf->bo.radeon);
347+#ifdef USE_GLAMOR
348+ if (buf->flags & RADEON_BO_FLAGS_GBM) {
349+ gbm_bo_destroy(buf->bo.gbm);
350+ } else
351+#endif
352+ {
353+ radeon_bo_unmap(buf->bo.radeon);
354+ radeon_bo_unref(buf->bo.radeon);
355+ }
356+
357 free(buf);
358 *buffer = NULL;
359 }
360diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
361index 584a1d9d..ab3db6c5 100644
362--- a/src/radeon_dri2.c
363+++ b/src/radeon_dri2.c
364@@ -79,11 +79,12 @@ static DevPrivateKeyRec dri2_window_private_key_rec;
365 static Bool
366 radeon_get_flink_name(RADEONEntPtr pRADEONEnt, PixmapPtr pixmap, uint32_t *name)
367 {
368- struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap)->bo.radeon;
369+ struct radeon_buffer *bo = radeon_get_pixmap_bo(pixmap);
370 struct drm_gem_flink flink;
371
372- if (bo)
373- return radeon_gem_get_kernel_name(bo, name) == 0;
374+ if (bo && !(bo->flags & RADEON_BO_FLAGS_GBM) &&
375+ radeon_gem_get_kernel_name(bo->bo.radeon, name) == 0)
376+ return TRUE;
377
378 if (radeon_get_pixmap_handle(pixmap, &flink.handle)) {
379 if (drmIoctl(pRADEONEnt->fd, DRM_IOCTL_GEM_FLINK, &flink) != 0)
380diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
381index b199c793..688e594e 100644
382--- a/src/radeon_dri3.c
383+++ b/src/radeon_dri3.c
384@@ -213,17 +213,16 @@ static int radeon_dri3_fd_from_pixmap(ScreenPtr screen,
385 {
386 struct radeon_bo *bo;
387 int fd;
388-
389- bo = radeon_get_pixmap_bo(pixmap)->bo.radeon;
390- if (!bo) {
391 #ifdef USE_GLAMOR
392- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
393- RADEONInfoPtr info = RADEONPTR(scrn);
394+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
395+ RADEONInfoPtr info = RADEONPTR(scrn);
396
397- if (info->use_glamor)
398- return glamor_fd_from_pixmap(screen, pixmap, stride, size);
399+ if (info->use_glamor)
400+ return glamor_fd_from_pixmap(screen, pixmap, stride, size);
401 #endif
402
403+ bo = radeon_get_pixmap_bo(pixmap)->bo.radeon;
404+ if (!bo) {
405 exaMoveInPixmap(pixmap);
406 bo = radeon_get_pixmap_bo(pixmap)->bo.radeon;
407 if (!bo)
408diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c
409index c1d96160..fa634947 100644
410--- a/src/radeon_glamor.c
411+++ b/src/radeon_glamor.c
412@@ -52,6 +52,7 @@ radeon_glamor_create_screen_resources(ScreenPtr screen)
413 {
414 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
415 RADEONInfoPtr info = RADEONPTR(scrn);
416+ uint32_t handle;
417
418 if (!info->use_glamor)
419 return TRUE;
420@@ -61,8 +62,12 @@ radeon_glamor_create_screen_resources(ScreenPtr screen)
421 return FALSE;
422 #endif
423
424- if (!glamor_egl_create_textured_screen(screen,
425- info->front_buffer->bo.radeon->handle,
426+ if (info->front_buffer->flags & RADEON_BO_FLAGS_GBM)
427+ handle = gbm_bo_get_handle(info->front_buffer->bo.gbm).u32;
428+ else
429+ handle = info->front_buffer->bo.radeon->handle;
430+
431+ if (!glamor_egl_create_textured_screen(screen, handle,
432 scrn->displayWidth *
433 info->pixel_bytes))
434 return FALSE;
435@@ -136,6 +141,13 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn)
436 }
437 #endif
438
439+ info->gbm = gbm_create_device(pRADEONEnt->fd);
440+ if (!info->gbm) {
441+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
442+ "gbm_create_device returned NULL\n");
443+ return FALSE;
444+ }
445+
446 /* Load glamor module */
447 if ((glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME))) {
448 version = xf86GetModuleVersion(glamor_module);
449@@ -164,10 +176,21 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn)
450 }
451
452 Bool
453-radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv)
454+radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo)
455 {
456- return glamor_egl_create_textured_pixmap(pixmap, priv->bo->bo.radeon->handle,
457- pixmap->devKind);
458+ ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
459+ RADEONInfoPtr info = RADEONPTR(scrn);
460+ uint32_t handle;
461+
462+ if (!info->use_glamor)
463+ return TRUE;
464+
465+ if (bo->flags & RADEON_BO_FLAGS_GBM)
466+ handle = gbm_bo_get_handle(bo->bo.gbm).u32;
467+ else
468+ handle = bo->bo.radeon->handle;
469+
470+ return glamor_egl_create_textured_pixmap(pixmap, handle, pixmap->devKind);
471 }
472
473 static Bool radeon_glamor_destroy_pixmap(PixmapPtr pixmap)
474@@ -179,13 +202,6 @@ static Bool radeon_glamor_destroy_pixmap(PixmapPtr pixmap)
475 #endif
476
477 if (pixmap->refcnt == 1) {
478- if (pixmap->devPrivate.ptr) {
479- struct radeon_buffer *bo = radeon_get_pixmap_bo(pixmap);
480-
481- if (bo)
482- radeon_bo_unmap(bo->bo.radeon);
483- }
484-
485 #ifdef HAVE_GLAMOR_EGL_DESTROY_TEXTURED_PIXMAP
486 glamor_egl_destroy_textured_pixmap(pixmap);
487 #endif
488@@ -259,7 +275,7 @@ radeon_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
489
490 screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
491
492- if (!radeon_glamor_create_textured_pixmap(pixmap, priv))
493+ if (!radeon_glamor_create_textured_pixmap(pixmap, priv->bo))
494 goto fallback_glamor;
495
496 pixmap->devPrivate.ptr = NULL;
497@@ -390,13 +406,12 @@ radeon_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle)
498 {
499 ScreenPtr screen = pixmap->drawable.pScreen;
500 ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
501- struct radeon_pixmap *priv;
502
503 if (!radeon_set_shared_pixmap_backing(pixmap, handle, NULL))
504 return FALSE;
505
506- priv = radeon_get_pixmap_private(pixmap);
507- if (!radeon_glamor_create_textured_pixmap(pixmap, priv)) {
508+ if (!radeon_glamor_create_textured_pixmap(pixmap,
509+ radeon_get_pixmap_bo(pixmap))) {
510 xf86DrvMsg(scrn->scrnIndex, X_ERROR,
511 "Failed to get PRIME drawable for glamor pixmap.\n");
512 return FALSE;
513diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h
514index ec42df1f..2740ab33 100644
515--- a/src/radeon_glamor.h
516+++ b/src/radeon_glamor.h
517@@ -33,6 +33,12 @@ struct radeon_pixmap;
518
519 #ifdef USE_GLAMOR
520
521+#ifndef HAVE_GLAMOR_FINISH
522+#include <GL/gl.h>
523+#endif
524+
525+#include <gbm.h>
526+
527 #define GLAMOR_FOR_XORG 1
528 #include <glamor.h>
529
530@@ -65,12 +71,27 @@ void radeon_glamor_screen_init(ScreenPtr screen);
531 Bool radeon_glamor_create_screen_resources(ScreenPtr screen);
532 void radeon_glamor_free_screen(int scrnIndex, int flags);
533
534-Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv);
535+Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo);
536 void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst);
537 PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap);
538
539 XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt);
540
541+static inline void
542+radeon_glamor_finish(ScrnInfoPtr scrn)
543+{
544+ RADEONInfoPtr info = RADEONPTR(scrn);
545+
546+#if HAVE_GLAMOR_FINISH
547+ glamor_finish(scrn->pScreen);
548+#else
549+ glamor_block_handler(scrn);
550+ glFinish();
551+#endif
552+
553+ info->gpu_flushed++;
554+}
555+
556 #else
557
558 static inline Bool radeon_glamor_pre_init(ScrnInfoPtr scrn) { return FALSE; }
559@@ -79,7 +100,7 @@ static inline void radeon_glamor_fini(ScreenPtr screen) { }
560 static inline Bool radeon_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; }
561 static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { }
562
563-static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { return TRUE; }
564+static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo) { return TRUE; }
565
566 static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {}
567 static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, PixmapPtr pixmap) { return pixmap; }
568@@ -87,6 +108,9 @@ static inline PixmapPtr radeon_glamor_set_pixmap_bo(DrawablePtr drawable, Pixmap
569 static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; }
570
571 static inline XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return NULL; }
572+
573+static inline void radeon_glamor_finish(ScrnInfoPtr pScrn) { }
574+
575 #endif
576
577 #endif /* RADEON_GLAMOR_H */
578diff --git a/src/radeon_kms.c b/src/radeon_kms.c
579index d3eeebea..72e60831 100644
580--- a/src/radeon_kms.c
581+++ b/src/radeon_kms.c
582@@ -212,6 +212,11 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn)
583 info->accel_state = NULL;
584 }
585
586+#ifdef USE_GLAMOR
587+ if (info->gbm)
588+ gbm_device_destroy(info->gbm);
589+#endif
590+
591 pEnt = info->pEnt;
592 free(pScrn->driverPrivate);
593 pScrn->driverPrivate = NULL;
594@@ -2269,7 +2274,11 @@ Bool RADEONScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)
595 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "radeon_setup_kernel_mem failed\n");
596 return FALSE;
597 }
598- front_ptr = info->front_buffer->bo.radeon->ptr;
599+
600+ if (!(info->front_buffer->flags & RADEON_BO_FLAGS_GBM))
601+ front_ptr = info->front_buffer->bo.radeon->ptr;
602+ else
603+ front_ptr = NULL;
604
605 if (info->r600_shadow_fb) {
606 info->fb_shadow = calloc(1,
607@@ -2739,21 +2748,24 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen)
608 ErrorF("Failed to map cursor buffer memory\n");
609 }
610 }
611+
612+ if (!info->use_glamor) {
613 #if X_BYTE_ORDER == X_BIG_ENDIAN
614- switch (cpp) {
615- case 4:
616- tiling_flags |= RADEON_TILING_SWAP_32BIT;
617- break;
618- case 2:
619- tiling_flags |= RADEON_TILING_SWAP_16BIT;
620- break;
621- }
622- if (info->ChipFamily < CHIP_FAMILY_R600 &&
623- info->r600_shadow_fb && tiling_flags)
624- tiling_flags |= RADEON_TILING_SURFACE;
625+ switch (cpp) {
626+ case 4:
627+ tiling_flags |= RADEON_TILING_SWAP_32BIT;
628+ break;
629+ case 2:
630+ tiling_flags |= RADEON_TILING_SWAP_16BIT;
631+ break;
632+ }
633+ if (info->ChipFamily < CHIP_FAMILY_R600 &&
634+ info->r600_shadow_fb && tiling_flags)
635+ tiling_flags |= RADEON_TILING_SURFACE;
636 #endif
637- if (tiling_flags)
638- radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
639+ if (tiling_flags)
640+ radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
641+ }
642 }
643
644 pScrn->displayWidth = pitch / cpp;
645commit 499d2f9d5d301ef1efd4ffc2952677609ef05122
646Author: Michel Dänzer <michel.daenzer@amd.com>
647Date: Tue Jul 17 11:43:12 2018 +0200
648
649 glamor: Invalidate cached GEM handle in radeon_set_pixmap_bo
650
651 We continued using the stale cached handle, causing issues e.g. when
652 resizing the screen via RandR.
653
654 Reported-by: iive on IRC
655 Acked-by: Alex Deucher <alexander.deucher@amd.com>
656
657diff --git a/src/radeon.h b/src/radeon.h
658index 450c69aa..1a1edb1b 100644
659--- a/src/radeon.h
660+++ b/src/radeon.h
661@@ -735,6 +735,7 @@ static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_buffer *bo
662 return TRUE;
663
664 radeon_buffer_unref(&priv->bo);
665+ priv->handle_valid = FALSE;
666 }
667
668 drmmode_fb_reference(pRADEONEnt->fd, &priv->fb, NULL);