aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/qxl/qxl_cmd.c19
-rw-r--r--drivers/gpu/drm/qxl/qxl_release.c21
2 files changed, 16 insertions, 24 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
index 736365e6ca80..08b0823c93d5 100644
--- a/drivers/gpu/drm/qxl/qxl_cmd.c
+++ b/drivers/gpu/drm/qxl/qxl_cmd.c
@@ -435,22 +435,18 @@ void qxl_io_monitors_config(struct qxl_device *qdev)
435int qxl_surface_id_alloc(struct qxl_device *qdev, 435int qxl_surface_id_alloc(struct qxl_device *qdev,
436 struct qxl_bo *surf) 436 struct qxl_bo *surf)
437{ 437{
438 uint32_t handle = -ENOMEM; 438 uint32_t handle;
439 int idr_ret; 439 int idr_ret;
440 int count = 0; 440 int count = 0;
441again: 441again:
442 if (idr_pre_get(&qdev->surf_id_idr, GFP_ATOMIC) == 0) { 442 idr_preload(GFP_ATOMIC);
443 DRM_ERROR("Out of memory for surf idr\n");
444 kfree(surf);
445 goto alloc_fail;
446 }
447
448 spin_lock(&qdev->surf_id_idr_lock); 443 spin_lock(&qdev->surf_id_idr_lock);
449 idr_ret = idr_get_new_above(&qdev->surf_id_idr, NULL, 1, &handle); 444 idr_ret = idr_alloc(&qdev->surf_id_idr, NULL, 1, 0, GFP_NOWAIT);
450 spin_unlock(&qdev->surf_id_idr_lock); 445 spin_unlock(&qdev->surf_id_idr_lock);
451 446 idr_preload_end();
452 if (idr_ret == -EAGAIN) 447 if (idr_ret < 0)
453 goto again; 448 return idr_ret;
449 handle = idr_ret;
454 450
455 if (handle >= qdev->rom->n_surfaces) { 451 if (handle >= qdev->rom->n_surfaces) {
456 count++; 452 count++;
@@ -465,7 +461,6 @@ again:
465 spin_lock(&qdev->surf_id_idr_lock); 461 spin_lock(&qdev->surf_id_idr_lock);
466 qdev->last_alloced_surf_id = handle; 462 qdev->last_alloced_surf_id = handle;
467 spin_unlock(&qdev->surf_id_idr_lock); 463 spin_unlock(&qdev->surf_id_idr_lock);
468 alloc_fail:
469 return 0; 464 return 0;
470} 465}
471 466
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c
index c4267c71dd2d..b443d6751d5f 100644
--- a/drivers/gpu/drm/qxl/qxl_release.c
+++ b/drivers/gpu/drm/qxl/qxl_release.c
@@ -43,7 +43,7 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
43 struct qxl_release **ret) 43 struct qxl_release **ret)
44{ 44{
45 struct qxl_release *release; 45 struct qxl_release *release;
46 int handle = 0; 46 int handle;
47 size_t size = sizeof(*release); 47 size_t size = sizeof(*release);
48 int idr_ret; 48 int idr_ret;
49 49
@@ -56,19 +56,16 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
56 release->bo_count = 0; 56 release->bo_count = 0;
57 release->release_offset = 0; 57 release->release_offset = 0;
58 release->surface_release_id = 0; 58 release->surface_release_id = 0;
59again: 59
60 if (idr_pre_get(&qdev->release_idr, GFP_KERNEL) == 0) { 60 idr_preload(GFP_KERNEL);
61 DRM_ERROR("Out of memory for release idr\n");
62 kfree(release);
63 goto release_fail;
64 }
65 spin_lock(&qdev->release_idr_lock); 61 spin_lock(&qdev->release_idr_lock);
66 idr_ret = idr_get_new_above(&qdev->release_idr, release, 1, &handle); 62 idr_ret = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_NOWAIT);
67 spin_unlock(&qdev->release_idr_lock); 63 spin_unlock(&qdev->release_idr_lock);
68 if (idr_ret == -EAGAIN) 64 idr_preload_end();
69 goto again; 65 handle = idr_ret;
70 if (ret) 66 if (idr_ret < 0)
71 *ret = release; 67 goto release_fail;
68 *ret = release;
72 QXL_INFO(qdev, "allocated release %lld\n", handle); 69 QXL_INFO(qdev, "allocated release %lld\n", handle);
73 release->id = handle; 70 release->id = handle;
74release_fail: 71release_fail: