Commit 2ae7f165 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Gerd Hoffmann

drm/virtio: Use IDAs more efficiently

0-based IDAs are more efficient than any other base.  Convert the
1-based IDAs to be 0-based.
Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20181030165352.13065-2-willy@infradead.orgSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 556c62e8
...@@ -55,10 +55,11 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work) ...@@ -55,10 +55,11 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work)
static int virtio_gpu_context_create(struct virtio_gpu_device *vgdev, static int virtio_gpu_context_create(struct virtio_gpu_device *vgdev,
uint32_t nlen, const char *name) uint32_t nlen, const char *name)
{ {
int handle = ida_alloc_min(&vgdev->ctx_id_ida, 1, GFP_KERNEL); int handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL);
if (handle < 0) if (handle < 0)
return handle; return handle;
handle += 1;
virtio_gpu_cmd_context_create(vgdev, handle, nlen, name); virtio_gpu_cmd_context_create(vgdev, handle, nlen, name);
return handle; return handle;
} }
...@@ -67,7 +68,7 @@ static void virtio_gpu_context_destroy(struct virtio_gpu_device *vgdev, ...@@ -67,7 +68,7 @@ static void virtio_gpu_context_destroy(struct virtio_gpu_device *vgdev,
uint32_t ctx_id) uint32_t ctx_id)
{ {
virtio_gpu_cmd_context_destroy(vgdev, ctx_id); virtio_gpu_cmd_context_destroy(vgdev, ctx_id);
ida_free(&vgdev->ctx_id_ida, ctx_id); ida_free(&vgdev->ctx_id_ida, ctx_id - 1);
} }
static void virtio_gpu_init_vq(struct virtio_gpu_queue *vgvq, static void virtio_gpu_init_vq(struct virtio_gpu_queue *vgvq,
......
...@@ -28,18 +28,18 @@ ...@@ -28,18 +28,18 @@
static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev, static int virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
uint32_t *resid) uint32_t *resid)
{ {
int handle = ida_alloc_min(&vgdev->resource_ida, 1, GFP_KERNEL); int handle = ida_alloc(&vgdev->resource_ida, GFP_KERNEL);
if (handle < 0) if (handle < 0)
return handle; return handle;
*resid = handle; *resid = handle + 1;
return 0; return 0;
} }
static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id) static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
{ {
ida_free(&vgdev->resource_ida, id); ida_free(&vgdev->resource_ida, id - 1);
} }
static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) static void virtio_gpu_ttm_bo_destroy(struct ttm_buffer_object *tbo)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment