linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@intel.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jon Hunter <jonathanh@nvidia.com>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] usb: xhci: tegra: Add runtime PM support
Date: Fri, 9 Mar 2018 11:13:02 +0200	[thread overview]
Message-ID: <1fff9fc1-2ad2-dba1-cb1d-d531254984ce@intel.com> (raw)
In-Reply-To: <20180309083629.GA13877@ulmo>

On 09.03.2018 10:36, Thierry Reding wrote:
> On Thu, Mar 08, 2018 at 09:31:07PM +0000, Jon Hunter wrote:
>>
>> On 01/03/18 14:18, Mathias Nyman wrote:
>>> On 14.02.2018 18:34, Jon Hunter wrote:
>>>> Add runtime PM support to the Tegra XHCI driver and move the function
>>>> calls to enable/disable the clocks, regulators and PHY into the runtime
>>>> PM callbacks.
>>>>
>>>> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
>>>> ---
>>>>    drivers/usb/host/xhci-tegra.c | 80
>>>> ++++++++++++++++++++++++++++++-------------
>>>>    1 file changed, 56 insertions(+), 24 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/host/xhci-tegra.c
>>>> b/drivers/usb/host/xhci-tegra.c
>>>> index 02b0b24faa58..42aa67858b53 100644
>>>> --- a/drivers/usb/host/xhci-tegra.c
>>>> +++ b/drivers/usb/host/xhci-tegra.c
>>>> @@ -18,6 +18,7 @@
>>>>    #include <linux/phy/tegra/xusb.h>
>>>>    #include <linux/platform_device.h>
>>>>    #include <linux/pm.h>
>>>> +#include <linux/pm_runtime.h>
>>>>    #include <linux/regulator/consumer.h>
>>>>    #include <linux/reset.h>
>>>>    #include <linux/slab.h>
>>>> @@ -1067,22 +1068,12 @@ static int tegra_xusb_probe(struct
>>>> platform_device *pdev)
>>>>         */
>>>>        platform_set_drvdata(pdev, tegra);
>>>>    -    err = tegra_xusb_clk_enable(tegra);
>>>> -    if (err) {
>>>> -        dev_err(&pdev->dev, "failed to enable clocks: %d\n", err);
>>>> -        goto put_usb2;
>>>> -    }
>>>> -
>>>> -    err = regulator_bulk_enable(tegra->soc->num_supplies,
>>>> tegra->supplies);
>>>> -    if (err) {
>>>> -        dev_err(&pdev->dev, "failed to enable regulators: %d\n", err);
>>>> -        goto disable_clk;
>>>> -    }
>>>> +    pm_runtime_enable(&pdev->dev);
>>>>    -    err = tegra_xusb_phy_enable(tegra);
>>>> +    err = pm_runtime_get_sync(&pdev->dev);
>>>>        if (err < 0) {
>>>
>>> Does this mean that if runtime PM is disabled then clocks and regulator
>>> will never be enabled
>>> for Tegra xhci?
>>>
>>> How about keeping the clock and regualtor enabling in probe, and instead
>>> add something like:
>>>
>>> pm_runtime_set_active(&pdev->dev);
>>> pm_runtime_enable(&pdev->dev);
>>> pm_runtime_get_noresume(&pdev->dev);
>>
>> For 64-bit Tegra there is a dependency on CONFIG_PM, but for 32-bit
>> AFAIK there is not and so yes we should handle the case when PM_RUNTIME
>> is disabled.
>>
>> Typically we do something like ...
>>
>>      pm_runtime_enable(&pdev->dev);
>>      if (!pm_runtime_enabled(&pdev->dev))
>> 	ret = tegra_xusb_runtime_resume(&pdev->dev);
>>      else
>>          ret = pm_runtime_get_sync(&pdev->dev);
>>
>> That way we can keep the regulator and clock stuff in the handler. I
>> will update this series.
> 
> Is there any good reason why we don't depend on PM for 32-bit as well?
> I'm not aware of any differences in drivers that are 32-bit specific for
> Tegra, and I'm not even sure the !PM case gets any testing at all. And
> even if, do we really still want to support that?
> 
> I don't see any advantage these days for having it disabled.

I don't know much about Tegra, but I'd still like to turn this question around:

Is there any reason why clks and regulators can't initially be turned on in probe,
and then let runtime PM handle them later if PM is supported?

Shouldn't this work in all cases, and it avoids creating new dependencies?

Thanks
Mathias

  reply	other threads:[~2018-03-09  9:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 16:34 [PATCH 1/3] usb: xhci: tegra: Prepare for adding runtime PM support Jon Hunter
2018-02-14 16:34 ` [PATCH 2/3] usb: xhci: tegra: Add " Jon Hunter
2018-03-01 14:18   ` Mathias Nyman
2018-03-08 21:31     ` Jon Hunter
2018-03-09  8:36       ` Thierry Reding
2018-03-09  9:13         ` Mathias Nyman [this message]
2018-03-09 11:19           ` Jon Hunter
2018-03-09 11:13         ` Jon Hunter
2018-02-14 16:34 ` [PATCH 3/3] usb: xhci: tegra: Add support for managing powergates Jon Hunter

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=1fff9fc1-2ad2-dba1-cb1d-d531254984ce@intel.com \
    --to=mathias.nyman@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=thierry.reding@gmail.com \
    /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).