提交 307b9c02 编写于 作者: D Dave Airlie

qxl: update to new idr interfaces.

Signed-off-by: NDave Airlie <airlied@redhat.com>
上级 d2dbaaf6
...@@ -435,22 +435,18 @@ void qxl_io_monitors_config(struct qxl_device *qdev) ...@@ -435,22 +435,18 @@ void qxl_io_monitors_config(struct qxl_device *qdev)
int qxl_surface_id_alloc(struct qxl_device *qdev, int qxl_surface_id_alloc(struct qxl_device *qdev,
struct qxl_bo *surf) struct qxl_bo *surf)
{ {
uint32_t handle = -ENOMEM; uint32_t handle;
int idr_ret; int idr_ret;
int count = 0; int count = 0;
again: again:
if (idr_pre_get(&qdev->surf_id_idr, GFP_ATOMIC) == 0) { idr_preload(GFP_ATOMIC);
DRM_ERROR("Out of memory for surf idr\n");
kfree(surf);
goto alloc_fail;
}
spin_lock(&qdev->surf_id_idr_lock); spin_lock(&qdev->surf_id_idr_lock);
idr_ret = idr_get_new_above(&qdev->surf_id_idr, NULL, 1, &handle); idr_ret = idr_alloc(&qdev->surf_id_idr, NULL, 1, 0, GFP_NOWAIT);
spin_unlock(&qdev->surf_id_idr_lock); spin_unlock(&qdev->surf_id_idr_lock);
idr_preload_end();
if (idr_ret == -EAGAIN) if (idr_ret < 0)
goto again; return idr_ret;
handle = idr_ret;
if (handle >= qdev->rom->n_surfaces) { if (handle >= qdev->rom->n_surfaces) {
count++; count++;
...@@ -465,7 +461,6 @@ int qxl_surface_id_alloc(struct qxl_device *qdev, ...@@ -465,7 +461,6 @@ int qxl_surface_id_alloc(struct qxl_device *qdev,
spin_lock(&qdev->surf_id_idr_lock); spin_lock(&qdev->surf_id_idr_lock);
qdev->last_alloced_surf_id = handle; qdev->last_alloced_surf_id = handle;
spin_unlock(&qdev->surf_id_idr_lock); spin_unlock(&qdev->surf_id_idr_lock);
alloc_fail:
return 0; return 0;
} }
......
...@@ -43,7 +43,7 @@ qxl_release_alloc(struct qxl_device *qdev, int type, ...@@ -43,7 +43,7 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
struct qxl_release **ret) struct qxl_release **ret)
{ {
struct qxl_release *release; struct qxl_release *release;
int handle = 0; int handle;
size_t size = sizeof(*release); size_t size = sizeof(*release);
int idr_ret; int idr_ret;
...@@ -56,19 +56,16 @@ qxl_release_alloc(struct qxl_device *qdev, int type, ...@@ -56,19 +56,16 @@ qxl_release_alloc(struct qxl_device *qdev, int type,
release->bo_count = 0; release->bo_count = 0;
release->release_offset = 0; release->release_offset = 0;
release->surface_release_id = 0; release->surface_release_id = 0;
again:
if (idr_pre_get(&qdev->release_idr, GFP_KERNEL) == 0) { idr_preload(GFP_KERNEL);
DRM_ERROR("Out of memory for release idr\n");
kfree(release);
goto release_fail;
}
spin_lock(&qdev->release_idr_lock); spin_lock(&qdev->release_idr_lock);
idr_ret = idr_get_new_above(&qdev->release_idr, release, 1, &handle); idr_ret = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_NOWAIT);
spin_unlock(&qdev->release_idr_lock); spin_unlock(&qdev->release_idr_lock);
if (idr_ret == -EAGAIN) idr_preload_end();
goto again; handle = idr_ret;
if (ret) if (idr_ret < 0)
*ret = release; goto release_fail;
*ret = release;
QXL_INFO(qdev, "allocated release %lld\n", handle); QXL_INFO(qdev, "allocated release %lld\n", handle);
release->id = handle; release->id = handle;
release_fail: release_fail:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册