diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2019-07-31 18:23:26 +0200 |
---|---|---|
committer | Álvaro Fernández Rojas <noltari@gmail.com> | 2019-08-02 18:51:32 +0200 |
commit | 19226502bf6393706defe7f049c587b32c9b4f33 (patch) | |
tree | 0bff89a72b7006051a6eec1ac3c0c9250490cf4f /target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch | |
parent | 66458c49aa14ebc9ba2e4f9b6a323b8ff122807b (diff) | |
download | upstream-19226502bf6393706defe7f049c587b32c9b4f33.tar.gz upstream-19226502bf6393706defe7f049c587b32c9b4f33.tar.bz2 upstream-19226502bf6393706defe7f049c587b32c9b4f33.zip |
brcm2708: update to latest patches from the RPi foundation
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch')
-rw-r--r-- | target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch b/target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch deleted file mode 100644 index 7472b69156..0000000000 --- a/target/linux/brcm2708/patches-4.19/950-0617-drm-v3d-Clock-V3D-down-when-not-in-use.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 167429373da6ab4f3f498013277eb5545d6f0c64 Mon Sep 17 00:00:00 2001 -From: Eric Anholt <eric@anholt.net> -Date: Thu, 2 May 2019 13:22:53 -0700 -Subject: [PATCH 617/703] drm/v3d: Clock V3D down when not in use. - -My various attempts at re-enabling runtime PM have failed, so just -crank the clock down when V3D is idle to reduce power consumption. - -Signed-off-by: Eric Anholt <eric@anholt.net> ---- - drivers/gpu/drm/v3d/v3d_drv.c | 18 +++++++++++++ - drivers/gpu/drm/v3d/v3d_drv.h | 6 +++++ - drivers/gpu/drm/v3d/v3d_gem.c | 49 +++++++++++++++++++++++++++++++++++ - 3 files changed, 73 insertions(+) - ---- a/drivers/gpu/drm/v3d/v3d_drv.c -+++ b/drivers/gpu/drm/v3d/v3d_drv.c -@@ -297,6 +297,21 @@ static int v3d_platform_drm_probe(struct - } - } - -+ v3d->clk = devm_clk_get(dev, NULL); -+ if (IS_ERR(v3d->clk)) { -+ if (ret != -EPROBE_DEFER) -+ dev_err(dev, "Failed to get clock\n"); -+ goto dev_free; -+ } -+ v3d->clk_up_rate = clk_get_rate(v3d->clk); -+ /* For downclocking, drop it to the minimum frequency we can get from -+ * the CPRMAN clock generator dividing off our parent. The divider is -+ * 4 bits, but ask for just higher than that so that rounding doesn't -+ * make cprman reject our rate. -+ */ -+ v3d->clk_down_rate = -+ (clk_get_rate(clk_get_parent(v3d->clk)) / (1 << 4)) + 10000; -+ - if (v3d->ver < 41) { - ret = map_regs(v3d, &v3d->gca_regs, "gca"); - if (ret) -@@ -331,6 +346,9 @@ static int v3d_platform_drm_probe(struct - if (ret) - goto irq_disable; - -+ ret = clk_set_rate(v3d->clk, v3d->clk_down_rate); -+ WARN_ON_ONCE(ret != 0); -+ - return 0; - - irq_disable: ---- a/drivers/gpu/drm/v3d/v3d_drv.h -+++ b/drivers/gpu/drm/v3d/v3d_drv.h -@@ -45,6 +45,12 @@ struct v3d_dev { - void __iomem *bridge_regs; - void __iomem *gca_regs; - struct clk *clk; -+ struct delayed_work clk_down_work; -+ unsigned long clk_up_rate, clk_down_rate; -+ struct mutex clk_lock; -+ u32 clk_refcount; -+ bool clk_up; -+ - struct reset_control *reset; - - /* Virtual and DMA addresses of the single shared page table. */ ---- a/drivers/gpu/drm/v3d/v3d_gem.c -+++ b/drivers/gpu/drm/v3d/v3d_gem.c -@@ -3,6 +3,7 @@ - - #include <drm/drmP.h> - #include <drm/drm_syncobj.h> -+#include <linux/clk.h> - #include <linux/module.h> - #include <linux/platform_device.h> - #include <linux/pm_runtime.h> -@@ -17,6 +18,47 @@ - #include "v3d_trace.h" - - static void -+v3d_clock_down_work(struct work_struct *work) -+{ -+ struct v3d_dev *v3d = -+ container_of(work, struct v3d_dev, clk_down_work.work); -+ int ret; -+ -+ ret = clk_set_rate(v3d->clk, v3d->clk_down_rate); -+ v3d->clk_up = false; -+ WARN_ON_ONCE(ret != 0); -+} -+ -+static void -+v3d_clock_up_get(struct v3d_dev *v3d) -+{ -+ mutex_lock(&v3d->clk_lock); -+ if (v3d->clk_refcount++ == 0) { -+ cancel_delayed_work_sync(&v3d->clk_down_work); -+ if (!v3d->clk_up) { -+ int ret; -+ -+ ret = clk_set_rate(v3d->clk, v3d->clk_up_rate); -+ WARN_ON_ONCE(ret != 0); -+ v3d->clk_up = true; -+ } -+ } -+ mutex_unlock(&v3d->clk_lock); -+} -+ -+static void -+v3d_clock_up_put(struct v3d_dev *v3d) -+{ -+ mutex_lock(&v3d->clk_lock); -+ if (--v3d->clk_refcount == 0) { -+ schedule_delayed_work(&v3d->clk_down_work, -+ msecs_to_jiffies(100)); -+ } -+ mutex_unlock(&v3d->clk_lock); -+} -+ -+ -+static void - v3d_init_core(struct v3d_dev *v3d, int core) - { - /* Set OVRTMUOUT, which means that the texture sampler uniform -@@ -490,6 +532,7 @@ static void - v3d_job_free(struct kref *ref) - { - struct v3d_job *job = container_of(ref, struct v3d_job, refcount); -+ struct v3d_dev *v3d = job->v3d; - int i; - - for (i = 0; i < job->bo_count; i++) { -@@ -505,6 +548,8 @@ v3d_job_free(struct kref *ref) - dma_fence_put(job->irq_fence); - dma_fence_put(job->done_fence); - -+ v3d_clock_up_put(v3d); -+ - kfree(job); - } - -@@ -596,6 +641,7 @@ v3d_job_init(struct v3d_dev *v3d, struct - if (ret) - return ret; - -+ v3d_clock_up_get(v3d); - kref_init(&job->refcount); - - return 0; -@@ -963,6 +1009,9 @@ v3d_gem_init(struct drm_device *dev) - mutex_init(&v3d->sched_lock); - mutex_init(&v3d->cache_clean_lock); - -+ mutex_init(&v3d->clk_lock); -+ INIT_DELAYED_WORK(&v3d->clk_down_work, v3d_clock_down_work); -+ - /* Note: We don't allocate address 0. Various bits of HW - * treat 0 as special, such as the occlusion query counters - * where 0 means "disabled". |