linux/drivers/clk/mediatek
AngeloGioacchino Del Regno b05ea33143 clk: mediatek: clk-mux: Add .determine_rate() callback
Since commit 262ca38f4b ("clk: Stop forwarding clk_rate_requests
to the parent"), the clk_rate_request is .. as the title says, not
forwarded anymore to the parent: this produces an issue with the
MediaTek clock MUX driver during GPU DVFS on MT8195, but not on
MT8192 or others.

This is because, differently from others, like MT8192 where all of
the clocks in the MFG parents tree are of mtk_mux type, but in the
parent tree of MT8195's MFG clock, we have one mtk_mux clock and
one (clk framework generic) mux clock, like so:

names: mfg_bg3d -> mfg_ck_fast_ref -> top_mfg_core_tmp (or) mfgpll
types: mtk_gate ->      mux        ->     mtk_mux      (or) mtk_pll

To solve this issue and also keep the GPU DVFS clocks code working
as expected, wire up a .determine_rate() callback for the mtk_mux
ops; for that, the standard clk_mux_determine_rate_flags() was used
as it was possible to.

This commit was successfully tested on MT6795 Xperia M5, MT8173 Elm,
MT8192 Spherion and MT8195 Tomato; no regressions were seen.

For the sake of some more documentation about this issue here's the
trace of it:

[   12.211587] ------------[ cut here ]------------
[   12.211589] WARNING: CPU: 6 PID: 78 at drivers/clk/clk.c:1462 clk_core_init_rate_req+0x84/0x90
[   12.211593] Modules linked in: stp crct10dif_ce mtk_adsp_common llc rfkill snd_sof_xtensa_dsp
               panfrost(+) sbs_battery cros_ec_lid_angle cros_ec_sensors snd_sof_of
               cros_ec_sensors_core hid_multitouch cros_usbpd_logger snd_sof gpu_sched
               snd_sof_utils fuse ipv6
[   12.211614] CPU: 6 PID: 78 Comm: kworker/u16:2 Tainted: G        W          6.0.0-next-20221011+ #58
[   12.211616] Hardware name: Acer Tomato (rev2) board (DT)
[   12.211617] Workqueue: devfreq_wq devfreq_monitor
[   12.211620] pstate: 40400009 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   12.211622] pc : clk_core_init_rate_req+0x84/0x90
[   12.211625] lr : clk_core_forward_rate_req+0xa4/0xe4
[   12.211627] sp : ffff80000893b8e0
[   12.211628] x29: ffff80000893b8e0 x28: ffffdddf92f9b000 x27: ffff46a2c0e8bc05
[   12.211632] x26: ffff46a2c1041200 x25: 0000000000000000 x24: 00000000173eed80
[   12.211636] x23: ffff80000893b9c0 x22: ffff80000893b940 x21: 0000000000000000
[   12.211641] x20: ffff46a2c1039f00 x19: ffff46a2c1039f00 x18: 0000000000000000
[   12.211645] x17: 0000000000000038 x16: 000000000000d904 x15: 0000000000000003
[   12.211649] x14: ffffdddf9357ce48 x13: ffffdddf935e71c8 x12: 000000000004803c
[   12.211653] x11: 00000000a867d7ad x10: 00000000a867d7ad x9 : ffffdddf90c28df4
[   12.211657] x8 : ffffdddf9357a980 x7 : 0000000000000000 x6 : 0000000000000004
[   12.211661] x5 : ffffffffffffffc8 x4 : 00000000173eed80 x3 : ffff80000893b940
[   12.211665] x2 : 00000000173eed80 x1 : ffff80000893b940 x0 : 0000000000000000
[   12.211669] Call trace:
[   12.211670]  clk_core_init_rate_req+0x84/0x90
[   12.211673]  clk_core_round_rate_nolock+0xe8/0x10c
[   12.211675]  clk_mux_determine_rate_flags+0x174/0x1f0
[   12.211677]  clk_mux_determine_rate+0x1c/0x30
[   12.211680]  clk_core_determine_round_nolock+0x74/0x130
[   12.211682]  clk_core_round_rate_nolock+0x58/0x10c
[   12.211684]  clk_core_round_rate_nolock+0xf4/0x10c
[   12.211686]  clk_core_set_rate_nolock+0x194/0x2ac
[   12.211688]  clk_set_rate+0x40/0x94
[   12.211691]  _opp_config_clk_single+0x38/0xa0
[   12.211693]  _set_opp+0x1b0/0x500
[   12.211695]  dev_pm_opp_set_rate+0x120/0x290
[   12.211697]  panfrost_devfreq_target+0x3c/0x50 [panfrost]
[   12.211705]  devfreq_set_target+0x8c/0x2d0
[   12.211707]  devfreq_update_target+0xcc/0xf4
[   12.211708]  devfreq_monitor+0x40/0x1d0
[   12.211710]  process_one_work+0x294/0x664
[   12.211712]  worker_thread+0x7c/0x45c
[   12.211713]  kthread+0x104/0x110
[   12.211716]  ret_from_fork+0x10/0x20
[   12.211718] irq event stamp: 7102
[   12.211719] hardirqs last  enabled at (7101): [<ffffdddf904ea5a0>] finish_task_switch.isra.0+0xec/0x2f0
[   12.211723] hardirqs last disabled at (7102): [<ffffdddf91794b74>] el1_dbg+0x24/0x90
[   12.211726] softirqs last  enabled at (6716): [<ffffdddf90410be4>] __do_softirq+0x414/0x588
[   12.211728] softirqs last disabled at (6507): [<ffffdddf904171d8>] ____do_softirq+0x18/0x24
[   12.211730] ---[ end trace 0000000000000000 ]---

Fixes: 262ca38f4b ("clk: Stop forwarding clk_rate_requests to the parent")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20221011135548.318323-1-angelogioacchino.delregno@collabora.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
2022-10-14 13:38:20 -07:00
..
clk-apmixed.c clk: mediatek: Switch to clk_hw provider APIs 2022-05-19 16:57:57 -07:00
clk-cpumux.c clk: mediatek: Switch to clk_hw provider APIs 2022-05-19 16:57:57 -07:00
clk-cpumux.h clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-gate.c clk: mediatek: Switch to clk_hw provider APIs 2022-05-19 16:57:57 -07:00
clk-gate.h clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701-bdp.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701-eth.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt2701-g3d.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt2701-hif.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt2701-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2701.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt2712-bdp.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-jpgdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-mfg.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712-venc.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt2712.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt6765-audio.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765-cam.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765-mipi0a.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765-vcodec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6765.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-cam.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-ipe.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-mfg.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779-venc.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6779.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6797-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6797-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6797-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6797-venc.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt6797.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7622-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7622-eth.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt7622-hif.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt7622.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt7629-eth.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt7629-hif.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
clk-mt7629.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7986-apmixed.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7986-eth.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7986-infracfg.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt7986-topckgen.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8135.c clk: mediatek: reset: Support nonsequence base offsets of reset registers 2022-06-15 17:24:12 -07:00
clk-mt8167-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8167-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8167-mfgcfg.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8167-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8167-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8167.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8173-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8173.c clk: mediatek: reset: Support nonsequence base offsets of reset registers 2022-06-15 17:24:12 -07:00
clk-mt8183-audio.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-cam.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-img.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-ipu0.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-ipu1.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-ipu_adl.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-ipu_conn.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-mfgcfg.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-vdec.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183-venc.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8183.c clk: mediatek: reset: Add infra_ao reset support for MT8192/MT8195 2022-06-15 17:24:13 -07:00
clk-mt8186-apmixedsys.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8186-cam.c clk: mediatek: Add MT8186 camsys clock support 2022-04-25 16:59:40 -07:00
clk-mt8186-img.c clk: mediatek: Add MT8186 imgsys clock support 2022-04-25 16:59:40 -07:00
clk-mt8186-imp_iic_wrap.c clk: mediatek: Add MT8186 imp i2c wrapper clock support 2022-04-25 16:59:39 -07:00
clk-mt8186-infra_ao.c clk: mediatek: reset: Add infra_ao reset support for MT8186 2022-06-15 17:24:25 -07:00
clk-mt8186-ipe.c clk: mediatek: Add MT8186 ipesys clock support 2022-04-25 16:59:41 -07:00
clk-mt8186-mcu.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8186-mdp.c clk: mediatek: Add MT8186 mdpsys clock support 2022-04-25 16:59:40 -07:00
clk-mt8186-mfg.c clk: mediatek: Add MT8186 mfgsys clock support 2022-04-25 16:59:39 -07:00
clk-mt8186-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8186-topckgen.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8186-vdec.c clk: mediatek: Add MT8186 vdecsys clock support 2022-04-25 16:59:40 -07:00
clk-mt8186-venc.c clk: mediatek: Add MT8186 vencsys clock support 2022-04-25 16:59:40 -07:00
clk-mt8186-wpe.c clk: mediatek: Add MT8186 wpesys clock support 2022-04-25 16:59:40 -07:00
clk-mt8192-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8192-cam.c clk: mediatek: Add MT8192 camsys clock support 2021-07-27 10:53:07 -07:00
clk-mt8192-img.c clk: mediatek: Add MT8192 imgsys clock support 2021-07-27 10:53:08 -07:00
clk-mt8192-imp_iic_wrap.c clk: mediatek: Add MT8192 imp i2c wrapper clock support 2021-07-27 10:53:08 -07:00
clk-mt8192-ipe.c clk: mediatek: Add MT8192 ipesys clock support 2021-07-27 10:53:08 -07:00
clk-mt8192-mdp.c clk: mediatek: Add MT8192 mdpsys clock support 2021-07-27 10:53:09 -07:00
clk-mt8192-mfg.c clk: mediatek: Add MT8192 mfgcfg clock support 2021-07-27 10:53:09 -07:00
clk-mt8192-mm.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8192-msdc.c clk: mediatek: Delete MT8192 msdc gate 2022-06-09 15:45:27 -07:00
clk-mt8192-scp_adsp.c clk: mediatek: Add MT8192 scp adsp clock support 2021-07-27 10:53:10 -07:00
clk-mt8192-vdec.c clk: mediatek: Add MT8192 vdecsys clock support 2021-07-27 10:53:10 -07:00
clk-mt8192-venc.c clk: mediatek: Add MT8192 vencsys clock support 2021-07-27 10:53:10 -07:00
clk-mt8192.c clk: mediatek: reset: Add infra_ao reset support for MT8192/MT8195 2022-06-15 17:24:13 -07:00
clk-mt8195-apmixedsys.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8195-apusys_pll.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8195-cam.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-ccu.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-img.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-imp_iic_wrap.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-infra_ao.c clk: mediatek: reset: Add infra_ao reset support for MT8192/MT8195 2022-06-15 17:24:13 -07:00
clk-mt8195-ipe.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-mfg.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-peri_ao.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-scp_adsp.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-topckgen.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8195-vdec.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-vdo0.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8195-vdo1.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8195-venc.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-vpp0.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-vpp1.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8195-wpe.c clk: mediatek: mt8195: Hook up mtk_clk_simple_remove() 2022-02-17 12:12:25 -08:00
clk-mt8516-aud.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mt8516.c clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-mtk.c clk: mediatek: reset: Add reset support for simple probe 2022-06-15 17:24:13 -07:00
clk-mtk.h clk: mediatek: reset: Add reset support for simple probe 2022-06-15 17:24:13 -07:00
clk-mux.c clk: mediatek: clk-mux: Add .determine_rate() callback 2022-10-14 13:38:20 -07:00
clk-mux.h clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
clk-pll.c clk: mediatek: Switch to clk_hw provider APIs 2022-05-19 16:57:57 -07:00
clk-pll.h clk: mediatek: Replace 'struct clk' with 'struct clk_hw' 2022-05-19 16:57:56 -07:00
Kconfig clk: mediatek: Add MT8186 mcusys clock support 2022-04-25 16:59:39 -07:00
Makefile clk: mediatek: Add MT8186 ipesys clock support 2022-04-25 16:59:41 -07:00
reset.c clk: mediatek: reset: Add new register reset function with device 2022-06-15 17:24:13 -07:00
reset.h clk: mediatek: reset: Add infra_ao reset support for MT8192/MT8195 2022-06-15 17:24:13 -07:00