Thread (67 messages) 67 messages, 8 authors, 2020-02-19
STALE2290d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 09/27] ocxl: Free detached contexts in ocxl_context_detach_all()

From: Alastair D'Silva <hidden>
Date: 2019-12-03 03:50:01
Also in: linux-mm, lkml, nvdimm
Subsystem: char and misc drivers, ocxl (open coherent accelerator processor interface opencapi) driver, the rest · Maintainers: Arnd Bergmann, Greg Kroah-Hartman, Mahesh J Salgaonkar, Linus Torvalds

From: Alastair D'Silva <redacted>

ocxl_context_detach_all() is called from ocxl_function_close(), so
there is no reason to leave the contexts allocated, as the caller
can do nothing useful with them at that point.

This also has the side-effect of freeing any allocated IRQs
within the context.

Signed-off-by: Alastair D'Silva <redacted>
---
 drivers/misc/ocxl/context.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
index 994563a078eb..6cb36ef96e09 100644
--- a/drivers/misc/ocxl/context.c
+++ b/drivers/misc/ocxl/context.c
@@ -259,10 +259,11 @@ void ocxl_context_detach_all(struct ocxl_afu *afu)
 {
 	struct ocxl_context *ctx;
 	int tmp;
+	int rc;
 
 	mutex_lock(&afu->contexts_lock);
 	idr_for_each_entry(&afu->contexts_idr, ctx, tmp) {
-		ocxl_context_detach(ctx);
+		rc = ocxl_context_detach(ctx);
 		/*
 		 * We are force detaching - remove any active mmio
 		 * mappings so userspace cannot interfere with the
@@ -274,6 +275,9 @@ void ocxl_context_detach_all(struct ocxl_afu *afu)
 		if (ctx->mapping)
 			unmap_mapping_range(ctx->mapping, 0, 0, 1);
 		mutex_unlock(&ctx->mapping_lock);
+
+		if (rc != -EBUSY)
+			ocxl_context_free(ctx);
 	}
 	mutex_unlock(&afu->contexts_lock);
 }
-- 
2.23.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help