goto err1;
}
- idr_preload(GFP_KERNEL);
- rc = idr_alloc(&afu->idr, ctx, 0, afu->max_pasid, GFP_NOWAIT);
- idr_preload_end();
+ rc = ida_alloc_max(&afu->ctx_ids, afu->max_pasid, GFP_KERNEL);
if (unlikely(rc < 0)) {
- dev_err(dev, "%s: idr_alloc failed rc=%d\n", __func__, rc);
+ dev_err(dev, "%s: Context ID alloc failed rc=%d\n", __func__,
+ rc);
goto err2;
}
}
mutex_unlock(&ctx->state_mutex);
- idr_remove(&ctx->hw_afu->idr, ctx->pe);
+ ida_free(&ctx->hw_afu->ctx_ids, ctx->pe);
ocxlflash_release_mapping(ctx);
kfree(ctx);
out:
return;
ocxlflash_release_context(afu->ocxl_ctx);
- idr_destroy(&afu->idr);
/* Disable the AFU */
pos = afu->acfg.dvsec_afu_control_pos;
dev_dbg(dev, "%s: acTag base=%d enabled=%d\n", __func__, base, count);
afu->afu_actag_base = base;
afu->afu_actag_enabled = count;
- afu->max_pasid = 1 << acfg->pasid_supported_log;
+ afu->max_pasid = (1 << acfg->pasid_supported_log) - 1;
ocxl_config_set_afu_pasid(pdev, pos, 0, acfg->pasid_supported_log);
afu->pdev = pdev;
afu->dev = dev;
- idr_init(&afu->idr);
+ ida_init(&afu->ctx_ids);
rc = ocxlflash_config_fn(pdev, afu);
if (unlikely(rc)) {
err2:
ocxlflash_unconfig_fn(pdev, afu);
err1:
- idr_destroy(&afu->idr);
kfree(afu);
afu = NULL;
goto out;
void __iomem *gmmio_virt; /* Global MMIO map */
void *link_token; /* Link token for the SPA */
- struct idr idr; /* IDR to manage contexts */
+ struct ida ctx_ids; /* Context ID allocations */
int max_pasid; /* Maximum number of contexts */
bool is_present; /* Function has AFUs defined */
};