All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajendra Nayak <rnayak@codeaurora.org>
To: Stanimir Varbanov <stanimir.varbanov@linaro.org>,
	sboyd@codeaurora.org, mturquette@baylibre.com
Cc: linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, sricharan@codeaurora.org
Subject: Re: [PATCH] clk: qcom: gdsc: Fix handling of hw control enable/disable
Date: Mon, 23 Jan 2017 09:36:34 +0530	[thread overview]
Message-ID: <5885814A.9040304@codeaurora.org> (raw)
In-Reply-To: <3164de46-a251-3b3f-e6f5-5c3699bb4df8@linaro.org>


[]..

>> ---
>>
>> Stan,
>> If there was a specific issue you saw with venus because of the missing
>> delay and poll, can you check if this fixes any of that.
>>
>>  drivers/clk/qcom/gdsc.c | 58 ++++++++++++++++++++++++++++++++++++++-----------
>>  1 file changed, 45 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
>> index 288186c..6fbd6df 100644
>> --- a/drivers/clk/qcom/gdsc.c
>> +++ b/drivers/clk/qcom/gdsc.c
>> @@ -63,11 +63,26 @@ static int gdsc_hwctrl(struct gdsc *sc, bool en)
>>  	return regmap_update_bits(sc->regmap, sc->gdscr, HW_CONTROL_MASK, val);
>>  }
>>  
>> +static int gdsc_poll_status(struct gdsc *sc, unsigned int reg, bool val)
> 
> Could you rename 'val' to 'en'.

yes, I seem to have messed up with the value to write into the register and
the one to poll. I will fix this up and post a v2.

> 
>> +{
>> +	ktime_t start;
>> +
>> +	start = ktime_get();
>> +	do {
>> +		if (gdsc_is_enabled(sc, reg) == val)
>> +			return 0;
>> +	} while (ktime_us_delta(ktime_get(), start) < TIMEOUT_US);
>> +
>> +	if (gdsc_is_enabled(sc, reg) == val)
>> +		return 0;
>> +
>> +	return -ETIMEDOUT;
>> +}
>> +
>>  static int gdsc_toggle_logic(struct gdsc *sc, bool en)
>>  {
>>  	int ret;
>>  	u32 val = en ? 0 : SW_COLLAPSE_MASK;
>> -	ktime_t start;
>>  	unsigned int status_reg = sc->gdscr;
>>  
>>  	ret = regmap_update_bits(sc->regmap, sc->gdscr, SW_COLLAPSE_MASK, val);
>> @@ -100,16 +115,7 @@ static int gdsc_toggle_logic(struct gdsc *sc, bool en)
>>  		udelay(1);
>>  	}
>>  
>> -	start = ktime_get();
>> -	do {
>> -		if (gdsc_is_enabled(sc, status_reg) == en)
>> -			return 0;
>> -	} while (ktime_us_delta(ktime_get(), start) < TIMEOUT_US);
>> -
>> -	if (gdsc_is_enabled(sc, status_reg) == en)
>> -		return 0;
>> -
>> -	return -ETIMEDOUT;
>> +	return gdsc_poll_status(sc, status_reg, en);
>>  }
>>  
>>  static inline int gdsc_deassert_reset(struct gdsc *sc)
>> @@ -188,8 +194,19 @@ static int gdsc_enable(struct generic_pm_domain *domain)
>>  	udelay(1);
>>  
>>  	/* Turn on HW trigger mode if supported */
>> -	if (sc->flags & HW_CTRL)
>> -		return gdsc_hwctrl(sc, true);
>> +	if (sc->flags & HW_CTRL) {
>> +		ret = gdsc_hwctrl(sc, true);
>> +		/*
>> +		 * Wait for the GDSC to go through a power down and
>> +		 * up cycle.  In case a firmware ends up polling status
>> +		 * bits for the gdsc, it might read an 'on' status before
>> +		 * the GDSC can finish the power cycle.
>> +		 * We wait 1us before returning to ensure the firmware
>> +		 * can't immediately poll the status bits.
>> +		 */
>> +		mb();
> 
> Missing comment for this memory barrier, although I think it is
> pointless because regmap-mmio using readl and writel.

will get rid of the barrier here and below

> 
> 
>> +		udelay(1);
>> +	}
>>  
>>  	return 0;
>>  }
>> @@ -204,9 +221,24 @@ static int gdsc_disable(struct generic_pm_domain *domain)
>>  
>>  	/* Turn off HW trigger mode if supported */
>>  	if (sc->flags & HW_CTRL) {
>> +		unsigned int reg;
>> +
[]..

> 
>> +		udelay(1);
>> +
>> +		reg = sc->gds_hw_ctrl ? sc->gds_hw_ctrl : sc->gdscr;
>> +		ret = gdsc_poll_status(sc, reg, 0);
> 
> This should be gdsc_poll_status(sc, reg, true) because after disabling
> hw_control we expect that the GDSC is in power_on state.

correct, will fix. thanks for the review.


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

  parent reply	other threads:[~2017-01-23  4:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10  5:54 [PATCH] clk: qcom: gdsc: Fix handling of hw control enable/disable Rajendra Nayak
2017-01-10  9:31 ` Stanimir Varbanov
2017-01-20 23:20   ` Stephen Boyd
2017-01-23  4:03     ` Rajendra Nayak
2017-01-23  4:06   ` Rajendra Nayak [this message]
2017-01-10 16:43 ` Stanimir Varbanov
2017-01-10 19:29   ` Sricharan
2017-01-10 19:29     ` Sricharan
2017-01-11  8:55     ` Stanimir Varbanov
2017-01-12  8:47       ` Sricharan
2017-01-12  8:47         ` Sricharan

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=5885814A.9040304@codeaurora.org \
    --to=rnayak@codeaurora.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=sricharan@codeaurora.org \
    --cc=stanimir.varbanov@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 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.