Patch "pwm: tegra: Ensure the clock rate is not less than needed" has been added to the 6.1-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

    pwm: tegra: Ensure the clock rate is not less than needed

to the 6.1-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:
     pwm-tegra-ensure-the-clock-rate-is-not-less-than-nee.patch
and it can be found in the queue-6.1 subdirectory.

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



commit 109109143a5a57d3caef8cef432f827d153f9c02
Author: Jon Hunter <jonathanh@xxxxxxxxxx>
Date:   Fri Oct 28 13:33:56 2022 +0100

    pwm: tegra: Ensure the clock rate is not less than needed
    
    [ Upstream commit 5eccd0d9fabc4d2ab8d2a0c056fb1d7e2ff892fc ]
    
    When dynamically scaling the PWM clock, the function
    dev_pm_opp_set_rate() may set the PWM clock to a rate that is lower than
    what is required. The clock rate requested when calling
    dev_pm_opp_set_rate() is the minimum clock rate that is needed to drive
    the PWM to achieve the required period. Hence, if the actual clock
    rate is less than the requested clock rate, then the required period
    cannot be achieved and configuring the PWM fails. Fix this by
    calling clk_round_rate() to check if the clock rate that will be provided
    is sufficient and if not, double the required clock rate to ensure the
    required period can be attained.
    
    Fixes: 8c193f4714df ("pwm: tegra: Optimize period calculation")
    Signed-off-by: Jon Hunter <jonathanh@xxxxxxxxxx>
    Acked-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
    Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index b05ea2e8accc..6fc4b69a3ba7 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -148,6 +148,17 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 		required_clk_rate = DIV_ROUND_UP_ULL(NSEC_PER_SEC << PWM_DUTY_WIDTH,
 						     period_ns);
 
+		if (required_clk_rate > clk_round_rate(pc->clk, required_clk_rate))
+			/*
+			 * required_clk_rate is a lower bound for the input
+			 * rate; for lower rates there is no value for PWM_SCALE
+			 * that yields a period less than or equal to the
+			 * requested period. Hence, for lower rates, double the
+			 * required_clk_rate to get a clock rate that can meet
+			 * the requested period.
+			 */
+			required_clk_rate *= 2;
+
 		err = dev_pm_opp_set_rate(pc->dev, required_clk_rate);
 		if (err < 0)
 			return -EINVAL;



[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