Skip to content

Commit ffc843f

Browse files
committed
Merge back earlier system-wide PM changes for v6.7.
2 parents b21f18e + 7bf770f commit ffc843f

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

include/linux/pm.h

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,24 +374,39 @@ const struct dev_pm_ops name = { \
374374
RUNTIME_PM_OPS(runtime_suspend_fn, runtime_resume_fn, idle_fn) \
375375
}
376376

377-
#ifdef CONFIG_PM
378-
#define _EXPORT_DEV_PM_OPS(name, license, ns) \
377+
#define _EXPORT_PM_OPS(name, license, ns) \
379378
const struct dev_pm_ops name; \
380379
__EXPORT_SYMBOL(name, license, ns); \
381380
const struct dev_pm_ops name
382-
#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
383-
#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
384-
#else
385-
#define _EXPORT_DEV_PM_OPS(name, license, ns) \
381+
382+
#define _DISCARD_PM_OPS(name, license, ns) \
386383
static __maybe_unused const struct dev_pm_ops __static_##name
384+
385+
#ifdef CONFIG_PM
386+
#define _EXPORT_DEV_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns)
387+
#define EXPORT_PM_FN_GPL(name) EXPORT_SYMBOL_GPL(name)
388+
#define EXPORT_PM_FN_NS_GPL(name, ns) EXPORT_SYMBOL_NS_GPL(name, ns)
389+
#else
390+
#define _EXPORT_DEV_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns)
387391
#define EXPORT_PM_FN_GPL(name)
388392
#define EXPORT_PM_FN_NS_GPL(name, ns)
389393
#endif
390394

391-
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
392-
#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "")
393-
#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
394-
#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns)
395+
#ifdef CONFIG_PM_SLEEP
396+
#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _EXPORT_PM_OPS(name, license, ns)
397+
#else
398+
#define _EXPORT_DEV_SLEEP_PM_OPS(name, license, ns) _DISCARD_PM_OPS(name, license, ns)
399+
#endif
400+
401+
#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
402+
#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "GPL", "")
403+
#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
404+
#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "GPL", #ns)
405+
406+
#define EXPORT_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "", "")
407+
#define EXPORT_GPL_DEV_SLEEP_PM_OPS(name) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", "")
408+
#define EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "", #ns)
409+
#define EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) _EXPORT_DEV_SLEEP_PM_OPS(name, "GPL", #ns)
395410

396411
/*
397412
* Use this if you want to use the same suspend and resume callbacks for suspend
@@ -404,19 +419,19 @@ const struct dev_pm_ops name = { \
404419
_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL)
405420

406421
#define EXPORT_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
407-
EXPORT_DEV_PM_OPS(name) = { \
422+
EXPORT_DEV_SLEEP_PM_OPS(name) = { \
408423
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
409424
}
410425
#define EXPORT_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
411-
EXPORT_GPL_DEV_PM_OPS(name) = { \
426+
EXPORT_GPL_DEV_SLEEP_PM_OPS(name) = { \
412427
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
413428
}
414429
#define EXPORT_NS_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \
415-
EXPORT_NS_DEV_PM_OPS(name, ns) = { \
430+
EXPORT_NS_DEV_SLEEP_PM_OPS(name, ns) = { \
416431
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
417432
}
418433
#define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns) \
419-
EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
434+
EXPORT_NS_GPL_DEV_SLEEP_PM_OPS(name, ns) = { \
420435
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
421436
}
422437

kernel/power/snapshot.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2545,8 +2545,9 @@ static void *get_highmem_page_buffer(struct page *page,
25452545
pbe->copy_page = tmp;
25462546
} else {
25472547
/* Copy of the page will be stored in normal memory */
2548-
kaddr = safe_pages_list;
2549-
safe_pages_list = safe_pages_list->next;
2548+
kaddr = __get_safe_page(ca->gfp_mask);
2549+
if (!kaddr)
2550+
return ERR_PTR(-ENOMEM);
25502551
pbe->copy_page = virt_to_page(kaddr);
25512552
}
25522553
pbe->next = highmem_pblist;
@@ -2750,8 +2751,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
27502751
return ERR_PTR(-ENOMEM);
27512752
}
27522753
pbe->orig_address = page_address(page);
2753-
pbe->address = safe_pages_list;
2754-
safe_pages_list = safe_pages_list->next;
2754+
pbe->address = __get_safe_page(ca->gfp_mask);
2755+
if (!pbe->address)
2756+
return ERR_PTR(-ENOMEM);
27552757
pbe->next = restore_pblist;
27562758
restore_pblist = pbe;
27572759
return pbe->address;
@@ -2783,8 +2785,6 @@ int snapshot_write_next(struct snapshot_handle *handle)
27832785
if (handle->cur > 1 && handle->cur > nr_meta_pages + nr_copy_pages + nr_zero_pages)
27842786
return 0;
27852787

2786-
handle->sync_read = 1;
2787-
27882788
if (!handle->cur) {
27892789
if (!buffer)
27902790
/* This makes the buffer be freed by swsusp_free() */
@@ -2827,7 +2827,6 @@ int snapshot_write_next(struct snapshot_handle *handle)
28272827
memory_bm_position_reset(&zero_bm);
28282828
restore_pblist = NULL;
28292829
handle->buffer = get_buffer(&orig_bm, &ca);
2830-
handle->sync_read = 0;
28312830
if (IS_ERR(handle->buffer))
28322831
return PTR_ERR(handle->buffer);
28332832
}
@@ -2837,9 +2836,8 @@ int snapshot_write_next(struct snapshot_handle *handle)
28372836
handle->buffer = get_buffer(&orig_bm, &ca);
28382837
if (IS_ERR(handle->buffer))
28392838
return PTR_ERR(handle->buffer);
2840-
if (handle->buffer != buffer)
2841-
handle->sync_read = 0;
28422839
}
2840+
handle->sync_read = (handle->buffer == buffer);
28432841
handle->cur++;
28442842

28452843
/* Zero pages were not included in the image, memset it and move on. */

kernel/power/swap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ int swsusp_read(unsigned int *flags_p)
15131513
static void *swsusp_holder;
15141514

15151515
/**
1516-
* swsusp_check - Check for swsusp signature in the resume device
1516+
* swsusp_check - Open the resume device and check for the swsusp signature.
15171517
* @exclusive: Open the resume device exclusively.
15181518
*/
15191519

@@ -1564,7 +1564,7 @@ int swsusp_check(bool exclusive)
15641564
}
15651565

15661566
/**
1567-
* swsusp_close - close swap device.
1567+
* swsusp_close - close resume device.
15681568
* @exclusive: Close the resume device which is exclusively opened.
15691569
*/
15701570

0 commit comments

Comments
 (0)