Skip to contentSkip to conversation

libdrm/nouveau: Support nested bo mapping

PATCH New Luca Barbieri 1 participant 1 message Jan 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libdrm/nouveau: Support nested bo mapping

Most Gallium drivers support nested mapping by using a reference count. We don't, and swtnl fallback triggers an error due to this.

This patch adds this support in libdrm.

---
 nouveau/nouveau_bo.c      |    8 +++++++-
 nouveau/nouveau_private.h |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)
nouveau/nouveau_bo.c +7 -1
index 10cc8a6..c1a9843 100644
@@ -417,9 +417,12 @@ nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size,
 	struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
 	int ret;
 
-	if (!nvbo || bo->map)
+	if (!nvbo)
 		return -EINVAL;
 
+	if(nvbo->map_count++)
+		return 0;
+
 	if (!nouveau_bo_allocated(nvbo)) {
 		if (nvbo->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) {
 			ret = nouveau_bo_kalloc(nvbo, NULL);
@@ -470,6 +473,9 @@ nouveau_bo_unmap(struct nouveau_bo *bo)
 {
 	struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
 
+	if(--nvbo->map_count)
+		return 0;
+
 	if (bo->map && !nvbo->sysmem) {
 		struct nouveau_device_priv *nvdev = nouveau_device(bo->device);
 		struct drm_nouveau_gem_cpu_fini req;
nouveau/nouveau_private.h +1 -0
index 39758d1..512bc1e 100644
@@ -115,6 +115,7 @@ struct nouveau_bo_priv {
 	drm_handle_t handle;
 	uint64_t map_handle;
 	void *map;
+	unsigned map_count;
 
 	/* Last known information from kernel on buffer status */
 	int pinned;
Signature · 1 line
1.6.3.3