drm/nouveau/tegra: Set clock rate if not set
authorThierry Reding <treding@nvidia.com>
Mon, 9 Dec 2019 12:00:02 +0000 (13:00 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 15 Jan 2020 00:49:59 +0000 (10:49 +1000)
If the GPU clock has not had a rate set, initialize it to the maximum
clock rate to make sure it does run.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c

index 747a775121cfbd628c8252927630199a27a34aa4..d0d52c1d4aee05868a6b2c89f010828c325ff010 100644 (file)
@@ -279,6 +279,7 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
                      struct nvkm_device **pdevice)
 {
        struct nvkm_device_tegra *tdev;
+       unsigned long rate;
        int ret;
 
        if (!(tdev = kzalloc(sizeof(*tdev), GFP_KERNEL)))
@@ -307,6 +308,17 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
                goto free;
        }
 
+       rate = clk_get_rate(tdev->clk);
+       if (rate == 0) {
+               ret = clk_set_rate(tdev->clk, ULONG_MAX);
+               if (ret < 0)
+                       goto free;
+
+               rate = clk_get_rate(tdev->clk);
+
+               dev_dbg(&pdev->dev, "GPU clock set to %lu\n", rate);
+       }
+
        if (func->require_ref_clk)
                tdev->clk_ref = devm_clk_get(&pdev->dev, "ref");
        if (IS_ERR(tdev->clk_ref)) {