Skip to content

Commit 062920d

Browse files
computersforpeacebroonie
authored andcommitted
regulator: core: Sleep (not delay) in set_voltage()
These delays can be relatively large (e.g., hundreds of microseconds to several milliseconds on RK3399 Gru systems). Per Documentation/timers/timers-howto.rst, that should usually use a sleeping delay. Let's use the existing regulator delay helper to handle both large and small delays appropriately. This avoids burning a bunch of CPU time and hurting scheduling latencies when hitting regulators a lot (e.g., during cpufreq). The sleep vs. delay issue choice has been made differently over time -- early versions of RK3399 Gru PWM-regulator support used usleep_range() in pwm-regulator.c. More of this got moved into the regulator core, in commits like: 73e705b regulator: core: Add set_voltage_time op At the same time, the sleep turned into a delay. It's OK to sleep in _regulator_do_set_voltage(), as we aren't in an atomic context. (All our callers grab various mutexes already.) I avoid using fsleep() because it uses a usleep_range() of [N to N*2], and usleep_range() very commonly biases to the high end of the range. We don't want to double the expected delay, especially for long delays. Signed-off-by: Brian Norris <[email protected]> Reviewed-by: Matthias Kaehlcke <[email protected]> Link: https://lore.kernel.org/r/20220420141511.v2.2.If0fc61a894f537b052ca41572aff098cf8e7e673@changeid Signed-off-by: Mark Brown <[email protected]>
1 parent a38dce4 commit 062920d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,12 +3566,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
35663566
}
35673567

35683568
/* Insert any necessary delays */
3569-
if (delay >= 1000) {
3570-
mdelay(delay / 1000);
3571-
udelay(delay % 1000);
3572-
} else if (delay) {
3573-
udelay(delay);
3574-
}
3569+
_regulator_delay_helper(delay);
35753570

35763571
if (best_val >= 0) {
35773572
unsigned long data = best_val;

0 commit comments

Comments
 (0)