[openib-general] [PATCH] uverbs: deregister memory before ib_umem_release

Michael S. Tsirkin mst at mellanox.co.il
Tue Jun 28 11:50:22 PDT 2005


While all qps and cqs are closed first, so HCA doesnt have a reason to
write to the mr, I think its still cleaner to first deregister
the mr, and then release the memory.
It might become more important if/when shared mrs are implemented.

---

Deregister memory before ib_umem_release, to make sure HCA wont be writing
there.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: core/uverbs_main.c
===================================================================
--- core/uverbs_main.c	(revision 2732)
+++ core/uverbs_main.c	(working copy)
@@ -132,11 +132,10 @@ static int ib_dealloc_ucontext(struct ib
 		struct ib_mr *mr = idr_find(&ib_uverbs_mr_idr, uobj->id);
 		struct ib_umem_object *memobj;
 
-		memobj = container_of(uobj, struct ib_umem_object, uobject);
-		ib_umem_release(mr->device, &memobj->umem);
-
 		idr_remove(&ib_uverbs_mr_idr, uobj->id);
 		ib_dereg_mr(mr);
+		memobj = container_of(uobj, struct ib_umem_object, uobject);
+		ib_umem_release(mr->device, &memobj->umem);
 		list_del(&uobj->list);
 		kfree(memobj);
 	}

-- 
MST



More information about the general mailing list