nouveau: remove delayed kernel bo creation

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
main
Ben Skeggs 2009-12-17 13:07:18 +10:00
parent fbc8b2d95f
commit f1660c2491
1 changed files with 17 additions and 24 deletions

View File

@ -59,7 +59,7 @@ nouveau_bo_info(struct nouveau_bo_priv *nvbo, struct drm_nouveau_gem_info *arg)
static int static int
nouveau_bo_allocated(struct nouveau_bo_priv *nvbo) 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 1;
return 0; 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; struct drm_nouveau_gem_info *info = &req.info;
int ret; int ret;
if (nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN)) if (nvbo->handle)
return 0; return 0;
req.channel_hint = chan ? chan->id : 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->base.tile_flags = tile_flags;
nvbo->refcount = 1; nvbo->refcount = 1;
/* Don't set NOUVEAU_BO_PIN here, or nouveau_bo_allocated() will nvbo->flags = flags;
* 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->size = size; nvbo->size = size;
nvbo->align = align; nvbo->align = align;
if (flags & NOUVEAU_BO_PIN) { if (flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) {
ret = nouveau_bo_pin((void *)nvbo, nvbo->flags); ret = nouveau_bo_kalloc(nvbo, NULL);
if (ret) { if (ret) {
nouveau_bo_ref(NULL, (void *)nvbo); nouveau_bo_ref(NULL, (void *)nvbo);
return ret; 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; *bo = &nvbo->base;
@ -489,25 +493,15 @@ nouveau_bo_pin(struct nouveau_bo *bo, uint32_t flags)
if (nvbo->pinned) if (nvbo->pinned)
return 0; return 0;
/* Ensure we have a kernel object... */ if (!nvbo->handle)
if (!nvbo->flags) { return -EINVAL;
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;
}
/* Now force it to stay put :) */ /* Now force it to stay put :) */
req.handle = nvbo->handle; req.handle = nvbo->handle;
req.domain = 0; req.domain = 0;
if (nvbo->flags & NOUVEAU_BO_VRAM) if (flags & NOUVEAU_BO_VRAM)
req.domain |= NOUVEAU_GEM_DOMAIN_VRAM; req.domain |= NOUVEAU_GEM_DOMAIN_VRAM;
if (nvbo->flags & NOUVEAU_BO_GART) if (flags & NOUVEAU_BO_GART)
req.domain |= NOUVEAU_GEM_DOMAIN_GART; req.domain |= NOUVEAU_GEM_DOMAIN_GART;
ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_PIN, &req, 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->offset = req.offset;
nvbo->domain = req.domain; nvbo->domain = req.domain;
nvbo->pinned = 1; nvbo->pinned = 1;
nvbo->flags |= NOUVEAU_BO_PIN;
/* Fill in public nouveau_bo members */ /* Fill in public nouveau_bo members */
if (nvbo->domain & NOUVEAU_GEM_DOMAIN_VRAM) if (nvbo->domain & NOUVEAU_GEM_DOMAIN_VRAM)