* [PATCH v4 1/2] irqchip: irq-qcom-mpm: Register MPM with cpu_pm for RPM notification
2026-11-18 6:06 [PATCH v4 0/2] Add fallback method to handle RPM notification in MPM driver Sneh Mankad
@ 2026-11-18 6:06 ` Sneh Mankad
2026-11-30 9:11 ` Maulik Shah
2026-11-18 6:06 ` [PATCH v4 2/2] arm64: dts: qcom: shikra: Add CPU idle states Sneh Mankad
1 sibling, 1 reply; 5+ messages in thread
From: Sneh Mankad @ 2026-11-18 6:06 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thomas Gleixner, Shawn Guo, Marc Zyngier,
Catalin Marinas, Will Deacon, Anna-Maria Behnsen,
Frederic Weisbecker
Cc: linux-arm-msm, devicetree, linux-kernel, linux-arm-kernel, Sneh Mankad
MPM irqchip needs to notify RPM (Resource Power Manager) processor to read
the latest wake up capable interrupts when the CPU cluster is entering the
deepest idle state. This is done by sending IPC interrupt to RPM and is
implemented as .power_off() callback by registering MPM as parent power
domain to CPU cluster.
Such implementation earlier introduced a hard probe dependency between MPM
irqchip and CPU cluster power domains. That is MPM irqchip needs to finish
probe before PSCI power domains are probed.
The above problem has since been resolved after bd7f488a8e5d ("cpuidle:
psci: Fix support for probe deferral by dropping the faux device") / [1].
However, it makes sense to remodel the RPM notification in MPM irqchip due
to general consistency.
MPM is not really a power domain provider, all it needs is a notification
when CPU cluster is going to power collapse to carry out the RPM
notification. We can register for CPU_PM notifications for that purpose.
This way we can avoid such unrelated dependencies.
We cannot register MPM under CPU cluster power domain and rely on
GENPD notifications here, since that way cluster low power modes will be
blocked whenever some consumer of MPM, and in turn MPM itself, are
runtime active. This will add another unnecessary dependency for CPU
cluster low power modes.
For now as first step, register with cpu_pm as a fallback to manage RPM
notification. Trigger the RPM notification when the last CPU in CPU cluster
goes to power collapse.
[1] https://lore.kernel.org/all/20260909134240.685115374@linuxfoundation.org
Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com>
---
drivers/irqchip/irq-qcom-mpm.c | 106 +++++++++++++++++++++++++++++++----------
1 file changed, 81 insertions(+), 25 deletions(-)
diff --git a/drivers/irqchip/irq-qcom-mpm.c b/drivers/irqchip/irq-qcom-mpm.c
index 181320528a47ac1bde6cf7d2d0a9f79499990092..b837be1cce0e571de983799c4b7f2228f11d04fa 100644
--- a/drivers/irqchip/irq-qcom-mpm.c
+++ b/drivers/irqchip/irq-qcom-mpm.c
@@ -4,6 +4,7 @@
* Copyright (c) 2010-2020, The Linux Foundation. All rights reserved.
*/
+#include <linux/cpu_pm.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
@@ -85,6 +86,8 @@ struct qcom_mpm_priv {
unsigned int reg_stride;
struct irq_domain *domain;
struct generic_pm_domain genpd;
+ struct notifier_block mpm_pm;
+ atomic_t cpus_in_pm;
};
static u32 qcom_mpm_read(struct qcom_mpm_priv *priv, unsigned int reg,
@@ -292,10 +295,8 @@ static irqreturn_t qcom_mpm_handler(int irq, void *dev_id)
return ret;
}
-static int mpm_pd_power_off(struct generic_pm_domain *genpd)
+static int handle_rpm_notification(struct qcom_mpm_priv *priv)
{
- struct qcom_mpm_priv *priv = container_of(genpd, struct qcom_mpm_priv,
- genpd);
int i, ret;
for (i = 0; i < priv->reg_stride; i++)
@@ -311,6 +312,50 @@ static int mpm_pd_power_off(struct generic_pm_domain *genpd)
return 0;
}
+static int mpm_pd_power_off(struct generic_pm_domain *genpd)
+{
+ struct qcom_mpm_priv *priv = container_of(genpd, struct qcom_mpm_priv, genpd);
+
+ return handle_rpm_notification(priv);
+}
+
+static int mpm_cpu_pm_callback(struct notifier_block *nfb, unsigned long action, void *v)
+{
+ struct qcom_mpm_priv *priv = container_of(nfb, struct qcom_mpm_priv, mpm_pm);
+ int cpus_in_pm;
+
+ switch (action) {
+ case CPU_PM_ENTER:
+ cpus_in_pm = atomic_inc_return(&priv->cpus_in_pm);
+ /*
+ * NOTE: comments for num_online_cpus() point out that it's
+ * only a snapshot so we need to be careful. It should be OK
+ * for us to use, though. It's important for us not to miss
+ * if we're the last CPU going down so it would only be a
+ * problem if a CPU went offline right after we did the check
+ * AND that CPU was not idle AND that CPU was the last non-idle
+ * CPU. That can't happen. CPUs would have to come out of idle
+ * before the CPU could go offline.
+ */
+ if (cpus_in_pm < num_online_cpus())
+ return NOTIFY_OK;
+ break;
+ case CPU_PM_ENTER_FAILED:
+ case CPU_PM_EXIT:
+ atomic_dec(&priv->cpus_in_pm);
+ return NOTIFY_OK;
+ default:
+ return NOTIFY_DONE;
+ }
+
+ if (handle_rpm_notification(priv)) {
+ atomic_dec(&priv->cpus_in_pm);
+ return NOTIFY_BAD;
+ }
+
+ return NOTIFY_OK;
+}
+
static bool gic_hwirq_is_mapped(struct mpm_gic_map *maps, int cnt, u32 hwirq)
{
int i;
@@ -415,26 +460,6 @@ static int qcom_mpm_probe(struct platform_device *pdev, struct device_node *pare
if (irq < 0)
return irq;
- genpd = &priv->genpd;
- genpd->flags = GENPD_FLAG_IRQ_SAFE;
- genpd->power_off = mpm_pd_power_off;
-
- genpd->name = devm_kasprintf(dev, GFP_KERNEL, "%s", dev_name(dev));
- if (!genpd->name)
- return -ENOMEM;
-
- ret = pm_genpd_init(genpd, NULL, false);
- if (ret) {
- dev_err(dev, "failed to init genpd: %d\n", ret);
- return ret;
- }
-
- ret = of_genpd_add_provider_simple(np, genpd);
- if (ret) {
- dev_err(dev, "failed to add genpd provider: %d\n", ret);
- goto remove_genpd;
- }
-
priv->mbox_client.dev = dev;
priv->mbox_client.knows_txdone = true;
priv->mbox_chan = mbox_request_channel(&priv->mbox_client, 0);
@@ -469,14 +494,45 @@ static int qcom_mpm_probe(struct platform_device *pdev, struct device_node *pare
goto remove_domain;
}
+ if (of_find_property(np, "#power-domain-cells", NULL)) {
+ genpd = &priv->genpd;
+ genpd->flags = GENPD_FLAG_IRQ_SAFE;
+ genpd->power_off = mpm_pd_power_off;
+
+ genpd->name = devm_kasprintf(dev, GFP_KERNEL, "%s", dev_name(dev));
+ if (!genpd->name) {
+ ret = -ENOMEM;
+ goto remove_domain;
+ }
+
+ ret = pm_genpd_init(genpd, NULL, false);
+ if (ret) {
+ dev_err(dev, "failed to init genpd: %d\n", ret);
+ goto remove_domain;
+ }
+
+ ret = of_genpd_add_provider_simple(np, genpd);
+ if (ret) {
+ dev_err(dev, "failed to add genpd provider: %d\n", ret);
+ goto remove_genpd;
+ }
+ } else {
+ priv->mpm_pm.notifier_call = mpm_cpu_pm_callback;
+ ret = cpu_pm_register_notifier(&priv->mpm_pm);
+ if (ret) {
+ dev_err(dev, "failed to register for CPU_PM notifications: %d\n", ret);
+ goto remove_domain;
+ }
+ }
+
return 0;
+remove_genpd:
+ pm_genpd_remove(genpd);
remove_domain:
irq_domain_remove(priv->domain);
free_mbox:
mbox_free_channel(priv->mbox_chan);
-remove_genpd:
- pm_genpd_remove(genpd);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v4 2/2] arm64: dts: qcom: shikra: Add CPU idle states
2026-11-18 6:06 [PATCH v4 0/2] Add fallback method to handle RPM notification in MPM driver Sneh Mankad
2026-11-18 6:06 ` [PATCH v4 1/2] irqchip: irq-qcom-mpm: Register MPM with cpu_pm for RPM notification Sneh Mankad
@ 2026-11-18 6:06 ` Sneh Mankad
2026-11-30 8:59 ` Maulik Shah
1 sibling, 1 reply; 5+ messages in thread
From: Sneh Mankad @ 2026-11-18 6:06 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Thomas Gleixner, Shawn Guo, Marc Zyngier,
Catalin Marinas, Will Deacon, Anna-Maria Behnsen,
Frederic Weisbecker
Cc: linux-arm-msm, devicetree, linux-kernel, linux-arm-kernel, Sneh Mankad
Add idle states for the CPUs as well as the whole cluster. This enables
deeper-than-WFI cpuidle.
Remove #power-domain-cells from MPM device so that the driver follows the
cpu_pm notifications path to handle RPM notification. This avoids other
probe dependencies that arise due to MPM being a power domain provider.
Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com>
---
arch/arm64/boot/dts/qcom/shikra.dtsi | 93 +++++++++++++++++++++++++++++++++++-
1 file changed, 92 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/qcom/shikra.dtsi b/arch/arm64/boot/dts/qcom/shikra.dtsi
index 4e5bc9e17c8ed8914733ac9fdc9b69128b40216e..74be82ae50d16c7dcc7bc7af4deb28794efd47e8 100644
--- a/arch/arm64/boot/dts/qcom/shikra.dtsi
+++ b/arch/arm64/boot/dts/qcom/shikra.dtsi
@@ -40,6 +40,8 @@ cpu0: cpu@0 {
compatible = "arm,cortex-a55";
reg = <0x0 0x0>;
enable-method = "psci";
+ power-domains = <&cpu_pd0>;
+ power-domain-names = "psci";
next-level-cache = <&l3>;
capacity-dmips-mhz = <1024>;
dynamic-power-coefficient = <100>;
@@ -50,6 +52,8 @@ cpu1: cpu@100 {
compatible = "arm,cortex-a55";
reg = <0x0 0x100>;
enable-method = "psci";
+ power-domains = <&cpu_pd1>;
+ power-domain-names = "psci";
next-level-cache = <&l3>;
capacity-dmips-mhz = <1024>;
dynamic-power-coefficient = <100>;
@@ -60,6 +64,8 @@ cpu2: cpu@200 {
compatible = "arm,cortex-a55";
reg = <0x0 0x200>;
enable-method = "psci";
+ power-domains = <&cpu_pd2>;
+ power-domain-names = "psci";
next-level-cache = <&l3>;
capacity-dmips-mhz = <1024>;
dynamic-power-coefficient = <100>;
@@ -70,6 +76,8 @@ cpu3: cpu@300 {
compatible = "arm,cortex-a78c";
reg = <0x0 0x300>;
enable-method = "psci";
+ power-domains = <&cpu_pd3>;
+ power-domain-names = "psci";
next-level-cache = <&l2_3>;
capacity-dmips-mhz = <1946>;
dynamic-power-coefficient = <489>;
@@ -105,6 +113,61 @@ core0 {
};
};
+ idle-states {
+ entry-method = "psci";
+
+ little_cpu_sleep_0: cpu-sleep-0-0 {
+ compatible = "arm,idle-state";
+ idle-state-name = "little-power-down";
+ arm,psci-suspend-param = <0x40000003>;
+ entry-latency-us = <549>;
+ exit-latency-us = <901>;
+ min-residency-us = <1774>;
+ local-timer-stop;
+ };
+
+ little_cpu_sleep_1: cpu-sleep-0-1 {
+ compatible = "arm,idle-state";
+ idle-state-name = "little-pll-power-down";
+ arm,psci-suspend-param = <0x40000004>;
+ entry-latency-us = <702>;
+ exit-latency-us = <915>;
+ min-residency-us = <4001>;
+ local-timer-stop;
+ };
+
+ big_cpu_sleep_0: cpu-sleep-1-0 {
+ compatible = "arm,idle-state";
+ idle-state-name = "big-power-down";
+ arm,psci-suspend-param = <0x40000003>;
+ entry-latency-us = <523>;
+ exit-latency-us = <1244>;
+ min-residency-us = <2207>;
+ local-timer-stop;
+ };
+
+ big_cpu_sleep_1: cpu-sleep-1-1 {
+ compatible = "arm,idle-state";
+ idle-state-name = "big-pll-power-down";
+ arm,psci-suspend-param = <0x40000004>;
+ entry-latency-us = <526>;
+ exit-latency-us = <1854>;
+ min-residency-us = <5555>;
+ local-timer-stop;
+ };
+ };
+
+ domain_idle_states: domain-idle-states {
+ cluster_sleep_apss_off: cluster-sleep-0 {
+ compatible = "domain-idle-state";
+ idle-state-name = "cluster-power-down";
+ arm,psci-suspend-param = <0x41000044>;
+ entry-latency-us = <2752>;
+ exit-latency-us = <3038>;
+ min-residency-us = <6118>;
+ };
+ };
+
l3: l3-cache {
compatible = "cache";
cache-level = <3>;
@@ -144,6 +207,35 @@ pmu-a78c {
psci {
compatible = "arm,psci-1.0";
method = "smc";
+
+ cpu_pd0: power-domain-cpu0 {
+ #power-domain-cells = <0>;
+ power-domains = <&cluster_pd>;
+ domain-idle-states = <&little_cpu_sleep_0>, <&little_cpu_sleep_1>;
+ };
+
+ cpu_pd1: power-domain-cpu1 {
+ #power-domain-cells = <0>;
+ power-domains = <&cluster_pd>;
+ domain-idle-states = <&little_cpu_sleep_0>, <&little_cpu_sleep_1>;
+ };
+
+ cpu_pd2: power-domain-cpu2 {
+ #power-domain-cells = <0>;
+ power-domains = <&cluster_pd>;
+ domain-idle-states = <&little_cpu_sleep_0>, <&little_cpu_sleep_1>;
+ };
+
+ cpu_pd3: power-domain-cpu3 {
+ #power-domain-cells = <0>;
+ power-domains = <&cluster_pd>;
+ domain-idle-states = <&big_cpu_sleep_0>, <&big_cpu_sleep_1>;
+ };
+
+ cluster_pd: power-domain-cluster {
+ #power-domain-cells = <0>;
+ domain-idle-states = <&cluster_sleep_apss_off>;
+ };
};
rpm: remoteproc {
@@ -217,7 +309,6 @@ mpm: interrupt-controller {
mboxes = <&apcs_glb 1>;
interrupt-controller;
#interrupt-cells = <2>;
- #power-domain-cells = <0>;
interrupt-parent = <&intc>;
qcom,mpm-pin-count = <96>;
qcom,mpm-pin-map = <2 275>, /* TSENS0 uplow */
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread