[PATCH] glamor: Prepare for GLAMOR_* flags being removed from xserver
From: Michel Dänzer michel.daen...@amd.com The behaviour will be the same when the flags are removed. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_glamor.c | 8 +++- src/radeon_glamor.h | 11 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index c49c7f6..e3633ce 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -327,11 +327,9 @@ radeon_glamor_init(ScreenPtr screen) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN | -#ifdef GLAMOR_NO_DRI3 -GLAMOR_NO_DRI3 | -#endif -GLAMOR_USE_SCREEN | GLAMOR_USE_PICTURE_SCREEN)) { + if (!glamor_init(screen, GLAMOR_USE_EGL_SCREEN | GLAMOR_USE_SCREEN | +GLAMOR_USE_PICTURE_SCREEN | GLAMOR_INVERTED_Y_AXIS | +GLAMOR_NO_DRI3)) { xf86DrvMsg(scrn-scrnIndex, X_ERROR, Failed to initialize glamor.\n); return FALSE; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 7cef1a9..a504acb 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -36,10 +36,21 @@ #include radeon_surface.h #ifndef GLAMOR_NO_DRI3 +#define GLAMOR_NO_DRI3 0 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap #define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd #endif +#ifndef GLAMOR_INVERTED_Y_AXIS +#define GLAMOR_INVERTED_Y_AXIS 0 +#endif +#ifndef GLAMOR_USE_SCREEN +#define GLAMOR_USE_SCREEN 0 +#endif +#ifndef GLAMOR_USE_PICTURE_SCREEN +#define GLAMOR_USE_PICTURE_SCREEN 0 +#endif + Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); Bool radeon_glamor_init(ScreenPtr screen); Bool radeon_glamor_create_screen_resources(ScreenPtr screen); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] Move radeon_drm_handler/abort_proc fields to drmmode_flipdata_rec v2
From: Michel Dänzer michel.daen...@amd.com Their values are the same for all DRM flip ioctl calls. v2: Adapt to v2 of patch 1 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 12 ++-- src/drmmode_display.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 74c5d1d..fd49805 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1846,7 +1846,7 @@ drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; if (flipdata-flip_count == 1) - flipcarrier-abort(scrn, flipdata-event_data); + flipdata-abort(scrn, flipdata-event_data); drmmode_flip_free(flipcarrier); } @@ -1867,9 +1867,9 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even if (flipdata-flip_count == 1) { /* Deliver cached msc, ust from reference crtc to flip event handler */ if (flipdata-event_data) - flipcarrier-handler(scrn, flipdata-fe_frame, -flipdata-fe_usec, -flipdata-event_data); + flipdata-handler(scrn, flipdata-fe_frame, + flipdata-fe_usec, + flipdata-event_data); /* Release framebuffer */ drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); @@ -2326,6 +2326,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-handler = handler; +flipdata-abort = abort; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2346,8 +2348,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, */ flipcarrier-dispatch_me = (drmmode_crtc-hw_id == ref_crtc_hw_id); flipcarrier-flipdata = flipdata; - flipcarrier-handler = handler; - flipcarrier-abort = abort; drm_queue = radeon_drm_queue_alloc(scrn, client, id, flipcarrier, diff --git a/src/drmmode_display.h b/src/drmmode_display.h index b3804ba..c6c076c 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -63,13 +63,13 @@ typedef struct { void *event_data; unsigned int fe_frame; uint64_t fe_usec; + radeon_drm_handler_proc handler; + radeon_drm_abort_proc abort; } drmmode_flipdata_rec, *drmmode_flipdata_ptr; typedef struct { drmmode_flipdata_ptr flipdata; Bool dispatch_me; - radeon_drm_handler_proc handler; - radeon_drm_abort_proc abort; } drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/3] Increase robustness against DRM page flip ioctl failures v2
From: Michel Dänzer michel.daen...@amd.com Centralize cleanup, only clean up things that have been allocated for the failed ioctl call. Fixes double-free after a flip ioctl failure. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89681 v2: Only call drmModeRmFB for flipdata-old_fb_id on receipt of last DRM page flip event. Fixes Black screen on making glxgears fullscreen with DRI3 enabled. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 46 +- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index f719f0c..35bbd9e 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1836,9 +1836,6 @@ drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) if (--flipdata-flip_count 0) return; - /* Release framebuffer */ - drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); - free(flipdata); } @@ -1867,10 +1864,16 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even flipdata-fe_usec = usec; } - /* Deliver cached msc, ust from reference crtc to flip event handler */ - if (flipdata-event_data flipdata-flip_count == 1) - flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, -flipdata-event_data); + if (flipdata-flip_count == 1) { + /* Deliver cached msc, ust from reference crtc to flip event handler */ + if (flipdata-event_data) + flipcarrier-handler(scrn, flipdata-fe_frame, +flipdata-fe_usec, +flipdata-event_data); + + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + } drmmode_flip_free(flipcarrier); } @@ -2276,10 +2279,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, unsigned int pitch; int i, old_fb_id; uint32_t tiling_flags = 0; - int height, emitted = 0; + int height; drmmode_flipdata_ptr flipdata; drmmode_flipevtcarrier_ptr flipcarrier = NULL; - struct radeon_drm_queue_entry *drm_queue = 0; + struct radeon_drm_queue_entry *drm_queue = NULL; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) @@ -2322,6 +2325,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2334,8 +2338,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - if (emitted == 0) - free(flipdata); goto error_undo; } @@ -2362,25 +2364,27 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - free(flipcarrier); - if (emitted == 0) - free(flipdata); goto error_undo; } - emitted++; + flipcarrier = NULL; + drm_queue = NULL; } - flipdata-old_fb_id = old_fb_id; - return TRUE; + if (flipdata-flip_count 0) + return TRUE; error_undo: + if (!flipdata || flipdata-flip_count = 1) { + drmModeRmFB(drmmode-fd, drmmode-fb_id); + drmmode-fb_id = old_fb_id; + } + if (drm_queue) radeon_drm_abort_entry(drm_queue); - else + else if (flipcarrier) drmmode_flip_abort(scrn, flipcarrier); - - drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + else + free(flipdata); error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/2] Move get_pixmap_handle helper to radeon_bo_helper.c
From: Michel Dänzer michel.daen...@amd.com No functional change. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_bo_helper.c | 49 ++ src/radeon_bo_helper.h | 3 +++ src/radeon_present.c | 53 +++--- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c index c3a2d63..f45aa76 100644 --- a/src/radeon_bo_helper.c +++ b/src/radeon_bo_helper.c @@ -25,6 +25,7 @@ #endif #include radeon.h +#include radeon_glamor.h #ifdef RADEON_PIXMAP_SHARING #include radeon_bo_gem.h @@ -187,6 +188,54 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, return bo; } +/* Get GEM handle for the pixmap */ +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)); +#endif + +if (bo) { + *handle = bo-handle; + return TRUE; +} + +#ifdef USE_GLAMOR +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd, r; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv-handle_valid) { + *handle = priv-handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (fd 0) + return FALSE; + + r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); + close(fd); + if (r == 0) { + priv-handle_valid = TRUE; + *handle = priv-handle; + return TRUE; + } +} +#endif + +return FALSE; +} + #ifdef RADEON_PIXMAP_SHARING Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p) diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h index 9c3d73f..89ad4be 100644 --- a/src/radeon_bo_helper.h +++ b/src/radeon_bo_helper.h @@ -29,6 +29,9 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, struct radeon_surface *new_surface, uint32_t *new_tiling); extern Bool +radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle); + +extern Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p); extern Bool diff --git a/src/radeon_present.c b/src/radeon_present.c index 711b45d..b402110 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include time.h #include errno.h +#include radeon_bo_helper.h #include radeon_glamor.h #include radeon_video.h @@ -217,54 +218,6 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) return NULL; } -static Bool -radeon_present_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)); -#endif - -if (bo) { - *handle = bo-handle; - return TRUE; -} - -#ifdef USE_GLAMOR -if (info-use_glamor) { - struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); - CARD16 stride; - CARD32 size; - int fd, r; - - if (!priv) { - priv = calloc(1, sizeof(*priv)); - radeon_set_pixmap_private(pixmap, priv); - } - - if (priv-handle_valid) { - *handle = priv-handle; - return TRUE; - } - - fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); - if (fd 0) - return FALSE; - - r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); - close(fd); - if (r == 0) { - priv-handle_valid = TRUE; - *handle = priv-handle; - return TRUE; - } -} -#endif - -return FALSE; -} - /* * Test to see if page flipping is possible on the target crtc */ @@ -340,7 +293,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, if (!radeon_present_check_flip(crtc, screen-root, pixmap, sync_flip)) return FALSE; -if (!radeon_present_get_pixmap_handle(pixmap, handle)) +if (!radeon_get_pixmap_handle(pixmap, handle)) return FALSE; event = calloc(1, sizeof(struct radeon_present_vblank_event)); @@ -374,7 +327,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) if (!radeon_present_check_flip(NULL, screen-root, pixmap, TRUE)) return; -if (!radeon_present_get_pixmap_handle(pixmap, handle)) +if (!radeon_get_pixmap_handle(pixmap, handle)) return; event = calloc(1, sizeof(struct radeon_present_vblank_event)); -- 2.1.4 ___ xorg-driver-ati mailing list
[PATCH 2/2] DRI2: Use radeon_get_pixmap_handle
From: Michel Dänzer michel.daen...@amd.com Now we can share pixmaps with no struct radeon_bo via DRI2. Fixes VDPAU video playback freezing when using an OpenGL compositor with DRI3 enabled. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89755 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 35 ++- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 2636456..edf643d 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -40,6 +40,7 @@ #include fcntl.h #include errno.h +#include radeon_bo_helper.h #include radeon_version.h #include radeon_list.h @@ -125,6 +126,26 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) return old; } +/* Get GEM flink name for a pixmap */ +static Bool +radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t *name) +{ +struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +struct drm_gem_flink flink; + +if (bo) + 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) + return FALSE; + + *name = flink.name; + return TRUE; +} + +return FALSE; +} static BufferPtr radeon_dri2_create_buffer2(ScreenPtr pScreen, @@ -137,7 +158,6 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, BufferPtr buffers; struct dri2_buffer_priv *privates; PixmapPtr pixmap, depth_pixmap; -struct radeon_bo *bo; int flags; unsigned front_width; uint32_t tiling = 0; @@ -171,10 +191,12 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, pixmap = depth_pixmap = NULL; if (attachment == DRI2BufferFrontLeft) { + uint32_t handle; + pixmap = get_drawable_pixmap(drawable); if (pScreen != pixmap-drawable.pScreen) pixmap = NULL; - else if (info-use_glamor !radeon_get_pixmap_bo(pixmap)) { + else if (info-use_glamor !radeon_get_pixmap_handle(pixmap, handle)) { is_glamor_pixmap = TRUE; aligned_width = pixmap-drawable.width; height = pixmap-drawable.height; @@ -285,8 +307,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, if (is_glamor_pixmap) pixmap = fixup_glamor(drawable, pixmap); - bo = radeon_get_pixmap_bo(pixmap); - if (!bo || radeon_gem_get_kernel_name(bo, buffers-name) != 0) + if (!radeon_get_flink_name(info, pixmap, buffers-name)) goto error; } @@ -657,20 +678,16 @@ radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client, static Bool update_front(DrawablePtr draw, DRI2BufferPtr front) { -int r; PixmapPtr pixmap; RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(draw-pScreen)); struct dri2_buffer_priv *priv = front-driverPrivate; -struct radeon_bo *bo; pixmap = get_drawable_pixmap(draw); pixmap-refcnt++; if (!info-use_glamor) exaMoveInPixmap(pixmap); -bo = radeon_get_pixmap_bo(pixmap); -r = radeon_gem_get_kernel_name(bo, front-name); -if (r) { +if (!radeon_get_flink_name(info, pixmap, front-name)) { (*draw-pScreen-DestroyPixmap)(pixmap); return FALSE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89772] xf86-video-ati-git unstable
https://bugs.freedesktop.org/show_bug.cgi?id=89772 --- Comment #2 from John john.etted...@gmail.com --- Created attachment 114636 -- https://bugs.freedesktop.org/attachment.cgi?id=114636action=edit Xorg log after Xorg restarted -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89772] xf86-video-ati-git unstable
https://bugs.freedesktop.org/show_bug.cgi?id=89772 --- Comment #1 from John john.etted...@gmail.com --- Created attachment 114635 -- https://bugs.freedesktop.org/attachment.cgi?id=114635action=edit dmesg after the restart of Xorg -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89772] xf86-video-ati-git unstable
https://bugs.freedesktop.org/show_bug.cgi?id=89772 --- Comment #3 from John john.etted...@gmail.com --- Created attachment 114637 -- https://bugs.freedesktop.org/attachment.cgi?id=114637action=edit Xorg log of the previous Xorg session, including the crash information -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89772] xf86-video-ati-git unstable
https://bugs.freedesktop.org/show_bug.cgi?id=89772 Michel Dänzer mic...@daenzer.net changed: What|Removed |Added CC|mic...@daenzer.net | --- Comment #4 from Michel Dänzer mic...@daenzer.net --- Does the patch from bug 89681 help? If not, can you get a backtrace of the crash with gdb, and double-check that the git bisect result is correct? It really doesn't make sense for that commit to be the culprit, in particular with DRI3 disabled. -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89681] X segfaults when switching virtual desktops of KDE
https://bugs.freedesktop.org/show_bug.cgi?id=89681 --- Comment #16 from Michel Dänzer mic...@daenzer.net --- Can one of you attach gdb to the Xorg process, set a breakpoint at the drmmode_display.c line printing the flip queue failed error message, trigger the breakpoint and get a backtrace? -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89681] X segfaults when switching virtual desktops of KDE
https://bugs.freedesktop.org/show_bug.cgi?id=89681 --- Comment #17 from Michel Dänzer mic...@daenzer.net --- (In reply to Michel Dänzer from comment #16) Can one of you attach gdb to the Xorg process, set a breakpoint at the drmmode_display.c line printing the flip queue failed error message, trigger the breakpoint and get a backtrace? Never mind, it'll be basically the same as in comment 4. -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[Bug 89772] xf86-video-ati-git unstable
https://bugs.freedesktop.org/show_bug.cgi?id=89772 --- Comment #5 from John john.etted...@gmail.com --- I got a crash in the commit I thought was safe, so I guess it's more randomized than I thought. I was fine for about an hour and then got it... The patch did not help either, although that other bug describes pretty much the behavior I am seeing (and I'm also using KDE if that matters). I'll try to find the correct git commit and then the backtrace. Thanks! -- You are receiving this mail because: You are the assignee for the bug. ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] Move radeon_drm_handler/abort_proc fields to drmmode_flipdata_rec
From: Michel Dänzer michel.daen...@amd.com Their values are the same for all DRM flip ioctl calls. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 10 +- src/drmmode_display.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index bd1ab76..be02a8b 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1846,7 +1846,7 @@ drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; if (flipdata-flip_count == 1) - flipcarrier-abort(scrn, flipdata-event_data); + flipdata-abort(scrn, flipdata-event_data); drmmode_flip_free(flipcarrier); } @@ -1866,8 +1866,8 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even /* Deliver cached msc, ust from reference crtc to flip event handler */ if (flipdata-event_data flipdata-flip_count == 1) - flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, -flipdata-event_data); + flipdata-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, + flipdata-event_data); /* Release framebuffer */ drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); @@ -2323,6 +2323,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-handler = handler; +flipdata-abort = abort; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2343,8 +2345,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, */ flipcarrier-dispatch_me = (drmmode_crtc-hw_id == ref_crtc_hw_id); flipcarrier-flipdata = flipdata; - flipcarrier-handler = handler; - flipcarrier-abort = abort; drm_queue = radeon_drm_queue_alloc(scrn, client, id, flipcarrier, diff --git a/src/drmmode_display.h b/src/drmmode_display.h index b3804ba..c6c076c 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -63,13 +63,13 @@ typedef struct { void *event_data; unsigned int fe_frame; uint64_t fe_usec; + radeon_drm_handler_proc handler; + radeon_drm_abort_proc abort; } drmmode_flipdata_rec, *drmmode_flipdata_ptr; typedef struct { drmmode_flipdata_ptr flipdata; Bool dispatch_me; - radeon_drm_handler_proc handler; - radeon_drm_abort_proc abort; } drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/3] Increase robustness against DRM page flip ioctl failures
From: Michel Dänzer michel.daen...@amd.com Centralize cleanup, only clean up things that have been allocated for the failed ioctl call. Fixes double-free after a flip ioctl failure. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89681 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index f719f0c..b8aaf64 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1836,9 +1836,6 @@ drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) if (--flipdata-flip_count 0) return; - /* Release framebuffer */ - drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); - free(flipdata); } @@ -1872,6 +1869,9 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, flipdata-event_data); + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + drmmode_flip_free(flipcarrier); } @@ -2276,10 +2276,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, unsigned int pitch; int i, old_fb_id; uint32_t tiling_flags = 0; - int height, emitted = 0; + int height; drmmode_flipdata_ptr flipdata; drmmode_flipevtcarrier_ptr flipcarrier = NULL; - struct radeon_drm_queue_entry *drm_queue = 0; + struct radeon_drm_queue_entry *drm_queue = NULL; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) @@ -2322,6 +2322,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2334,8 +2335,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - if (emitted == 0) - free(flipdata); goto error_undo; } @@ -2362,25 +2361,27 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - free(flipcarrier); - if (emitted == 0) - free(flipdata); goto error_undo; } - emitted++; + flipcarrier = NULL; + drm_queue = NULL; } - flipdata-old_fb_id = old_fb_id; - return TRUE; + if (flipdata-flip_count 0) + return TRUE; error_undo: + if (!flipdata || flipdata-flip_count = 1) { + drmModeRmFB(drmmode-fd, drmmode-fb_id); + drmmode-fb_id = old_fb_id; + } + if (drm_queue) radeon_drm_abort_entry(drm_queue); - else + else if (flipcarrier) drmmode_flip_abort(scrn, flipcarrier); - - drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + else + free(flipdata); error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/3] Simplify radeon_do_pageflip() error handling slightly more
From: Michel Dänzer michel.daen...@amd.com We don't need the local variable old_fb_id. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 33 - 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index b8aaf64..bd1ab76 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2274,7 +2274,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drmmode_crtc_private_ptr drmmode_crtc = config-crtc[0]-driver_private; drmmode_ptr drmmode = drmmode_crtc-drmmode; unsigned int pitch; - int i, old_fb_id; + int i; uint32_t tiling_flags = 0; int height; drmmode_flipdata_ptr flipdata; @@ -2295,21 +2295,22 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, pitch = info-front_surface.level[0].pitch_bytes; } +flipdata = calloc(1, sizeof(drmmode_flipdata_rec)); +if (!flipdata) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, +flip queue: data alloc failed.\n); + goto error; +} + /* * Create a new handle for the back buffer */ - old_fb_id = drmmode-fb_id; + flipdata-old_fb_id = drmmode-fb_id; if (drmModeAddFB(drmmode-fd, scrn-virtualX, height, scrn-depth, scrn-bitsPerPixel, pitch, new_front_handle, drmmode-fb_id)) - goto error_out; + goto error; -flipdata = calloc(1, sizeof(drmmode_flipdata_rec)); -if (!flipdata) { - xf86DrvMsg(scrn-scrnIndex, X_WARNING, -flip queue: data alloc failed.\n); - goto error_undo; -} /* * Queue flips on all enabled CRTCs * Note that if/when we get per-CRTC buffers, we'll have to update this. @@ -2322,7 +2323,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; -flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2335,7 +2335,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - goto error_undo; + goto error; } /* Only the reference crtc will finally deliver its page flip @@ -2353,7 +2353,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!drm_queue) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, Allocating DRM queue event entry failed.\n); - goto error_undo; + goto error; } if (drmModePageFlip(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, @@ -2361,7 +2361,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - goto error_undo; + goto error; } flipcarrier = NULL; drm_queue = NULL; @@ -2370,10 +2370,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (flipdata-flip_count 0) return TRUE; -error_undo: - if (!flipdata || flipdata-flip_count = 1) { +error: + if (flipdata flipdata-flip_count = 1) { drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + drmmode-fb_id = flipdata-old_fb_id; } if (drm_queue) @@ -2383,7 +2383,6 @@ error_undo: else free(flipdata); -error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, strerror(errno)); return FALSE; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati