]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cxl: Rework context lifetimes
authorMichael Neuling <mikey@neuling.org>
Wed, 27 May 2015 06:07:14 +0000 (16:07 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 3 Jun 2015 03:27:19 +0000 (13:27 +1000)
This reworks contexts lifetimes a bit to enable the kernel API where we may
want to reuse contexts. Here we will want to start and stop contexts without
freeing them.

Start context does the get pid & ctx so stop context will need to do the puts.
Here we move put pid & ctx to the detach context path which will become part of
the stop context path.

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>
drivers/misc/cxl/context.c
drivers/misc/cxl/file.c

index 7d857b7d686d8729dc91606df36a062ac7391100..2a4c80ac322ad2500a13fc6162d8920ac4a6b8db 100644 (file)
@@ -186,6 +186,9 @@ int __detach_context(struct cxl_context *ctx)
                return -EBUSY;
 
        WARN_ON(cxl_detach_process(ctx));
+       flush_work(&ctx->fault_work); /* Only needed for dedicated process */
+       put_pid(ctx->pid);
+       cxl_ctx_put();
        return 0;
 }
 
@@ -204,7 +207,6 @@ void cxl_context_detach(struct cxl_context *ctx)
                return;
 
        afu_release_irqs(ctx, ctx);
-       flush_work(&ctx->fault_work); /* Only needed for dedicated process */
        wake_up_all(&ctx->wq);
 }
 
@@ -245,7 +247,6 @@ static void reclaim_ctx(struct rcu_head *rcu)
        free_page((u64)ctx->sstp);
        ctx->sstp = NULL;
 
-       put_pid(ctx->pid);
        kfree(ctx);
 }
 
index 676e2c8bc1abb388e2d1abb7a513439e4f5aaffd..c16bd6fa06ed20638eb359cd586541b8610ba730 100644 (file)
@@ -128,7 +128,6 @@ static int afu_release(struct inode *inode, struct file *file)
         */
        cxl_context_free(ctx);
 
-       cxl_ctx_put();
        return 0;
 }