mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Siddharth Karanam <sid9.karanam@gmail.com>
To: andersson@kernel.org, mathieu.poirier@linaro.org
Cc: linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	Siddharth Karanam <sid9.karanam@gmail.com>
Subject: [PATCH 2/2] remoteproc: k3: Abstract ti_sci_handle's dev_ops calls through pm_runtime
Date: Wed, 23 Sep 2026 00:44:53 +0530	[thread overview]
Message-ID: <20260922191453.324983-3-sid9.karanam@gmail.com> (raw)
In-Reply-To: <20260922191453.324983-1-sid9.karanam@gmail.com>

Instead of directly invoking ti_sci_handle->dev_ops.get_device /
put_device (that is direct firmware logic), it is better to abstract it
through linux/pm_runtime.h's pm_runtime_put/get_sync which will call
the vendor's specific firmware logic automatically. The rationale here
being better code quality and reduced scope for refactoring in case of
any changes to the ti_sci protocol.

Signed-off-by: Siddharth Karanam <sid9.karanam@gmail.com>
---
 drivers/remoteproc/ti_sci_dev.h | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/remoteproc/ti_sci_dev.h b/drivers/remoteproc/ti_sci_dev.h
index 897998a97d7f..ec17af3ebf5e 100644
--- a/drivers/remoteproc/ti_sci_dev.h
+++ b/drivers/remoteproc/ti_sci_dev.h
@@ -59,23 +59,30 @@ static inline int ti_sci_dev_is_on(struct ti_sci_dev *tsd, bool *r_state,
 	return ret;
 }
 
+/* Request power on to rproc through the TI-SCI PM domain */
 static inline int ti_sci_dev_get_device(struct ti_sci_dev *tsd)
 {
-	int ret;
+	int ret = 0;
+
+	ret = pm_runtime_get_sync(tsd->dev);
+	if (ret < 0) {
+		dev_err(tsd->dev, "pm_runtime_get_sync failed, ret = %d\n", ret);
+		pm_runtime_put_noidle(tsd->dev);
+	}
 
-	ret = tsd->ops->get_device(tsd->sci, tsd->dev_id);
-	if (ret)
-		dev_err(tsd->dev, "ti-sci device get failed: %d\n", ret);
 	return ret;
 }
 
+/* Request power off to a rproc through the TI-SCI PM domain */
 static inline int ti_sci_dev_put_device(struct ti_sci_dev *tsd)
 {
-	int ret;
+	int ret = 0;
+
+	ret = pm_runtime_put_sync(tsd->dev);
+
+	if (ret < 0)
+		dev_err(tsd->dev, "pm_runtime_put_sync failed, ret = %d\n", ret);
 
-	ret = tsd->ops->put_device(tsd->sci, tsd->dev_id);
-	if (ret)
-		dev_err(tsd->dev, "ti-sci device put failed: %d\n", ret);
 	return ret;
 }
 
-- 
2.55.0


      parent reply	other threads:[~2026-09-22 19:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 19:14 [PATCH 0/2] remoteproc: Add ti_sci_dev_ops abstraction Siddharth Karanam
2026-09-22 19:14 ` [PATCH 1/2] " Siddharth Karanam
2026-09-22 19:14 ` Siddharth Karanam [this message]

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=20260922191453.324983-3-sid9.karanam@gmail.com \
    --to=sid9.karanam@gmail.com \
    --cc=andersson@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.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

all inboxes | Powered by JetHome®