linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume
@ 2020-07-09 14:40 Douglas Anderson
  2020-07-10  4:17 ` Rajendra Nayak
  2020-07-10  4:41 ` Akash Asthana
  0 siblings, 2 replies; 3+ messages in thread
From: Douglas Anderson @ 2020-07-09 14:40 UTC (permalink / raw)
  To: Mark Brown, Andy Gross, Bjorn Andersson
  Cc: mkshah, georgi.djakov, Akash Asthana, swboyd, linux-arm-msm, mka,
	ctheegal, Rajendra Nayak, Douglas Anderson, linux-kernel,
	linux-spi

In the patch ("spi: spi-geni-qcom: Avoid clock setting if not needed")
we avoid a whole pile of clock code.  As part of that, we should have
restored the clock at runtime resume.  Do that.

It turns out that, at least with today's configurations, this doesn't
actually matter.  That's because none of the current device trees have
an OPP table for geni SPI yet.  That makes dev_pm_opp_set_rate(dev, 0)
a no-op.  This is why it wasn't noticed in the testing of the original
patch.  It's still a good idea to fix, though.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Mark Brown <broonie@kernel.org>
---
Sending this as a separate patch even though I think the patch it's
fixing [1] hasn't landed yet.  I'd be happy if this was squashed into
that patch when landing if that suits everyone, but it could land on
its own too.

Like the patch it's fixing, this needs to target the Qualcomm tree in
order to avoid merge conflicts.

[1] https://lore.kernel.org/r/20200701174506.1.Icfdcee14649fc0a6c38e87477b28523d4e60bab3@changeid

Changes in v2:
- Return error from runtime resume if dev_pm_opp_set_rate() fails.

 drivers/spi/spi-geni-qcom.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
index 97fac5ea6afd..0e11a90490ff 100644
--- a/drivers/spi/spi-geni-qcom.c
+++ b/drivers/spi/spi-geni-qcom.c
@@ -79,6 +79,7 @@ struct spi_geni_master {
 	u32 tx_wm;
 	u32 last_mode;
 	unsigned long cur_speed_hz;
+	unsigned long cur_sclk_hz;
 	unsigned int cur_bits_per_word;
 	unsigned int tx_rem_bytes;
 	unsigned int rx_rem_bytes;
@@ -116,6 +117,9 @@ static int get_spi_clk_cfg(unsigned int speed_hz,
 	ret = dev_pm_opp_set_rate(mas->dev, sclk_freq);
 	if (ret)
 		dev_err(mas->dev, "dev_pm_opp_set_rate failed %d\n", ret);
+	else
+		mas->cur_sclk_hz = sclk_freq;
+
 	return ret;
 }
 
@@ -670,7 +674,11 @@ static int __maybe_unused spi_geni_runtime_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	return geni_se_resources_on(&mas->se);
+	ret = geni_se_resources_on(&mas->se);
+	if (ret)
+		return ret;
+
+	return dev_pm_opp_set_rate(mas->dev, mas->cur_sclk_hz);
 }
 
 static int __maybe_unused spi_geni_suspend(struct device *dev)
-- 
2.27.0.383.g050319c2ae-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume
  2020-07-09 14:40 [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume Douglas Anderson
@ 2020-07-10  4:17 ` Rajendra Nayak
  2020-07-10  4:41 ` Akash Asthana
  1 sibling, 0 replies; 3+ messages in thread
From: Rajendra Nayak @ 2020-07-10  4:17 UTC (permalink / raw)
  To: Douglas Anderson, Mark Brown, Andy Gross, Bjorn Andersson
  Cc: mkshah, georgi.djakov, Akash Asthana, swboyd, linux-arm-msm, mka,
	ctheegal, linux-kernel, linux-spi


On 7/9/2020 8:10 PM, Douglas Anderson wrote:
> In the patch ("spi: spi-geni-qcom: Avoid clock setting if not needed")
> we avoid a whole pile of clock code.  As part of that, we should have
> restored the clock at runtime resume.  Do that.
> 
> It turns out that, at least with today's configurations, this doesn't
> actually matter.  That's because none of the current device trees have
> an OPP table for geni SPI yet.  That makes dev_pm_opp_set_rate(dev, 0)
> a no-op.  This is why it wasn't noticed in the testing of the original
> patch.  It's still a good idea to fix, though.
> 
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> Acked-by: Mark Brown <broonie@kernel.org>

Reviewed-by: Rajendra Nayak <rnayak@codeaurora.org>

> ---
> Sending this as a separate patch even though I think the patch it's
> fixing [1] hasn't landed yet.  I'd be happy if this was squashed into
> that patch when landing if that suits everyone, but it could land on
> its own too.
> 
> Like the patch it's fixing, this needs to target the Qualcomm tree in
> order to avoid merge conflicts.
> 
> [1] https://lore.kernel.org/r/20200701174506.1.Icfdcee14649fc0a6c38e87477b28523d4e60bab3@changeid
> 
> Changes in v2:
> - Return error from runtime resume if dev_pm_opp_set_rate() fails.
> 
>   drivers/spi/spi-geni-qcom.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index 97fac5ea6afd..0e11a90490ff 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
> @@ -79,6 +79,7 @@ struct spi_geni_master {
>   	u32 tx_wm;
>   	u32 last_mode;
>   	unsigned long cur_speed_hz;
> +	unsigned long cur_sclk_hz;
>   	unsigned int cur_bits_per_word;
>   	unsigned int tx_rem_bytes;
>   	unsigned int rx_rem_bytes;
> @@ -116,6 +117,9 @@ static int get_spi_clk_cfg(unsigned int speed_hz,
>   	ret = dev_pm_opp_set_rate(mas->dev, sclk_freq);
>   	if (ret)
>   		dev_err(mas->dev, "dev_pm_opp_set_rate failed %d\n", ret);
> +	else
> +		mas->cur_sclk_hz = sclk_freq;
> +
>   	return ret;
>   }
>   
> @@ -670,7 +674,11 @@ static int __maybe_unused spi_geni_runtime_resume(struct device *dev)
>   	if (ret)
>   		return ret;
>   
> -	return geni_se_resources_on(&mas->se);
> +	ret = geni_se_resources_on(&mas->se);
> +	if (ret)
> +		return ret;
> +
> +	return dev_pm_opp_set_rate(mas->dev, mas->cur_sclk_hz);
>   }
>   
>   static int __maybe_unused spi_geni_suspend(struct device *dev)
> 

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume
  2020-07-09 14:40 [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume Douglas Anderson
  2020-07-10  4:17 ` Rajendra Nayak
@ 2020-07-10  4:41 ` Akash Asthana
  1 sibling, 0 replies; 3+ messages in thread
From: Akash Asthana @ 2020-07-10  4:41 UTC (permalink / raw)
  To: Douglas Anderson, Mark Brown, Andy Gross, Bjorn Andersson
  Cc: mkshah, georgi.djakov, swboyd, linux-arm-msm, mka, ctheegal,
	Rajendra Nayak, linux-kernel, linux-spi


On 7/9/2020 8:10 PM, Douglas Anderson wrote:
> In the patch ("spi: spi-geni-qcom: Avoid clock setting if not needed")
> we avoid a whole pile of clock code.  As part of that, we should have
> restored the clock at runtime resume.  Do that.
>
> It turns out that, at least with today's configurations, this doesn't
> actually matter.  That's because none of the current device trees have
> an OPP table for geni SPI yet.  That makes dev_pm_opp_set_rate(dev, 0)
> a no-op.  This is why it wasn't noticed in the testing of the original
> patch.  It's still a good idea to fix, though.
Reviewed-by: Akash Asthana <akashast@codeaurora.org>

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-10  4:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 14:40 [PATCH v2] spi: spi-geni-qcom: Set the clock properly at runtime resume Douglas Anderson
2020-07-10  4:17 ` Rajendra Nayak
2020-07-10  4:41 ` Akash Asthana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).