mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 04:48:04 +09:00
BACKPORT: virtio: Rework virtio_gpu_object_kmap()
Currently, virtio_gpu_object_kmap() is only called by
virtio_gpufb_create(), when a DRM framebuffer is created.
Thus, instead of returning the vmap'ed address, emit a warning
if virtio_gpu_object_kmap is called on an already mapped
object. With this change, kmap/kunmap calls are now balanced.
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180925161606.17980-3-ezequiel@collabora.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit a20c4173c4)
Signed-off-by: Greg Hartman <ghartman@google.com>
BUG: 139386237
Change-Id: I970b24d86c43017aa9d58b6cdc6e4909c3870c31
This commit is contained in:
committed by
Alistair Delva
parent
97587ca703
commit
8661999dad
@@ -363,7 +363,8 @@ void virtio_gpu_fence_event_process(struct virtio_gpu_device *vdev,
|
||||
int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
|
||||
unsigned long size, bool kernel, bool pinned,
|
||||
struct virtio_gpu_object **bo_ptr);
|
||||
int virtio_gpu_object_kmap(struct virtio_gpu_object *bo, void **ptr);
|
||||
void virtio_gpu_object_kunmap(struct virtio_gpu_object *bo);
|
||||
int virtio_gpu_object_kmap(struct virtio_gpu_object *bo);
|
||||
int virtio_gpu_object_get_sg_table(struct virtio_gpu_device *qdev,
|
||||
struct virtio_gpu_object *bo);
|
||||
void virtio_gpu_object_free_sg_table(struct virtio_gpu_object *bo);
|
||||
|
||||
@@ -203,12 +203,6 @@ static struct fb_ops virtio_gpufb_ops = {
|
||||
.fb_imageblit = virtio_gpu_3d_imageblit,
|
||||
};
|
||||
|
||||
static int virtio_gpu_vmap_fb(struct virtio_gpu_device *vgdev,
|
||||
struct virtio_gpu_object *obj)
|
||||
{
|
||||
return virtio_gpu_object_kmap(obj, NULL);
|
||||
}
|
||||
|
||||
static int virtio_gpufb_create(struct drm_fb_helper *helper,
|
||||
struct drm_fb_helper_surface_size *sizes)
|
||||
{
|
||||
@@ -241,9 +235,9 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
|
||||
virtio_gpu_cmd_create_resource(vgdev, resid, format,
|
||||
mode_cmd.width, mode_cmd.height);
|
||||
|
||||
ret = virtio_gpu_vmap_fb(vgdev, obj);
|
||||
ret = virtio_gpu_object_kmap(obj);
|
||||
if (ret) {
|
||||
DRM_ERROR("failed to vmap fb %d\n", ret);
|
||||
DRM_ERROR("failed to kmap fb %d\n", ret);
|
||||
goto err_obj_vmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,22 +99,23 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int virtio_gpu_object_kmap(struct virtio_gpu_object *bo, void **ptr)
|
||||
void virtio_gpu_object_kunmap(struct virtio_gpu_object *bo)
|
||||
{
|
||||
bo->vmap = NULL;
|
||||
ttm_bo_kunmap(&bo->kmap);
|
||||
}
|
||||
|
||||
int virtio_gpu_object_kmap(struct virtio_gpu_object *bo)
|
||||
{
|
||||
bool is_iomem;
|
||||
int r;
|
||||
|
||||
if (bo->vmap) {
|
||||
if (ptr)
|
||||
*ptr = bo->vmap;
|
||||
return 0;
|
||||
}
|
||||
WARN_ON(bo->vmap);
|
||||
|
||||
r = ttm_bo_kmap(&bo->tbo, 0, bo->tbo.num_pages, &bo->kmap);
|
||||
if (r)
|
||||
return r;
|
||||
bo->vmap = ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
|
||||
if (ptr)
|
||||
*ptr = bo->vmap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user