mirror of
https://github.com/openwrt/openwrt.git
synced 2026-06-17 12:40:16 +04:00
8f638f9366
Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.12.91 Remove upstreamed patches: - airoha/patches-6.12/017-v6.13-net-airoha-Implement-BQL-support.patch[1] - airoha/patches-6.12/138-v7.1-net-airoha-Add-missing-RX_CPU_IDX-configuration-in-a.patch[2] - airoha/patches-6.12/149-v7.1-net-airoha-Move-ndesc-initialization-at-end-of-airoh.patch[3] - generic/backport-6.12/940-v7.1-net-dsa-realtek-rtl8365mb-fix-mode-mask-calculation.patch[5] Manually rebased patches: - airoha/patches-6.12/048-01-v6.15-net-airoha-Move-airoha_eth-driver-in-a-dedicated-fol.patch[1] - ath79/patches-6.12/800-leds-add-reset-controller-based-driver.patch[4] - bcm27xx/patches-6.12/950-0122-bcmgenet-Better-coalescing-parameter-defaults.patch[6] We also backported four patches to fix perf tool regression: - generic/backport-6.12/216-01-revert-perf-cgroup-update-metric-leader-in-evlist__e.patch - generic/backport-6.12/216-02-revert-perf-tool_pmu-fix-aggregation-on-duration_tim.patch - generic/backport-6.12/216-03-revert-perf-python-add-parse_events-function.patch - generic/backport-6.12/216-04-revert-perf-tool_pmu-factor-tool-events-into-their-o.patch All other patches are automatically refreshed. [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=ca24fcac1daaa5e8a667981d81986a3eb4b9fb04 [2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=f00037a99bc2332ef59dc85298b98b20af165904 [3] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=d36be272adda7f313e39dd118086955d993bf6a7 [4] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=07d3611389ba7d78b80ea360a42ce32ab2521fbc [5] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=3354d6c62fd4baa7b32cbd80cc5a8aa3f2bd0656 [6] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.12.91&id=b84351dcc359667bc952131c1424b692ec83dce2 Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Link: https://github.com/openwrt/openwrt/pull/23444 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
206 lines
5.6 KiB
Diff
206 lines
5.6 KiB
Diff
From 7c8c3bd6d622a8c900c05ee00b6c290b45e43f2d Mon Sep 17 00:00:00 2001
|
|
From: Dom Cobley <popcornmix@gmail.com>
|
|
Date: Wed, 31 Jan 2024 18:48:01 +0000
|
|
Subject: [PATCH] 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>
|
|
|
|
drm/v3d: Plug dma_fence leak
|
|
|
|
The irq_fence and done_fence are given a reference that is never
|
|
released. The necessary dma_fence_put()s seem to have been
|
|
deleted in error in an earlier commit.
|
|
|
|
Fixes: 0b73676836b2 ("drm/v3d: Clock V3D down when not in use.")
|
|
|
|
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
|
|
|
v3d_drv: Handle missing clock more gracefully
|
|
|
|
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
|
|
|
v3d_gem: Kick the clock so firmware knows we are using firmware clock interface
|
|
|
|
Setting the v3d clock to low value allows firmware to handle dvfs in case
|
|
where v3d hardware is not being actively used (e.g. console use).
|
|
|
|
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
|
---
|
|
drivers/gpu/drm/v3d/v3d_drv.c | 17 ++++++++++
|
|
drivers/gpu/drm/v3d/v3d_drv.h | 7 ++++
|
|
drivers/gpu/drm/v3d/v3d_gem.c | 3 ++
|
|
drivers/gpu/drm/v3d/v3d_submit.c | 56 ++++++++++++++++++++++++++++++++
|
|
4 files changed, 83 insertions(+)
|
|
|
|
--- a/drivers/gpu/drm/v3d/v3d_drv.c
|
|
+++ b/drivers/gpu/drm/v3d/v3d_drv.c
|
|
@@ -341,6 +341,21 @@ static int v3d_platform_drm_probe(struct
|
|
}
|
|
}
|
|
|
|
+ v3d->clk = devm_clk_get(dev, NULL);
|
|
+ if (IS_ERR_OR_NULL(v3d->clk)) {
|
|
+ if (PTR_ERR(v3d->clk) != -EPROBE_DEFER)
|
|
+ dev_err(dev, "Failed to get clock (%ld)\n", PTR_ERR(v3d->clk));
|
|
+ return PTR_ERR(v3d->clk);
|
|
+ }
|
|
+ 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)
|
|
@@ -370,6 +385,8 @@ static int v3d_platform_drm_probe(struct
|
|
ret = v3d_sysfs_init(dev);
|
|
if (ret)
|
|
goto drm_unregister;
|
|
+ ret = clk_set_rate(v3d->clk, v3d->clk_down_rate);
|
|
+ WARN_ON_ONCE(ret != 0);
|
|
|
|
return 0;
|
|
|
|
--- a/drivers/gpu/drm/v3d/v3d_drv.h
|
|
+++ b/drivers/gpu/drm/v3d/v3d_drv.h
|
|
@@ -121,6 +121,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. */
|
|
@@ -597,3 +603,4 @@ int v3d_perfmon_get_counter_ioctl(struct
|
|
/* v3d_sysfs.c */
|
|
int v3d_sysfs_init(struct device *dev);
|
|
void v3d_sysfs_destroy(struct device *dev);
|
|
+void v3d_submit_init(struct drm_device *dev);
|
|
--- a/drivers/gpu/drm/v3d/v3d_gem.c
|
|
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
|
|
@@ -4,6 +4,7 @@
|
|
#include <linux/device.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/io.h>
|
|
+#include <linux/clk.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/reset.h>
|
|
@@ -271,6 +272,8 @@ v3d_gem_init(struct drm_device *dev)
|
|
if (ret)
|
|
return ret;
|
|
|
|
+ v3d_submit_init(dev);
|
|
+
|
|
/* 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".
|
|
--- a/drivers/gpu/drm/v3d/v3d_submit.c
|
|
+++ b/drivers/gpu/drm/v3d/v3d_submit.c
|
|
@@ -5,11 +5,52 @@
|
|
*/
|
|
|
|
#include <drm/drm_syncobj.h>
|
|
+#include <linux/clk.h>
|
|
|
|
#include "v3d_drv.h"
|
|
#include "v3d_regs.h"
|
|
#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);
|
|
+}
|
|
+
|
|
/* Takes the reservation lock on all the BOs being referenced, so that
|
|
* at queue submit time we can update the reservations.
|
|
*
|
|
@@ -87,6 +128,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;
|
|
|
|
if (job->bo) {
|
|
@@ -98,6 +140,8 @@ v3d_job_free(struct kref *ref)
|
|
dma_fence_put(job->irq_fence);
|
|
dma_fence_put(job->done_fence);
|
|
|
|
+ v3d_clock_up_put(v3d);
|
|
+
|
|
if (job->perfmon)
|
|
v3d_perfmon_put(job->perfmon);
|
|
|
|
@@ -199,6 +243,7 @@ v3d_job_init(struct v3d_dev *v3d, struct
|
|
goto fail_deps;
|
|
}
|
|
|
|
+ v3d_clock_up_get(v3d);
|
|
kref_init(&job->refcount);
|
|
|
|
return 0;
|
|
@@ -1398,3 +1443,14 @@ fail:
|
|
|
|
return ret;
|
|
}
|
|
+
|
|
+void v3d_submit_init(struct drm_device *dev) {
|
|
+ struct v3d_dev *v3d = to_v3d_dev(dev);
|
|
+
|
|
+ mutex_init(&v3d->clk_lock);
|
|
+ INIT_DELAYED_WORK(&v3d->clk_down_work, v3d_clock_down_work);
|
|
+
|
|
+ /* kick the clock so firmware knows we are using firmware clock interface */
|
|
+ v3d_clock_up_get(v3d);
|
|
+ v3d_clock_up_put(v3d);
|
|
+}
|
|
\ No newline at end of file
|