drm/virtio: fix resource id handling
Move virtio_gpu_resource_id_{get,put} to virtgpu_object.c and make them static. Allocate and free the id on creation and destroy, drop all other calls. That way objects have a valid handle for the whole lifetime of the object. Also fixes ids leaking. Worst offender are dumb buffers, and I think some error paths too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20181019061847.18958-7-kraxel@redhat.com
This commit is contained in:
@@ -38,26 +38,6 @@
|
||||
+ MAX_INLINE_CMD_SIZE \
|
||||
+ MAX_INLINE_RESP_SIZE)
|
||||
|
||||
void virtio_gpu_resource_id_get(struct virtio_gpu_device *vgdev,
|
||||
uint32_t *resid)
|
||||
{
|
||||
int handle;
|
||||
|
||||
idr_preload(GFP_KERNEL);
|
||||
spin_lock(&vgdev->resource_idr_lock);
|
||||
handle = idr_alloc(&vgdev->resource_idr, NULL, 1, 0, GFP_NOWAIT);
|
||||
spin_unlock(&vgdev->resource_idr_lock);
|
||||
idr_preload_end();
|
||||
*resid = handle;
|
||||
}
|
||||
|
||||
void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t id)
|
||||
{
|
||||
spin_lock(&vgdev->resource_idr_lock);
|
||||
idr_remove(&vgdev->resource_idr, id);
|
||||
spin_unlock(&vgdev->resource_idr_lock);
|
||||
}
|
||||
|
||||
void virtio_gpu_ctrl_ack(struct virtqueue *vq)
|
||||
{
|
||||
struct drm_device *dev = vq->vdev->priv;
|
||||
|
Reference in New Issue
Block a user