Skip to content

Commit 42b4ca0

Browse files
committed
Merge branches 'pm-sleep', 'pm-acpi', 'pm-domains' and 'powercap'
* pm-sleep: PM: sleep: Add dev_wakeup_path() helper PM / suspend: fix kernel-doc markup PM: sleep: Print driver flags for all devices during suspend/resume * pm-acpi: PM: ACPI: Refresh wakeup device power configuration every time PM: ACPI: PCI: Drop acpi_pm_set_bridge_wakeup() PM: ACPI: reboot: Use S5 for reboot * pm-domains: PM: domains: create debugfs nodes when adding power domains PM: domains: replace -ENOTSUPP with -EOPNOTSUPP * powercap: powercap: Adjust printing the constraint name with new line powercap: RAPL: Add AMD Fam19h RAPL support powercap: Add AMD Fam17h RAPL support powercap/intel_rapl_msr: Convert rapl_msr_priv into pointer x86/msr-index: sort AMD RAPL MSRs by address
5 parents 4c5744a + 4e1d9a7 + b93b7ef + 718072c + b4ba76f commit 42b4ca0

File tree

14 files changed

+152
-102
lines changed

14 files changed

+152
-102
lines changed

arch/x86/include/asm/msr-index.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,9 @@
326326
#define MSR_PP1_ENERGY_STATUS 0x00000641
327327
#define MSR_PP1_POLICY 0x00000642
328328

329-
#define MSR_AMD_PKG_ENERGY_STATUS 0xc001029b
330329
#define MSR_AMD_RAPL_POWER_UNIT 0xc0010299
330+
#define MSR_AMD_CORE_ENERGY_STATUS 0xc001029a
331+
#define MSR_AMD_PKG_ENERGY_STATUS 0xc001029b
331332

332333
/* Config TDP MSRs */
333334
#define MSR_CONFIG_TDP_NOMINAL 0x00000648

drivers/acpi/device_pm.c

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -749,23 +749,34 @@ static void acpi_pm_notify_work_func(struct acpi_device_wakeup_context *context)
749749
static DEFINE_MUTEX(acpi_wakeup_lock);
750750

751751
static int __acpi_device_wakeup_enable(struct acpi_device *adev,
752-
u32 target_state, int max_count)
752+
u32 target_state)
753753
{
754754
struct acpi_device_wakeup *wakeup = &adev->wakeup;
755755
acpi_status status;
756756
int error = 0;
757757

758758
mutex_lock(&acpi_wakeup_lock);
759759

760-
if (wakeup->enable_count >= max_count)
761-
goto out;
762-
760+
/*
761+
* If the device wakeup power is already enabled, disable it and enable
762+
* it again in case it depends on the configuration of subordinate
763+
* devices and the conditions have changed since it was enabled last
764+
* time.
765+
*/
763766
if (wakeup->enable_count > 0)
764-
goto inc;
767+
acpi_disable_wakeup_device_power(adev);
765768

766769
error = acpi_enable_wakeup_device_power(adev, target_state);
767-
if (error)
770+
if (error) {
771+
if (wakeup->enable_count > 0) {
772+
acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number);
773+
wakeup->enable_count = 0;
774+
}
768775
goto out;
776+
}
777+
778+
if (wakeup->enable_count > 0)
779+
goto inc;
769780

770781
status = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number);
771782
if (ACPI_FAILURE(status)) {
@@ -778,7 +789,10 @@ static int __acpi_device_wakeup_enable(struct acpi_device *adev,
778789
(unsigned int)wakeup->gpe_number);
779790

780791
inc:
781-
wakeup->enable_count++;
792+
if (wakeup->enable_count < INT_MAX)
793+
wakeup->enable_count++;
794+
else
795+
acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n");
782796

783797
out:
784798
mutex_unlock(&acpi_wakeup_lock);
@@ -799,7 +813,7 @@ static int __acpi_device_wakeup_enable(struct acpi_device *adev,
799813
*/
800814
static int acpi_device_wakeup_enable(struct acpi_device *adev, u32 target_state)
801815
{
802-
return __acpi_device_wakeup_enable(adev, target_state, 1);
816+
return __acpi_device_wakeup_enable(adev, target_state);
803817
}
804818

805819
/**
@@ -829,8 +843,12 @@ static void acpi_device_wakeup_disable(struct acpi_device *adev)
829843
mutex_unlock(&acpi_wakeup_lock);
830844
}
831845

832-
static int __acpi_pm_set_device_wakeup(struct device *dev, bool enable,
833-
int max_count)
846+
/**
847+
* acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device.
848+
* @dev: Device to enable/disable to generate wakeup events.
849+
* @enable: Whether to enable or disable the wakeup functionality.
850+
*/
851+
int acpi_pm_set_device_wakeup(struct device *dev, bool enable)
834852
{
835853
struct acpi_device *adev;
836854
int error;
@@ -850,36 +868,14 @@ static int __acpi_pm_set_device_wakeup(struct device *dev, bool enable,
850868
return 0;
851869
}
852870

853-
error = __acpi_device_wakeup_enable(adev, acpi_target_system_state(),
854-
max_count);
871+
error = __acpi_device_wakeup_enable(adev, acpi_target_system_state());
855872
if (!error)
856873
dev_dbg(dev, "Wakeup enabled by ACPI\n");
857874

858875
return error;
859876
}
860-
861-
/**
862-
* acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device.
863-
* @dev: Device to enable/disable to generate wakeup events.
864-
* @enable: Whether to enable or disable the wakeup functionality.
865-
*/
866-
int acpi_pm_set_device_wakeup(struct device *dev, bool enable)
867-
{
868-
return __acpi_pm_set_device_wakeup(dev, enable, 1);
869-
}
870877
EXPORT_SYMBOL_GPL(acpi_pm_set_device_wakeup);
871878

872-
/**
873-
* acpi_pm_set_bridge_wakeup - Enable/disable remote wakeup for given bridge.
874-
* @dev: Bridge device to enable/disable to generate wakeup events.
875-
* @enable: Whether to enable or disable the wakeup functionality.
876-
*/
877-
int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable)
878-
{
879-
return __acpi_pm_set_device_wakeup(dev, enable, INT_MAX);
880-
}
881-
EXPORT_SYMBOL_GPL(acpi_pm_set_bridge_wakeup);
882-
883879
/**
884880
* acpi_dev_pm_low_power - Put ACPI device into a low-power state.
885881
* @dev: Device to put into a low-power state.

drivers/base/power/domain.c

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/suspend.h>
2222
#include <linux/export.h>
2323
#include <linux/cpu.h>
24+
#include <linux/debugfs.h>
2425

2526
#include "power.h"
2627

@@ -210,6 +211,18 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd)
210211
}
211212

212213
#ifdef CONFIG_DEBUG_FS
214+
static struct dentry *genpd_debugfs_dir;
215+
216+
static void genpd_debug_add(struct generic_pm_domain *genpd);
217+
218+
static void genpd_debug_remove(struct generic_pm_domain *genpd)
219+
{
220+
struct dentry *d;
221+
222+
d = debugfs_lookup(genpd->name, genpd_debugfs_dir);
223+
debugfs_remove(d);
224+
}
225+
213226
static void genpd_update_accounting(struct generic_pm_domain *genpd)
214227
{
215228
ktime_t delta, now;
@@ -234,6 +247,8 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
234247
genpd->accounting_time = now;
235248
}
236249
#else
250+
static inline void genpd_debug_add(struct generic_pm_domain *genpd) {}
251+
static inline void genpd_debug_remove(struct generic_pm_domain *genpd) {}
237252
static inline void genpd_update_accounting(struct generic_pm_domain *genpd) {}
238253
#endif
239254

@@ -1142,7 +1157,7 @@ static int genpd_finish_suspend(struct device *dev, bool poweroff)
11421157
if (ret)
11431158
return ret;
11441159

1145-
if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd))
1160+
if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
11461161
return 0;
11471162

11481163
if (genpd->dev_ops.stop && genpd->dev_ops.start &&
@@ -1196,7 +1211,7 @@ static int genpd_resume_noirq(struct device *dev)
11961211
if (IS_ERR(genpd))
11971212
return -EINVAL;
11981213

1199-
if (dev->power.wakeup_path && genpd_is_active_wakeup(genpd))
1214+
if (device_wakeup_path(dev) && genpd_is_active_wakeup(genpd))
12001215
return pm_generic_resume_noirq(dev);
12011216

12021217
genpd_lock(genpd);
@@ -1973,6 +1988,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
19731988

19741989
mutex_lock(&gpd_list_lock);
19751990
list_add(&genpd->gpd_list_node, &gpd_list);
1991+
genpd_debug_add(genpd);
19761992
mutex_unlock(&gpd_list_lock);
19771993

19781994
return 0;
@@ -2006,6 +2022,7 @@ static int genpd_remove(struct generic_pm_domain *genpd)
20062022
kfree(link);
20072023
}
20082024

2025+
genpd_debug_remove(genpd);
20092026
list_del(&genpd->gpd_list_node);
20102027
genpd_unlock(genpd);
20112028
cancel_work_sync(&genpd->power_off_work);
@@ -2912,14 +2929,6 @@ core_initcall(genpd_bus_init);
29122929
/*** debugfs support ***/
29132930

29142931
#ifdef CONFIG_DEBUG_FS
2915-
#include <linux/pm.h>
2916-
#include <linux/device.h>
2917-
#include <linux/debugfs.h>
2918-
#include <linux/seq_file.h>
2919-
#include <linux/init.h>
2920-
#include <linux/kobject.h>
2921-
static struct dentry *genpd_debugfs_dir;
2922-
29232932
/*
29242933
* TODO: This function is a slightly modified version of rtpm_status_show
29252934
* from sysfs.c, so generalize it.
@@ -3196,35 +3205,43 @@ DEFINE_SHOW_ATTRIBUTE(total_idle_time);
31963205
DEFINE_SHOW_ATTRIBUTE(devices);
31973206
DEFINE_SHOW_ATTRIBUTE(perf_state);
31983207

3199-
static int __init genpd_debug_init(void)
3208+
static void genpd_debug_add(struct generic_pm_domain *genpd)
32003209
{
32013210
struct dentry *d;
3211+
3212+
if (!genpd_debugfs_dir)
3213+
return;
3214+
3215+
d = debugfs_create_dir(genpd->name, genpd_debugfs_dir);
3216+
3217+
debugfs_create_file("current_state", 0444,
3218+
d, genpd, &status_fops);
3219+
debugfs_create_file("sub_domains", 0444,
3220+
d, genpd, &sub_domains_fops);
3221+
debugfs_create_file("idle_states", 0444,
3222+
d, genpd, &idle_states_fops);
3223+
debugfs_create_file("active_time", 0444,
3224+
d, genpd, &active_time_fops);
3225+
debugfs_create_file("total_idle_time", 0444,
3226+
d, genpd, &total_idle_time_fops);
3227+
debugfs_create_file("devices", 0444,
3228+
d, genpd, &devices_fops);
3229+
if (genpd->set_performance_state)
3230+
debugfs_create_file("perf_state", 0444,
3231+
d, genpd, &perf_state_fops);
3232+
}
3233+
3234+
static int __init genpd_debug_init(void)
3235+
{
32023236
struct generic_pm_domain *genpd;
32033237

32043238
genpd_debugfs_dir = debugfs_create_dir("pm_genpd", NULL);
32053239

32063240
debugfs_create_file("pm_genpd_summary", S_IRUGO, genpd_debugfs_dir,
32073241
NULL, &summary_fops);
32083242

3209-
list_for_each_entry(genpd, &gpd_list, gpd_list_node) {
3210-
d = debugfs_create_dir(genpd->name, genpd_debugfs_dir);
3211-
3212-
debugfs_create_file("current_state", 0444,
3213-
d, genpd, &status_fops);
3214-
debugfs_create_file("sub_domains", 0444,
3215-
d, genpd, &sub_domains_fops);
3216-
debugfs_create_file("idle_states", 0444,
3217-
d, genpd, &idle_states_fops);
3218-
debugfs_create_file("active_time", 0444,
3219-
d, genpd, &active_time_fops);
3220-
debugfs_create_file("total_idle_time", 0444,
3221-
d, genpd, &total_idle_time_fops);
3222-
debugfs_create_file("devices", 0444,
3223-
d, genpd, &devices_fops);
3224-
if (genpd->set_performance_state)
3225-
debugfs_create_file("perf_state", 0444,
3226-
d, genpd, &perf_state_fops);
3227-
}
3243+
list_for_each_entry(genpd, &gpd_list, gpd_list_node)
3244+
genpd_debug_add(genpd);
32283245

32293246
return 0;
32303247
}

drivers/base/power/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ static pm_callback_t pm_noirq_op(const struct dev_pm_ops *ops, pm_message_t stat
441441

442442
static void pm_dev_dbg(struct device *dev, pm_message_t state, const char *info)
443443
{
444-
dev_dbg(dev, "%s%s%s\n", info, pm_verb(state.event),
444+
dev_dbg(dev, "%s%s%s driver flags: %x\n", info, pm_verb(state.event),
445445
((state.event & PM_EVENT_SLEEP) && device_may_wakeup(dev)) ?
446-
", may wakeup" : "");
446+
", may wakeup" : "", dev->power.driver_flags);
447447
}
448448

449449
static void pm_dev_err(struct device *dev, pm_message_t state, const char *info,
@@ -1359,7 +1359,7 @@ static void dpm_propagate_wakeup_to_parent(struct device *dev)
13591359

13601360
spin_lock_irq(&parent->power.lock);
13611361

1362-
if (dev->power.wakeup_path && !parent->power.ignore_children)
1362+
if (device_wakeup_path(dev) && !parent->power.ignore_children)
13631363
parent->power.wakeup_path = true;
13641364

13651365
spin_unlock_irq(&parent->power.lock);
@@ -1627,7 +1627,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
16271627
goto Complete;
16281628

16291629
/* Avoid direct_complete to let wakeup_path propagate. */
1630-
if (device_may_wakeup(dev) || dev->power.wakeup_path)
1630+
if (device_may_wakeup(dev) || device_wakeup_path(dev))
16311631
dev->power.direct_complete = false;
16321632

16331633
if (dev->power.direct_complete) {

drivers/i2c/busses/i2c-stm32f7.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ static int stm32f7_i2c_suspend(struct device *dev)
23222322

23232323
i2c_mark_adapter_suspended(&i2c_dev->adap);
23242324

2325-
if (!device_may_wakeup(dev) && !dev->power.wakeup_path) {
2325+
if (!device_may_wakeup(dev) && !device_wakeup_path(dev)) {
23262326
ret = stm32f7_i2c_regs_backup(i2c_dev);
23272327
if (ret < 0) {
23282328
i2c_mark_adapter_resumed(&i2c_dev->adap);
@@ -2341,7 +2341,7 @@ static int stm32f7_i2c_resume(struct device *dev)
23412341
struct stm32f7_i2c_dev *i2c_dev = dev_get_drvdata(dev);
23422342
int ret;
23432343

2344-
if (!device_may_wakeup(dev) && !dev->power.wakeup_path) {
2344+
if (!device_may_wakeup(dev) && !device_wakeup_path(dev)) {
23452345
ret = pm_runtime_force_resume(dev);
23462346
if (ret < 0)
23472347
return ret;

drivers/pci/pci-acpi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,15 +1060,15 @@ static int acpi_pci_propagate_wakeup(struct pci_bus *bus, bool enable)
10601060
{
10611061
while (bus->parent) {
10621062
if (acpi_pm_device_can_wakeup(&bus->self->dev))
1063-
return acpi_pm_set_bridge_wakeup(&bus->self->dev, enable);
1063+
return acpi_pm_set_device_wakeup(&bus->self->dev, enable);
10641064

10651065
bus = bus->parent;
10661066
}
10671067

10681068
/* We have reached the root bus. */
10691069
if (bus->bridge) {
10701070
if (acpi_pm_device_can_wakeup(bus->bridge))
1071-
return acpi_pm_set_bridge_wakeup(bus->bridge, enable);
1071+
return acpi_pm_set_device_wakeup(bus->bridge, enable);
10721072
}
10731073
return 0;
10741074
}

drivers/powercap/intel_rapl_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@ static const struct rapl_defaults rapl_defaults_cht = {
10111011
.compute_time_window = rapl_compute_time_window_atom,
10121012
};
10131013

1014+
static const struct rapl_defaults rapl_defaults_amd = {
1015+
.check_unit = rapl_check_unit_core,
1016+
};
1017+
10141018
static const struct x86_cpu_id rapl_ids[] __initconst = {
10151019
X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE, &rapl_defaults_core),
10161020
X86_MATCH_INTEL_FAM6_MODEL(SANDYBRIDGE_X, &rapl_defaults_core),
@@ -1061,6 +1065,9 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
10611065

10621066
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNL, &rapl_defaults_hsw_server),
10631067
X86_MATCH_INTEL_FAM6_MODEL(XEON_PHI_KNM, &rapl_defaults_hsw_server),
1068+
1069+
X86_MATCH_VENDOR_FAM(AMD, 0x17, &rapl_defaults_amd),
1070+
X86_MATCH_VENDOR_FAM(AMD, 0x19, &rapl_defaults_amd),
10641071
{}
10651072
};
10661073
MODULE_DEVICE_TABLE(x86cpu, rapl_ids);

0 commit comments

Comments
 (0)