diff options
author | Michael Neuling <mikey@neuling.org> | 2015-05-27 08:07:08 +0200 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-06-03 05:27:18 +0200 |
commit | eda3693c842ed169af66af943554c648633769d0 (patch) | |
tree | bd5a1094982e749efe42e61f1e2c72398bbef900 /drivers/misc/cxl/context.c | |
parent | cxl: Add cookie parameter to afu_release_irqs() (diff) | |
download | linux-eda3693c842ed169af66af943554c648633769d0.tar.xz linux-eda3693c842ed169af66af943554c648633769d0.zip |
cxl: Rework detach context functions
Rework __detach_context() and cxl_context_detach() so we can reuse them in the
kernel API.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/misc/cxl/context.c')
-rw-r--r-- | drivers/misc/cxl/context.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c index 36bb8e4195d5..7d857b7d686d 100644 --- a/drivers/misc/cxl/context.c +++ b/drivers/misc/cxl/context.c @@ -174,7 +174,7 @@ int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma) * return until all outstanding interrupts for this context have completed. The * hardware should no longer access *ctx after this has returned. */ -static void __detach_context(struct cxl_context *ctx) +int __detach_context(struct cxl_context *ctx) { enum cxl_context_status status; @@ -183,12 +183,10 @@ static void __detach_context(struct cxl_context *ctx) ctx->status = CLOSED; mutex_unlock(&ctx->status_mutex); if (status != STARTED) - return; + return -EBUSY; WARN_ON(cxl_detach_process(ctx)); - afu_release_irqs(ctx, ctx); - flush_work(&ctx->fault_work); /* Only needed for dedicated process */ - wake_up_all(&ctx->wq); + return 0; } /* @@ -199,7 +197,15 @@ static void __detach_context(struct cxl_context *ctx) */ void cxl_context_detach(struct cxl_context *ctx) { - __detach_context(ctx); + int rc; + + rc = __detach_context(ctx); + if (rc) + return; + + afu_release_irqs(ctx, ctx); + flush_work(&ctx->fault_work); /* Only needed for dedicated process */ + wake_up_all(&ctx->wq); } /* @@ -216,7 +222,7 @@ void cxl_context_detach_all(struct cxl_afu *afu) * Anything done in here needs to be setup before the IDR is * created and torn down after the IDR removed */ - __detach_context(ctx); + cxl_context_detach(ctx); /* * We are force detaching - remove any active PSA mappings so |