These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / gpu / drm / drm_fb_cma_helper.c
index 5c1aca4..c19a625 100644 (file)
@@ -209,23 +209,11 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
        struct drm_framebuffer *fb;
-       int ret;
-
-       ret = mutex_lock_interruptible(&dev->mode_config.mutex);
-       if (ret)
-               return ret;
 
-       ret = mutex_lock_interruptible(&dev->struct_mutex);
-       if (ret) {
-               mutex_unlock(&dev->mode_config.mutex);
-               return ret;
-       }
-
-       list_for_each_entry(fb, &dev->mode_config.fb_list, head)
+       mutex_lock(&dev->mode_config.fb_lock);
+       drm_for_each_fb(fb, dev)
                drm_fb_cma_describe(fb, m);
-
-       mutex_unlock(&dev->struct_mutex);
-       mutex_unlock(&dev->mode_config.mutex);
+       mutex_unlock(&dev->mode_config.fb_lock);
 
        return 0;
 }
@@ -234,9 +222,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show);
 
 static struct fb_ops drm_fbdev_cma_ops = {
        .owner          = THIS_MODULE,
-       .fb_fillrect    = sys_fillrect,
-       .fb_copyarea    = sys_copyarea,
-       .fb_imageblit   = sys_imageblit,
+       .fb_fillrect    = drm_fb_helper_sys_fillrect,
+       .fb_copyarea    = drm_fb_helper_sys_copyarea,
+       .fb_imageblit   = drm_fb_helper_sys_imageblit,
        .fb_check_var   = drm_fb_helper_check_var,
        .fb_set_par     = drm_fb_helper_set_par,
        .fb_blank       = drm_fb_helper_blank,
@@ -275,10 +263,9 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
        if (IS_ERR(obj))
                return -ENOMEM;
 
-       fbi = framebuffer_alloc(0, dev->dev);
-       if (!fbi) {
-               dev_err(dev->dev, "Failed to allocate framebuffer info.\n");
-               ret = -ENOMEM;
+       fbi = drm_fb_helper_alloc_fbi(helper);
+       if (IS_ERR(fbi)) {
+               ret = PTR_ERR(fbi);
                goto err_drm_gem_cma_free_object;
        }
 
@@ -286,23 +273,16 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
        if (IS_ERR(fbdev_cma->fb)) {
                dev_err(dev->dev, "Failed to allocate DRM framebuffer.\n");
                ret = PTR_ERR(fbdev_cma->fb);
-               goto err_framebuffer_release;
+               goto err_fb_info_destroy;
        }
 
        fb = &fbdev_cma->fb->fb;
        helper->fb = fb;
-       helper->fbdev = fbi;
 
        fbi->par = helper;
        fbi->flags = FBINFO_FLAG_DEFAULT;
        fbi->fbops = &drm_fbdev_cma_ops;
 
-       ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
-       if (ret) {
-               dev_err(dev->dev, "Failed to allocate color map.\n");
-               goto err_drm_fb_cma_destroy;
-       }
-
        drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth);
        drm_fb_helper_fill_var(fbi, helper, sizes->fb_width, sizes->fb_height);
 
@@ -317,11 +297,8 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
 
        return 0;
 
-err_drm_fb_cma_destroy:
-       drm_framebuffer_unregister_private(fb);
-       drm_fb_cma_destroy(fb);
-err_framebuffer_release:
-       framebuffer_release(fbi);
+err_fb_info_destroy:
+       drm_fb_helper_release_fbi(helper);
 err_drm_gem_cma_free_object:
        drm_gem_cma_free_object(&obj->base);
        return ret;
@@ -397,20 +374,8 @@ EXPORT_SYMBOL_GPL(drm_fbdev_cma_init);
  */
 void drm_fbdev_cma_fini(struct drm_fbdev_cma *fbdev_cma)
 {
-       if (fbdev_cma->fb_helper.fbdev) {
-               struct fb_info *info;
-               int ret;
-
-               info = fbdev_cma->fb_helper.fbdev;
-               ret = unregister_framebuffer(info);
-               if (ret < 0)
-                       DRM_DEBUG_KMS("failed unregister_framebuffer()\n");
-
-               if (info->cmap.len)
-                       fb_dealloc_cmap(&info->cmap);
-
-               framebuffer_release(info);
-       }
+       drm_fb_helper_unregister_fbi(&fbdev_cma->fb_helper);
+       drm_fb_helper_release_fbi(&fbdev_cma->fb_helper);
 
        if (fbdev_cma->fb) {
                drm_framebuffer_unregister_private(&fbdev_cma->fb->fb);