Re: [Nouveau] [PATCH v2 2/4] drm/nouveau: propagate errors from vm flushes

2012-05-27 Thread Marcin Slusarz
From: Marcin Slusarz marcin.slus...@gmail.com
Subject: [PATCH v3] drm/nouveau: propagate errors from vm flushes

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
v3: rebased on top of current nouveau-git
---
 drivers/gpu/drm/nouveau/nouveau_bo.c   |9 +++--
 drivers/gpu/drm/nouveau/nouveau_drv.h  |2 +-
 drivers/gpu/drm/nouveau/nouveau_fifo.h |2 +-
 drivers/gpu/drm/nouveau/nouveau_vm.c   |   20 ++--
 drivers/gpu/drm/nouveau/nouveau_vm.h   |   20 ++--
 drivers/gpu/drm/nouveau/nv50_fifo.c|4 ++--
 drivers/gpu/drm/nouveau/nv50_graph.c   |   12 
 drivers/gpu/drm/nouveau/nv50_mpeg.c|4 ++--
 drivers/gpu/drm/nouveau/nv50_vm.c  |   16 
 drivers/gpu/drm/nouveau/nv84_crypt.c   |4 ++--
 drivers/gpu/drm/nouveau/nv98_crypt.c   |4 ++--
 drivers/gpu/drm/nouveau/nva3_copy.c|4 ++--
 drivers/gpu/drm/nouveau/nvc0_vm.c  |   14 +++---
 13 files changed, 70 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index ab15f5e..f30a75a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1427,10 +1427,15 @@ nouveau_bo_vma_add(struct nouveau_bo *nvbo, struct 
nouveau_vm *vm,
return ret;
 
if (nvbo-bo.mem.mem_type == TTM_PL_VRAM)
-   nouveau_vm_map(vma, nvbo-bo.mem.mm_node);
+   ret = nouveau_vm_map(vma, nvbo-bo.mem.mm_node);
else
if (nvbo-bo.mem.mem_type == TTM_PL_TT)
-   nouveau_vm_map_sg(vma, 0, size, node);
+   ret = nouveau_vm_map_sg(vma, 0, size, node);
+
+   if (ret) {
+   nouveau_vm_put(vma);
+   return ret;
+   }
 
list_add_tail(vma-head, nvbo-vma_list);
vma-refcount = 1;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
b/drivers/gpu/drm/nouveau/nouveau_drv.h
index b800c79..c1539b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -125,7 +125,7 @@ struct nouveau_engine {
int  (*object_new)(struct nouveau_channel *, int engine,
   u32 handle, u16 class);
void (*set_tile_region)(struct nouveau_device *, int i);
-   void (*tlb_flush)(struct nouveau_device *, int engine);
+   int  (*tlb_flush)(struct nouveau_device *, int engine);
 };
 
 #define nouveau_engine_create(ndev,engine,sstr,fstr,data)  
\
diff --git a/drivers/gpu/drm/nouveau/nouveau_fifo.h 
b/drivers/gpu/drm/nouveau/nouveau_fifo.h
index 13a96ef..c2fb136 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fifo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fifo.h
@@ -20,7 +20,7 @@ void nv04_fifo_ramht(struct nouveau_device *, struct 
nouveau_ramht **);
 
 void nv50_fifo_playlist_update(struct nouveau_device *);
 void nv50_fifo_destroy(struct nouveau_device *, int);
-void nv50_fifo_tlb_flush(struct nouveau_device *, int);
+int  nv50_fifo_tlb_flush(struct nouveau_device *, int);
 
 int  nv04_fifo_create(struct nouveau_device *, int engine);
 int  nv10_fifo_create(struct nouveau_device *, int engine);
diff --git a/drivers/gpu/drm/nouveau/nouveau_vm.c 
b/drivers/gpu/drm/nouveau/nouveau_vm.c
index 2678a0b7..e3cd453 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vm.c
@@ -29,7 +29,7 @@
 #include nouveau_vm.h
 #include nouveau_gpuobj.h
 
-void
+int
 nouveau_vm_map_at(struct nouveau_vma *vma, u64 delta, struct nouveau_mem *node)
 {
struct nouveau_vm *vm = vma-vm;
@@ -69,16 +69,16 @@ nouveau_vm_map_at(struct nouveau_vma *vma, u64 delta, 
struct nouveau_mem *node)
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_map(struct nouveau_vma *vma, struct nouveau_mem *node)
 {
-   nouveau_vm_map_at(vma, 0, node);
+   return nouveau_vm_map_at(vma, 0, node);
 }
 
-void
+int
 nouveau_vm_map_sg(struct nouveau_vma *vma, u64 delta, u64 length,
  struct nouveau_mem *mem)
 {
@@ -112,10 +112,10 @@ nouveau_vm_map_sg(struct nouveau_vma *vma, u64 delta, u64 
length,
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_unmap_at(struct nouveau_vma *vma, u64 delta, u64 length)
 {
struct nouveau_vm *vm = vma-vm;
@@ -146,13 +146,13 @@ nouveau_vm_unmap_at(struct nouveau_vma *vma, u64 delta, 
u64 length)
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_unmap(struct nouveau_vma *vma)
 {
-   nouveau_vm_unmap_at(vma, 0, (u64)vma-node-length  12);
+   return nouveau_vm_unmap_at(vma, 0, (u64)vma-node-length  12);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_vm.h 
b/drivers/gpu/drm/nouveau/nouveau_vm.h
index 93a975e..f3bd0a5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_vm.h
@@ -73,7 +73,7 @@ struct nouveau_vm {
  

[Nouveau] [PATCH v2 2/4] drm/nouveau: propagate errors from vm flushes

2012-04-25 Thread Marcin Slusarz
We need this for lockup recovery.

Signed-off-by: Marcin Slusarz marcin.slus...@gmail.com
---
 drivers/gpu/drm/nouveau/nouveau_bo.c  |9 +++--
 drivers/gpu/drm/nouveau/nouveau_drv.h |6 +++---
 drivers/gpu/drm/nouveau/nouveau_vm.c  |   20 ++--
 drivers/gpu/drm/nouveau/nouveau_vm.h  |   18 +-
 drivers/gpu/drm/nouveau/nv50_fifo.c   |4 ++--
 drivers/gpu/drm/nouveau/nv50_graph.c  |   12 
 drivers/gpu/drm/nouveau/nv50_mpeg.c   |4 ++--
 drivers/gpu/drm/nouveau/nv50_vm.c |   30 --
 drivers/gpu/drm/nouveau/nv84_crypt.c  |4 ++--
 drivers/gpu/drm/nouveau/nva3_copy.c   |4 ++--
 drivers/gpu/drm/nouveau/nvc0_vm.c |3 ++-
 11 files changed, 67 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 638ae32..5b0dc50 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1230,10 +1230,15 @@ nouveau_bo_vma_add(struct nouveau_bo *nvbo, struct 
nouveau_vm *vm,
return ret;
 
if (nvbo-bo.mem.mem_type == TTM_PL_VRAM)
-   nouveau_vm_map(vma, nvbo-bo.mem.mm_node);
+   ret = nouveau_vm_map(vma, nvbo-bo.mem.mm_node);
else
if (nvbo-bo.mem.mem_type == TTM_PL_TT)
-   nouveau_vm_map_sg(vma, 0, size, node);
+   ret = nouveau_vm_map_sg(vma, 0, size, node);
+
+   if (ret) {
+   nouveau_vm_put(vma);
+   return ret;
+   }
 
list_add_tail(vma-head, nvbo-vma_list);
vma-refcount = 1;
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h 
b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 2f8e80a..d120baf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -320,7 +320,7 @@ struct nouveau_exec_engine {
int  (*object_new)(struct nouveau_channel *, int engine,
   u32 handle, u16 class);
void (*set_tile_region)(struct drm_device *dev, int i);
-   void (*tlb_flush)(struct drm_device *, int engine);
+   int (*tlb_flush)(struct drm_device *, int engine);
 };
 
 struct nouveau_instmem_engine {
@@ -387,7 +387,7 @@ struct nouveau_fifo_engine {
void (*destroy_context)(struct nouveau_channel *);
int  (*load_context)(struct nouveau_channel *);
int  (*unload_context)(struct drm_device *);
-   void (*tlb_flush)(struct drm_device *dev);
+   int  (*tlb_flush)(struct drm_device *dev);
 };
 
 struct nouveau_display_engine {
@@ -1246,7 +1246,7 @@ extern int  nv50_fifo_create_context(struct 
nouveau_channel *);
 extern void nv50_fifo_destroy_context(struct nouveau_channel *);
 extern int  nv50_fifo_load_context(struct nouveau_channel *);
 extern int  nv50_fifo_unload_context(struct drm_device *);
-extern void nv50_fifo_tlb_flush(struct drm_device *dev);
+extern int  nv50_fifo_tlb_flush(struct drm_device *dev);
 
 /* nvc0_fifo.c */
 extern int  nvc0_fifo_init(struct drm_device *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_vm.c 
b/drivers/gpu/drm/nouveau/nouveau_vm.c
index 2bf6c03..e2d4853 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vm.c
@@ -27,7 +27,7 @@
 #include nouveau_mm.h
 #include nouveau_vm.h
 
-void
+int
 nouveau_vm_map_at(struct nouveau_vma *vma, u64 delta, struct nouveau_mem *node)
 {
struct nouveau_vm *vm = vma-vm;
@@ -67,16 +67,16 @@ nouveau_vm_map_at(struct nouveau_vma *vma, u64 delta, 
struct nouveau_mem *node)
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_map(struct nouveau_vma *vma, struct nouveau_mem *node)
 {
-   nouveau_vm_map_at(vma, 0, node);
+   return nouveau_vm_map_at(vma, 0, node);
 }
 
-void
+int
 nouveau_vm_map_sg(struct nouveau_vma *vma, u64 delta, u64 length,
  struct nouveau_mem *mem)
 {
@@ -110,10 +110,10 @@ nouveau_vm_map_sg(struct nouveau_vma *vma, u64 delta, u64 
length,
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_unmap_at(struct nouveau_vma *vma, u64 delta, u64 length)
 {
struct nouveau_vm *vm = vma-vm;
@@ -144,13 +144,13 @@ nouveau_vm_unmap_at(struct nouveau_vma *vma, u64 delta, 
u64 length)
}
}
 
-   vm-flush(vm);
+   return vm-flush(vm);
 }
 
-void
+int
 nouveau_vm_unmap(struct nouveau_vma *vma)
 {
-   nouveau_vm_unmap_at(vma, 0, (u64)vma-node-length  12);
+   return nouveau_vm_unmap_at(vma, 0, (u64)vma-node-length  12);
 }
 
 static void
diff --git a/drivers/gpu/drm/nouveau/nouveau_vm.h 
b/drivers/gpu/drm/nouveau/nouveau_vm.h
index 4fb6e72..59dc206 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_vm.h
@@ -73,7 +73,7 @@ struct nouveau_vm {
void (*map_sg)(struct nouveau_vma *, struct nouveau_gpuobj *,
   struct nouveau_mem *, u32 pte, u32 cnt,