xf86-video-ati: Branch 'master' - 5 commits
Michel Dänzer
daenzer at kemper.freedesktop.org
Sun Mar 29 19:15:39 PDT 2015
src/drmmode_display.c | 79 +++++++++++++++++++++++++------------------------
src/drmmode_display.h | 4 +-
src/radeon_bo_helper.c | 49 ++++++++++++++++++++++++++++++
src/radeon_bo_helper.h | 3 +
src/radeon_dri2.c | 35 ++++++++++++++++-----
src/radeon_present.c | 53 +-------------------------------
6 files changed, 124 insertions(+), 99 deletions(-)
New commits:
commit f8b0f23e9f4af9f9097ee5e72d53b45173163c41
Author: Michel Dänzer <michel.daenzer at amd.com>
Date: Fri Mar 27 12:34:55 2015 +0900
DRI2: Use radeon_get_pixmap_handle
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
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Tested-by: Nick Sarnie <commendsarnex at gmail.com>
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;
}
commit ccbda955ebae1d457d35293833f12791e0f9fb0b
Author: Michel Dänzer <michel.daenzer at amd.com>
Date: Fri Mar 27 12:16:44 2015 +0900
Move get_pixmap_handle helper to radeon_bo_helper.c
No functional change.
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Tested-by: Nick Sarnie <commendsarnex at gmail.com>
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));
commit de5ddd09db82141b263338dcf0c28e01f58268ee
Author: Michel Dänzer <michel.daenzer at amd.com>
Date: Thu Mar 26 16:33:02 2015 +0900
Move radeon_drm_handler/abort_proc fields to drmmode_flipdata_rec
Their values are the same for all DRM flip ioctl calls within a single
radeon_do_pageflip() call.
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 285e7b4..e81c6d4 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 {
commit e8c0f6319fbf4c3ea11e22ab1a68837031bdec8c
Author: Michel Dänzer <michel.daenzer at amd.com>
Date: Thu Mar 26 16:27:35 2015 +0900
Simplify radeon_do_pageflip() error handling slightly more
We don't need the local variable old_fb_id.
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index cad0bc3..285e7b4 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2277,7 +2277,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;
@@ -2298,21 +2298,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.
@@ -2325,7 +2326,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)
@@ -2338,7 +2338,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
@@ -2356,7 +2356,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,
@@ -2364,7 +2364,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;
@@ -2373,10 +2373,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)
@@ -2386,7 +2386,6 @@ error_undo:
else if (flipdata && flipdata->flip_count <= 1)
free(flipdata);
-error_out:
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Page flip failed: %s\n",
strerror(errno));
return FALSE;
commit 8fc22360d5520469c82092ccb0fcf2af330c573f
Author: Michel Dänzer <michel.daenzer at amd.com>
Date: Thu Mar 26 15:58:01 2015 +0900
Increase robustness against DRM page flip ioctl failures v3
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.
v3: Avoid double-free of flipdata in the unlikely case that calloc fails
for flipcarrier, but only for the second or later CRTC.
Reviewed-by: Alex Deucher <alexander.deucher at amd.com> (v2)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index f719f0c..cad0bc3 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 if (flipdata && flipdata->flip_count <= 1)
+ free(flipdata);
error_out:
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Page flip failed: %s\n",
More information about the xorg-commit
mailing list