aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs2009-12-16 21:07:18 -0600
committerBen Skeggs2009-12-16 21:07:18 -0600
commitf1660c249198b5cc14ebbb75107da7bcb6972033 (patch)
tree487af78a5f79dbdbe939f3119e288601c5ad3f54 /nouveau
parentfbc8b2d95f5da096ee771a3e2ef6f89306679e89 (diff)
downloadlibdrm-f1660c249198b5cc14ebbb75107da7bcb6972033.tar.gz
libdrm-f1660c249198b5cc14ebbb75107da7bcb6972033.tar.xz
libdrm-f1660c249198b5cc14ebbb75107da7bcb6972033.zip
nouveau: remove delayed kernel bo creation
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'nouveau')
-rw-r--r--nouveau/nouveau_bo.c41
1 files changed, 17 insertions, 24 deletions
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)
59static int 59static int
60nouveau_bo_allocated(struct nouveau_bo_priv *nvbo) 60nouveau_bo_allocated(struct nouveau_bo_priv *nvbo)
61{ 61{
62 if (nvbo->sysmem || nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN)) 62 if (nvbo->sysmem || nvbo->handle)
63 return 1; 63 return 1;
64 return 0; 64 return 0;
65} 65}
@@ -116,7 +116,7 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan)
116 struct drm_nouveau_gem_info *info = &req.info; 116 struct drm_nouveau_gem_info *info = &req.info;
117 int ret; 117 int ret;
118 118
119 if (nvbo->handle || (nvbo->flags & NOUVEAU_BO_PIN)) 119 if (nvbo->handle)
120 return 0; 120 return 0;
121 121
122 req.channel_hint = chan ? chan->id : 0; 122 req.channel_hint = chan ? chan->id : 0;
@@ -191,20 +191,24 @@ nouveau_bo_new_tile(struct nouveau_device *dev, uint32_t flags, int align,
191 nvbo->base.tile_flags = tile_flags; 191 nvbo->base.tile_flags = tile_flags;
192 192
193 nvbo->refcount = 1; 193 nvbo->refcount = 1;
194 /* Don't set NOUVEAU_BO_PIN here, or nouveau_bo_allocated() will 194 nvbo->flags = flags;
195 * decided the buffer's already allocated when it's not. The
196 * call to nouveau_bo_pin() later will set this flag.
197 */
198 nvbo->flags = (flags & ~NOUVEAU_BO_PIN);
199 nvbo->size = size; 195 nvbo->size = size;
200 nvbo->align = align; 196 nvbo->align = align;
201 197
202 if (flags & NOUVEAU_BO_PIN) { 198 if (flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) {
203 ret = nouveau_bo_pin((void *)nvbo, nvbo->flags); 199 ret = nouveau_bo_kalloc(nvbo, NULL);
204 if (ret) { 200 if (ret) {
205 nouveau_bo_ref(NULL, (void *)nvbo); 201 nouveau_bo_ref(NULL, (void *)nvbo);
206 return ret; 202 return ret;
207 } 203 }
204
205 if (flags & NOUVEAU_BO_PIN) {
206 ret = nouveau_bo_pin((void *)nvbo, nvbo->flags);
207 if (ret) {
208 nouveau_bo_ref(NULL, (void *)nvbo);
209 return ret;
210 }
211 }
208 } 212 }
209 213
210 *bo = &nvbo->base; 214 *bo = &nvbo->base;
@@ -489,25 +493,15 @@ nouveau_bo_pin(struct nouveau_bo *bo, uint32_t flags)
489 if (nvbo->pinned) 493 if (nvbo->pinned)
490 return 0; 494 return 0;
491 495
492 /* Ensure we have a kernel object... */ 496 if (!nvbo->handle)
493 if (!nvbo->flags) { 497 return -EINVAL;
494 if (!(flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)))
495 return -EINVAL;
496 nvbo->flags = flags;
497 }
498
499 if (!nvbo->handle) {
500 ret = nouveau_bo_kalloc(nvbo, NULL);
501 if (ret)
502 return ret;
503 }
504 498
505 /* Now force it to stay put :) */ 499 /* Now force it to stay put :) */
506 req.handle = nvbo->handle; 500 req.handle = nvbo->handle;
507 req.domain = 0; 501 req.domain = 0;
508 if (nvbo->flags & NOUVEAU_BO_VRAM) 502 if (flags & NOUVEAU_BO_VRAM)
509 req.domain |= NOUVEAU_GEM_DOMAIN_VRAM; 503 req.domain |= NOUVEAU_GEM_DOMAIN_VRAM;
510 if (nvbo->flags & NOUVEAU_BO_GART) 504 if (flags & NOUVEAU_BO_GART)
511 req.domain |= NOUVEAU_GEM_DOMAIN_GART; 505 req.domain |= NOUVEAU_GEM_DOMAIN_GART;
512 506
513 ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_PIN, &req, 507 ret = drmCommandWriteRead(nvdev->fd, DRM_NOUVEAU_GEM_PIN, &req,
@@ -517,7 +511,6 @@ nouveau_bo_pin(struct nouveau_bo *bo, uint32_t flags)
517 nvbo->offset = req.offset; 511 nvbo->offset = req.offset;
518 nvbo->domain = req.domain; 512 nvbo->domain = req.domain;
519 nvbo->pinned = 1; 513 nvbo->pinned = 1;
520 nvbo->flags |= NOUVEAU_BO_PIN;
521 514
522 /* Fill in public nouveau_bo members */ 515 /* Fill in public nouveau_bo members */
523 if (nvbo->domain & NOUVEAU_GEM_DOMAIN_VRAM) 516 if (nvbo->domain & NOUVEAU_GEM_DOMAIN_VRAM)