|
@@ -82,12 +82,12 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master)
|
|
* Allocating IDR! We better make sure everything's setup that
|
|
* Allocating IDR! We better make sure everything's setup that
|
|
* dereferences from it.
|
|
* dereferences from it.
|
|
*/
|
|
*/
|
|
|
|
+ mutex_lock(&afu->contexts_lock);
|
|
idr_preload(GFP_KERNEL);
|
|
idr_preload(GFP_KERNEL);
|
|
- spin_lock(&afu->contexts_lock);
|
|
|
|
i = idr_alloc(&ctx->afu->contexts_idr, ctx, 0,
|
|
i = idr_alloc(&ctx->afu->contexts_idr, ctx, 0,
|
|
ctx->afu->num_procs, GFP_NOWAIT);
|
|
ctx->afu->num_procs, GFP_NOWAIT);
|
|
- spin_unlock(&afu->contexts_lock);
|
|
|
|
idr_preload_end();
|
|
idr_preload_end();
|
|
|
|
+ mutex_unlock(&afu->contexts_lock);
|
|
if (i < 0)
|
|
if (i < 0)
|
|
return i;
|
|
return i;
|
|
|
|
|
|
@@ -168,21 +168,22 @@ void cxl_context_detach_all(struct cxl_afu *afu)
|
|
struct cxl_context *ctx;
|
|
struct cxl_context *ctx;
|
|
int tmp;
|
|
int tmp;
|
|
|
|
|
|
- rcu_read_lock();
|
|
|
|
- idr_for_each_entry(&afu->contexts_idr, ctx, tmp)
|
|
|
|
|
|
+ mutex_lock(&afu->contexts_lock);
|
|
|
|
+ idr_for_each_entry(&afu->contexts_idr, ctx, tmp) {
|
|
/*
|
|
/*
|
|
* 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);
|
|
__detach_context(ctx);
|
|
- rcu_read_unlock();
|
|
|
|
|
|
+ }
|
|
|
|
+ mutex_unlock(&afu->contexts_lock);
|
|
}
|
|
}
|
|
|
|
|
|
void cxl_context_free(struct cxl_context *ctx)
|
|
void cxl_context_free(struct cxl_context *ctx)
|
|
{
|
|
{
|
|
- spin_lock(&ctx->afu->contexts_lock);
|
|
|
|
|
|
+ mutex_lock(&ctx->afu->contexts_lock);
|
|
idr_remove(&ctx->afu->contexts_idr, ctx->pe);
|
|
idr_remove(&ctx->afu->contexts_idr, ctx->pe);
|
|
- spin_unlock(&ctx->afu->contexts_lock);
|
|
|
|
|
|
+ mutex_unlock(&ctx->afu->contexts_lock);
|
|
synchronize_rcu();
|
|
synchronize_rcu();
|
|
|
|
|
|
free_page((u64)ctx->sstp);
|
|
free_page((u64)ctx->sstp);
|