Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save notro/0adcfcb12460b54e54458afe11dc8ea2 to your computer and use it in GitHub Desktop.
Save notro/0adcfcb12460b54e54458afe11dc8ea2 to your computer and use it in GitHub Desktop.
From 694299489e9a1e7b95245c4adff272b980f7f852 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
Date: Fri, 2 Sep 2022 13:19:15 +0200
Subject: [PATCH 3/3] HACK: drm/vc4: Keep the VEC clock running all the time
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Workaround to prevent crash on Pi4 when running command:
$ modetest -M vc4 -s 45:720x576i -w 45:'TV mode':4
Crash report:
[ 166.702171] SError Interrupt on CPU1, code 0x00000000bf000002 -- SError
[ 166.702187] CPU: 1 PID: 8 Comm: kworker/u8:0 Tainted: G W 5.19.0-rc6-00096-gba7973977976-dirty #1
[ 166.702200] Hardware name: Raspberry Pi 4 Model B Rev 1.1 (DT)
[ 166.702206] Workqueue: events_freezable_power_ thermal_zone_device_check
[ 166.702231] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 166.702242] pc : regmap_mmio_read32le+0x10/0x28
[ 166.702261] lr : regmap_mmio_read+0x44/0x70
[ 166.702271] sp : ffff800008063bf0
[ 166.702274] x29: ffff800008063bf0 x28: ffffba2ec3257000 x27: ffff22e50000c078
[ 166.702290] x26: ffff22e50000c028 x25: 0000000000000000 x24: ffff22e500831be0
[ 166.702303] x23: ffff800008063da4 x22: ffff800008063cc4 x21: ffff800008063cc4
[ 166.702315] x20: 0000000000000200 x19: ffff22e503c9ae00 x18: 0000000000000010
[ 166.702328] x17: 0000000400000000 x16: ffffba2ec2528798 x15: 000000532dba6262
[ 166.702341] x14: 0000000000000094 x13: 0000000000000001 x12: 0000000000000000
[ 166.702354] x11: 0000000000000001 x10: 0000000000000a50 x9 : ffff22e500041584
[ 166.702366] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff22e500041574
[ 166.702378] x5 : 005f7265776f705f x4 : 0000000000000000 x3 : ffffba2ec252ea68
[ 166.702390] x2 : ffffba2ec252e8b0 x1 : 0000000000000200 x0 : 0000000000000000
[ 166.702405] Kernel panic - not syncing: Asynchronous SError Interrupt
[ 166.702410] CPU: 1 PID: 8 Comm: kworker/u8:0 Tainted: G W 5.19.0-rc6-00096-gba7973977976-dirty #1
[ 166.702421] Hardware name: Raspberry Pi 4 Model B Rev 1.1 (DT)
[ 166.702425] Workqueue: events_freezable_power_ thermal_zone_device_check
[ 166.702439] Call trace:
[ 166.702443] dump_backtrace+0xdc/0xe8
[ 166.702463] show_stack+0x18/0x68
[ 166.702475] dump_stack_lvl+0x68/0x84
[ 166.702488] dump_stack+0x18/0x34
[ 166.702496] panic+0x16c/0x32c
[ 166.702513] add_taint+0x0/0xa8
[ 166.702526] arm64_serror_panic+0x6c/0x80
[ 166.702534] do_serror+0x34/0x80
[ 166.702541] el1h_64_error_handler+0x34/0x50
[ 166.702555] el1h_64_error+0x64/0x68
[ 166.702563] regmap_mmio_read32le+0x10/0x28
[ 166.702573] _regmap_bus_reg_read+0x18/0x28
[ 166.702591] _regmap_read+0x64/0xf8
[ 166.702598] regmap_read+0x4c/0x78
[ 166.702606] bcm2711_get_temp+0x58/0xb0 [bcm2711_thermal]
[ 166.702622] of_thermal_get_temp+0x28/0x40
[ 166.702637] thermal_zone_get_temp+0x70/0x158
[ 166.702648] thermal_zone_device_update+0x7c/0x2d8
[ 166.702658] thermal_zone_device_check+0x18/0x28
[ 166.702668] process_one_work+0x1c0/0x308
[ 166.702681] worker_thread+0x4c/0x400
[ 166.702691] kthread+0x110/0x120
[ 166.702699] ret_from_fork+0x10/0x20
[ 166.702710] SMP: stopping secondary CPUs
[ 167.834381] SMP: failed to stop secondary CPUs 0-2
[ 167.834389] Kernel Offset: 0x3a2eb9e00000 from 0xffff800008000000
[ 167.834395] PHYS_OFFSET: 0xffffdd1b40000000
[ 167.834398] CPU features: 0x800,00027810,00001086
[ 167.834404] Memory Limit: none
[ 168.135055] ---[ end Kernel panic - not syncing: Asynchronous SError Interrupt ]---
Link: https://lore.kernel.org/dri-devel/24e09a29-6d04-3b1e-63ce-cd3c31d350e2@tronnes.org/T/#u
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
drivers/gpu/drm/vc4/vc4_vec.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c
index 55f6f490877c..7191bce270b0 100644
--- a/drivers/gpu/drm/vc4/vc4_vec.c
+++ b/drivers/gpu/drm/vc4/vc4_vec.c
@@ -543,8 +543,6 @@ static void vc4_vec_encoder_disable(struct drm_encoder *encoder,
VEC_DAC_MISC_DAC_PWRDN |
VEC_DAC_MISC_LDO_PWRDN);
- clk_disable_unprepare(vec->clock);
-
ret = pm_runtime_put(&vec->pdev->dev);
if (ret < 0) {
DRM_ERROR("Failed to release power domain: %d\n", ret);
@@ -595,12 +593,6 @@ static void vc4_vec_encoder_enable(struct drm_encoder *encoder,
goto err_put_runtime_pm;
}
- ret = clk_prepare_enable(vec->clock);
- if (ret) {
- DRM_ERROR("Failed to turn on core clock: %d\n", ret);
- goto err_put_runtime_pm;
- }
-
/* Reset the different blocks */
VEC_WRITE(VEC_WSE_RESET, 1);
VEC_WRITE(VEC_SOFT_RESET, 1);
@@ -739,6 +731,12 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
if (ret)
return ret;
+ ret = clk_prepare_enable(vec->clock);
+ if (ret) {
+ DRM_ERROR("Failed to turn on core clock: %d\n", ret);
+ return ret;
+ }
+
ret = drmm_encoder_init(drm, &vec->encoder.base,
&vc4_vec_encoder_funcs,
DRM_MODE_ENCODER_TVDAC,
@@ -757,8 +755,17 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data)
return 0;
}
+static void vc4_vec_unbind(struct device *dev, struct device *master,
+ void *data)
+{
+ struct vc4_vec *vec = dev_get_drvdata(dev);
+
+ clk_disable_unprepare(vec->clock);
+}
+
static const struct component_ops vc4_vec_ops = {
.bind = vc4_vec_bind,
+ .unbind = vc4_vec_unbind,
};
static int vc4_vec_dev_probe(struct platform_device *pdev)
--
2.25.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment