backend-drm: Retrieve reason if dmabuf import failed

As we could have situations where dmabuf import failed when attempting
to figure it the framebuffer is scanout-capable, make sure we also have
a way to store that information. Otherwise, we could end up
NULL-dereferencing, as we don't provide a valid storage for it.

Further more, with this, we also print out the reason why it failed, to
aid in further debugging.

Observed on platforms where GBM_BO_HANDLE failed + in combination w/
direct-display proto extension.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
dev
Marius Vlad 2 years ago
parent 8ebebb20ef
commit 7412a01437
  1. 7
      libweston/backend-drm/fb.c

@ -454,14 +454,15 @@ drm_can_scanout_dmabuf(struct weston_compositor *ec,
struct drm_fb *fb;
struct drm_backend *b = to_drm_backend(ec);
bool ret = false;
uint32_t try_reason = 0x0;
fb = drm_fb_get_from_dmabuf(dmabuf, b, true, NULL);
fb = drm_fb_get_from_dmabuf(dmabuf, b, true, &try_reason);
if (fb)
ret = true;
drm_fb_unref(fb);
drm_debug(b, "[dmabuf] dmabuf %p, import test %s\n", dmabuf,
ret ? "succeeded" : "failed");
drm_debug(b, "[dmabuf] dmabuf %p, import test %s, with reason 0x%x\n", dmabuf,
ret ? "succeeded" : "failed", try_reason);
return ret;
}

Loading…
Cancel
Save