From f1660c249198b5cc14ebbb75107da7bcb6972033 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 17 Dec 2009 13:07:18 +1000 Subject: nouveau: remove delayed kernel bo creation Signed-off-by: Ben Skeggs --- nouveau/nouveau_bo.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'nouveau') diff --git a/nouveau/nouveau_bo.c b/nouveau/nouveau_bo.c index ae11b689..10cc8a67 100644 --- a/nouveau/nouveau_bo.c +++ b/nouveau/nouveau_bo.c @@ -59,7 +59,7 @@ nouveau_bo_info(struct nouveau_bo_priv *nvbo, struct drm_nouveau_gem_info *arg) static int nouveau_bo_allocated(struct nouveau_bo_priv *nvbo) { - if (nvbo->sysmem || nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN)) + if (nvbo->sysmem || nvbo->handle) return 1; return 0; } @@ -116,7 +116,7 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan) struct drm_nouveau_gem_info *info = &req.info; int ret; - if (nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN)) + if (nvbo->handle) return 0; req.channel_hint = chan ? chan->id : 0; @@ -191,20 +191,24 @@ nouveau_bo_new_tile(struct nouveau_device *dev, uint32_t flags, int align, nvbo->base.tile_flags = tile_flags; nvbo->refcount = 1; - /* Don't set NOUVEAU_BO_PIN here, or nouveau_bo_allocated() will - * decided the buffer's already allocated when it's not. The - * call to nouveau_bo_pin() later will set this flag. - */ - nvbo->flags = (flags & ~NOUVEAU_BO_PIN); + nvbo->flags = flags; nvbo->size = size; nvbo->align = align; - if (flags & NOUVEAU_BO_PIN) { - ret = nouveau_bo_pin((void *)nvbo, nvbo->flags); + if (flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) { + ret = nouveau_bo_kalloc(nvbo, NULL); if (ret) { nouveau_bo_ref(NULL, (void *)nvbo); return ret; } + + if (flags & NOUVEAU_BO_PIN) { + ret = nouveau_bo_pin((void *)nvbo, nvbo->flags); + if (ret) { + nouveau_bo_ref(NULL, (void *)nvbo); + return ret; + } + } } *bo = &nvbo->base; @@ -489,25 +493,15 @@ nouveau_bo_pin(struct nouveau_bo *bo, uint32_t flags) if (nvbo->pinned) return 0; - /* Ensure we have a kernel object... */ - if (!nvbo->flags) { - if (!(flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART))) - return -EINVAL; - nvbo->flags = flags; - } - - if (!nvbo->handle) { - ret = nouveau_bo_kalloc(nvbo, NULL); - if (ret) - return ret; - } + if (!nvbo->handle) + return -EINVAL; /* Now force it to stay put :) */ req.handle = nvbo->handle; req.domain = 0; - if (nvbo->flags & NOUVEAU_BO_VRAM) + if (flags & NOUVEAU_BO_VRAM) req.domain |= NOUVEAU_GEM_DOMAIN_VRAM; - if (nvbo->flags & NOUVEAU_BO_GART) + if (flags & NOUVEAU_BO_GART) req.domain |= NOUVEAU_GEM_DOMAIN_GART; ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_PIN, &req, @@ -517,7 +511,6 @@ nouveau_bo_pin(struct nouveau_bo *bo, uint32_t flags) nvbo->offset = req.offset; nvbo->domain = req.domain; nvbo->pinned = 1; - nvbo->flags |= NOUVEAU_BO_PIN; /* Fill in public nouveau_bo members */ if (nvbo->domain & NOUVEAU_GEM_DOMAIN_VRAM) -- cgit v1.2.3