Skip to content

Commit 7b5bcf9

Browse files
committed
Merge tag 'pm-6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "These restore the asynchronous device resume optimization removed by the previous PM merge, make the intel_pstate driver work better on Meteor Lake systems, optimize the PM QoS core code slightly and fix up typos in admin-guide. Specifics: - Restore the system-wide asynchronous device resume optimization removed by a recent concurrency fix (Rafael J. Wysocki) - Make the intel_pstate cpufreq driver allow Meteor Lake systems to run at somewhat higher frequencies (Srinivas Pandruvada) - Make the PM QoS core code use kcalloc() for array allocation (Erick Archer) - Fix two PM-related typos in admin-guide (Erwan Velu)" * tag 'pm-6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM: sleep: Restore asynchronous device resume optimization Documentation: admin-guide: PM: Fix two typos cpufreq: intel_pstate: Update hybrid scaling factor for Meteor Lake PM: QoS: Use kcalloc() instead of kzalloc()
2 parents 82fd5ee + 9223614 commit 7b5bcf9

File tree

6 files changed

+86
-59
lines changed

6 files changed

+86
-59
lines changed

Documentation/admin-guide/acpi/cppc_sysfs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ taking two different snapshots of feedback counters at time T1 and T2.
7575
delivered_counter_delta = fbc_t2[del] - fbc_t1[del]
7676
reference_counter_delta = fbc_t2[ref] - fbc_t1[ref]
7777

78-
delivered_perf = (refernce_perf x delivered_counter_delta) / reference_counter_delta
78+
delivered_perf = (reference_perf x delivered_counter_delta) / reference_counter_delta

Documentation/admin-guide/pm/amd-pstate.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ Global Attributes
361361

362362
``amd-pstate`` exposes several global attributes (files) in ``sysfs`` to
363363
control its functionality at the system level. They are located in the
364-
``/sys/devices/system/cpu/amd-pstate/`` directory and affect all CPUs.
364+
``/sys/devices/system/cpu/amd_pstate/`` directory and affect all CPUs.
365365

366366
``status``
367367
Operation mode of the driver: "active", "passive" or "disable".

drivers/base/power/main.c

Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -579,15 +579,15 @@ bool dev_pm_skip_resume(struct device *dev)
579579
}
580580

581581
/**
582-
* __device_resume_noirq - Execute a "noirq resume" callback for given device.
582+
* device_resume_noirq - Execute a "noirq resume" callback for given device.
583583
* @dev: Device to handle.
584584
* @state: PM transition of the system being carried out.
585585
* @async: If true, the device is being resumed asynchronously.
586586
*
587587
* The driver of @dev will not receive interrupts while this function is being
588588
* executed.
589589
*/
590-
static void __device_resume_noirq(struct device *dev, pm_message_t state, bool async)
590+
static void device_resume_noirq(struct device *dev, pm_message_t state, bool async)
591591
{
592592
pm_callback_t callback = NULL;
593593
const char *info = NULL;
@@ -674,35 +674,33 @@ static bool dpm_async_fn(struct device *dev, async_func_t func)
674674
{
675675
reinit_completion(&dev->power.completion);
676676

677-
if (!is_async(dev))
678-
return false;
679-
680-
get_device(dev);
677+
if (is_async(dev)) {
678+
dev->power.async_in_progress = true;
681679

682-
if (async_schedule_dev_nocall(func, dev))
683-
return true;
680+
get_device(dev);
684681

685-
put_device(dev);
682+
if (async_schedule_dev_nocall(func, dev))
683+
return true;
686684

685+
put_device(dev);
686+
}
687+
/*
688+
* Because async_schedule_dev_nocall() above has returned false or it
689+
* has not been called at all, func() is not running and it is safe to
690+
* update the async_in_progress flag without extra synchronization.
691+
*/
692+
dev->power.async_in_progress = false;
687693
return false;
688694
}
689695

690696
static void async_resume_noirq(void *data, async_cookie_t cookie)
691697
{
692698
struct device *dev = data;
693699

694-
__device_resume_noirq(dev, pm_transition, true);
700+
device_resume_noirq(dev, pm_transition, true);
695701
put_device(dev);
696702
}
697703

698-
static void device_resume_noirq(struct device *dev)
699-
{
700-
if (dpm_async_fn(dev, async_resume_noirq))
701-
return;
702-
703-
__device_resume_noirq(dev, pm_transition, false);
704-
}
705-
706704
static void dpm_noirq_resume_devices(pm_message_t state)
707705
{
708706
struct device *dev;
@@ -712,18 +710,28 @@ static void dpm_noirq_resume_devices(pm_message_t state)
712710
mutex_lock(&dpm_list_mtx);
713711
pm_transition = state;
714712

713+
/*
714+
* Trigger the resume of "async" devices upfront so they don't have to
715+
* wait for the "non-async" ones they don't depend on.
716+
*/
717+
list_for_each_entry(dev, &dpm_noirq_list, power.entry)
718+
dpm_async_fn(dev, async_resume_noirq);
719+
715720
while (!list_empty(&dpm_noirq_list)) {
716721
dev = to_device(dpm_noirq_list.next);
717-
get_device(dev);
718722
list_move_tail(&dev->power.entry, &dpm_late_early_list);
719723

720-
mutex_unlock(&dpm_list_mtx);
724+
if (!dev->power.async_in_progress) {
725+
get_device(dev);
721726

722-
device_resume_noirq(dev);
727+
mutex_unlock(&dpm_list_mtx);
723728

724-
put_device(dev);
729+
device_resume_noirq(dev, state, false);
725730

726-
mutex_lock(&dpm_list_mtx);
731+
put_device(dev);
732+
733+
mutex_lock(&dpm_list_mtx);
734+
}
727735
}
728736
mutex_unlock(&dpm_list_mtx);
729737
async_synchronize_full();
@@ -747,14 +755,14 @@ void dpm_resume_noirq(pm_message_t state)
747755
}
748756

749757
/**
750-
* __device_resume_early - Execute an "early resume" callback for given device.
758+
* device_resume_early - Execute an "early resume" callback for given device.
751759
* @dev: Device to handle.
752760
* @state: PM transition of the system being carried out.
753761
* @async: If true, the device is being resumed asynchronously.
754762
*
755763
* Runtime PM is disabled for @dev while this function is being executed.
756764
*/
757-
static void __device_resume_early(struct device *dev, pm_message_t state, bool async)
765+
static void device_resume_early(struct device *dev, pm_message_t state, bool async)
758766
{
759767
pm_callback_t callback = NULL;
760768
const char *info = NULL;
@@ -820,18 +828,10 @@ static void async_resume_early(void *data, async_cookie_t cookie)
820828
{
821829
struct device *dev = data;
822830

823-
__device_resume_early(dev, pm_transition, true);
831+
device_resume_early(dev, pm_transition, true);
824832
put_device(dev);
825833
}
826834

827-
static void device_resume_early(struct device *dev)
828-
{
829-
if (dpm_async_fn(dev, async_resume_early))
830-
return;
831-
832-
__device_resume_early(dev, pm_transition, false);
833-
}
834-
835835
/**
836836
* dpm_resume_early - Execute "early resume" callbacks for all devices.
837837
* @state: PM transition of the system being carried out.
@@ -845,18 +845,28 @@ void dpm_resume_early(pm_message_t state)
845845
mutex_lock(&dpm_list_mtx);
846846
pm_transition = state;
847847

848+
/*
849+
* Trigger the resume of "async" devices upfront so they don't have to
850+
* wait for the "non-async" ones they don't depend on.
851+
*/
852+
list_for_each_entry(dev, &dpm_late_early_list, power.entry)
853+
dpm_async_fn(dev, async_resume_early);
854+
848855
while (!list_empty(&dpm_late_early_list)) {
849856
dev = to_device(dpm_late_early_list.next);
850-
get_device(dev);
851857
list_move_tail(&dev->power.entry, &dpm_suspended_list);
852858

853-
mutex_unlock(&dpm_list_mtx);
859+
if (!dev->power.async_in_progress) {
860+
get_device(dev);
854861

855-
device_resume_early(dev);
862+
mutex_unlock(&dpm_list_mtx);
856863

857-
put_device(dev);
864+
device_resume_early(dev, state, false);
858865

859-
mutex_lock(&dpm_list_mtx);
866+
put_device(dev);
867+
868+
mutex_lock(&dpm_list_mtx);
869+
}
860870
}
861871
mutex_unlock(&dpm_list_mtx);
862872
async_synchronize_full();
@@ -876,12 +886,12 @@ void dpm_resume_start(pm_message_t state)
876886
EXPORT_SYMBOL_GPL(dpm_resume_start);
877887

878888
/**
879-
* __device_resume - Execute "resume" callbacks for given device.
889+
* device_resume - Execute "resume" callbacks for given device.
880890
* @dev: Device to handle.
881891
* @state: PM transition of the system being carried out.
882892
* @async: If true, the device is being resumed asynchronously.
883893
*/
884-
static void __device_resume(struct device *dev, pm_message_t state, bool async)
894+
static void device_resume(struct device *dev, pm_message_t state, bool async)
885895
{
886896
pm_callback_t callback = NULL;
887897
const char *info = NULL;
@@ -975,18 +985,10 @@ static void async_resume(void *data, async_cookie_t cookie)
975985
{
976986
struct device *dev = data;
977987

978-
__device_resume(dev, pm_transition, true);
988+
device_resume(dev, pm_transition, true);
979989
put_device(dev);
980990
}
981991

982-
static void device_resume(struct device *dev)
983-
{
984-
if (dpm_async_fn(dev, async_resume))
985-
return;
986-
987-
__device_resume(dev, pm_transition, false);
988-
}
989-
990992
/**
991993
* dpm_resume - Execute "resume" callbacks for non-sysdev devices.
992994
* @state: PM transition of the system being carried out.
@@ -1006,16 +1008,25 @@ void dpm_resume(pm_message_t state)
10061008
pm_transition = state;
10071009
async_error = 0;
10081010

1011+
/*
1012+
* Trigger the resume of "async" devices upfront so they don't have to
1013+
* wait for the "non-async" ones they don't depend on.
1014+
*/
1015+
list_for_each_entry(dev, &dpm_suspended_list, power.entry)
1016+
dpm_async_fn(dev, async_resume);
1017+
10091018
while (!list_empty(&dpm_suspended_list)) {
10101019
dev = to_device(dpm_suspended_list.next);
10111020

10121021
get_device(dev);
10131022

1014-
mutex_unlock(&dpm_list_mtx);
1023+
if (!dev->power.async_in_progress) {
1024+
mutex_unlock(&dpm_list_mtx);
10151025

1016-
device_resume(dev);
1026+
device_resume(dev, state, false);
10171027

1018-
mutex_lock(&dpm_list_mtx);
1028+
mutex_lock(&dpm_list_mtx);
1029+
}
10191030

10201031
if (!list_empty(&dev->power.entry))
10211032
list_move_tail(&dev->power.entry, &dpm_prepared_list);

drivers/base/power/qos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev)
201201
if (!qos)
202202
return -ENOMEM;
203203

204-
n = kzalloc(3 * sizeof(*n), GFP_KERNEL);
204+
n = kcalloc(3, sizeof(*n), GFP_KERNEL);
205205
if (!n) {
206206
kfree(qos);
207207
return -ENOMEM;

drivers/cpufreq/intel_pstate.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ static bool hwp_forced __read_mostly;
302302

303303
static struct cpufreq_driver *intel_pstate_driver __read_mostly;
304304

305-
#define HYBRID_SCALING_FACTOR 78741
305+
#define HYBRID_SCALING_FACTOR 78741
306+
#define HYBRID_SCALING_FACTOR_MTL 80000
307+
308+
static int hybrid_scaling_factor = HYBRID_SCALING_FACTOR;
306309

307310
static inline int core_get_scaling(void)
308311
{
@@ -422,7 +425,7 @@ static int intel_pstate_cppc_get_scaling(int cpu)
422425
*/
423426
if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq &&
424427
cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq)
425-
return HYBRID_SCALING_FACTOR;
428+
return hybrid_scaling_factor;
426429

427430
return core_get_scaling();
428431
}
@@ -1968,7 +1971,7 @@ static int hwp_get_cpu_scaling(int cpu)
19681971
smp_call_function_single(cpu, hybrid_get_type, &cpu_type, 1);
19691972
/* P-cores have a smaller perf level-to-freqency scaling factor. */
19701973
if (cpu_type == 0x40)
1971-
return HYBRID_SCALING_FACTOR;
1974+
return hybrid_scaling_factor;
19721975

19731976
/* Use default core scaling for E-cores */
19741977
if (cpu_type == 0x20)
@@ -3399,6 +3402,11 @@ static const struct x86_cpu_id intel_epp_balance_perf[] = {
33993402
{}
34003403
};
34013404

3405+
static const struct x86_cpu_id intel_hybrid_scaling_factor[] = {
3406+
X86_MATCH_INTEL_FAM6_MODEL(METEORLAKE_L, HYBRID_SCALING_FACTOR_MTL),
3407+
{}
3408+
};
3409+
34023410
static int __init intel_pstate_init(void)
34033411
{
34043412
static struct cpudata **_all_cpu_data;
@@ -3489,9 +3497,16 @@ static int __init intel_pstate_init(void)
34893497

34903498
if (hwp_active) {
34913499
const struct x86_cpu_id *id = x86_match_cpu(intel_epp_balance_perf);
3500+
const struct x86_cpu_id *hybrid_id = x86_match_cpu(intel_hybrid_scaling_factor);
34923501

34933502
if (id)
34943503
epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = id->driver_data;
3504+
3505+
if (hybrid_id) {
3506+
hybrid_scaling_factor = hybrid_id->driver_data;
3507+
pr_debug("hybrid scaling factor: %d\n", hybrid_scaling_factor);
3508+
}
3509+
34953510
}
34963511

34973512
mutex_lock(&intel_pstate_driver_lock);

include/linux/pm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ struct dev_pm_info {
681681
bool wakeup_path:1;
682682
bool syscore:1;
683683
bool no_pm_callbacks:1; /* Owned by the PM core */
684+
bool async_in_progress:1; /* Owned by the PM core */
684685
unsigned int must_resume:1; /* Owned by the PM core */
685686
unsigned int may_skip_resume:1; /* Set by subsystems */
686687
#else

0 commit comments

Comments
 (0)