diff options
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 16556170fb32..bc784254e78e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
@@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res) | |||
177 | 177 | ||
178 | BUG_ON(res->id != -1); | 178 | BUG_ON(res->id != -1); |
179 | 179 | ||
180 | do { | 180 | idr_preload(GFP_KERNEL); |
181 | if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0)) | 181 | write_lock(&dev_priv->resource_lock); |
182 | return -ENOMEM; | ||
183 | |||
184 | write_lock(&dev_priv->resource_lock); | ||
185 | ret = idr_get_new_above(idr, res, 1, &res->id); | ||
186 | write_unlock(&dev_priv->resource_lock); | ||
187 | 182 | ||
188 | } while (ret == -EAGAIN); | 183 | ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT); |
184 | if (ret >= 0) | ||
185 | res->id = ret; | ||
189 | 186 | ||
190 | return ret; | 187 | write_unlock(&dev_priv->resource_lock); |
188 | idr_preload_end(); | ||
189 | return ret < 0 ? ret : 0; | ||
191 | } | 190 | } |
192 | 191 | ||
193 | /** | 192 | /** |