aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancisco Jerez2010-10-30 19:22:29 -0500
committerFrancisco Jerez2010-10-30 20:09:59 -0500
commitd0a4f2e292e5b347f7e5ee2cdbe4f077986eb9da (patch)
treeb8da3cc292c2293d1fdab0b3c14de0f4b9f82232 /nouveau
parent362457715faacd3101929e5f0d8ae250d0ad09df (diff)
downloadlibdrm-d0a4f2e292e5b347f7e5ee2cdbe4f077986eb9da.tar.gz
libdrm-d0a4f2e292e5b347f7e5ee2cdbe4f077986eb9da.tar.xz
libdrm-d0a4f2e292e5b347f7e5ee2cdbe4f077986eb9da.zip
nouveau: Avoid unnecessary call to CPU_FINI.
nouveau_bo_unmap called the CPU_FINI IOCTL even if it was a NOSYNC mapping. It caused no harmful effects (actually CPU_FINI is a no-op on recent enough kernels) besides the precious CPU cycles being wasted. Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Diffstat (limited to 'nouveau')
-rw-r--r--nouveau/nouveau_bo.c5
-rw-r--r--nouveau/nouveau_private.h1
2 files changed, 5 insertions, 1 deletions
diff --git a/nouveau/nouveau_bo.c b/nouveau/nouveau_bo.c
index c1432b0b..d6bb22de 100644
--- a/nouveau/nouveau_bo.c
+++ b/nouveau/nouveau_bo.c
@@ -434,6 +434,8 @@ nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size,
434 (flags & NOUVEAU_BO_NOWAIT), 0); 434 (flags & NOUVEAU_BO_NOWAIT), 0);
435 if (ret) 435 if (ret)
436 return ret; 436 return ret;
437
438 nvbo->map_refcnt++;
437 } 439 }
438 440
439 bo->map = (char *)nvbo->map + delta; 441 bo->map = (char *)nvbo->map + delta;
@@ -458,13 +460,14 @@ nouveau_bo_unmap(struct nouveau_bo *bo)
458{ 460{
459 struct nouveau_bo_priv *nvbo = nouveau_bo(bo); 461 struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
460 462
461 if (bo->map && !nvbo->sysmem) { 463 if (bo->map && !nvbo->sysmem && nvbo->map_refcnt) {
462 struct nouveau_device_priv *nvdev = nouveau_device(bo->device); 464 struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
463 struct drm_nouveau_gem_cpu_fini req; 465 struct drm_nouveau_gem_cpu_fini req;
464 466
465 req.handle = nvbo->handle; 467 req.handle = nvbo->handle;
466 drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_FINI, 468 drmCommandWrite(nvdev->fd, DRM_NOUVEAU_GEM_CPU_FINI,
467 &req, sizeof(req)); 469 &req, sizeof(req));
470 nvbo->map_refcnt--;
468 } 471 }
469 472
470 bo->map = NULL; 473 bo->map = NULL;
diff --git a/nouveau/nouveau_private.h b/nouveau/nouveau_private.h
index 4c535345..124fe870 100644
--- a/nouveau/nouveau_private.h
+++ b/nouveau/nouveau_private.h
@@ -115,6 +115,7 @@ struct nouveau_bo_priv {
115 uint32_t global_handle; 115 uint32_t global_handle;
116 drm_handle_t handle; 116 drm_handle_t handle;
117 uint64_t map_handle; 117 uint64_t map_handle;
118 int map_refcnt;
118 void *map; 119 void *map;
119 120
120 /* Last known information from kernel on buffer status */ 121 /* Last known information from kernel on buffer status */