Skip to content

Commit 2cf9ba2

Browse files
committed
Merge branches 'pm-core', 'pm-sleep', 'pm-pci' and 'pm-domains'
* pm-core: PM: runtime: Fix timer_expires data type on 32-bit arches PM: runtime: Remove link state checks in rpm_get/put_supplier() * pm-sleep: ACPI: EC: PM: Drop ec_no_wakeup check from acpi_ec_dispatch_gpe() ACPI: EC: PM: Flush EC work unconditionally after wakeup PM: hibernate: remove the bogus call to get_gendisk() in software_resume() PM: hibernate: Batch hibernate and resume IO requests * pm-pci: PCI/ACPI: Whitelist hotplug ports for D3 if power managed by ACPI * pm-domains: PM: domains: Allow to abort power off when no ->power_off() callback PM: domains: Rename power state enums for genpd
5 parents fe5975b + 6b61d49 + e0e9ce3 + c6e3313 + f63816e commit 2cf9ba2

8 files changed

Lines changed: 55 additions & 59 deletions

File tree

drivers/acpi/ec.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,20 +2011,16 @@ bool acpi_ec_dispatch_gpe(void)
20112011
if (acpi_any_gpe_status_set(first_ec->gpe))
20122012
return true;
20132013

2014-
if (ec_no_wakeup)
2015-
return false;
2016-
20172014
/*
20182015
* Dispatch the EC GPE in-band, but do not report wakeup in any case
20192016
* to allow the caller to process events properly after that.
20202017
*/
20212018
ret = acpi_dispatch_gpe(NULL, first_ec->gpe);
2022-
if (ret == ACPI_INTERRUPT_HANDLED) {
2019+
if (ret == ACPI_INTERRUPT_HANDLED)
20232020
pm_pr_dbg("ACPI EC GPE dispatched\n");
20242021

2025-
/* Flush the event and query workqueues. */
2026-
acpi_ec_flush_work();
2027-
}
2022+
/* Flush the event and query workqueues. */
2023+
acpi_ec_flush_work();
20282024

20292025
return false;
20302026
}

drivers/base/power/domain.c

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static const struct genpd_lock_ops genpd_spin_ops = {
123123
#define genpd_lock_interruptible(p) p->lock_ops->lock_interruptible(p)
124124
#define genpd_unlock(p) p->lock_ops->unlock(p)
125125

126-
#define genpd_status_on(genpd) (genpd->status == GPD_STATE_ACTIVE)
126+
#define genpd_status_on(genpd) (genpd->status == GENPD_STATE_ON)
127127
#define genpd_is_irq_safe(genpd) (genpd->flags & GENPD_FLAG_IRQ_SAFE)
128128
#define genpd_is_always_on(genpd) (genpd->flags & GENPD_FLAG_ALWAYS_ON)
129129
#define genpd_is_active_wakeup(genpd) (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
@@ -222,7 +222,7 @@ static void genpd_update_accounting(struct generic_pm_domain *genpd)
222222
* out of off and so update the idle time and vice
223223
* versa.
224224
*/
225-
if (genpd->status == GPD_STATE_ACTIVE) {
225+
if (genpd->status == GENPD_STATE_ON) {
226226
int state_idx = genpd->state_idx;
227227

228228
genpd->states[state_idx].idle_time =
@@ -497,6 +497,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
497497
struct pm_domain_data *pdd;
498498
struct gpd_link *link;
499499
unsigned int not_suspended = 0;
500+
int ret;
500501

501502
/*
502503
* Do not try to power off the domain in the following situations:
@@ -544,26 +545,15 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
544545
if (!genpd->gov)
545546
genpd->state_idx = 0;
546547

547-
if (genpd->power_off) {
548-
int ret;
549-
550-
if (atomic_read(&genpd->sd_count) > 0)
551-
return -EBUSY;
548+
/* Don't power off, if a child domain is waiting to power on. */
549+
if (atomic_read(&genpd->sd_count) > 0)
550+
return -EBUSY;
552551

553-
/*
554-
* If sd_count > 0 at this point, one of the subdomains hasn't
555-
* managed to call genpd_power_on() for the parent yet after
556-
* incrementing it. In that case genpd_power_on() will wait
557-
* for us to drop the lock, so we can call .power_off() and let
558-
* the genpd_power_on() restore power for us (this shouldn't
559-
* happen very often).
560-
*/
561-
ret = _genpd_power_off(genpd, true);
562-
if (ret)
563-
return ret;
564-
}
552+
ret = _genpd_power_off(genpd, true);
553+
if (ret)
554+
return ret;
565555

566-
genpd->status = GPD_STATE_POWER_OFF;
556+
genpd->status = GENPD_STATE_OFF;
567557
genpd_update_accounting(genpd);
568558

569559
list_for_each_entry(link, &genpd->child_links, child_node) {
@@ -616,7 +606,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
616606
if (ret)
617607
goto err;
618608

619-
genpd->status = GPD_STATE_ACTIVE;
609+
genpd->status = GENPD_STATE_ON;
620610
genpd_update_accounting(genpd);
621611

622612
return 0;
@@ -961,7 +951,7 @@ static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
961951
if (_genpd_power_off(genpd, false))
962952
return;
963953

964-
genpd->status = GPD_STATE_POWER_OFF;
954+
genpd->status = GENPD_STATE_OFF;
965955

966956
list_for_each_entry(link, &genpd->child_links, child_node) {
967957
genpd_sd_counter_dec(link->parent);
@@ -1007,8 +997,7 @@ static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
1007997
}
1008998

1009999
_genpd_power_on(genpd, false);
1010-
1011-
genpd->status = GPD_STATE_ACTIVE;
1000+
genpd->status = GENPD_STATE_ON;
10121001
}
10131002

10141003
/**
@@ -1287,7 +1276,7 @@ static int genpd_restore_noirq(struct device *dev)
12871276
* so make it appear as powered off to genpd_sync_power_on(),
12881277
* so that it tries to power it on in case it was really off.
12891278
*/
1290-
genpd->status = GPD_STATE_POWER_OFF;
1279+
genpd->status = GENPD_STATE_OFF;
12911280

12921281
genpd_sync_power_on(genpd, true, 0);
12931282
genpd_unlock(genpd);
@@ -1777,7 +1766,7 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
17771766
genpd->gov = gov;
17781767
INIT_WORK(&genpd->power_off_work, genpd_power_off_work_fn);
17791768
atomic_set(&genpd->sd_count, 0);
1780-
genpd->status = is_off ? GPD_STATE_POWER_OFF : GPD_STATE_ACTIVE;
1769+
genpd->status = is_off ? GENPD_STATE_OFF : GENPD_STATE_ON;
17811770
genpd->device_count = 0;
17821771
genpd->max_off_time_ns = -1;
17831772
genpd->max_off_time_changed = true;
@@ -2804,8 +2793,8 @@ static int genpd_summary_one(struct seq_file *s,
28042793
struct generic_pm_domain *genpd)
28052794
{
28062795
static const char * const status_lookup[] = {
2807-
[GPD_STATE_ACTIVE] = "on",
2808-
[GPD_STATE_POWER_OFF] = "off"
2796+
[GENPD_STATE_ON] = "on",
2797+
[GENPD_STATE_OFF] = "off"
28092798
};
28102799
struct pm_domain_data *pm_data;
28112800
const char *kobj_path;
@@ -2883,8 +2872,8 @@ static int summary_show(struct seq_file *s, void *data)
28832872
static int status_show(struct seq_file *s, void *data)
28842873
{
28852874
static const char * const status_lookup[] = {
2886-
[GPD_STATE_ACTIVE] = "on",
2887-
[GPD_STATE_POWER_OFF] = "off"
2875+
[GENPD_STATE_ON] = "on",
2876+
[GENPD_STATE_OFF] = "off"
28882877
};
28892878

28902879
struct generic_pm_domain *genpd = s->private;
@@ -2897,7 +2886,7 @@ static int status_show(struct seq_file *s, void *data)
28972886
if (WARN_ON_ONCE(genpd->status >= ARRAY_SIZE(status_lookup)))
28982887
goto exit;
28992888

2900-
if (genpd->status == GPD_STATE_POWER_OFF)
2889+
if (genpd->status == GENPD_STATE_OFF)
29012890
seq_printf(s, "%s-%u\n", status_lookup[genpd->status],
29022891
genpd->state_idx);
29032892
else
@@ -2940,7 +2929,7 @@ static int idle_states_show(struct seq_file *s, void *data)
29402929
ktime_t delta = 0;
29412930
s64 msecs;
29422931

2943-
if ((genpd->status == GPD_STATE_POWER_OFF) &&
2932+
if ((genpd->status == GENPD_STATE_OFF) &&
29442933
(genpd->state_idx == i))
29452934
delta = ktime_sub(ktime_get(), genpd->accounting_time);
29462935

@@ -2963,7 +2952,7 @@ static int active_time_show(struct seq_file *s, void *data)
29632952
if (ret)
29642953
return -ERESTARTSYS;
29652954

2966-
if (genpd->status == GPD_STATE_ACTIVE)
2955+
if (genpd->status == GENPD_STATE_ON)
29672956
delta = ktime_sub(ktime_get(), genpd->accounting_time);
29682957

29692958
seq_printf(s, "%lld ms\n", ktime_to_ms(
@@ -2986,7 +2975,7 @@ static int total_idle_time_show(struct seq_file *s, void *data)
29862975

29872976
for (i = 0; i < genpd->state_count; i++) {
29882977

2989-
if ((genpd->status == GPD_STATE_POWER_OFF) &&
2978+
if ((genpd->status == GENPD_STATE_OFF) &&
29902979
(genpd->state_idx == i))
29912980
delta = ktime_sub(ktime_get(), genpd->accounting_time);
29922981

drivers/base/power/runtime.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ static int rpm_get_suppliers(struct device *dev)
291291
device_links_read_lock_held()) {
292292
int retval;
293293

294-
if (!(link->flags & DL_FLAG_PM_RUNTIME) ||
295-
READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND)
294+
if (!(link->flags & DL_FLAG_PM_RUNTIME))
296295
continue;
297296

298297
retval = pm_runtime_get_sync(link->supplier);
@@ -312,8 +311,6 @@ static void rpm_put_suppliers(struct device *dev)
312311

313312
list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
314313
device_links_read_lock_held()) {
315-
if (READ_ONCE(link->status) == DL_STATE_SUPPLIER_UNBIND)
316-
continue;
317314

318315
while (refcount_dec_not_one(&link->rpm_active))
319316
pm_runtime_put(link->supplier);

drivers/pci/pci-acpi.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,16 @@ static bool acpi_pci_bridge_d3(struct pci_dev *dev)
944944
if (!dev->is_hotplug_bridge)
945945
return false;
946946

947+
/* Assume D3 support if the bridge is power-manageable by ACPI. */
948+
adev = ACPI_COMPANION(&dev->dev);
949+
if (!adev && !pci_dev_is_added(dev)) {
950+
adev = acpi_pci_find_companion(&dev->dev);
951+
ACPI_COMPANION_SET(&dev->dev, adev);
952+
}
953+
954+
if (adev && acpi_device_power_manageable(adev))
955+
return true;
956+
947957
/*
948958
* Look for a special _DSD property for the root port and if it
949959
* is set we know the hierarchy behind it supports D3 just fine.

include/linux/pm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ struct dev_pm_info {
590590
#endif
591591
#ifdef CONFIG_PM
592592
struct hrtimer suspend_timer;
593-
unsigned long timer_expires;
593+
u64 timer_expires;
594594
struct work_struct work;
595595
wait_queue_head_t wait_queue;
596596
struct wake_irq *wakeirq;

include/linux/pm_domain.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
#define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
6565

6666
enum gpd_status {
67-
GPD_STATE_ACTIVE = 0, /* PM domain is active */
68-
GPD_STATE_POWER_OFF, /* PM domain is off */
67+
GENPD_STATE_ON = 0, /* PM domain is on */
68+
GENPD_STATE_OFF, /* PM domain is off */
6969
};
7070

7171
struct dev_power_governor {

kernel/power/hibernate.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,6 @@ static int software_resume(void)
948948

949949
/* Check if the device is there */
950950
swsusp_resume_device = name_to_dev_t(resume_file);
951-
952-
/*
953-
* name_to_dev_t is ineffective to verify parition if resume_file is in
954-
* integer format. (e.g. major:minor)
955-
*/
956-
if (isdigit(resume_file[0]) && resume_wait) {
957-
int partno;
958-
while (!get_gendisk(swsusp_resume_device, &partno))
959-
msleep(10);
960-
}
961-
962951
if (!swsusp_resume_device) {
963952
/*
964953
* Some device discovery might still be in progress; we need

kernel/power/swap.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,20 @@ struct hib_bio_batch {
226226
atomic_t count;
227227
wait_queue_head_t wait;
228228
blk_status_t error;
229+
struct blk_plug plug;
229230
};
230231

231232
static void hib_init_batch(struct hib_bio_batch *hb)
232233
{
233234
atomic_set(&hb->count, 0);
234235
init_waitqueue_head(&hb->wait);
235236
hb->error = BLK_STS_OK;
237+
blk_start_plug(&hb->plug);
238+
}
239+
240+
static void hib_finish_batch(struct hib_bio_batch *hb)
241+
{
242+
blk_finish_plug(&hb->plug);
236243
}
237244

238245
static void hib_end_io(struct bio *bio)
@@ -294,6 +301,10 @@ static int hib_submit_io(int op, int op_flags, pgoff_t page_off, void *addr,
294301

295302
static blk_status_t hib_wait_io(struct hib_bio_batch *hb)
296303
{
304+
/*
305+
* We are relying on the behavior of blk_plug that a thread with
306+
* a plug will flush the plug list before sleeping.
307+
*/
297308
wait_event(hb->wait, atomic_read(&hb->count) == 0);
298309
return blk_status_to_errno(hb->error);
299310
}
@@ -561,6 +572,7 @@ static int save_image(struct swap_map_handle *handle,
561572
nr_pages++;
562573
}
563574
err2 = hib_wait_io(&hb);
575+
hib_finish_batch(&hb);
564576
stop = ktime_get();
565577
if (!ret)
566578
ret = err2;
@@ -854,6 +866,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
854866
pr_info("Image saving done\n");
855867
swsusp_show_speed(start, stop, nr_to_write, "Wrote");
856868
out_clean:
869+
hib_finish_batch(&hb);
857870
if (crc) {
858871
if (crc->thr)
859872
kthread_stop(crc->thr);
@@ -1084,6 +1097,7 @@ static int load_image(struct swap_map_handle *handle,
10841097
nr_pages++;
10851098
}
10861099
err2 = hib_wait_io(&hb);
1100+
hib_finish_batch(&hb);
10871101
stop = ktime_get();
10881102
if (!ret)
10891103
ret = err2;
@@ -1447,6 +1461,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
14471461
}
14481462
swsusp_show_speed(start, stop, nr_to_read, "Read");
14491463
out_clean:
1464+
hib_finish_batch(&hb);
14501465
for (i = 0; i < ring_size; i++)
14511466
free_page((unsigned long)page[i]);
14521467
if (crc) {

0 commit comments

Comments
 (0)