[openib-general] more comments on cxgb3
Steve Wise
swise at opengridcomputing.com
Thu Feb 8 07:49:16 PST 2007
> - Consider a user that does e.g. create QP, but never calls mmap.
> Is there some code that will clean out the unclamed mmap object?
> I couldn't find it, and iwch_dealloc_ucontext does not seem to
> do anything with it.
BTW: Here is my fix for this.
-----
Clean up pending mmaps on ucontext deallocation.
From: Steve Wise <swise at opengridcomputing.com>
Free all pending mmap structs when the ucontext is deallocated.
Signed-off-by: Steve Wise <swise at opengridcomputing.com>
---
drivers/infiniband/hw/cxgb3/iwch_provider.c | 1 +
drivers/infiniband/hw/cxgb3/iwch_provider.h | 15 +++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index db2b0a8..98568ee 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -99,6 +99,7 @@ static int iwch_dealloc_ucontext(struct
struct iwch_dev *rhp = to_iwch_dev(context->device);
struct iwch_ucontext *ucontext = to_iwch_ucontext(context);
PDBG("%s context %p\n", __FUNCTION__, context);
+ free_mmaps(ucontext);
cxio_release_ucontext(&rhp->rdev, &ucontext->uctx);
kfree(ucontext);
return 0;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index 1ede8a7..c8c07ee 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -199,6 +199,21 @@ struct iwch_mm_entry {
unsigned len;
};
+static inline void free_mmaps(struct iwch_ucontext *ucontext)
+{
+ struct list_head *pos, *nxt;
+ struct iwch_mm_entry *mm;
+
+ spin_lock(&ucontext->mmap_lock);
+ list_for_each_safe(pos, nxt, &ucontext->mmaps) {
+ mm = list_entry(pos, struct iwch_mm_entry, entry);
+ list_del(&mm->entry);
+ kfree(mm);
+ }
+ spin_unlock(&ucontext->mmap_lock);
+ return;
+}
+
static inline struct iwch_mm_entry *remove_mmap(struct iwch_ucontext *ucontext,
u64 addr, unsigned len)
{
More information about the general
mailing list