This can fail at least if the caller is not in DRM master mode and leak the corresponding FB object. So it's better to be verbose about it. Signed-off-by: Imre Deak <imre.deak at intel.com> --- src/intel_display.c | 25 ++++++++++++++++++------- src/sna/sna_video.c | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/intel_display.c b/src/intel_display.c index 6dfc8e6..6dd4556 100644 --- a/src/intel_display.c +++ b/src/intel_display.c @@ -630,6 +630,16 @@ intel_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) return rotate_pixmap; } +static void remove_drm_fb(int scrnIndex, int drm_fd, int fb_id) +{ + int err; + + err = drmModeRmFB(drm_fd, fb_id); + if (err) + xf86DrvMsg(scrnIndex, X_ERROR, + "Couldn't remove DRM framebuffer (%d)\n", err); +} + static void intel_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) { @@ -646,7 +656,8 @@ intel_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) if (data) { /* Be sure to sync acceleration before the memory gets * unbound. */ - drmModeRmFB(mode->fd, intel_crtc->rotate_fb_id); + remove_drm_fb(scrn->scrnIndex, mode->fd, + intel_crtc->rotate_fb_id); intel_crtc->rotate_fb_id = 0; dri_bo_unreference(intel_crtc->rotate_bo); @@ -1464,7 +1475,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) intel_uxa_create_screen_resources(scrn->pScreen); if (old_fb_id) - drmModeRmFB(mode->fd, old_fb_id); + remove_drm_fb(scrn->scrnIndex, mode->fd, old_fb_id); if (old_front) drm_intel_bo_unreference(old_front); @@ -1478,7 +1489,7 @@ fail: scrn->virtualY = old_height; scrn->displayWidth = old_pitch; if (old_fb_id != mode->fb_id) - drmModeRmFB(mode->fd, mode->fb_id); + remove_drm_fb(scrn->scrnIndex, mode->fd, mode->fb_id); mode->fb_id = old_fb_id; return FALSE; @@ -1559,7 +1570,7 @@ intel_do_pageflip(intel_screen_private *intel, return TRUE; error_undo: - drmModeRmFB(mode->fd, mode->fb_id); + remove_drm_fb(scrn->scrnIndex, mode->fd, mode->fb_id); mode->fb_id = old_fb_id; error_out: @@ -1601,7 +1612,7 @@ intel_page_flip_handler(int fd, unsigned int frame, unsigned int tv_sec, return; /* Release framebuffer */ - drmModeRmFB(mode->fd, mode->old_fb_id); + remove_drm_fb(0, mode->fd, mode->old_fb_id); if (mode->flip_info == NULL) return; @@ -1704,7 +1715,7 @@ intel_mode_remove_fb(intel_screen_private *intel) struct intel_mode *mode = intel->modes; if (mode->fb_id) { - drmModeRmFB(mode->fd, mode->fb_id); + remove_drm_fb(intel->scrn->scrnIndex, mode->fd, mode->fb_id); mode->fb_id = 0; } } @@ -1727,7 +1738,7 @@ intel_mode_fini(intel_screen_private *intel) } if (mode->fb_id) - drmModeRmFB(mode->fd, mode->fb_id); + remove_drm_fb(intel->scrn->scrnIndex, mode->fd, mode->fb_id); /* mode->rotate_fb_id should have been destroyed already */ diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index b8690ec..8f3f662 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -74,6 +74,16 @@ static inline bool sna_video_xvmc_setup(struct sna *sna, } #endif +static void remove_drm_fb(int scrnIndex, int drm_fd, int fb_id) +{ + int err; + + err = drmModeRmFB(drm_fd, fb_id); + if (err) + xf86DrvMsg(scrnIndex, X_ERROR, + "Couldn't remove DRM framebuffer (%d)\n", err); +} + void sna_video_free_buffers(struct sna *sna, struct sna_video *video) { unsigned int i; @@ -81,7 +91,7 @@ void sna_video_free_buffers(struct sna *sna, struct sna_video *video) for (i = 0; i < ARRAY_SIZE(video->old_buf); i++) { if (video->old_buf[i]) { if (video->old_buf[i]->unique_id) - drmModeRmFB(sna->kgem.fd, + remove_drm_fb(sna->scrn->scrnIndex, sna->kgem.fd, video->old_buf[i]->unique_id); kgem_bo_destroy(&sna->kgem, video->old_buf[i]); video->old_buf[i] = NULL; @@ -90,7 +100,8 @@ void sna_video_free_buffers(struct sna *sna, struct sna_video *video) if (video->buf) { if (video->buf->unique_id) - drmModeRmFB(sna->kgem.fd, video->buf->unique_id); + remove_drm_fb(sna->scrn->scrnIndex, sna->kgem.fd, + video->buf->unique_id); kgem_bo_destroy(&sna->kgem, video->buf); video->buf = NULL; } -- 1.7.9.5