drm/panfrost: Rework runtime PM initialization
authorRob Herring <robh@kernel.org>
Mon, 26 Aug 2019 22:33:10 +0000 (17:33 -0500)
committerRob Herring <robh@kernel.org>
Fri, 30 Aug 2019 14:51:41 +0000 (09:51 -0500)
There's a few issues with the runtime PM initialization.

The documentation states pm_runtime_set_active() should be called before
pm_runtime_enable(). The pm_runtime_put_autosuspend() could suspend the GPU
before panfrost_perfcnt_init() is called which touches the h/w. The
autosuspend delay keeps things from breaking. There's no need explicitly
power off the GPU only to wake back up with pm_runtime_get_sync(). Just
delaying pm_runtime_enable to the end of probe is sufficient.

Lets move all the runtime PM calls into the probe() function so they are
all in one place and are done after all initialization.

Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Cc: Steven Price <steven.price@arm.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190826223317.28509-2-robh@kernel.org
drivers/gpu/drm/panfrost/panfrost_device.c
drivers/gpu/drm/panfrost/panfrost_drv.c

index 4da71bb56c2030974ee4f7e6f85128a297be7e25..73805210834e4a0a00eb29ea2faee830a4276fbd 100644 (file)
@@ -5,7 +5,6 @@
 #include <linux/clk.h>
 #include <linux/reset.h>
 #include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
 
 #include "panfrost_device.h"
@@ -166,14 +165,6 @@ int panfrost_device_init(struct panfrost_device *pfdev)
        if (err)
                goto err_out4;
 
-       /* runtime PM will wake us up later */
-       panfrost_gpu_power_off(pfdev);
-
-       pm_runtime_set_active(pfdev->dev);
-       pm_runtime_get_sync(pfdev->dev);
-       pm_runtime_mark_last_busy(pfdev->dev);
-       pm_runtime_put_autosuspend(pfdev->dev);
-
        err = panfrost_perfcnt_init(pfdev);
        if (err)
                goto err_out5;
index d74442d71048361de310373efb53545d087faa39..bc2ddeb55f5d86ffbc9cbe1a39e2e90d77ce60df 100644 (file)
@@ -523,10 +523,6 @@ static int panfrost_probe(struct platform_device *pdev)
        mutex_init(&pfdev->shrinker_lock);
        INIT_LIST_HEAD(&pfdev->shrinker_list);
 
-       pm_runtime_use_autosuspend(pfdev->dev);
-       pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */
-       pm_runtime_enable(pfdev->dev);
-
        err = panfrost_device_init(pfdev);
        if (err) {
                if (err != -EPROBE_DEFER)
@@ -541,6 +537,12 @@ static int panfrost_probe(struct platform_device *pdev)
                goto err_out1;
        }
 
+       pm_runtime_set_active(pfdev->dev);
+       pm_runtime_mark_last_busy(pfdev->dev);
+       pm_runtime_enable(pfdev->dev);
+       pm_runtime_set_autosuspend_delay(pfdev->dev, 50); /* ~3 frames */
+       pm_runtime_use_autosuspend(pfdev->dev);
+
        /*
         * Register the DRM device with the core and the connectors with
         * sysfs