clk: imx: composite-8m: Fix clock divisions greater than 8
Subsystems (3)
PATCH 1/1 clk: imx: composite-8m: Fix clock divisions greater than 8
When adding imx8m_clk_divider_determine_rate to let the imx8mm and imx8mn get finer granulatiry of video clocks, it accidentally broke the imx8mp ability to divide clocks by more than 8 on clocks when the CLK_SET_RATE_PARENT flag is not set.
On the imx8mp, the CLK_SET_RATE_PARENT flag cannot be set on either media_disp1_pix or media_disp2_pix, because they both share the video_pll as a common clock, and if two displays are used, the parent clock needs to be something that both child clocks can divide.
imx8m_clk_divider_determine_rate ends up calling clk_divider_bestdiv which uses the value of 'width' to setup the maximum divisor. The clk-composite-8m driver sets the with to 3 which means the maximum divisor is 8, but these clocks can divide by up to 64.
Currently, if the video_pll is set to 1039500000, the slowest clock rate achievable is 129937500 which breaks a whole bunch of lower resolution and refresh options for both media_disp1_pix and media_disp2_pix.
By changing the 'width' variable to PCG_DIV_WIDTH, the maximum divisor becomes 64 which allows the clocks to divide down more, so the lower resolutions and refresh rates are achievable again.
drivers/clk/imx/clk-composite-8m.c +3 -2
@@ -47,6 +47,7 @@ static unsigned long imx8m_clk_composite_divider_recalc_rate(struct clk_hw *hw, divider->flags, PCG_DIV_WIDTH); } +static int imx8m_clk_composite_compute_dividers (unsigned long rate,unsigned long parent_rate,int *prediv,int *postdiv)
@@ -215,12 +216,12 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name, mux_ops = &imx8m_clk_composite_mux_ops; }else if (composite_flags &IMX_COMPOSITE_BUS ) { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ; divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &imx8m_clk_composite_mux_ops; }else { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ; divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &clk_mux_ops;if (!(composite_flags &IMX_COMPOSITE_FW_MANAGED ))
Signature · 1 line
2.39.2
Peng Fan
reviewerQuoted 44 lines
Subject: [PATCH] clk: imx: composite-8m: Fix clock divisions greater than 8
When adding
imx8m_clk_divider_determine_rateto let the imx8mm and imx8mn get finer granulatiry of video clocks, it accidentally broke the imx8mp ability to divide clocks by more than 8 on clocks when theCLK_SET_RATE_PARENTflag is not set.On the imx8mp, the
CLK_SET_RATE_PARENTflag cannot be set on eithermedia_disp1_pixormedia_disp2_pix, because they both share thevideo_pllas a common clock, and if two displays are used, the parent clock needs to be something that both child clocks can divide.
imx8m_clk_divider_determine_rateends up callingclk_divider_bestdivwhich uses the value of 'width' to setup the maximum divisor. The clk- composite-8m driver sets the with to 3 which means the maximum divisor is 8, but these clocks can divide by up to 64.Currently, if the
video_pllis set to 1039500000, the slowest clock rate achievable is 129937500 which breaks a whole bunch of lower resolution and refresh options for bothmedia_disp1_pixandmedia_disp2_pix.By changing the 'width' variable to
PCG_DIV_WIDTH, the maximum divisor becomes 64 which allows the clocks to divide down more, so the lower resolutions and refresh rates are achievable again.Fixes 156e96ff2172 ("clk: imx: composite-8m: Add support to
determine_rate")Signed-off-by Adam Ford <[email protected]>drivers/clk/imx/clk- renamed from drivers/clk/imx/clk-composite-8m.c +0
-0
composite-8m.c
index6883a8199b6c..805e6aada83d100644drivers/clk/imx/clk-composite-8m.c +1
-0@@ -47,6 +47,7 @@ static unsigned long imx8m_clk_composite_divider_recalc_rate(struct clk_hw *hw, divider->flags, PCG_DIV_WIDTH); } + static int imx8m_clk_composite_compute_dividers(unsigned long rate, unsigned long parent_rate,drivers/clk/imx/clk-composite-8m.c +0
-0int *prediv, int *postdiv)
drivers/clk/imx/clk-composite-8m.c struct clk_hw *__imx8m_clk_hw_composite(const · line 220
Quoted 6 lines
drivers/clk/imx/clk-composite-8m.c +1
-1@@ -215,12 +216,12 @@ struct clk_hw *__imx8m_clk_hw_composite(constchar *name, mux_ops = &imx8m_clk_composite_mux_ops; }else if (composite_flags &IMX_COMPOSITE_BUS ) { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ;
This is wrong. Pre divider width is 3, not 6.
drivers/clk/imx/clk-composite-8m.c struct clk_hw *__imx8m_clk_hw_composite(const char *name, · line 224
Quoted 6 lines
drivers/clk/imx/clk-composite-8m.c +1
-1divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &imx8m_clk_composite_mux_ops; }else { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ;
Ditto.
You need find the other way to resolve the regression.
Regards,
Peng.
Quoted 5 lines
drivers/clk/imx/clk-composite-8m.c +0
-0divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &clk_mux_ops;if (!(composite_flags &
IMX_COMPOSITE_FW_MANAGED))
--
2.39.2
Quoted 59 lines · Peng Fan
Quoted 45 lines
Subject: [PATCH] clk: imx: composite-8m: Fix clock divisions greater than 8
When adding
imx8m_clk_divider_determine_rateto let the imx8mm and imx8mn get finer granulatiry of video clocks, it accidentally broke the imx8mp ability to divide clocks by more than 8 on clocks when theCLK_SET_RATE_PARENTflag is not set.On the imx8mp, the
CLK_SET_RATE_PARENTflag cannot be set on eithermedia_disp1_pixormedia_disp2_pix, because they both share thevideo_pllas a common clock, and if two displays are used, the parent clock needs to be something that both child clocks can divide.
imx8m_clk_divider_determine_rateends up callingclk_divider_bestdivwhich uses the value of 'width' to setup the maximum divisor. The clk- composite-8m driver sets the with to 3 which means the maximum divisor is 8, but these clocks can divide by up to 64.Currently, if the
video_pllis set to 1039500000, the slowest clock rate achievable is 129937500 which breaks a whole bunch of lower resolution and refresh options for bothmedia_disp1_pixandmedia_disp2_pix.By changing the 'width' variable to
PCG_DIV_WIDTH, the maximum divisor becomes 64 which allows the clocks to divide down more, so the lower resolutions and refresh rates are achievable again.Fixes 156e96ff2172 ("clk: imx: composite-8m: Add support to
determine_rate")Signed-off-by Adam Ford <[email protected]>drivers/clk/imx/clk- renamed from drivers/clk/imx/clk-composite-8m.c +0
-0
composite-8m.c
index6883a8199b6c..805e6aada83d100644drivers/clk/imx/clk-composite-8m.c +1
-0@@ -47,6 +47,7 @@ static unsigned long imx8m_clk_composite_divider_recalc_rate(struct clk_hw *hw, divider->flags, PCG_DIV_WIDTH); } + static int imx8m_clk_composite_compute_dividers(unsigned long rate, unsigned long parent_rate,int *prediv, int *postdiv)
drivers/clk/imx/clk-composite-8m.c struct clk_hw *__imx8m_clk_hw_composite(const · line 220
Quoted 6 lines
drivers/clk/imx/clk-composite-8m.c +1
-1@@ -215,12 +216,12 @@ struct clk_hw *__imx8m_clk_hw_composite(constchar *name, mux_ops = &imx8m_clk_composite_mux_ops; }else if (composite_flags &IMX_COMPOSITE_BUS ) { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ;This is wrong. Pre divider width is 3, not 6.
drivers/clk/imx/clk-composite-8m.c struct clk_hw *__imx8m_clk_hw_composite(const char *name, · line 224
Quoted 6 lines
drivers/clk/imx/clk-composite-8m.c +1
-1divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &imx8m_clk_composite_mux_ops; }else { div->shift =PCG_PREDIV_SHIFT ; - div->width =PCG_PREDIV_WIDTH ; + div->width =PCG_DIV_WIDTH ;
Quoted 3 lines
Ditto.
You need find the other way to resolve the regression.
Peng,
Thank you for the review! It took me a bit to better understand the clock driver, but I think I found a solution that seems to work without breaking 8mp. I did a clock dump on the 8mp, and I found no differences in the clock rates generated before and after my patch. I will re-test the solution on the Mini and Nano. If all goes well, I will post a V2 patch which both does a revert and posts the fix. Instead of using a common function to determine_rate, I wrote one specific for the composite-8m which uses max values from both the pre-div and post-div to determine the possible clock rates. If the read-only flag is set, it reads the existing values of the pre and post dividers to determine whatever the divider is. It doesn't touch any pre-existing composite-8m functions.
adam
Quoted 10 lines
Regards,
Peng.Quoted 5 lines
drivers/clk/imx/clk-composite-8m.c +0
-0divider_ops = &imx8m_clk_composite_divider_ops; mux_ops = &clk_mux_ops;if (!(composite_flags &
IMX_COMPOSITE_FW_MANAGED))
--
2.39.2