Commit eda3693c authored by Michael Neuling's avatar Michael Neuling Committed by Michael Ellerman

cxl: Rework detach context functions

Rework __detach_context() and cxl_context_detach() so we can reuse them in the
kernel API.
Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
Acked-by: default avatarIan Munsie <imunsie@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 6428832a
...@@ -174,7 +174,7 @@ int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma) ...@@ -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 * return until all outstanding interrupts for this context have completed. The
* hardware should no longer access *ctx after this has returned. * 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; enum cxl_context_status status;
...@@ -183,12 +183,10 @@ static void __detach_context(struct cxl_context *ctx) ...@@ -183,12 +183,10 @@ static void __detach_context(struct cxl_context *ctx)
ctx->status = CLOSED; ctx->status = CLOSED;
mutex_unlock(&ctx->status_mutex); mutex_unlock(&ctx->status_mutex);
if (status != STARTED) if (status != STARTED)
return; return -EBUSY;
WARN_ON(cxl_detach_process(ctx)); WARN_ON(cxl_detach_process(ctx));
afu_release_irqs(ctx, ctx); return 0;
flush_work(&ctx->fault_work); /* Only needed for dedicated process */
wake_up_all(&ctx->wq);
} }
/* /*
...@@ -199,7 +197,15 @@ static void __detach_context(struct cxl_context *ctx) ...@@ -199,7 +197,15 @@ static void __detach_context(struct cxl_context *ctx)
*/ */
void cxl_context_detach(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) ...@@ -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 * Anything done in here needs to be setup before the IDR is
* created and torn down after the IDR removed * 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 * We are force detaching - remove any active PSA mappings so
......
...@@ -636,6 +636,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master, ...@@ -636,6 +636,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master,
struct address_space *mapping); struct address_space *mapping);
void cxl_context_free(struct cxl_context *ctx); void cxl_context_free(struct cxl_context *ctx);
int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma); int cxl_context_iomap(struct cxl_context *ctx, struct vm_area_struct *vma);
int __detach_context(struct cxl_context *ctx);
/* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */ /* This matches the layout of the H_COLLECT_CA_INT_INFO retbuf */
struct cxl_irq_info { struct cxl_irq_info {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment