public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Rahul Sharma <r-sharma3@ti.com>
To: <peter.ujfalusi@gmail.com>, <vkoul@kernel.org>,
	<Frank.Li@kernel.org>, <nm@ti.com>, <kristo@kernel.org>,
	<ssantosh@kernel.org>, <tglx@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] irqchip: ti-sci-inta: add runtime PM and system sleep support
Date: Wed, 29 Apr 2026 23:19:04 +0530	[thread overview]
Message-ID: <20260429174904.4049243-3-r-sharma3@ti.com> (raw)
In-Reply-To: <20260429174904.4049243-1-r-sharma3@ti.com>

Register runtime PM callbacks and enable runtime PM via
devm_pm_runtime_enable() in probe.

runtime_suspend is a no-op; IRQ routing context is preserved by TI SCI
firmware across power-gate cycles.

runtime_resume restores VINT_ENABLE_SET for each active event bit,
skipping IRQs with irqd_irq_masked set to avoid re-enabling
intentionally disabled interrupts.

System sleep reuses these callbacks via pm_runtime_force_suspend/resume
as late/early sleep ops. This ensures MMIO writes in runtime_resume
happen after genpd restores the power domain (dpm_resume_noirq),
avoiding writes to a powered-off device.

Signed-off-by: Rahul Sharma <r-sharma3@ti.com>
---
 drivers/irqchip/irq-ti-sci-inta.c | 49 +++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/irqchip/irq-ti-sci-inta.c b/drivers/irqchip/irq-ti-sci-inta.c
index f1eb2f92f0ca..0d4451b208c1 100644
--- a/drivers/irqchip/irq-ti-sci-inta.c
+++ b/drivers/irqchip/irq-ti-sci-inta.c
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/soc/ti/ti_sci_inta_msi.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
@@ -720,11 +721,58 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&inta->vint_list);
 	mutex_init(&inta->vint_mutex);
 
+	dev_set_drvdata(dev, inta);
+
+	ret = devm_pm_runtime_enable(dev);
+	if (ret)
+		return ret;
+
 	dev_info(dev, "Interrupt Aggregator domain %d created\n", inta->ti_sci_id);
 
 	return 0;
 }
 
+static int ti_sci_inta_runtime_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int ti_sci_inta_runtime_resume(struct device *dev)
+{
+	struct ti_sci_inta_irq_domain *inta = dev_get_drvdata(dev);
+	struct ti_sci_inta_vint_desc *vint_desc;
+	int bit;
+
+	mutex_lock(&inta->vint_mutex);
+	list_for_each_entry(vint_desc, &inta->vint_list, list) {
+		for_each_set_bit(bit, vint_desc->event_map, MAX_EVENTS_PER_VINT) {
+			unsigned int virq;
+			struct irq_data *data;
+
+			virq = irq_find_mapping(vint_desc->domain,
+						vint_desc->events[bit].hwirq);
+			if (!virq)
+				continue;
+			data = irq_get_irq_data(virq);
+			if (!data || irqd_irq_masked(data))
+				continue;
+			writeq_relaxed(BIT(bit), inta->base +
+				       vint_desc->vint_id * 0x1000 +
+				       VINT_ENABLE_SET_OFFSET);
+		}
+	}
+	mutex_unlock(&inta->vint_mutex);
+
+	return 0;
+}
+
+static const struct dev_pm_ops ti_sci_inta_pm_ops = {
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				     pm_runtime_force_resume)
+	SET_RUNTIME_PM_OPS(ti_sci_inta_runtime_suspend,
+			   ti_sci_inta_runtime_resume, NULL)
+};
+
 static const struct of_device_id ti_sci_inta_irq_domain_of_match[] = {
 	{ .compatible = "ti,sci-inta", },
 	{ /* sentinel */ },
@@ -736,6 +784,7 @@ static struct platform_driver ti_sci_inta_irq_domain_driver = {
 	.driver = {
 		.name = "ti-sci-inta",
 		.of_match_table = ti_sci_inta_irq_domain_of_match,
+		.pm = pm_ptr(&ti_sci_inta_pm_ops),
 	},
 };
 module_platform_driver(ti_sci_inta_irq_domain_driver);
-- 
2.34.1



  parent reply	other threads:[~2026-04-29 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 17:49 [PATCH 0/2] Add runtime PM support to K3 UDMA and K3 INTA Rahul Sharma
2026-04-29 17:49 ` [PATCH 1/2] dma: ti: k3-udma: enable runtime PM support Rahul Sharma
2026-04-29 17:49 ` Rahul Sharma [this message]
2026-04-30  6:11 ` [PATCH 0/2] Add runtime PM support to K3 UDMA and K3 INTA Rahul Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429174904.4049243-3-r-sharma3@ti.com \
    --to=r-sharma3@ti.com \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=peter.ujfalusi@gmail.com \
    --cc=ssantosh@kernel.org \
    --cc=tglx@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox