From: Matthew Wilcox Date: Wed, 13 Feb 2019 14:39:17 +0000 (-0500) Subject: drm: Convert magic_map to XArray X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=11abab6768e28e92640ba09a55ba37fc7a48e9a5;p=users%2Fwilly%2Fxarray.git drm: Convert magic_map to XArray Part of the mass conversion of IDR users to the XArray API. Signed-off-by: Matthew Wilcox --- diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index cc9acd986c68f..89e72ff32b629 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -68,17 +68,16 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv) mutex_lock(&dev->master_mutex); if (!file_priv->magic) { - ret = idr_alloc(&file_priv->master->magic_map, file_priv, - 1, 0, GFP_KERNEL); - if (ret >= 0) - file_priv->magic = ret; + ret = xa_alloc(&file_priv->master->magic_map, + &file_priv->magic, file_priv, + xa_limit_31b, GFP_KERNEL); } auth->magic = file_priv->magic; mutex_unlock(&dev->master_mutex); DRM_DEBUG("%u\n", auth->magic); - return ret < 0 ? ret : 0; + return ret; } int drm_authmagic(struct drm_device *dev, void *data, @@ -90,10 +89,10 @@ int drm_authmagic(struct drm_device *dev, void *data, DRM_DEBUG("%u\n", auth->magic); mutex_lock(&dev->master_mutex); - file = idr_find(&file_priv->master->magic_map, auth->magic); + file = xa_load(&file_priv->master->magic_map, auth->magic); if (file) { file->authenticated = 1; - idr_replace(&file_priv->master->magic_map, NULL, auth->magic); + xa_store(&file_priv->master->magic_map, auth->magic, NULL, 0); } mutex_unlock(&dev->master_mutex); @@ -110,7 +109,7 @@ struct drm_master *drm_master_create(struct drm_device *dev) kref_init(&master->refcount); drm_master_legacy_init(master); - idr_init(&master->magic_map); + xa_init_flags(&master->magic_map, XA_FLAGS_ALLOC1); master->dev = dev; /* initialize the tree of output resource lessees */ @@ -272,7 +271,7 @@ void drm_master_release(struct drm_file *file_priv) mutex_lock(&dev->master_mutex); if (file_priv->magic) - idr_remove(&file_priv->master->magic_map, file_priv->magic); + xa_erase(&file_priv->master->magic_map, file_priv->magic); if (!drm_is_current_master(file_priv)) goto out; @@ -337,7 +336,6 @@ static void drm_master_destroy(struct kref *kref) drm_legacy_master_rmmaps(dev, master); - idr_destroy(&master->magic_map); idr_destroy(&master->leases); idr_destroy(&master->lessee_idr); diff --git a/include/drm/drm_auth.h b/include/drm/drm_auth.h index 6bf8b2b789919..28f94e7ccf822 100644 --- a/include/drm/drm_auth.h +++ b/include/drm/drm_auth.h @@ -82,10 +82,9 @@ struct drm_master { */ int unique_len; /** - * @magic_map: Map of used authentication tokens. Protected by - * &drm_device.master_mutex. + * @magic_map: Map of used authentication tokens. */ - struct idr magic_map; + struct xarray magic_map; void *driver_priv; /* Tree of display resource leases, each of which is a drm_master struct