From c9003c6d9602dba682e577ea7ce39990ea378db3 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 11 Jun 2014 15:29:59 +0100 Subject: sna: Fix scanout creation routine for old kernels <= 3.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With an old kernel, we would fail to actually mark the display as part of the scanout domain, but proceed to assign it a fb id. This caused our asserts to report our bookkeeping error. Reported-by: Pavel Ondračka Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79909 Signed-off-by: Chris Wilson --- src/sna/kgem.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index f29f8fd1..7582e075 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -4373,18 +4373,23 @@ static void __kgem_bo_make_scanout(struct kgem *kgem, arg.depth = scrn->depth; arg.handle = bo->handle; - if (gem_set_caching(kgem->fd, bo->handle, DISPLAY)) { - bo->scanout = true; + /* First move the scanout out of cached memory */ + if (kgem->has_llc) { + if (!gem_set_caching(kgem->fd, bo->handle, DISPLAY) && + !gem_set_caching(kgem->fd, bo->handle, UNCACHED)) + return; + } - /* Pre-emptively move the object into the mappable - * portion to avoid rebinding later when busy. - */ - if (bo->map__gtt == NULL) - bo->map__gtt = __kgem_bo_map__gtt(kgem, bo); - if (bo->map__gtt) { - *(uint32_t *)bo->map__gtt = 0; - bo->domain = DOMAIN_GTT; - } + bo->scanout = true; + + /* Then pre-emptively move the object into the mappable + * portion to avoid rebinding later when busy. + */ + if (bo->map__gtt == NULL) + bo->map__gtt = __kgem_bo_map__gtt(kgem, bo); + if (bo->map__gtt) { + *(uint32_t *)bo->map__gtt = 0; + bo->domain = DOMAIN_GTT; } if (do_ioctl(kgem->fd, DRM_IOCTL_MODE_ADDFB, &arg) == 0) { -- cgit v1.2.3