diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2023-02-01 18:26:08 +0300 |
---|---|---|
committer | Lucas Stach <l.stach@pengutronix.de> | 2023-02-07 22:49:54 +0300 |
commit | d306788b6e1bc9df1cc427f7db5921e7ecb29369 (patch) | |
tree | 7fb8b01153b618f43b71b3a96c5715ae35ec515b /drivers/gpu/drm/etnaviv/etnaviv_drv.c | |
parent | df622729ddbf6607c10670e52d2cb484b1abe7c7 (diff) | |
download | linux-d306788b6e1bc9df1cc427f7db5921e7ecb29369.tar.xz |
drm/etnaviv: allocate unique ID per drm_file
Allows to easily track if several fd are pointing to the same
execution context due to being dup'ed.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/drm/etnaviv/etnaviv_drv.c')
-rw-r--r-- | drivers/gpu/drm/etnaviv/etnaviv_drv.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index 1d2b4fb4bcf8..31a7f59ccb49 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -56,6 +56,11 @@ static int etnaviv_open(struct drm_device *dev, struct drm_file *file) if (!ctx) return -ENOMEM; + ret = xa_alloc_cyclic(&priv->active_contexts, &ctx->id, ctx, + xa_limit_32b, &priv->next_context_id, GFP_KERNEL); + if (ret < 0) + goto out_free; + ctx->mmu = etnaviv_iommu_context_init(priv->mmu_global, priv->cmdbuf_suballoc); if (!ctx->mmu) { @@ -99,6 +104,8 @@ static void etnaviv_postclose(struct drm_device *dev, struct drm_file *file) etnaviv_iommu_context_put(ctx->mmu); + xa_erase(&priv->active_contexts, ctx->id); + kfree(ctx); } @@ -514,6 +521,8 @@ static int etnaviv_bind(struct device *dev) dma_set_max_seg_size(dev, SZ_2G); + xa_init_flags(&priv->active_contexts, XA_FLAGS_ALLOC); + mutex_init(&priv->gem_lock); INIT_LIST_HEAD(&priv->gem_list); priv->num_gpus = 0; @@ -563,6 +572,8 @@ static void etnaviv_unbind(struct device *dev) etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc); + xa_destroy(&priv->active_contexts); + drm->dev_private = NULL; kfree(priv); |