Skip to content

Commit

Permalink
cxl: Rework detach context functions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Neuling authored and Michael Ellerman committed Jun 3, 2015
1 parent 6428832 commit eda3693
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions drivers/misc/cxl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

/*
Expand All @@ -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);
}

/*
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/cxl/cxl.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master,
struct address_space *mapping);
void cxl_context_free(struct cxl_context *ctx);
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 */
struct cxl_irq_info {
Expand Down

0 comments on commit eda3693

Please sign in to comment.