]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - drivers/gpu/drm/vc4/vc4_drv.c
drm/vc4: Use runtime autosuspend to avoid thrashing V3D power state.
[mirror_ubuntu-zesty-kernel.git] / drivers / gpu / drm / vc4 / vc4_drv.c
index 9ecef93854914579ee74b4d96432d15dfaa1fd6b..7abfe088f2d109706103a37ba342b6a16227dfb3 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include "drm_fb_cma_helper.h"
+#include <drm/drm_fb_helper.h>
 
 #include "uapi/drm/vc4_drm.h"
 #include "vc4_drv.h"
@@ -60,23 +61,27 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT0);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_V3D_IDENT1:
                ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT1);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_V3D_IDENT2:
                ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
                if (ret < 0)
                        return ret;
                args->value = V3D_READ(V3D_IDENT2);
-               pm_runtime_put(&vc4->v3d->pdev->dev);
+               pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
+               pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
                break;
        case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
+       case DRM_VC4_PARAM_SUPPORTS_ETC1:
                args->value = true;
                break;
        default:
@@ -214,7 +219,7 @@ static void vc4_kick_out_firmware_fb(void)
        ap->ranges[0].base = 0;
        ap->ranges[0].size = ~0;
 
-       remove_conflicting_framebuffers(ap, "vc4drmfb", false);
+       drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false);
        kfree(ap);
 }
 
@@ -232,8 +237,8 @@ static int vc4_drm_bind(struct device *dev)
                return -ENOMEM;
 
        drm = drm_dev_alloc(&vc4_drm_driver, dev);
-       if (!drm)
-               return -ENOMEM;
+       if (IS_ERR(drm))
+               return PTR_ERR(drm);
        platform_set_drvdata(pdev, drm);
        vc4->dev = drm;
        drm->dev_private = vc4;