Skip to content

Commit fe58335

Browse files
committed
Merge branches 'pm-pci', 'pm-sleep', 'pm-domains' and 'powercap'
* pm-pci: PCI: PM: Enable PME if it can be signaled from D3cold PCI: PM: Avoid forcing PCI_D0 for wakeup reasons inconsistently PCI: Use pci_update_current_state() in pci_enable_device_flags() * pm-sleep: PM: sleep: unmark 'state' functions as kernel-doc PM: sleep: check RTC features instead of ops in suspend_test PM: sleep: s2idle: Replace deprecated CPU-hotplug functions * pm-domains: PM: domains: Fix domain attach for CONFIG_PM_OPP=n arm64: dts: sc7180: Add required-opps for i2c PM: domains: Add support for 'required-opps' to set default perf state opp: Don't print an error if required-opps is missing * powercap: powercap: Add Power Limit4 support for Alder Lake SoC powercap: intel_rapl: Replace deprecated CPU-hotplug functions
5 parents 88e9c0b + 0e00392 + dbcfa71 + bc0d0b1 + 1cc5b9a commit fe58335

File tree

10 files changed

+105
-53
lines changed

10 files changed

+105
-53
lines changed

arch/arm64/boot/dts/qcom/sc7180.dtsi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@
786786
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
787787
interconnect-names = "qup-core", "qup-config",
788788
"qup-memory";
789+
power-domains = <&rpmhpd SC7180_CX>;
790+
required-opps = <&rpmhpd_opp_low_svs>;
789791
status = "disabled";
790792
};
791793

@@ -838,6 +840,8 @@
838840
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
839841
interconnect-names = "qup-core", "qup-config",
840842
"qup-memory";
843+
power-domains = <&rpmhpd SC7180_CX>;
844+
required-opps = <&rpmhpd_opp_low_svs>;
841845
status = "disabled";
842846
};
843847

@@ -890,6 +894,8 @@
890894
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
891895
interconnect-names = "qup-core", "qup-config",
892896
"qup-memory";
897+
power-domains = <&rpmhpd SC7180_CX>;
898+
required-opps = <&rpmhpd_opp_low_svs>;
893899
status = "disabled";
894900
};
895901

@@ -924,6 +930,8 @@
924930
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
925931
interconnect-names = "qup-core", "qup-config",
926932
"qup-memory";
933+
power-domains = <&rpmhpd SC7180_CX>;
934+
required-opps = <&rpmhpd_opp_low_svs>;
927935
status = "disabled";
928936
};
929937

@@ -976,6 +984,8 @@
976984
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
977985
interconnect-names = "qup-core", "qup-config",
978986
"qup-memory";
987+
power-domains = <&rpmhpd SC7180_CX>;
988+
required-opps = <&rpmhpd_opp_low_svs>;
979989
status = "disabled";
980990
};
981991

@@ -1010,6 +1020,8 @@
10101020
<&aggre1_noc MASTER_QUP_0 0 &mc_virt SLAVE_EBI1 0>;
10111021
interconnect-names = "qup-core", "qup-config",
10121022
"qup-memory";
1023+
power-domains = <&rpmhpd SC7180_CX>;
1024+
required-opps = <&rpmhpd_opp_low_svs>;
10131025
status = "disabled";
10141026
};
10151027

@@ -1075,6 +1087,8 @@
10751087
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
10761088
interconnect-names = "qup-core", "qup-config",
10771089
"qup-memory";
1090+
power-domains = <&rpmhpd SC7180_CX>;
1091+
required-opps = <&rpmhpd_opp_low_svs>;
10781092
status = "disabled";
10791093
};
10801094

@@ -1127,6 +1141,8 @@
11271141
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
11281142
interconnect-names = "qup-core", "qup-config",
11291143
"qup-memory";
1144+
power-domains = <&rpmhpd SC7180_CX>;
1145+
required-opps = <&rpmhpd_opp_low_svs>;
11301146
status = "disabled";
11311147
};
11321148

@@ -1161,6 +1177,8 @@
11611177
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
11621178
interconnect-names = "qup-core", "qup-config",
11631179
"qup-memory";
1180+
power-domains = <&rpmhpd SC7180_CX>;
1181+
required-opps = <&rpmhpd_opp_low_svs>;
11641182
status = "disabled";
11651183
};
11661184

@@ -1213,6 +1231,8 @@
12131231
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
12141232
interconnect-names = "qup-core", "qup-config",
12151233
"qup-memory";
1234+
power-domains = <&rpmhpd SC7180_CX>;
1235+
required-opps = <&rpmhpd_opp_low_svs>;
12161236
status = "disabled";
12171237
};
12181238

@@ -1247,6 +1267,8 @@
12471267
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
12481268
interconnect-names = "qup-core", "qup-config",
12491269
"qup-memory";
1270+
power-domains = <&rpmhpd SC7180_CX>;
1271+
required-opps = <&rpmhpd_opp_low_svs>;
12501272
status = "disabled";
12511273
};
12521274

@@ -1299,6 +1321,8 @@
12991321
<&aggre2_noc MASTER_QUP_1 0 &mc_virt SLAVE_EBI1 0>;
13001322
interconnect-names = "qup-core", "qup-config",
13011323
"qup-memory";
1324+
power-domains = <&rpmhpd SC7180_CX>;
1325+
required-opps = <&rpmhpd_opp_low_svs>;
13021326
status = "disabled";
13031327
};
13041328

drivers/base/power/domain.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,12 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
26042604

26052605
dev_dbg(dev, "removing from PM domain %s\n", pd->name);
26062606

2607+
/* Drop the default performance state */
2608+
if (dev_gpd_data(dev)->default_pstate) {
2609+
dev_pm_genpd_set_performance_state(dev, 0);
2610+
dev_gpd_data(dev)->default_pstate = 0;
2611+
}
2612+
26072613
for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
26082614
ret = genpd_remove_device(pd, dev);
26092615
if (ret != -EAGAIN)
@@ -2643,6 +2649,7 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
26432649
{
26442650
struct of_phandle_args pd_args;
26452651
struct generic_pm_domain *pd;
2652+
int pstate;
26462653
int ret;
26472654

26482655
ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
@@ -2681,10 +2688,29 @@ static int __genpd_dev_pm_attach(struct device *dev, struct device *base_dev,
26812688
genpd_unlock(pd);
26822689
}
26832690

2684-
if (ret)
2691+
if (ret) {
26852692
genpd_remove_device(pd, dev);
2693+
return -EPROBE_DEFER;
2694+
}
26862695

2687-
return ret ? -EPROBE_DEFER : 1;
2696+
/* Set the default performance state */
2697+
pstate = of_get_required_opp_performance_state(dev->of_node, index);
2698+
if (pstate < 0 && pstate != -ENODEV && pstate != -EOPNOTSUPP) {
2699+
ret = pstate;
2700+
goto err;
2701+
} else if (pstate > 0) {
2702+
ret = dev_pm_genpd_set_performance_state(dev, pstate);
2703+
if (ret)
2704+
goto err;
2705+
dev_gpd_data(dev)->default_pstate = pstate;
2706+
}
2707+
return 1;
2708+
2709+
err:
2710+
dev_err(dev, "failed to set required performance state for power-domain %s: %d\n",
2711+
pd->name, ret);
2712+
genpd_remove_device(pd, dev);
2713+
return ret;
26882714
}
26892715

26902716
/**

drivers/opp/of.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,7 @@ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table,
9595
static struct device_node *of_parse_required_opp(struct device_node *np,
9696
int index)
9797
{
98-
struct device_node *required_np;
99-
100-
required_np = of_parse_phandle(np, "required-opps", index);
101-
if (unlikely(!required_np)) {
102-
pr_err("%s: Unable to parse required-opps: %pOF, index: %d\n",
103-
__func__, np, index);
104-
}
105-
106-
return required_np;
98+
return of_parse_phandle(np, "required-opps", index);
10799
}
108100

109101
/* The caller must call dev_pm_opp_put_opp_table() after the table is used */
@@ -1328,7 +1320,7 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
13281320

13291321
required_np = of_parse_required_opp(np, index);
13301322
if (!required_np)
1331-
return -EINVAL;
1323+
return -ENODEV;
13321324

13331325
opp_table = _find_table_of_opp_np(required_np);
13341326
if (IS_ERR(opp_table)) {

drivers/pci/pci.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,11 +1906,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
19061906
* so that things like MSI message writing will behave as expected
19071907
* (e.g. if the device really is in D0 at enable time).
19081908
*/
1909-
if (dev->pm_cap) {
1910-
u16 pmcsr;
1911-
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
1912-
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
1913-
}
1909+
pci_update_current_state(dev, dev->current_state);
19141910

19151911
if (atomic_inc_return(&dev->enable_cnt) > 1)
19161912
return 0; /* already enabled */
@@ -2495,7 +2491,14 @@ static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable
24952491
if (enable) {
24962492
int error;
24972493

2498-
if (pci_pme_capable(dev, state))
2494+
/*
2495+
* Enable PME signaling if the device can signal PME from
2496+
* D3cold regardless of whether or not it can signal PME from
2497+
* the current target state, because that will allow it to
2498+
* signal PME when the hierarchy above it goes into D3cold and
2499+
* the device itself ends up in D3cold as a result of that.
2500+
*/
2501+
if (pci_pme_capable(dev, state) || pci_pme_capable(dev, PCI_D3cold))
24992502
pci_pme_active(dev, true);
25002503
else
25012504
ret = 1;
@@ -2599,16 +2602,20 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
25992602
if (dev->current_state == PCI_D3cold)
26002603
target_state = PCI_D3cold;
26012604

2602-
if (wakeup) {
2605+
if (wakeup && dev->pme_support) {
2606+
pci_power_t state = target_state;
2607+
26032608
/*
26042609
* Find the deepest state from which the device can generate
26052610
* PME#.
26062611
*/
2607-
if (dev->pme_support) {
2608-
while (target_state
2609-
&& !(dev->pme_support & (1 << target_state)))
2610-
target_state--;
2611-
}
2612+
while (state && !(dev->pme_support & (1 << state)))
2613+
state--;
2614+
2615+
if (state)
2616+
return state;
2617+
else if (dev->pme_support & 1)
2618+
return PCI_D0;
26122619
}
26132620

26142621
return target_state;

0 commit comments

Comments
 (0)