clk: mediatek: Fix descriptor clock ID allocation
Subsystems (2)
cover clk: mediatek: Fix descriptor clock ID allocation
Several MediaTek clock providers have clock IDs that do not match the size of the clock array allocated by the common descriptor-based probe.
Add dummy entries for missing IDs so that the allocated onecell data covers the complete clock ID space used by each provider.
Akari Tsuyukusa (6):
clk: mediatek: Fix MT6779 clock onecell IDs
clk: mediatek: Fix MT6797 clock onecell IDs
clk: mediatek: Reserve missing MT8167 clock ID
clk: mediatek: Reserve missing MT8173 topckgen IDs
clk: mediatek: Reserve missing MT8196 MDP clock IDs
clk: mediatek: Reserve missing MT8516 top clock IDs
drivers/clk/mediatek/clk-mt6779-aud.c | 1 + drivers/clk/mediatek/clk-mt6779-cam.c | 1 + drivers/clk/mediatek/clk-mt6779-img.c | 1 + drivers/clk/mediatek/clk-mt6779-ipe.c | 1 + drivers/clk/mediatek/clk-mt6779-mfg.c | 1 + drivers/clk/mediatek/clk-mt6779-mm.c | 2 ++ drivers/clk/mediatek/clk-mt6779-vdec.c | 1 + drivers/clk/mediatek/clk-mt6779-venc.c | 1 + drivers/clk/mediatek/clk-mt6779.c | 1 + drivers/clk/mediatek/clk-mt6797-img.c | 1 + drivers/clk/mediatek/clk-mt6797-mm.c | 1 + drivers/clk/mediatek/clk-mt6797-vdec.c | 1 + drivers/clk/mediatek/clk-mt6797-venc.c | 1 + drivers/clk/mediatek/clk-mt8167.c | 1 + drivers/clk/mediatek/clk-mt8173-topckgen.c | 7 +++++++ drivers/clk/mediatek/clk-mt8196-mdpsys.c | 2 ++ drivers/clk/mediatek/clk-mt8516.c | 2 ++ 17 files changed, 26 insertions(+)
Signature · 1 line
2.55.0
PATCH 1/6 clk: mediatek: Fix MT6779 clock onecell IDs
Add the missing dummy slot for clock ID 0 in the MT6779 audio, camera, image, IPE, MFG, multimedia, VDEC and VENC clock providers.
Also register the missing SSPM infracfg clock and reserve the binding-defined MDP WDMA0 slot in the multimedia provider.
This fixes the onecell clock data allocation so all registered clock IDs are within bounds.
--- drivers/clk/mediatek/clk-mt6779-aud.c | 1 + drivers/clk/mediatek/clk-mt6779-cam.c | 1 + drivers/clk/mediatek/clk-mt6779-img.c | 1 + drivers/clk/mediatek/clk-mt6779-ipe.c | 1 + drivers/clk/mediatek/clk-mt6779-mfg.c | 1 + drivers/clk/mediatek/clk-mt6779-mm.c | 2 ++ drivers/clk/mediatek/clk-mt6779-vdec.c | 1 + drivers/clk/mediatek/clk-mt6779-venc.c | 1 + drivers/clk/mediatek/clk-mt6779.c | 1 + 9 files changed, 10 insertions(+)
drivers/clk/mediatek/clk-mt6779-aud.c +1 -0
@@ -33,6 +33,7 @@ static const struct mtk_gate_regs audio1_cg_regs = { &mtk_clk_gate_ops_no_setclr)static const struct mtk_gate audio_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"aud_dummy" ),/* AUDIO0 */ GATE_AUDIO0 (CLK_AUD_AFE ,"aud_afe" ,"audio_sel" ,2 ),GATE_AUDIO0 (CLK_AUD_22M ,"aud_22m" ,"aud_eng1_sel" ,8 ),
drivers/clk/mediatek/clk-mt6779-cam.c +1 -0
@@ -23,6 +23,7 @@ static const struct mtk_gate_regs cam_cg_regs = { &mtk_clk_gate_ops_setclr)static const struct mtk_gate cam_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"cam_dummy" ),GATE_CAM (CLK_CAM_LARB10 ,"camsys_larb10" ,"cam_sel" ,0 ),GATE_CAM (CLK_CAM_DFP_VAD ,"camsys_dfp_vad" ,"cam_sel" ,1 ),GATE_CAM (CLK_CAM_LARB11 ,"camsys_larb11" ,"cam_sel" ,2 ),
drivers/clk/mediatek/clk-mt6779-img.c +1 -0
@@ -23,6 +23,7 @@ static const struct mtk_gate_regs img_cg_regs = { &mtk_clk_gate_ops_setclr)static const struct mtk_gate img_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"img_dummy" ),GATE_IMG (CLK_IMG_LARB5 ,"imgsys_larb5" ,"img_sel" ,0 ),GATE_IMG (CLK_IMG_LARB6 ,"imgsys_larb6" ,"img_sel" ,1 ),GATE_IMG (CLK_IMG_DIP ,"imgsys_dip" ,"img_sel" ,2 ),
drivers/clk/mediatek/clk-mt6779-ipe.c +1 -0
@@ -23,6 +23,7 @@ static const struct mtk_gate_regs ipe_cg_regs = { &mtk_clk_gate_ops_setclr)static const struct mtk_gate ipe_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"ipe_dummy" ),GATE_IPE (CLK_IPE_LARB7 ,"ipe_larb7" ,"ipe_sel" ,0 ),GATE_IPE (CLK_IPE_LARB8 ,"ipe_larb8" ,"ipe_sel" ,1 ),GATE_IPE (CLK_IPE_SMI_SUBCOM ,"ipe_smi_subcom" ,"ipe_sel" ,2 ),
drivers/clk/mediatek/clk-mt6779-mfg.c +1 -0
@@ -24,6 +24,7 @@ static const struct mtk_gate_regs mfg_cg_regs = { &mtk_clk_gate_ops_setclr)static const struct mtk_gate mfg_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"mfg_dummy" ),GATE_MFG (CLK_MFGCFG_BG3D ,"mfg_bg3d" ,"mfg_sel" ,0 ), };
drivers/clk/mediatek/clk-mt6779-mm.c +2 -0
@@ -32,6 +32,7 @@ static const struct mtk_gate_regs mm1_cg_regs = { &mtk_clk_gate_ops_setclr)static const struct mtk_gate mm_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"mm_dummy" ),/* MM0 */ GATE_MM0 (CLK_MM_SMI_COMMON ,"mm_smi_common" ,"mm_sel" ,0 ),GATE_MM0 (CLK_MM_SMI_LARB0 ,"mm_smi_larb0" ,"mm_sel" ,1 ),
@@ -76,6 +77,7 @@ static const struct mtk_gate mm_clks[] = {GATE_MM1 (CLK_MM_26M ,"mm_26m" ,"f_f26m_ck" ,7 ),GATE_MM1 (CLK_MM_MM_R2Y ,"mm_mmsys_r2y" ,"mm_sel" ,8 ),GATE_MM1 (CLK_MM_DISP_RSZ ,"mm_disp_rsz" ,"mm_sel" ,9 ), +GATE_DUMMY (CLK_MM_MDP_WDMA0 ,"mm_mdp_wdma0_dummy" ),GATE_MM1 (CLK_MM_MDP_AAL ,"mm_mdp_aal" ,"mm_sel" ,10 ),GATE_MM1 (CLK_MM_MDP_HDR ,"mm_mdp_hdr" ,"mm_sel" ,11 ), GATE_MM1(CLK_MM_DBI_MM_CK, "mm_dbi_mmck", "mm_sel", 12),
drivers/clk/mediatek/clk-mt6779-vdec.c +1 -0
@@ -33,6 +33,7 @@ static const struct mtk_gate_regs vdec1_cg_regs = { &mtk_clk_gate_ops_setclr_inv)static const struct mtk_gate vdec_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"vdec_dummy" ),/* VDEC0 */ GATE_VDEC0_I (CLK_VDEC_VDEC ,"vdec_cken" ,"vdec_sel" ,0 ),/* VDEC1 */
drivers/clk/mediatek/clk-mt6779-venc.c +1 -0
@@ -24,6 +24,7 @@ static const struct mtk_gate_regs venc_cg_regs = { &mtk_clk_gate_ops_setclr_inv)static const struct mtk_gate venc_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"venc_dummy" ),GATE_VENC_I (CLK_VENC_GCON_LARB ,"venc_larb" ,"venc_sel" ,0 ),GATE_VENC_I (CLK_VENC_GCON_VENC ,"venc_venc" ,"venc_sel" ,4 ),GATE_VENC_I (CLK_VENC_GCON_JPGENC ,"venc_jpgenc" ,"venc_sel" ,8 ),
drivers/clk/mediatek/clk-mt6779.c +1 -0
@@ -1014,6 +1014,7 @@ static const struct mtk_gate infra_clks[] = { "fufs_sel", 13),GATE_INFRA2 (CLK_INFRA_MD32_BCLK ,"infra_md32_bclk" ,"axi_sel" ,14 ), +GATE_DUMMY (CLK_INFRA_SSPM ,"infra_sspm_dummy" ),GATE_INFRA2 (CLK_INFRA_UNIPRO_MBIST ,"infra_unipro_mbist" ,"axi_sel" ,16 ), GATE_INFRA2(CLK_INFRA_SSPM_BUS_HCLK, "infra_sspm_bus_hclk",
Signature · 1 line
2.55.0
PATCH 2/6 clk: mediatek: Fix MT6797 clock onecell IDs
In reply to Akari TsuyukusaAdd the missing dummy clock at ID 0 to the MT6797 image, multimedia, VDEC and VENC clock providers.
This keeps the descriptor-based onecell allocations consistent with the binding clock IDs and prevents out-of-bounds accesses.
--- drivers/clk/mediatek/clk-mt6797-img.c | 1 + drivers/clk/mediatek/clk-mt6797-mm.c | 1 + drivers/clk/mediatek/clk-mt6797-vdec.c | 1 + drivers/clk/mediatek/clk-mt6797-venc.c | 1 + 4 files changed, 4 insertions(+)
drivers/clk/mediatek/clk-mt6797-img.c +1 -0
@@ -20,6 +20,7 @@ static const struct mtk_gate_regs img_cg_regs = { GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr)static const struct mtk_gate img_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"img_dummy" ),GATE_IMG (CLK_IMG_FDVT ,"img_fdvt" ,"mm_sel" ,11 ),GATE_IMG (CLK_IMG_DPE ,"img_dpe" ,"mm_sel" ,10 ),GATE_IMG (CLK_IMG_DIP ,"img_dip" ,"mm_sel" ,6 ),
drivers/clk/mediatek/clk-mt6797-mm.c +1 -0
@@ -30,6 +30,7 @@ static const struct mtk_gate_regs mm1_cg_regs = { GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)static const struct mtk_gate mm_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"mm_dummy" ),GATE_MM0 (CLK_MM_SMI_COMMON ,"mm_smi_common" ,"mm_sel" ,0 ),GATE_MM0 (CLK_MM_SMI_LARB0 ,"mm_smi_larb0" ,"mm_sel" ,1 ),GATE_MM0 (CLK_MM_SMI_LARB5 ,"mm_smi_larb5" ,"mm_sel" ,2 ),
drivers/clk/mediatek/clk-mt6797-vdec.c +1 -0
@@ -31,6 +31,7 @@ static const struct mtk_gate_regs vdec1_cg_regs = { GATE_MTK(_id, _name, _parent, &vdec1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)static const struct mtk_gate vdec_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"vdec_dummy" ),GATE_VDEC0 (CLK_VDEC_CKEN_ENG ,"vdec_cken_eng" ,"vdec_sel" ,8 ),GATE_VDEC0 (CLK_VDEC_ACTIVE ,"vdec_active" ,"vdec_sel" ,4 ),GATE_VDEC0 (CLK_VDEC_CKEN ,"vdec_cken" ,"vdec_sel" ,0 ),
drivers/clk/mediatek/clk-mt6797-venc.c +1 -0
@@ -22,6 +22,7 @@ static const struct mtk_gate_regs venc_cg_regs = { GATE_MTK(_id, _name, _parent, &venc_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)static const struct mtk_gate venc_clks[] = { +GATE_DUMMY (CLK_DUMMY ,"venc_dummy" ),GATE_VENC (CLK_VENC_0 ,"venc_0" ,"mm_sel" ,0 ),GATE_VENC (CLK_VENC_1 ,"venc_1" ,"venc_sel" ,4 ),GATE_VENC (CLK_VENC_2 ,"venc_2" ,"venc_sel" ,8 ),
Signature · 1 line
2.55.0
PATCH 3/6 clk: mediatek: Reserve missing MT8167 clock ID
In reply to Akari TsuyukusaReserve the binding-defined CLK_TOP_HDMTX_CLKDIG_CTS slot in the MT8167 top clock provider with a dummy clock.
The clock is not implemented by the topckgen driver, but the slot must remain present in the onecell data to keep the descriptor allocation large enough for the registered IDs.
--- drivers/clk/mediatek/clk-mt8167.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/mediatek/clk-mt8167.c +1 -0
@@ -746,6 +746,7 @@ static const struct mtk_gate_regs top5_cg_regs = { GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)static const struct mtk_gate top_clks[] = { +GATE_DUMMY (CLK_TOP_HDMTX_CLKDIG_CTS ,"hdmtx_clkdig_cts_dummy" ),/* TOP0 */ GATE_TOP0 (CLK_TOP_PWM_MM ,"pwm_mm" ,"pwm_mm_sel" ,0 ),GATE_TOP0 (CLK_TOP_CAM_MM ,"cam_mm" ,"camtg_mm_sel" ,1 ),
Signature · 1 line
2.55.0
PATCH 3/6 clk: mediatek: Reserve missing MT8167 clock ID
I tested this patch on the Sony PlayStation Classic Mini (MT8167) and unfortunately it breaks HDMI output.
MediaTek HDMI PHY driver registers the hdmtx_clkdig_cts clock at runtime [1]. When this patch is applied, the following boot error appears:
10018300.hdmi-phy: error -EEXIST: failed to register clk 'hdmtx_dig_cts'
(0xffff0000018539a0)
10018300.hdmi-phy: error -EEXIST: Failed to register PLL 10018300.hdmi-phy: probe with driver mediatek-hdmi-phy failed with error
-17
The original problem is caused by having the HDMI PHY node disabled in the DTS, which is usually the dtsi default, but it does not happen if the HDMI PHY is enabled. If this is merged I think this error would show up on all the affected SoCs.
Re: [PATCH 3/6] clk: mediatek: Reserve missing MT8167 clock ID
I apologize, I just noticed that your patch adds the "_dummy" suffix to the clock name. I had originally applied your change manually using the DTS clock name "hdmtx_dig_cts", that's why I experienced that error, but when using the name as you sent it it actually works fine; the additional dummy clock does not interfere with the one provided by the HDMI PHY.
I apologize for the confusion, but at least I can provide a tested tag :-)
PATCH 4/6 clk: mediatek: Reserve missing MT8173 topckgen IDs
In reply to Akari TsuyukusaReserve the unused clock ID 2 and the binding-defined CLK_TOP_HDMITX_DIG_CTS slot in the MT8173 topckgen provider.
Neither clock is implemented by topckgen: ID 2 corresponds to the removed DPI clock, while the HDMI digital clock is provided by the HDMI PHY.
Keep both onecell slots populated with dummy clocks so the descriptor-based allocation covers the complete registered ID range.
--- drivers/clk/mediatek/clk-mt8173-topckgen.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/clk/mediatek/clk-mt8173-topckgen.c +7 -0
@@ -624,6 +624,11 @@ static const struct mtk_composite top_muxes[] = { MUX(CLK_TOP_I2S3_B_SEL, "i2s3_b_ck_sel", i2s3_b_ck_parents, 0x120, 8, 1), }; +static const struct mtk_gate top_dummy_clks[] = { +GATE_DUMMY (2 ,"topck_reserved_2" ), +GATE_DUMMY (CLK_TOP_HDMITX_DIG_CTS ,"hdmitx_dig_cts_dummy" ), +}; +static const struct mtk_clk_desc topck_desc = { .fixed_clks = fixed_clks, .num_fixed_clks =ARRAY_SIZE (fixed_clks),
@@ -631,6 +636,8 @@ static const struct mtk_clk_desc topck_desc = { .num_factor_clks = ARRAY_SIZE(top_divs), .composite_clks = top_muxes, .num_composite_clks = ARRAY_SIZE(top_muxes), + .clks = top_dummy_clks, + .num_clks = ARRAY_SIZE(top_dummy_clks), .clk_lock = &mt8173_top_clk_lock, };
Signature · 1 line
2.55.0
PATCH 5/6 clk: mediatek: Reserve missing MT8196 MDP clock IDs
In reply to Akari TsuyukusaReserve the binding-defined CLK_MDP_SMI0_SMI and CLK_MDP1_SMI0_SMI IDs with dummy clocks in the MT8196 MDP clock providers.
These clocks are not implemented by the current MDP clock driver and have no known consumers. Keeping the slots occupied preserves the binding-defined ID space and prevents out-of-bounds accesses in the descriptor-based onecell data.
--- drivers/clk/mediatek/clk-mt8196-mdpsys.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt8196-mdpsys.c +2 -0
@@ -66,6 +66,7 @@ static const struct mtk_gate mdp1_clks[] = {/* MDP1-0 */ GATE_MDP0 (CLK_MDP1_MDP_MUTEX0 ,"mdp1_mdp_mutex0" ,"mdp" ,0 ),GATE_MDP0 (CLK_MDP1_SMI0 ,"mdp1_smi0" ,"mdp" ,1 ), +GATE_DUMMY (CLK_MDP1_SMI0_SMI ,"mdp1_smi0_smi_dummy" ),GATE_MDP0 (CLK_MDP1_APB_BUS ,"mdp1_apb_bus" ,"mdp" ,2 ),GATE_MDP0 (CLK_MDP1_MDP_RDMA0 ,"mdp1_mdp_rdma0" ,"mdp" ,3 ), GATE_MDP0(CLK_MDP1_MDP_RDMA1, "mdp1_mdp_rdma1", "mdp", 4),
@@ -118,6 +119,7 @@ static const struct mtk_gate mdp_clks[] = {/* MDP0 */ GATE_MDP0 (CLK_MDP_MDP_MUTEX0 ,"mdp_mdp_mutex0" ,"mdp" ,0 ),GATE_MDP0 (CLK_MDP_SMI0 ,"mdp_smi0" ,"mdp" ,1 ), +GATE_DUMMY (CLK_MDP_SMI0_SMI ,"mdp_smi0_smi_dummy" ),GATE_MDP0 (CLK_MDP_APB_BUS ,"mdp_apb_bus" ,"mdp" ,2 ),GATE_MDP0 (CLK_MDP_MDP_RDMA0 ,"mdp_mdp_rdma0" ,"mdp" ,3 ), GATE_MDP0(CLK_MDP_MDP_RDMA1, "mdp_mdp_rdma1", "mdp", 4),
Signature · 1 line
2.55.0
PATCH 6/6 clk: mediatek: Reserve missing MT8516 top clock IDs
In reply to Akari TsuyukusaReserve the binding-defined CLK_TOP_EMI_DDRPHY_SEL and CLK_TOP_DDRPHYCFG_SEL slots in the MT8516 top clock provider with dummy clocks.
These muxes are not implemented by the Linux MT8516 clock driver, but their binding IDs must remain represented in the onecell data to preserve a valid ID-to-slot mapping.
--- drivers/clk/mediatek/clk-mt8516.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/mediatek/clk-mt8516.c +2 -0
@@ -545,6 +545,8 @@ static const struct mtk_gate_regs top5_cg_regs = { GATE_MTK(_id, _name, _parent, &top5_cg_regs, _shift, &mtk_clk_gate_ops_setclr)static const struct mtk_gate top_clks[] = { +GATE_DUMMY (CLK_TOP_EMI_DDRPHY_SEL ,"emi_ddrphy_sel_dummy" ), +GATE_DUMMY (CLK_TOP_DDRPHYCFG_SEL ,"ddrphycfg_sel_dummy" ),/* TOP1 */ GATE_TOP1 (CLK_TOP_THEM ,"them" ,"ahb_infra_sel" ,1 ),GATE_TOP1 (CLK_TOP_APDMA ,"apdma" ,"ahb_infra_sel" ,2 ),
Signature · 1 line
2.55.0
Quoted 14 lines · Akari Tsuyukusa
Several MediaTek clock providers have clock IDs that do not match the size of the clock array allocated by the common descriptor-based probe.
Add dummy entries for missing IDs so that the allocated onecell data covers the complete clock ID space used by each provider.
Akari Tsuyukusa (6):
clk: mediatek: Fix MT6779 clock onecell IDs
clk: mediatek: Fix MT6797 clock onecell IDs
clk: mediatek: Reserve missing MT8167 clock ID
clk: mediatek: Reserve missing MT8173 topckgen IDs
clk: mediatek: Reserve missing MT8196 MDP clock IDs
clk: mediatek: Reserve missing MT8516 top clock IDs
Quoted 1 line
[...]
Applied to v7.4-next/clk, thanks!
[1/6] clk: mediatek: Fix MT6779 clock onecell IDs
commit: 8dcfe9e6b3cc7e0a2ae54ee89b27fc75048875d9
[2/6] clk: mediatek: Fix MT6797 clock onecell IDs
commit: dbed26f4c489548a1aed48db66ec9d7b98f4189e
[3/6] clk: mediatek: Reserve missing MT8167 clock ID
commit: 3ccbdb37d10af155da69a7bf26dd68e62abd45cd
[4/6] clk: mediatek: Reserve missing MT8173 topckgen IDs
commit: afd8231b5a43486458b5b17608e7f9986bfde675
[5/6] clk: mediatek: Reserve missing MT8196 MDP clock IDs
commit: 8779893558124fd4e4a189c2bcb1ad4ae7014e9e
[6/6] clk: mediatek: Reserve missing MT8516 top clock IDs
commit: 24bf5189aadf39d713b33e58b61f39854a99b1d9Cheers,
Angelo