Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+15
+11
drivers/gpu/drm/etnaviv/etnaviv_drv.c
··· 56 56 if (!ctx) 57 57 return -ENOMEM; 58 58 59 + ret = xa_alloc_cyclic(&priv->active_contexts, &ctx->id, ctx, 60 + xa_limit_32b, &priv->next_context_id, GFP_KERNEL); 61 + if (ret < 0) 62 + goto out_free; 63 + 59 64 ctx->mmu = etnaviv_iommu_context_init(priv->mmu_global, 60 65 priv->cmdbuf_suballoc); 61 66 if (!ctx->mmu) { ··· 103 98 } 104 99 105 100 etnaviv_iommu_context_put(ctx->mmu); 101 + 102 + xa_erase(&priv->active_contexts, ctx->id); 106 103 107 104 kfree(ctx); 108 105 } ··· 521 514 522 515 dma_set_max_seg_size(dev, SZ_2G); 523 516 517 + xa_init_flags(&priv->active_contexts, XA_FLAGS_ALLOC); 518 + 524 519 mutex_init(&priv->gem_lock); 525 520 INIT_LIST_HEAD(&priv->gem_list); 526 521 priv->num_gpus = 0; ··· 571 562 component_unbind_all(dev, drm); 572 563 573 564 etnaviv_cmdbuf_suballoc_destroy(priv->cmdbuf_suballoc); 565 + 566 + xa_destroy(&priv->active_contexts); 574 567 575 568 drm->dev_private = NULL; 576 569 kfree(priv);
+4
drivers/gpu/drm/etnaviv/etnaviv_drv.h
··· 29 29 #define ETNAVIV_SOFTPIN_START_ADDRESS SZ_4M /* must be >= SUBALLOC_SIZE */ 30 30 31 31 struct etnaviv_file_private { 32 + int id; 32 33 struct etnaviv_iommu_context *mmu; 33 34 struct drm_sched_entity sched_entity[ETNA_MAX_PIPES]; 34 35 }; ··· 41 40 42 41 struct etnaviv_cmdbuf_suballoc *cmdbuf_suballoc; 43 42 struct etnaviv_iommu_global *mmu_global; 43 + 44 + struct xarray active_contexts; 45 + u32 next_context_id; 44 46 45 47 /* list of GEM objects: */ 46 48 struct mutex gem_lock;