linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Mathieu Poirier
	<mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Alexandre Courbot
	<gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH V2] soc: tegra: pmc: Ensure GPU partition can be toggled on/off by PMC
Date: Fri, 26 Feb 2016 16:43:10 +0000	[thread overview]
Message-ID: <56D0809E.6060400@nvidia.com> (raw)
In-Reply-To: <CANLsYkwCx13YszW-67F2_KDwxgpzwKQft4eOpJvVM1nkNXGpXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


On 26/02/16 16:06, Mathieu Poirier wrote:
> On 15 February 2016 at 05:38, Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> For Tegra124 and Tegra210, the GPU partition cannot be toggled on and
>> off via the APBDEV_PMC_PWRGATE_TOGGLE_0 register. For these devices, the
>> partition is simply powered up and down via an external regulator.
>> For these devices, there is a separate register for controlling the
>> signal clamping of the partition and this is described in the PMC SoC
>> data by the "has_gpu_clamp" variable. Use this variable to determine if
>> the GPU partition can be controlled via the APBDEV_PMC_PWRGATE_TOGGLE_0
>> register and ensure that no one can incorrectly try to toggle the GPU
>> partition via the APBDEV_PMC_PWRGATE_TOGGLE_0 register.
>>
>> Furthermore, we cannot use the APBDEV_PMC_PWRGATE_STATUS_0 register to
>> determine if the GPU partition is powered for Tegra124 and Tegra210.
>> However, if the GPU partition is powered, then the signal clamp for the
>> GPU partition should be removed and so use bit 0 of the
>> APBDEV_PMC_GPU_RG_CNTRL_0 register to determine if the clamp has been
>> removed (bit[0] = 0) and the GPU partition is powered.
>>
>> Signed-off-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> ---
>>
>> Changes v1-v2:
>> - Drop the has_gpu_toggle and use has_gpu_clamps as it is not necessary
>>   to have two variables.
>> - Correct the register used for reading the clamps status for the GPU
>>   partition
>>
>>  drivers/soc/tegra/pmc.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
>> index 8e358dbffaed..e4fd40fa27e8 100644
>> --- a/drivers/soc/tegra/pmc.c
>> +++ b/drivers/soc/tegra/pmc.c
>> @@ -176,7 +176,10 @@ static void tegra_pmc_writel(u32 value, unsigned long offset)
>>
>>  static inline bool tegra_powergate_state(int id)
>>  {
>> -       return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) != 0;
>> +       if (id == TEGRA_POWERGATE_3D && pmc->soc->has_gpu_clamps)
>> +               return (tegra_pmc_readl(GPU_RG_CNTRL) & 0x1) == 0;
>> +       else
>> +               return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) != 0;
> 
> From what I deduce power is on if bit 0 of register GPU_RG_CNTRL is
> equal to 0.  In the other case power is on if bit 'id' of register
> PWRGATE_STATUS is equal to 1.  If I'm right this is highly confusing
> and some comments  would be appreciated.  Changing
> 
> "return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) != 0;"
> 
> for
> 
> "return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) == 1;"

Yes, it is a bit confusing, but the above does not work. You are
comparing a bit with 1. What you need is:

"return (tegra_pmc_readl(PWRGATE_STATUS) & BIT(id)) == BIT(id);"

> would also help.
> 
>>  }
>>
>>  static inline bool tegra_powergate_is_valid(int id)
>> @@ -191,6 +194,9 @@ static inline bool tegra_powergate_is_valid(int id)
>>   */
>>  static int tegra_powergate_set(unsigned int id, bool new_state)
>>  {
>> +       if (id == TEGRA_POWERGATE_3D && pmc->soc->has_gpu_clamps)
>> +               return -EINVAL;
>> +
>>         mutex_lock(&pmc->powergates_lock);
>>
>>         if (tegra_powergate_state(id) == new_state) {
>> --
>> 2.1.4
> 
> With the above in mind:
> 
> Reviewed-by: Mathieu Poirier <mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Thanks. Thierry has queued this version and so if you feel strongly we
could update in a follow-up.

Jon

  parent reply	other threads:[~2016-02-26 16:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11 18:03 [PATCH 0/8] soc: tegra: pmc: Various fixes Jon Hunter
     [not found] ` <1455213806-21871-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-11 18:03   ` [PATCH 1/8] soc: tegra: pmc: Remove non-existing L2 partition for Tegra124 Jon Hunter
2016-02-11 18:03   ` [PATCH 2/8] soc: tegra: pmc: Restore base address on probe failure Jon Hunter
2016-02-11 18:03   ` [PATCH 3/8] soc: tegra: pmc: Protect public functions from potential race conditions Jon Hunter
2016-02-11 18:03   ` [PATCH 4/8] soc: tegra: pmc: Change powergate and rail IDs to be an unsigned type Jon Hunter
2016-02-11 18:03   ` [PATCH 5/8] soc: tegra: pmc: Fix testing of powergate state Jon Hunter
2016-02-11 18:03   ` [PATCH 6/8] soc: tegra: pmc: Fix verification of valid partitions Jon Hunter
2016-02-11 18:03   ` [PATCH 7/8] soc: tegra: pmc: Remove additional check for a valid partition Jon Hunter
2016-02-11 18:03   ` [PATCH 8/8] soc: tegra: pmc: Ensure GPU partition can be toggled on/off by PMC Jon Hunter
     [not found]     ` <1455213806-21871-9-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-12  9:38       ` Jon Hunter
     [not found]         ` <56BDA826.2000304-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-12 17:25           ` Thierry Reding
2016-02-12 18:51             ` Jon Hunter
2016-02-15 12:38       ` [PATCH V2] " Jon Hunter
     [not found]         ` <1455539891-6508-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-26 16:06           ` Mathieu Poirier
     [not found]             ` <CANLsYkwCx13YszW-67F2_KDwxgpzwKQft4eOpJvVM1nkNXGpXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-26 16:43               ` Jon Hunter [this message]
     [not found]                 ` <56D0809E.6060400-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-26 17:47                   ` Mathieu Poirier
2016-02-11 18:15   ` [PATCH 0/8] soc: tegra: pmc: Various fixes Jon Hunter
     [not found]     ` <56BCCFCA.4010009-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-11 22:13       ` Mathieu Poirier
2016-02-25 16:56   ` Thierry Reding

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=56D0809E.6060400@nvidia.com \
    --to=jonathanh-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mathieu.poirier-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).