Skip to content

Commit

Permalink
Merge tag 'pm-6.8-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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()
  • Loading branch information
torvalds committed Jan 17, 2024
2 parents 82fd5ee + 9223614 commit 7b5bcf9
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Documentation/admin-guide/acpi/cppc_sysfs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ taking two different snapshots of feedback counters at time T1 and T2.
delivered_counter_delta = fbc_t2[del] - fbc_t1[del]
reference_counter_delta = fbc_t2[ref] - fbc_t1[ref]

delivered_perf = (refernce_perf x delivered_counter_delta) / reference_counter_delta
delivered_perf = (reference_perf x delivered_counter_delta) / reference_counter_delta
2 changes: 1 addition & 1 deletion Documentation/admin-guide/pm/amd-pstate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ Global Attributes

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

``status``
Operation mode of the driver: "active", "passive" or "disable".
Expand Down
117 changes: 64 additions & 53 deletions drivers/base/power/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,15 @@ bool dev_pm_skip_resume(struct device *dev)
}

/**
* __device_resume_noirq - Execute a "noirq resume" callback for given device.
* device_resume_noirq - Execute a "noirq resume" callback for given device.
* @dev: Device to handle.
* @state: PM transition of the system being carried out.
* @async: If true, the device is being resumed asynchronously.
*
* The driver of @dev will not receive interrupts while this function is being
* executed.
*/
static void __device_resume_noirq(struct device *dev, pm_message_t state, bool async)
static void device_resume_noirq(struct device *dev, pm_message_t state, bool async)
{
pm_callback_t callback = NULL;
const char *info = NULL;
Expand Down Expand Up @@ -674,35 +674,33 @@ static bool dpm_async_fn(struct device *dev, async_func_t func)
{
reinit_completion(&dev->power.completion);

if (!is_async(dev))
return false;

get_device(dev);
if (is_async(dev)) {
dev->power.async_in_progress = true;

if (async_schedule_dev_nocall(func, dev))
return true;
get_device(dev);

put_device(dev);
if (async_schedule_dev_nocall(func, dev))
return true;

put_device(dev);
}
/*
* Because async_schedule_dev_nocall() above has returned false or it
* has not been called at all, func() is not running and it is safe to
* update the async_in_progress flag without extra synchronization.
*/
dev->power.async_in_progress = false;
return false;
}

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

__device_resume_noirq(dev, pm_transition, true);
device_resume_noirq(dev, pm_transition, true);
put_device(dev);
}

static void device_resume_noirq(struct device *dev)
{
if (dpm_async_fn(dev, async_resume_noirq))
return;

__device_resume_noirq(dev, pm_transition, false);
}

static void dpm_noirq_resume_devices(pm_message_t state)
{
struct device *dev;
Expand All @@ -712,18 +710,28 @@ static void dpm_noirq_resume_devices(pm_message_t state)
mutex_lock(&dpm_list_mtx);
pm_transition = state;

/*
* Trigger the resume of "async" devices upfront so they don't have to
* wait for the "non-async" ones they don't depend on.
*/
list_for_each_entry(dev, &dpm_noirq_list, power.entry)
dpm_async_fn(dev, async_resume_noirq);

while (!list_empty(&dpm_noirq_list)) {
dev = to_device(dpm_noirq_list.next);
get_device(dev);
list_move_tail(&dev->power.entry, &dpm_late_early_list);

mutex_unlock(&dpm_list_mtx);
if (!dev->power.async_in_progress) {
get_device(dev);

device_resume_noirq(dev);
mutex_unlock(&dpm_list_mtx);

put_device(dev);
device_resume_noirq(dev, state, false);

mutex_lock(&dpm_list_mtx);
put_device(dev);

mutex_lock(&dpm_list_mtx);
}
}
mutex_unlock(&dpm_list_mtx);
async_synchronize_full();
Expand All @@ -747,14 +755,14 @@ void dpm_resume_noirq(pm_message_t state)
}

/**
* __device_resume_early - Execute an "early resume" callback for given device.
* device_resume_early - Execute an "early resume" callback for given device.
* @dev: Device to handle.
* @state: PM transition of the system being carried out.
* @async: If true, the device is being resumed asynchronously.
*
* Runtime PM is disabled for @dev while this function is being executed.
*/
static void __device_resume_early(struct device *dev, pm_message_t state, bool async)
static void device_resume_early(struct device *dev, pm_message_t state, bool async)
{
pm_callback_t callback = NULL;
const char *info = NULL;
Expand Down Expand Up @@ -820,18 +828,10 @@ static void async_resume_early(void *data, async_cookie_t cookie)
{
struct device *dev = data;

__device_resume_early(dev, pm_transition, true);
device_resume_early(dev, pm_transition, true);
put_device(dev);
}

static void device_resume_early(struct device *dev)
{
if (dpm_async_fn(dev, async_resume_early))
return;

__device_resume_early(dev, pm_transition, false);
}

/**
* dpm_resume_early - Execute "early resume" callbacks for all devices.
* @state: PM transition of the system being carried out.
Expand All @@ -845,18 +845,28 @@ void dpm_resume_early(pm_message_t state)
mutex_lock(&dpm_list_mtx);
pm_transition = state;

/*
* Trigger the resume of "async" devices upfront so they don't have to
* wait for the "non-async" ones they don't depend on.
*/
list_for_each_entry(dev, &dpm_late_early_list, power.entry)
dpm_async_fn(dev, async_resume_early);

while (!list_empty(&dpm_late_early_list)) {
dev = to_device(dpm_late_early_list.next);
get_device(dev);
list_move_tail(&dev->power.entry, &dpm_suspended_list);

mutex_unlock(&dpm_list_mtx);
if (!dev->power.async_in_progress) {
get_device(dev);

device_resume_early(dev);
mutex_unlock(&dpm_list_mtx);

put_device(dev);
device_resume_early(dev, state, false);

mutex_lock(&dpm_list_mtx);
put_device(dev);

mutex_lock(&dpm_list_mtx);
}
}
mutex_unlock(&dpm_list_mtx);
async_synchronize_full();
Expand All @@ -876,12 +886,12 @@ void dpm_resume_start(pm_message_t state)
EXPORT_SYMBOL_GPL(dpm_resume_start);

/**
* __device_resume - Execute "resume" callbacks for given device.
* device_resume - Execute "resume" callbacks for given device.
* @dev: Device to handle.
* @state: PM transition of the system being carried out.
* @async: If true, the device is being resumed asynchronously.
*/
static void __device_resume(struct device *dev, pm_message_t state, bool async)
static void device_resume(struct device *dev, pm_message_t state, bool async)
{
pm_callback_t callback = NULL;
const char *info = NULL;
Expand Down Expand Up @@ -975,18 +985,10 @@ static void async_resume(void *data, async_cookie_t cookie)
{
struct device *dev = data;

__device_resume(dev, pm_transition, true);
device_resume(dev, pm_transition, true);
put_device(dev);
}

static void device_resume(struct device *dev)
{
if (dpm_async_fn(dev, async_resume))
return;

__device_resume(dev, pm_transition, false);
}

/**
* dpm_resume - Execute "resume" callbacks for non-sysdev devices.
* @state: PM transition of the system being carried out.
Expand All @@ -1006,16 +1008,25 @@ void dpm_resume(pm_message_t state)
pm_transition = state;
async_error = 0;

/*
* Trigger the resume of "async" devices upfront so they don't have to
* wait for the "non-async" ones they don't depend on.
*/
list_for_each_entry(dev, &dpm_suspended_list, power.entry)
dpm_async_fn(dev, async_resume);

while (!list_empty(&dpm_suspended_list)) {
dev = to_device(dpm_suspended_list.next);

get_device(dev);

mutex_unlock(&dpm_list_mtx);
if (!dev->power.async_in_progress) {
mutex_unlock(&dpm_list_mtx);

device_resume(dev);
device_resume(dev, state, false);

mutex_lock(&dpm_list_mtx);
mutex_lock(&dpm_list_mtx);
}

if (!list_empty(&dev->power.entry))
list_move_tail(&dev->power.entry, &dpm_prepared_list);
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/power/qos.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int dev_pm_qos_constraints_allocate(struct device *dev)
if (!qos)
return -ENOMEM;

n = kzalloc(3 * sizeof(*n), GFP_KERNEL);
n = kcalloc(3, sizeof(*n), GFP_KERNEL);
if (!n) {
kfree(qos);
return -ENOMEM;
Expand Down
21 changes: 18 additions & 3 deletions drivers/cpufreq/intel_pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ static bool hwp_forced __read_mostly;

static struct cpufreq_driver *intel_pstate_driver __read_mostly;

#define HYBRID_SCALING_FACTOR 78741
#define HYBRID_SCALING_FACTOR 78741
#define HYBRID_SCALING_FACTOR_MTL 80000

static int hybrid_scaling_factor = HYBRID_SCALING_FACTOR;

static inline int core_get_scaling(void)
{
Expand Down Expand Up @@ -422,7 +425,7 @@ static int intel_pstate_cppc_get_scaling(int cpu)
*/
if (!ret && cppc_perf.nominal_perf && cppc_perf.nominal_freq &&
cppc_perf.nominal_perf * 100 != cppc_perf.nominal_freq)
return HYBRID_SCALING_FACTOR;
return hybrid_scaling_factor;

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

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

static const struct x86_cpu_id intel_hybrid_scaling_factor[] = {
X86_MATCH_INTEL_FAM6_MODEL(METEORLAKE_L, HYBRID_SCALING_FACTOR_MTL),
{}
};

static int __init intel_pstate_init(void)
{
static struct cpudata **_all_cpu_data;
Expand Down Expand Up @@ -3489,9 +3497,16 @@ static int __init intel_pstate_init(void)

if (hwp_active) {
const struct x86_cpu_id *id = x86_match_cpu(intel_epp_balance_perf);
const struct x86_cpu_id *hybrid_id = x86_match_cpu(intel_hybrid_scaling_factor);

if (id)
epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = id->driver_data;

if (hybrid_id) {
hybrid_scaling_factor = hybrid_id->driver_data;
pr_debug("hybrid scaling factor: %d\n", hybrid_scaling_factor);
}

}

mutex_lock(&intel_pstate_driver_lock);
Expand Down
1 change: 1 addition & 0 deletions include/linux/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ struct dev_pm_info {
bool wakeup_path:1;
bool syscore:1;
bool no_pm_callbacks:1; /* Owned by the PM core */
bool async_in_progress:1; /* Owned by the PM core */
unsigned int must_resume:1; /* Owned by the PM core */
unsigned int may_skip_resume:1; /* Set by subsystems */
#else
Expand Down

0 comments on commit 7b5bcf9

Please sign in to comment.