staging: vboxvideo: Add vbox_bo_k[un]map helper functions

Add vbox_bo_k[un]map helper functions instead of having code directly
poking struct vbox_bo internals.

While touch neighboring code anyways also fix a return -PTR_ERR(info),
which should be return PTR_ERR(info).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Hans de Goede 2018-09-18 19:44:38 +02:00 committed by Greg Kroah-Hartman
parent cfc1fc63be
commit beed1ce294
3 changed files with 36 additions and 13 deletions

View File

@ -269,6 +269,8 @@ static inline void vbox_bo_unreserve(struct vbox_bo *bo)
void vbox_ttm_placement(struct vbox_bo *bo, int domain);
int vbox_bo_push_sysram(struct vbox_bo *bo);
int vbox_mmap(struct file *filp, struct vm_area_struct *vma);
void *vbox_bo_kmap(struct vbox_bo *bo);
void vbox_bo_kunmap(struct vbox_bo *bo);
/* vbox_prime.c */
int vbox_gem_prime_pin(struct drm_gem_object *obj);

View File

@ -108,15 +108,14 @@ static int vboxfb_create(struct drm_fb_helper *helper,
if (ret)
return ret;
ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
if (ret) {
DRM_ERROR("failed to kmap fbcon\n");
return ret;
}
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info))
return -PTR_ERR(info);
return PTR_ERR(info);
info->screen_size = size;
info->screen_base = (char __iomem *)vbox_bo_kmap(bo);
if (IS_ERR(info->screen_base))
return PTR_ERR(info->screen_base);
info->par = fbdev;
@ -150,9 +149,6 @@ static int vboxfb_create(struct drm_fb_helper *helper,
info->fix.smem_start = info->apertures->ranges[0].base + gpu_addr;
info->fix.smem_len = vbox->available_vram_size - gpu_addr;
info->screen_base = (char __iomem *)bo->kmap.virtual;
info->screen_size = size;
#ifdef CONFIG_DRM_KMS_FB_HELPER
info->fbdefio = &vbox_defio;
fb_deferred_io_init(info);
@ -184,8 +180,7 @@ void vbox_fbdev_fini(struct vbox_private *vbox)
if (afb->obj) {
struct vbox_bo *bo = gem_to_vbox_bo(afb->obj);
if (bo->kmap.virtual)
ttm_bo_kunmap(&bo->kmap);
vbox_bo_kunmap(bo);
if (bo->pin_count)
vbox_bo_unpin(bo);

View File

@ -418,8 +418,10 @@ int vbox_bo_push_sysram(struct vbox_bo *bo)
if (bo->pin_count)
return 0;
if (bo->kmap.virtual)
if (bo->kmap.virtual) {
ttm_bo_kunmap(&bo->kmap);
bo->kmap.virtual = NULL;
}
vbox_ttm_placement(bo, TTM_PL_FLAG_SYSTEM);
@ -448,3 +450,27 @@ int vbox_mmap(struct file *filp, struct vm_area_struct *vma)
return ttm_bo_mmap(filp, vma, &vbox->ttm.bdev);
}
void *vbox_bo_kmap(struct vbox_bo *bo)
{
int ret;
if (bo->kmap.virtual)
return bo->kmap.virtual;
ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
if (ret) {
DRM_ERROR("Error kmapping bo: %d\n", ret);
return NULL;
}
return bo->kmap.virtual;
}
void vbox_bo_kunmap(struct vbox_bo *bo)
{
if (bo->kmap.virtual) {
ttm_bo_kunmap(&bo->kmap);
bo->kmap.virtual = NULL;
}
}