On 3 March 2017 at 23:05, Daniel Stone <dani...@collabora.com> wrote: > From: Tomohito Esaki <e...@igel.co.jp> > > The drm_fb destroy callback to mostly the same thing regardless of > whether the buffer is a dumb buffer or gbm buffer. This patch refactors > the common parts into a new function that can be called for both cases. > > [daniels: Rebased on top of fb->fd changes, cosmetic changes.] > > Differential Revision: https://phabricator.freedesktop.org/D1489 > > Signed-off-by: Tomohito Esaki <e...@igel.co.jp> > Signed-off-by: Daniel Stone <dani...@collabora.com> > Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk> > --- > libweston/compositor-drm.c | 60 > ++++++++++++++++++++++------------------------ > 1 file changed, 29 insertions(+), 31 deletions(-) > > v9: Add type asserts, don't pointlessly accept NULL. (Pekka) > > diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c > index 0d17859..b21b67a 100644 > --- a/libweston/compositor-drm.c > +++ b/libweston/compositor-drm.c > @@ -286,16 +286,38 @@ drm_output_find_by_connector(struct drm_backend *b, > uint32_t connector_id) > } > > static void > -drm_fb_destroy_callback(struct gbm_bo *bo, void *data) > +drm_fb_destroy(struct drm_fb *fb) > { > - struct drm_fb *fb = data; > - > - if (fb->fb_id) > + if (fb->fb_id != 0) > drmModeRmFB(fb->fd, fb->fb_id); > - > weston_buffer_reference(&fb->buffer_ref, NULL); > + free(fb); > +} > + > +static void > +drm_fb_destroy_dumb(struct drm_fb *fb) > +{ > + struct drm_mode_destroy_dumb destroy_arg; > + > + assert(fb->type == BUFFER_PIXMAN_DUMB); > + > + if (fb->map && fb->size > 0) > + munmap(fb->map, fb->size); > + > + memset(&destroy_arg, 0, sizeof(destroy_arg)); > + destroy_arg.handle = fb->handle; > + drmIoctl(fb->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_arg); > + > + drm_fb_destroy(fb);
Things looks wrong here. Afaict we should unmap, rmfb ('detach' for dumb) and then dumb_destroy. See the drm_fb_create_dumb() error path - perhaps we can drop that in favour of the updated drm_fb_destroy_dumb() ? Not sure where exactly weston_buffer_reference() should be though :-\ -Emil _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel