Skip to content

Commit abdf766

Browse files
committed
Merge tag 'pm-6.18-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These are cpufreq fixes and cleanups on top of the material merged previously, a power management core code fix and updates of the runtime PM framework including unit tests, documentation updates and introduction of auto-cleanup macros for runtime PM "resume and get" and "get without resuming" operations. Specifics: - Make cpufreq drivers setting the default CPU transition latency to CPUFREQ_ETERNAL specify a proper default transition latency value instead which addresses a regression introduced during the 6.6 cycle that broke CPUFREQ_ETERNAL handling (Rafael Wysocki) - Make the cpufreq CPPC driver use a proper transition delay value when CPUFREQ_ETERNAL is returned by cppc_get_transition_latency() to indicate an error condition (Rafael Wysocki) - Make cppc_get_transition_latency() return a negative error code to indicate error conditions instead of using CPUFREQ_ETERNAL for this purpose and drop CPUFREQ_ETERNAL that has no other users (Rafael Wysocki, Gopi Krishna Menon) - Fix device leak in the mediatek cpufreq driver (Johan Hovold) - Set target frequency on all CPUs sharing a policy during frequency updates in the tegra186 cpufreq driver and make it initialize all cores to max frequencies (Aaron Kling) - Rust cpufreq helper cleanup (Thorsten Blum) - Make pm_runtime_put*() family of functions return 1 when the given device is already suspended which is consistent with the documentation (Brian Norris) - Add basic kunit tests for runtime PM API contracts and update return values in kerneldoc comments for the runtime PM API (Brian Norris, Dan Carpenter) - Add auto-cleanup macros for runtime PM "resume and get" and "get without resume" operations, use one of them in the PCI core and drop the existing "free" macro introduced for similar purpose, but somewhat cumbersome to use (Rafael Wysocki) - Make the core power management code avoid waiting on device links marked as SYNC_STATE_ONLY which is consistent with the handling of those device links elsewhere (Pin-yen Lin)" * tag 'pm-6.18-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: docs/zh_CN: Fix malformed table docs/zh_TW: Fix malformed table PM: runtime: Fix error checking for kunit_device_register() PM: runtime: Introduce one more usage counter guard cpufreq: Drop unused symbol CPUFREQ_ETERNAL ACPI: CPPC: Do not use CPUFREQ_ETERNAL as an error value cpufreq: CPPC: Avoid using CPUFREQ_ETERNAL as transition delay cpufreq: Make drivers using CPUFREQ_ETERNAL specify transition latency PM: runtime: Drop DEFINE_FREE() for pm_runtime_put() PCI/sysfs: Use runtime PM guard macro for auto-cleanup PM: runtime: Add auto-cleanup macros for "resume and get" operations cpufreq: tegra186: Initialize all cores to max frequencies cpufreq: tegra186: Set target frequency for all cpus in policy rust: cpufreq: streamline find_supply_names cpufreq: mediatek: fix device leak on probe failure PM: sleep: Do not wait on SYNC_STATE_ONLY device links PM: runtime: Update kerneldoc return codes PM: runtime: Make put{,_sync}() return 1 when already suspended PM: runtime: Add basic kunit tests for API contracts
2 parents 522ba45 + 53d4d31 commit abdf766

28 files changed

Lines changed: 426 additions & 101 deletions

Documentation/admin-guide/pm/cpufreq.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ are the following:
274274
The time it takes to switch the CPUs belonging to this policy from one
275275
P-state to another, in nanoseconds.
276276

277-
If unknown or if known to be so high that the scaling driver does not
278-
work with the `ondemand`_ governor, -1 (:c:macro:`CPUFREQ_ETERNAL`)
279-
will be returned by reads from this attribute.
280-
281277
``related_cpus``
282278
List of all (online and offline) CPUs belonging to this policy.
283279

Documentation/cpu-freq/cpu-drivers.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ Then, the driver must fill in the following values:
109109
+-----------------------------------+--------------------------------------+
110110
|policy->cpuinfo.transition_latency | the time it takes on this CPU to |
111111
| | switch between two frequencies in |
112-
| | nanoseconds (if appropriate, else |
113-
| | specify CPUFREQ_ETERNAL) |
112+
| | nanoseconds |
114113
+-----------------------------------+--------------------------------------+
115114
|policy->cur | The current operating frequency of |
116115
| | this CPU (if appropriate) |

Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ CPUfreq核心层注册一个cpufreq_driver结构体。
112112
| | |
113113
+-----------------------------------+--------------------------------------+
114114
|policy->cpuinfo.transition_latency | CPU在两个频率之间切换所需的时间,以 |
115-
| | 纳秒为单位(如不适用,设定为 |
116-
| | CPUFREQ_ETERNAL) |
115+
| | 纳秒为单位 |
117116
| | |
118117
+-----------------------------------+--------------------------------------+
119118
|policy->cur | 该CPU当前的工作频率(如适用) |

Documentation/translations/zh_TW/cpu-freq/cpu-drivers.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ CPUfreq核心層註冊一個cpufreq_driver結構體。
112112
| | |
113113
+-----------------------------------+--------------------------------------+
114114
|policy->cpuinfo.transition_latency | CPU在兩個頻率之間切換所需的時間,以 |
115-
| | 納秒爲單位(如不適用,設定爲 |
116-
| | CPUFREQ_ETERNAL) |
115+
| | 納秒爲單位 |
117116
| | |
118117
+-----------------------------------+--------------------------------------+
119118
|policy->cur | 該CPU當前的工作頻率(如適用) |

drivers/acpi/cppc_acpi.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ EXPORT_SYMBOL_GPL(cppc_set_perf);
18761876
* If desired_reg is in the SystemMemory or SystemIo ACPI address space,
18771877
* then assume there is no latency.
18781878
*/
1879-
unsigned int cppc_get_transition_latency(int cpu_num)
1879+
int cppc_get_transition_latency(int cpu_num)
18801880
{
18811881
/*
18821882
* Expected transition latency is based on the PCCT timing values
@@ -1889,31 +1889,29 @@ unsigned int cppc_get_transition_latency(int cpu_num)
18891889
* completion of a command before issuing the next command,
18901890
* in microseconds.
18911891
*/
1892-
unsigned int latency_ns = 0;
18931892
struct cpc_desc *cpc_desc;
18941893
struct cpc_register_resource *desired_reg;
18951894
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu_num);
18961895
struct cppc_pcc_data *pcc_ss_data;
1896+
int latency_ns = 0;
18971897

18981898
cpc_desc = per_cpu(cpc_desc_ptr, cpu_num);
18991899
if (!cpc_desc)
1900-
return CPUFREQ_ETERNAL;
1900+
return -ENODATA;
19011901

19021902
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
19031903
if (CPC_IN_SYSTEM_MEMORY(desired_reg) || CPC_IN_SYSTEM_IO(desired_reg))
19041904
return 0;
1905-
else if (!CPC_IN_PCC(desired_reg))
1906-
return CPUFREQ_ETERNAL;
19071905

1908-
if (pcc_ss_id < 0)
1909-
return CPUFREQ_ETERNAL;
1906+
if (!CPC_IN_PCC(desired_reg) || pcc_ss_id < 0)
1907+
return -ENODATA;
19101908

19111909
pcc_ss_data = pcc_data[pcc_ss_id];
19121910
if (pcc_ss_data->pcc_mpar)
19131911
latency_ns = 60 * (1000 * 1000 * 1000 / pcc_ss_data->pcc_mpar);
19141912

1915-
latency_ns = max(latency_ns, pcc_ss_data->pcc_nominal * 1000);
1916-
latency_ns = max(latency_ns, pcc_ss_data->pcc_mrtt * 1000);
1913+
latency_ns = max_t(int, latency_ns, pcc_ss_data->pcc_nominal * 1000);
1914+
latency_ns = max_t(int, latency_ns, pcc_ss_data->pcc_mrtt * 1000);
19171915

19181916
return latency_ns;
19191917
}

drivers/base/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ config PM_QOS_KUNIT_TEST
167167
depends on KUNIT=y
168168
default KUNIT_ALL_TESTS
169169

170+
config PM_RUNTIME_KUNIT_TEST
171+
tristate "KUnit Tests for runtime PM" if !KUNIT_ALL_TESTS
172+
depends on KUNIT
173+
depends on PM
174+
default KUNIT_ALL_TESTS
175+
170176
config HMEM_REPORTING
171177
bool
172178
default n

drivers/base/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ void device_links_driver_cleanup(struct device *dev);
248248
void device_links_no_driver(struct device *dev);
249249
bool device_links_busy(struct device *dev);
250250
void device_links_unbind_consumers(struct device *dev);
251+
bool device_link_flag_is_sync_state_only(u32 flags);
251252
void fw_devlink_drivers_done(void);
252253
void fw_devlink_probing_done(void);
253254

drivers/base/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static bool device_is_ancestor(struct device *dev, struct device *target)
287287
#define DL_MARKER_FLAGS (DL_FLAG_INFERRED | \
288288
DL_FLAG_CYCLE | \
289289
DL_FLAG_MANAGED)
290-
static inline bool device_link_flag_is_sync_state_only(u32 flags)
290+
bool device_link_flag_is_sync_state_only(u32 flags)
291291
{
292292
return (flags & ~DL_MARKER_FLAGS) == DL_FLAG_SYNC_STATE_ONLY;
293293
}

drivers/base/power/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o wakeup_stats.o
44
obj-$(CONFIG_PM_TRACE_RTC) += trace.o
55
obj-$(CONFIG_HAVE_CLK) += clock_ops.o
66
obj-$(CONFIG_PM_QOS_KUNIT_TEST) += qos-test.o
7+
obj-$(CONFIG_PM_RUNTIME_KUNIT_TEST) += runtime-test.o
78

89
ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG

drivers/base/power/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async)
278278
* walking.
279279
*/
280280
dev_for_each_link_to_supplier(link, dev)
281-
if (READ_ONCE(link->status) != DL_STATE_DORMANT)
281+
if (READ_ONCE(link->status) != DL_STATE_DORMANT &&
282+
!device_link_flag_is_sync_state_only(link->flags))
282283
dpm_wait(link->supplier, async);
283284

284285
device_links_read_unlock(idx);
@@ -335,7 +336,8 @@ static void dpm_wait_for_consumers(struct device *dev, bool async)
335336
* unregistration).
336337
*/
337338
dev_for_each_link_to_consumer(link, dev)
338-
if (READ_ONCE(link->status) != DL_STATE_DORMANT)
339+
if (READ_ONCE(link->status) != DL_STATE_DORMANT &&
340+
!device_link_flag_is_sync_state_only(link->flags))
339341
dpm_wait(link->consumer, async);
340342

341343
device_links_read_unlock(idx);

0 commit comments

Comments
 (0)