Commit a7b4b007 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pm-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These make the buffer handling in pm_show_wakelocks() more robust and
  drop an unused hibernation-related function.

  Specifics:

   - Make the buffer handling in pm_show_wakelocks() more robust by
     using sysfs_emit_at() in it to generate output (Greg
     Kroah-Hartman).

   - Drop register_nosave_region_late() which is not used (Amadeusz
     Sławiński)"

* tag 'pm-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  PM: hibernate: Remove register_nosave_region_late()
  PM: wakeup: simplify the output logic of pm_show_wakelocks()
parents df000154 33569ef3
...@@ -430,15 +430,7 @@ struct platform_hibernation_ops { ...@@ -430,15 +430,7 @@ struct platform_hibernation_ops {
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATION
/* kernel/power/snapshot.c */ /* kernel/power/snapshot.c */
extern void __register_nosave_region(unsigned long b, unsigned long e, int km); extern void register_nosave_region(unsigned long b, unsigned long e);
static inline void __init register_nosave_region(unsigned long b, unsigned long e)
{
__register_nosave_region(b, e, 0);
}
static inline void __init register_nosave_region_late(unsigned long b, unsigned long e)
{
__register_nosave_region(b, e, 1);
}
extern int swsusp_page_is_forbidden(struct page *); extern int swsusp_page_is_forbidden(struct page *);
extern void swsusp_set_page_free(struct page *); extern void swsusp_set_page_free(struct page *);
extern void swsusp_unset_page_free(struct page *); extern void swsusp_unset_page_free(struct page *);
...@@ -458,7 +450,6 @@ int pfn_is_nosave(unsigned long pfn); ...@@ -458,7 +450,6 @@ int pfn_is_nosave(unsigned long pfn);
int hibernate_quiet_exec(int (*func)(void *data), void *data); int hibernate_quiet_exec(int (*func)(void *data), void *data);
#else /* CONFIG_HIBERNATION */ #else /* CONFIG_HIBERNATION */
static inline void register_nosave_region(unsigned long b, unsigned long e) {} static inline void register_nosave_region(unsigned long b, unsigned long e) {}
static inline void register_nosave_region_late(unsigned long b, unsigned long e) {}
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
static inline void swsusp_set_page_free(struct page *p) {} static inline void swsusp_set_page_free(struct page *p) {}
static inline void swsusp_unset_page_free(struct page *p) {} static inline void swsusp_unset_page_free(struct page *p) {}
......
...@@ -978,8 +978,7 @@ static void memory_bm_recycle(struct memory_bitmap *bm) ...@@ -978,8 +978,7 @@ static void memory_bm_recycle(struct memory_bitmap *bm)
* Register a range of page frames the contents of which should not be saved * Register a range of page frames the contents of which should not be saved
* during hibernation (to be used in the early initialization code). * during hibernation (to be used in the early initialization code).
*/ */
void __init __register_nosave_region(unsigned long start_pfn, void __init register_nosave_region(unsigned long start_pfn, unsigned long end_pfn)
unsigned long end_pfn, int use_kmalloc)
{ {
struct nosave_region *region; struct nosave_region *region;
...@@ -995,18 +994,12 @@ void __init __register_nosave_region(unsigned long start_pfn, ...@@ -995,18 +994,12 @@ void __init __register_nosave_region(unsigned long start_pfn,
goto Report; goto Report;
} }
} }
if (use_kmalloc) { /* This allocation cannot fail */
/* During init, this shouldn't fail */ region = memblock_alloc(sizeof(struct nosave_region),
region = kmalloc(sizeof(struct nosave_region), GFP_KERNEL); SMP_CACHE_BYTES);
BUG_ON(!region); if (!region)
} else { panic("%s: Failed to allocate %zu bytes\n", __func__,
/* This allocation cannot fail */ sizeof(struct nosave_region));
region = memblock_alloc(sizeof(struct nosave_region),
SMP_CACHE_BYTES);
if (!region)
panic("%s: Failed to allocate %zu bytes\n", __func__,
sizeof(struct nosave_region));
}
region->start_pfn = start_pfn; region->start_pfn = start_pfn;
region->end_pfn = end_pfn; region->end_pfn = end_pfn;
list_add_tail(&region->list, &nosave_regions); list_add_tail(&region->list, &nosave_regions);
......
...@@ -39,23 +39,20 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active) ...@@ -39,23 +39,20 @@ ssize_t pm_show_wakelocks(char *buf, bool show_active)
{ {
struct rb_node *node; struct rb_node *node;
struct wakelock *wl; struct wakelock *wl;
char *str = buf; int len = 0;
char *end = buf + PAGE_SIZE;
mutex_lock(&wakelocks_lock); mutex_lock(&wakelocks_lock);
for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) { for (node = rb_first(&wakelocks_tree); node; node = rb_next(node)) {
wl = rb_entry(node, struct wakelock, node); wl = rb_entry(node, struct wakelock, node);
if (wl->ws->active == show_active) if (wl->ws->active == show_active)
str += scnprintf(str, end - str, "%s ", wl->name); len += sysfs_emit_at(buf, len, "%s ", wl->name);
} }
if (str > buf)
str--;
str += scnprintf(str, end - str, "\n"); len += sysfs_emit_at(buf, len, "\n");
mutex_unlock(&wakelocks_lock); mutex_unlock(&wakelocks_lock);
return (str - buf); return len;
} }
#if CONFIG_PM_WAKELOCKS_LIMIT > 0 #if CONFIG_PM_WAKELOCKS_LIMIT > 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment