Patch "clk: Initialize orphan req_rate" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    clk: Initialize orphan req_rate

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     clk-initialize-orphan-req_rate.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b57df08475d3763ca7aead4570f0f490f3b257b6
Author: Maxime Ripard <maxime@xxxxxxxxxx>
Date:   Fri Mar 25 17:11:42 2022 +0100

    clk: Initialize orphan req_rate
    
    [ Upstream commit 5f7e2af00807f2117650e711a58b7f0e986ce1df ]
    
    When registering a clock that doesn't have a recalc_rate implementation,
    and doesn't have its parent registered yet, we initialize the clk_core
    rate and 'req_rate' fields to 0.
    
    The rate field is later updated when the parent is registered in
    clk_core_reparent_orphans_nolock() using __clk_recalc_rates(), but the
    'req_rate' field is never updated.
    
    This leads to an issue in clk_set_rate_range() and clk_put(), since
    those functions will call clk_set_rate() with the content of 'req_rate'
    to provide drivers with the opportunity to change the rate based on the
    new boundaries. In this case, we would call clk_set_rate() with a rate
    of 0, effectively enforcing the minimum allowed for this clock whenever
    we would call one of those two functions, even though the actual rate
    might be within range.
    
    Let's fix this by setting 'req_rate' in
    clk_core_reparent_orphans_nolock() with the rate field content just
    updated by the call to __clk_recalc_rates().
    
    Fixes: 1c8e600440c7 ("clk: Add rate constraints to clocks")
    Reported-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>
    Tested-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx> # T30 Nexus7
    Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220325161144.1901695-2-maxime@xxxxxxxxxx
    [sboyd@xxxxxxxxxx: Reword comment]
    Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 32fd2853e8b2..5cef73a85901 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3410,6 +3410,19 @@ static void clk_core_reparent_orphans_nolock(void)
 			__clk_set_parent_after(orphan, parent, NULL);
 			__clk_recalc_accuracies(orphan);
 			__clk_recalc_rates(orphan, 0);
+
+			/*
+			 * __clk_init_parent() will set the initial req_rate to
+			 * 0 if the clock doesn't have clk_ops::recalc_rate and
+			 * is an orphan when it's registered.
+			 *
+			 * 'req_rate' is used by clk_set_rate_range() and
+			 * clk_put() to trigger a clk_set_rate() call whenever
+			 * the boundaries are modified. Let's make sure
+			 * 'req_rate' is set to something non-zero so that
+			 * clk_set_rate_range() doesn't drop the frequency.
+			 */
+			orphan->req_rate = orphan->rate;
 		}
 	}
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux