All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: davem@davemloft.net, kuba@kernel.org
Cc: bjorn.andersson@linaro.org, evgreen@chromium.org,
	cpratapa@codeaurora.org, subashab@codeaurora.org,
	elder@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/5] net: ipa: don't use ipa_clock_get() in "ipa_main.c"
Date: Thu, 19 Aug 2021 17:19:23 -0500	[thread overview]
Message-ID: <20210819221927.3286267-2-elder@linaro.org> (raw)
In-Reply-To: <20210819221927.3286267-1-elder@linaro.org>

We need the hardware to be powered starting at the config stage of
initialization when the IPA driver probes.  And we need it powered
when the driver is removed, at least until the deconfig stage has
completed.

Replace callers of ipa_clock_get() in ipa_probe() and ipa_exit(),
calling pm_runtime_get_sync() instead.  Replace the corresponding
callers of ipa_clock_put(), calling pm_runtime_put() instead.

The only error we expect when getting power would occur when the
system is suspended.  The ->probe and ->remove driver callbacks
won't be called when suspended, so issue a WARN() call if an error
is seen getting power.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_main.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 69fa4b3120fd3..3969aef6c4370 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_address.h>
+#include <linux/pm_runtime.h>
 #include <linux/qcom_scm.h>
 #include <linux/soc/qcom/mdt_loader.h>
 
@@ -737,13 +738,13 @@ static int ipa_probe(struct platform_device *pdev)
 		goto err_table_exit;
 
 	/* The clock needs to be active for config and setup */
-	ret = ipa_clock_get(ipa);
+	ret = pm_runtime_get_sync(dev);
 	if (WARN_ON(ret < 0))
-		goto err_clock_put;
+		goto err_power_put;
 
 	ret = ipa_config(ipa, data);
 	if (ret)
-		goto err_clock_put;
+		goto err_power_put;
 
 	dev_info(dev, "IPA driver initialized");
 
@@ -765,14 +766,14 @@ static int ipa_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_deconfig;
 done:
-	(void)ipa_clock_put(ipa);
+	(void)pm_runtime_put(dev);
 
 	return 0;
 
 err_deconfig:
 	ipa_deconfig(ipa);
-err_clock_put:
-	(void)ipa_clock_put(ipa);
+err_power_put:
+	(void)pm_runtime_put(dev);
 	ipa_modem_exit(ipa);
 err_table_exit:
 	ipa_table_exit(ipa);
@@ -798,9 +799,9 @@ static int ipa_remove(struct platform_device *pdev)
 	struct ipa_clock *clock = ipa->clock;
 	int ret;
 
-	ret = ipa_clock_get(ipa);
+	ret = pm_runtime_get_sync(&pdev->dev);
 	if (WARN_ON(ret < 0))
-		goto out_clock_put;
+		goto out_power_put;
 
 	if (ipa->setup_complete) {
 		ret = ipa_modem_stop(ipa);
@@ -816,8 +817,8 @@ static int ipa_remove(struct platform_device *pdev)
 	}
 
 	ipa_deconfig(ipa);
-out_clock_put:
-	(void)ipa_clock_put(ipa);
+out_power_put:
+	(void)pm_runtime_put(&pdev->dev);
 
 	ipa_modem_exit(ipa);
 	ipa_table_exit(ipa);
-- 
2.27.0


  reply	other threads:[~2021-08-19 22:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 22:19 [PATCH net-next 0/5] net: ipa: kill off ipa_clock_get() Alex Elder
2021-08-19 22:19 ` Alex Elder [this message]
2021-08-19 22:19 ` [PATCH net-next 2/5] net: ipa: don't use ipa_clock_get() in "ipa_smp2p.c" Alex Elder
2021-08-19 22:19 ` [PATCH net-next 3/5] net: ipa: don't use ipa_clock_get() in "ipa_uc.c" Alex Elder
2021-08-19 22:19 ` [PATCH net-next 4/5] net: ipa: don't use ipa_clock_get() in "ipa_modem.c" Alex Elder
2021-08-19 22:19 ` [PATCH net-next 5/5] net: ipa: kill ipa_clock_get() Alex Elder
2021-08-20 14:00 ` [PATCH net-next 0/5] net: ipa: kill off ipa_clock_get() patchwork-bot+netdevbpf

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=20210819221927.3286267-2-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=cpratapa@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=elder@kernel.org \
    --cc=evgreen@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=subashab@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.