clk: milbeaut: Return divider update timeouts
Subsystems (2)
PATCH 1/1 clk: milbeaut: Return divider update timeouts
m10v_clk_divider_set_rate() logs when the hardware does not clear its write-valid request, but still returns success to the clock framework. It also uses the sleeping poll helper while holding the divider spinlock.
Use the atomic poll helper under the lock and return its timeout so the rate change is not reported as successful before the hardware accepts it.
The issue was found by our static-analysis tool and manually reviewed.
Fixes 6a6ba5b55a72 ("clock: milbeaut: Add Milbeaut M10V clock controller")
Assisted-by gpt 5
Signed-off-by Pengpeng Hou <[email protected]>
--- drivers/clk/clk-milbeaut.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/clk/clk-milbeaut.c +6 -4
@@ -410,8 +410,8 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) {struct m10v_clk_divider *divider =to_m10v_div (hw); -int value;unsigned long flags =0 ; +int value, ret =0 ;u32 val;u32 write_en =BIT (divider->width -1 );
@@ -433,8 +433,10 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,if (divider->write_valid_reg) {writel (M10V_DCHREQ , divider->write_valid_reg); -if (readl_poll_timeout (divider->write_valid_reg, val, - !val,M10V_UPOLL_RATE ,M10V_UTIMEOUT )) + ret =readl_poll_timeout_atomic (divider->write_valid_reg, val, + !val,M10V_UPOLL_RATE , +M10V_UTIMEOUT ); +if (ret)pr_err ("%s:%s couldn't stabilize\n" , __func__,clk_hw_get_name (hw)); }
@@ -444,7 +446,7 @@ static int m10v_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,else __release (divider->lock); -return 0 ; +return ret; }static const struct clk_ops m10v_clk_divider_ops = {
Signature · 1 line
2.50.1 (Apple Git-155)
Brian Masney
AppliedQuoted 1 line · Pengpeng Hou
clk: milbeaut: Return divider update timeouts
Applied, thanks!
[1/1] clk: milbeaut: Return divider update timeouts
commit: 526066a4bd5658962800fa64bd3e5432e1f7f92b
Best regards,
Signature · 1 line
Brian Masney <[email protected]>