Skip to content

Commit 9b8f363

Browse files
committed
Merge branches 'pm-sleep' and 'pm-domains'
Merge updates related to system-wide power management and generic power domains (genpd) updates for 6.5-rc1: - Fix the handling of pm_suspend_target_state when CONFIG_PM is unset (Kai-Heng Feng). - Correct spelling mistake in a comment in the hibernation code (Wang Honghui). - Add arch_resume_nosmt() prototype to avoid a "missing prototypes" build warning (Arnd Bergmann). - Restrict pm_pr_dbg() to system-wide power transitions and use it in a few additional places (Mario Limonciello). - Drop verification of in-params from genpd_add_device() and ensure that all of its callers will do it (Ulf Hansson). - Prevent possible integer overflows from occurring in genpd_parse_state() (Nikita Zhandarovich). * pm-sleep: platform/x86/amd: pmc: Use pm_pr_dbg() for suspend related messages pinctrl: amd: Use pm_pr_dbg to show debugging messages ACPI: x86: Add pm_debug_messages for LPS0 _DSM state tracking include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume PM: suspend: add a arch_resume_nosmt() prototype PM: hibernate: Correct spelling mistake in a comment PM: suspend: Fix pm_suspend_target_state handling for !CONFIG_PM * pm-domains: PM: domains: Move the verification of in-params from genpd_add_device() PM: domains: fix integer overflow issues in genpd_parse_state()
3 parents 4af191d + b77505e + 4384a70 commit 9b8f363

File tree

8 files changed

+77
-27
lines changed

8 files changed

+77
-27
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int lps0_dsm_func_mask;
5959

6060
static guid_t lps0_dsm_guid_microsoft;
6161
static int lps0_dsm_func_mask_microsoft;
62+
static int lps0_dsm_state;
6263

6364
/* Device constraint entry structure */
6465
struct lpi_device_info {
@@ -320,6 +321,44 @@ static void lpi_check_constraints(void)
320321
}
321322
}
322323

324+
static bool acpi_s2idle_vendor_amd(void)
325+
{
326+
return boot_cpu_data.x86_vendor == X86_VENDOR_AMD;
327+
}
328+
329+
static const char *acpi_sleep_dsm_state_to_str(unsigned int state)
330+
{
331+
if (lps0_dsm_func_mask_microsoft || !acpi_s2idle_vendor_amd()) {
332+
switch (state) {
333+
case ACPI_LPS0_SCREEN_OFF:
334+
return "screen off";
335+
case ACPI_LPS0_SCREEN_ON:
336+
return "screen on";
337+
case ACPI_LPS0_ENTRY:
338+
return "lps0 entry";
339+
case ACPI_LPS0_EXIT:
340+
return "lps0 exit";
341+
case ACPI_LPS0_MS_ENTRY:
342+
return "lps0 ms entry";
343+
case ACPI_LPS0_MS_EXIT:
344+
return "lps0 ms exit";
345+
}
346+
} else {
347+
switch (state) {
348+
case ACPI_LPS0_SCREEN_ON_AMD:
349+
return "screen on";
350+
case ACPI_LPS0_SCREEN_OFF_AMD:
351+
return "screen off";
352+
case ACPI_LPS0_ENTRY_AMD:
353+
return "lps0 entry";
354+
case ACPI_LPS0_EXIT_AMD:
355+
return "lps0 exit";
356+
}
357+
}
358+
359+
return "unknown";
360+
}
361+
323362
static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, guid_t dsm_guid)
324363
{
325364
union acpi_object *out_obj;
@@ -331,14 +370,15 @@ static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, g
331370
rev_id, func, NULL);
332371
ACPI_FREE(out_obj);
333372

334-
acpi_handle_debug(lps0_device_handle, "_DSM function %u evaluation %s\n",
335-
func, out_obj ? "successful" : "failed");
373+
lps0_dsm_state = func;
374+
if (pm_debug_messages_on) {
375+
acpi_handle_info(lps0_device_handle,
376+
"%s transitioned to state %s\n",
377+
out_obj ? "Successfully" : "Failed to",
378+
acpi_sleep_dsm_state_to_str(lps0_dsm_state));
379+
}
336380
}
337381

338-
static bool acpi_s2idle_vendor_amd(void)
339-
{
340-
return boot_cpu_data.x86_vendor == X86_VENDOR_AMD;
341-
}
342382

343383
static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *dsm_guid)
344384
{

drivers/base/power/domain.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
16321632

16331633
dev_dbg(dev, "%s()\n", __func__);
16341634

1635-
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
1636-
return -EINVAL;
1637-
16381635
gpd_data = genpd_alloc_dev_data(dev, gd);
16391636
if (IS_ERR(gpd_data))
16401637
return PTR_ERR(gpd_data);
@@ -1676,6 +1673,9 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
16761673
{
16771674
int ret;
16781675

1676+
if (!genpd || !dev)
1677+
return -EINVAL;
1678+
16791679
mutex_lock(&gpd_list_lock);
16801680
ret = genpd_add_device(genpd, dev, dev);
16811681
mutex_unlock(&gpd_list_lock);
@@ -2523,6 +2523,9 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
25232523
struct generic_pm_domain *genpd;
25242524
int ret;
25252525

2526+
if (!dev)
2527+
return -EINVAL;
2528+
25262529
mutex_lock(&gpd_list_lock);
25272530

25282531
genpd = genpd_get_from_provider(genpdspec);
@@ -2939,10 +2942,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,
29392942

29402943
err = of_property_read_u32(state_node, "min-residency-us", &residency);
29412944
if (!err)
2942-
genpd_state->residency_ns = 1000 * residency;
2945+
genpd_state->residency_ns = 1000LL * residency;
29432946

2944-
genpd_state->power_on_latency_ns = 1000 * exit_latency;
2945-
genpd_state->power_off_latency_ns = 1000 * entry_latency;
2947+
genpd_state->power_on_latency_ns = 1000LL * exit_latency;
2948+
genpd_state->power_off_latency_ns = 1000LL * entry_latency;
29462949
genpd_state->fwnode = &state_node->fwnode;
29472950

29482951
return 0;

drivers/base/power/wakeup.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919

2020
#include "power.h"
2121

22-
#ifndef CONFIG_SUSPEND
23-
suspend_state_t pm_suspend_target_state;
24-
#define pm_suspend_target_state (PM_SUSPEND_ON)
25-
#endif
26-
2722
#define list_for_each_entry_rcu_locked(pos, head, member) \
2823
list_for_each_entry_rcu(pos, head, member, \
2924
srcu_read_lock_held(&wakeup_srcu))

drivers/pinctrl/pinctrl-amd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/pinctrl/pinconf.h>
3131
#include <linux/pinctrl/pinconf-generic.h>
3232
#include <linux/pinctrl/pinmux.h>
33+
#include <linux/suspend.h>
3334

3435
#include "core.h"
3536
#include "pinctrl-utils.h"
@@ -636,9 +637,8 @@ static bool do_amd_gpio_irq_handler(int irq, void *dev_id)
636637
regval = readl(regs + i);
637638

638639
if (regval & PIN_IRQ_PENDING)
639-
dev_dbg(&gpio_dev->pdev->dev,
640-
"GPIO %d is active: 0x%x",
641-
irqnr + i, regval);
640+
pm_pr_dbg("GPIO %d is active: 0x%x",
641+
irqnr + i, regval);
642642

643643
/* caused wake on resume context for shared IRQ */
644644
if (irq < 0 && (regval & BIT(WAKE_STS_OFF)))

drivers/platform/x86/amd/pmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
543543
}
544544

545545
if (dev)
546-
dev_dbg(pdev->dev, "SMU idlemask s0i3: 0x%x\n", val);
546+
pm_pr_dbg("SMU idlemask s0i3: 0x%x\n", val);
547547

548548
if (s)
549549
seq_printf(s, "SMU idlemask : 0x%x\n", val);
@@ -769,7 +769,7 @@ static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg)
769769

770770
*arg |= (duration << 16);
771771
rc = rtc_alarm_irq_enable(rtc_device, 0);
772-
dev_dbg(pdev->dev, "wakeup timer programmed for %lld seconds\n", duration);
772+
pm_pr_dbg("wakeup timer programmed for %lld seconds\n", duration);
773773

774774
return rc;
775775
}

include/linux/suspend.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct platform_s2idle_ops {
202202
};
203203

204204
#ifdef CONFIG_SUSPEND
205+
extern suspend_state_t pm_suspend_target_state;
205206
extern suspend_state_t mem_sleep_current;
206207
extern suspend_state_t mem_sleep_default;
207208

@@ -337,6 +338,8 @@ extern bool sync_on_suspend_enabled;
337338
#else /* !CONFIG_SUSPEND */
338339
#define suspend_valid_only_mem NULL
339340

341+
#define pm_suspend_target_state (PM_SUSPEND_ON)
342+
340343
static inline void pm_suspend_clear_flags(void) {}
341344
static inline void pm_set_suspend_via_firmware(void) {}
342345
static inline void pm_set_resume_via_firmware(void) {}
@@ -468,6 +471,8 @@ static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) {
468471
}
469472
#endif /* CONFIG_HIBERNATION */
470473

474+
int arch_resume_nosmt(void);
475+
471476
#ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
472477
int is_hibernate_resume_dev(dev_t dev);
473478
#else
@@ -503,7 +508,6 @@ extern void pm_report_max_hw_sleep(u64 t);
503508

504509
/* drivers/base/power/wakeup.c */
505510
extern bool events_check_enabled;
506-
extern suspend_state_t pm_suspend_target_state;
507511

508512
extern bool pm_wakeup_pending(void);
509513
extern void pm_system_wakeup(void);
@@ -551,6 +555,7 @@ static inline void unlock_system_sleep(unsigned int flags) {}
551555
#ifdef CONFIG_PM_SLEEP_DEBUG
552556
extern bool pm_print_times_enabled;
553557
extern bool pm_debug_messages_on;
558+
extern bool pm_debug_messages_should_print(void);
554559
static inline int pm_dyn_debug_messages_on(void)
555560
{
556561
#ifdef CONFIG_DYNAMIC_DEBUG
@@ -564,14 +569,14 @@ static inline int pm_dyn_debug_messages_on(void)
564569
#endif
565570
#define __pm_pr_dbg(fmt, ...) \
566571
do { \
567-
if (pm_debug_messages_on) \
572+
if (pm_debug_messages_should_print()) \
568573
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
569574
else if (pm_dyn_debug_messages_on()) \
570575
pr_debug(fmt, ##__VA_ARGS__); \
571576
} while (0)
572577
#define __pm_deferred_pr_dbg(fmt, ...) \
573578
do { \
574-
if (pm_debug_messages_on) \
579+
if (pm_debug_messages_should_print()) \
575580
printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
576581
} while (0)
577582
#else
@@ -589,7 +594,8 @@ static inline int pm_dyn_debug_messages_on(void)
589594
/**
590595
* pm_pr_dbg - print pm sleep debug messages
591596
*
592-
* If pm_debug_messages_on is enabled, print message.
597+
* If pm_debug_messages_on is enabled and the system is entering/leaving
598+
* suspend, print message.
593599
* If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled,
594600
* print message only from instances explicitly enabled on dynamic debug's
595601
* control.

kernel/power/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,12 @@ power_attr_ro(pm_wakeup_irq);
556556

557557
bool pm_debug_messages_on __read_mostly;
558558

559+
bool pm_debug_messages_should_print(void)
560+
{
561+
return pm_debug_messages_on && pm_suspend_target_state != PM_SUSPEND_ON;
562+
}
563+
EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);
564+
559565
static ssize_t pm_debug_messages_show(struct kobject *kobj,
560566
struct kobj_attribute *attr, char *buf)
561567
{

kernel/power/snapshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ struct mem_zone_bm_rtree {
398398
unsigned int blocks; /* Number of Bitmap Blocks */
399399
};
400400

401-
/* strcut bm_position is used for browsing memory bitmaps */
401+
/* struct bm_position is used for browsing memory bitmaps */
402402

403403
struct bm_position {
404404
struct mem_zone_bm_rtree *zone;

0 commit comments

Comments
 (0)