Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1605383 > unrolled thread
| Started by | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| First post | 2017-03-21 09:00 +0100 |
| Last post | 2017-03-23 03:20 +0100 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Baolin Wang <baolin.wang@linaro.org> - 2017-03-21 09:00 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Felipe Balbi <balbi@kernel.org> - 2017-03-21 09:10 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Baolin Wang <baolin.wang@linaro.org> - 2017-03-22 06:10 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Felipe Balbi <balbi@kernel.org> - 2017-03-22 10:10 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Baolin Wang <baolin.wang@linaro.org> - 2017-03-22 11:50 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Mathias Nyman <mathias.nyman@linux.intel.com> - 2017-03-22 13:50 +0100
Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM Baolin Wang <baolin.wang@linaro.org> - 2017-03-23 03:20 +0100
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Date | 2017-03-21 09:00 +0100 |
| Subject | Re: [PATCH v5 1/2] usb: host: plat: Enable xhci plat runtime PM |
| Message-ID | <tnmRY-fw-9@gated-at.bofh.it> |
Hi Mathias, On 21 February 2017 at 10:09, Baolin Wang <baolin.wang@linaro.org> wrote: >>>>>> Do you have any comments about this patch? Thanks. >>>>>> >>>>>>> drivers/usb/host/xhci-plat.c | 41 >>>>>>> ++++++++++++++++++++++++++++++++++++----- >>>>>>> 1 file changed, 36 insertions(+), 5 deletions(-) >>>>>>> >>>>>>> diff --git a/drivers/usb/host/xhci-plat.c >>>>>>> b/drivers/usb/host/xhci-plat.c >>>>>>> index ed56bf9..5805c6a 100644 >>>>>>> --- a/drivers/usb/host/xhci-plat.c >>>>>>> +++ b/drivers/usb/host/xhci-plat.c >>>>>>> @@ -246,6 +246,10 @@ static int xhci_plat_probe(struct platform_device >>>>>>> *pdev) >>>>>>> if (ret) >>>>>>> goto dealloc_usb2_hcd; >>>>>>> >>>>>>> + pm_runtime_get_noresume(&pdev->dev); >>>>>>> + pm_runtime_set_active(&pdev->dev); >>>>>>> + pm_runtime_enable(&pdev->dev); >>>>>>> + >>>>>>> return 0; >>>>>>> >>>>>>> >>>>> >>>>> To me this looks like we are not really enabling runtime pm for xhci, we >>>>> increment the >>>>> usage count in probe, and keep it until remove is called. >>>>> >>>>> This would normally prevent parent dwc3 from runtime suspending, but I >>>>> see >>>>> that in patch 2/2 adds >>>>> pm_suspend_ignore_children(dev, true) to dwc3, and, that dwc3 actually >>>>> controls xhci runtime >>>>> pm by calling pm_runtime_get/put for xhci in its own dwc3 >>>>> runtime_suspend/resume callbacks. >>>>> >>>>> Looks a bit upside down to me, what's the reason for this? >>>>> >>>>> what prevents calling pm_runtime_put_* before leaving probe in xhci and >>>>> let >>>>> pm code handle >>>>> the runtime suspend and parent/child relationships? >>>> >>>> >>>> When dwc3 controller is working on host mode, which will create and >>>> add the USB hcd for host side. Then if we want to suspend dwc3 >>>> controller as host mode, the USB device (bus) of host side will >>>> runtime suspend automatically if there are no slave attached (by >>>> >>>> usb_runtime_suspend()--->usb_suspend_both()--->usb_suspend_interface()--->usb_suspend_device()--->generic_suspend()--->hcd_bus_suspend()--->xhci_bus_suspend()), >>>> but we should not suspend xHCI device (issuing xhci_suspend()) now, >>>> since some other controllers did not implement the runtime PM to >>>> control xHCI device's runtime state, which will cause other >>>> controllers can not resume xHCI device (issuing xhci_resume()) if the >>>> xHCI device suspend automatically by its child device. Thus we should >>>> get the runtime count for xHCI device in xhci_plat_probe() in case >>>> xHCI device will also suspend automatically by its child device. >>>> According to that, for xHCI device's parent: dwc3 device, we should >>>> put the xHCI device's runtime count to suspend xHCI device manually. >>>> >>> >>> Any more comments? >>> >> >> I think I at least partially understand your point. You don't want to enable >> runtime suspend for all xhci platform devices by default, but only for the >> ones >> that are part of dwc3. >> >> The implementation you suggest is that xhci platform driver always increase >> the xhci platform >> device usage counter during probe with pm_runtime_get_noresume(), and never >> decrement it, >> preventing xhci platform devices from runtime suspending by themselves. >> >> You then control xhci runtime suspend from dwc3 driver runtime suspend, >> allowing >> xhci platfrom controller to runtime suspend only when dwc3 runtime suspends >> by decrementing xhci >> platform device usage in dwc3 runtime suspend callback. >> As xhci is a child of dwc3 in this case, dwc3 would never runtime suspend >> as long as xhci is running, so >> dwc3 needed to be detached from xhci by setting dwc3 to ignore its children >> to get it to work. > > Yes, that's my point. > >> >> I don't yet understand why we can't just keep runtime pm disabled as a >> default for xhci platform devices. >> It could be enabled by whatever creates the platform device by setting some >> device property >> (or equivalent), which would be checked in xhci_plat_probe() before enabling >> runtime pm. It >> could then optionally be set in sysfs via power/control entry. > > I think runtime pm is not one hardware property, is it suitable if we > introduce one device property to enable/disable runtime pm? As I said, runtime pm is not one hardware property, I think it is not suitable if we introduce one device property to enable/disable runtime pm. Secondly, we only can resume the xhci platform device by getting the xhci usage counter from gadget driver, since the cable plug in/out events only can be notified to glue layer of gadget driver(like dwc3 glue layer). That means if we want to suspend xhci platform device, we must put xhci usage counter (so we can not keep their parent-child relationship intact). That is why we need pm_suspend_ignore_children(dev, true). Mathias, could you re-check this patch? Thanks. >> >> We would keep the usage counting intact, and only enable xhci platform >> device runtime pm >> if the platform supports it, and dwc3 and xhci would keep their parent-child >> relationship >> intact and make sure dwc3 can't runtime suspend before xhci. > > Yes, that is the benefits. > >> >> To the concerns about xhci runtime suspending too early, the codepath you >> describet only applies >> for roothub devices, which sohuld be called only after other devices have >> suspended. >> >> To make sure xhci platform device does not runtime suspend during probe >> after first >> hcd is added (without children), but before second one, make sure to >> increase the usage count before creating and adding >> both hcd's, and only decrease it after both are ready. >> >> This way it will only runtime suspend after both buses are created. >> >> xhci_plat_probe(pdev) >> /* prevent platform device runtime suspend between adding main and >> shared_hcd */ >> pm_runtime_get_noresume(&pdev->dev) >> usb_create_hcd() >> usb_create_shared_hcd() >> usb_add_hcd(hcd) >> usb_add_hcd(shared_hcd) >> /* both hcs's added, allow platform device to runtime suspend */ >> pm_runtime_put_noidle(&dev->dev); >> > > Make sense. > > -- > Baolin.wang > Best Regards -- Baolin.wang Best Regards
[toc] | [next] | [standalone]
| From | Felipe Balbi <balbi@kernel.org> |
|---|---|
| Date | 2017-03-21 09:10 +0100 |
| Message-ID | <tnn1E-xY-19@gated-at.bofh.it> |
| In reply to | #1605383 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
Baolin Wang <baolin.wang@linaro.org> writes:
>>> I don't yet understand why we can't just keep runtime pm disabled as a
>>> default for xhci platform devices.
>>> It could be enabled by whatever creates the platform device by setting some
>>> device property
>>> (or equivalent), which would be checked in xhci_plat_probe() before enabling
>>> runtime pm. It
>>> could then optionally be set in sysfs via power/control entry.
>>
>> I think runtime pm is not one hardware property, is it suitable if we
>> introduce one device property to enable/disable runtime pm?
>
> As I said, runtime pm is not one hardware property, I think it is not
> suitable if we introduce one device property to enable/disable runtime
> pm.
we already this functionality exposed on sysfs.
> Secondly, we only can resume the xhci platform device by getting the
> xhci usage counter from gadget driver, since the cable plug in/out
> events only can be notified to glue layer of gadget driver(like dwc3
> glue layer). That means if we want to suspend xhci platform device, we
this is a problem with the glue layer, IMO. It should be something like
so:
static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
{
struct dwc3_foobar_glue *glue = _glue;
u32 reg;
reg = real(glue->base, OFFSET);
if (reg & CONNECT)
pm_runtime_resume(&glue->dwc3);
return IRQ_HANDLED;
}
then dwc3's ->runtime_resume() should check if the event is supposed to
be handled by host or peripheral by checking which mode it was before
suspend and making the assumption that we don't change modes while
suspended. Something like:
static int dwc3_runtime_resume(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
[...]
if (dwc->is_host)
pm_runtime_resume(dwc->xhci.dev);
[...]
return 0;
}
> must put xhci usage counter (so we can not keep their parent-child
> relationship intact). That is why we need
> pm_suspend_ignore_children(dev, true).
you really shouldn't need that and it's still unclear why you think you
do.
--
balbi
[toc] | [prev] | [next] | [standalone]
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Date | 2017-03-22 06:10 +0100 |
| Message-ID | <tnGGZ-5HX-1@gated-at.bofh.it> |
| In reply to | #1605393 |
Hi,
On 21 March 2017 at 16:07, Felipe Balbi <balbi@kernel.org> wrote:
>
> Hi,
>
> Baolin Wang <baolin.wang@linaro.org> writes:
>>>> I don't yet understand why we can't just keep runtime pm disabled as a
>>>> default for xhci platform devices.
>>>> It could be enabled by whatever creates the platform device by setting some
>>>> device property
>>>> (or equivalent), which would be checked in xhci_plat_probe() before enabling
>>>> runtime pm. It
>>>> could then optionally be set in sysfs via power/control entry.
>>>
>>> I think runtime pm is not one hardware property, is it suitable if we
>>> introduce one device property to enable/disable runtime pm?
>>
>> As I said, runtime pm is not one hardware property, I think it is not
>> suitable if we introduce one device property to enable/disable runtime
>> pm.
>
> we already this functionality exposed on sysfs.
From my understanding, Mathias suggested me to add one device property
(name like "usb-host-runtimePM") by platform_device_add_properties()
to enable/disable runtime PM when creating platform device, like
usb3_lpm_capable:
if (dwc->usb3_lpm_capable)
props[prop_idx++].name = "usb3-lpm-capable";
ret = platform_device_add_properties(xhci, props);
if (ret) {
dev_err(dwc->dev, "failed to add properties to xHCI\n");
goto err1;
}
What I think It is not suitable to introduce one device property like
above to enable/disable runtime PM, it is not one hardware attribute.
>
>> Secondly, we only can resume the xhci platform device by getting the
>> xhci usage counter from gadget driver, since the cable plug in/out
>> events only can be notified to glue layer of gadget driver(like dwc3
>> glue layer). That means if we want to suspend xhci platform device, we
>
> this is a problem with the glue layer, IMO. It should be something like
> so:
>
> static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
> {
> struct dwc3_foobar_glue *glue = _glue;
> u32 reg;
>
> reg = real(glue->base, OFFSET);
> if (reg & CONNECT)
> pm_runtime_resume(&glue->dwc3);
>
> return IRQ_HANDLED;
> }
>
> then dwc3's ->runtime_resume() should check if the event is supposed to
> be handled by host or peripheral by checking which mode it was before
> suspend and making the assumption that we don't change modes while
> suspended. Something like:
>
> static int dwc3_runtime_resume(struct device *dev)
> {
> struct dwc3 *dwc = dev_get_drvdata(dev);
>
> [...]
>
> if (dwc->is_host)
> pm_runtime_resume(dwc->xhci.dev);
>
> [...]
>
> return 0;
> }
Yeah, if we don't need to get xhci usage counter in xhci_plat_probe()
to avoid affecting other controller's runtime PM, we can do like this
and do not need to get/put counter.
>> must put xhci usage counter (so we can not keep their parent-child
>> relationship intact). That is why we need
>> pm_suspend_ignore_children(dev, true).
>
> you really shouldn't need that and it's still unclear why you think you
> do.
>
> --
> balbi
--
Baolin.wang
Best Regards
[toc] | [prev] | [next] | [standalone]
| From | Felipe Balbi <balbi@kernel.org> |
|---|---|
| Date | 2017-03-22 10:10 +0100 |
| Message-ID | <tnKrg-8tF-29@gated-at.bofh.it> |
| In reply to | #1606210 |
[Multipart message — attachments visible in raw view] — view raw
Hi,
Baolin Wang <baolin.wang@linaro.org> writes:
>>>>> I don't yet understand why we can't just keep runtime pm disabled as a
>>>>> default for xhci platform devices.
>>>>> It could be enabled by whatever creates the platform device by setting some
>>>>> device property
>>>>> (or equivalent), which would be checked in xhci_plat_probe() before enabling
>>>>> runtime pm. It
>>>>> could then optionally be set in sysfs via power/control entry.
>>>>
>>>> I think runtime pm is not one hardware property, is it suitable if we
>>>> introduce one device property to enable/disable runtime pm?
>>>
>>> As I said, runtime pm is not one hardware property, I think it is not
>>> suitable if we introduce one device property to enable/disable runtime
>>> pm.
>>
>> we already this functionality exposed on sysfs.
>
> From my understanding, Mathias suggested me to add one device property
> (name like "usb-host-runtimePM") by platform_device_add_properties()
> to enable/disable runtime PM when creating platform device, like
> usb3_lpm_capable:
>
> if (dwc->usb3_lpm_capable)
> props[prop_idx++].name = "usb3-lpm-capable";
>
> ret = platform_device_add_properties(xhci, props);
> if (ret) {
> dev_err(dwc->dev, "failed to add properties to xHCI\n");
> goto err1;
> }
>
> What I think It is not suitable to introduce one device property like
> above to enable/disable runtime PM, it is not one hardware attribute.
yeah, that's silly. We already have means for doing that:
my_probe()
{
[...]
pm_runtime_enable(dev);
pm_runtime_forbid(dev);
[...]
return 0;
}
>>> Secondly, we only can resume the xhci platform device by getting the
>>> xhci usage counter from gadget driver, since the cable plug in/out
>>> events only can be notified to glue layer of gadget driver(like dwc3
>>> glue layer). That means if we want to suspend xhci platform device, we
>>
>> this is a problem with the glue layer, IMO. It should be something like
>> so:
>>
>> static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
>> {
>> struct dwc3_foobar_glue *glue = _glue;
>> u32 reg;
>>
>> reg = real(glue->base, OFFSET);
>> if (reg & CONNECT)
>> pm_runtime_resume(&glue->dwc3);
>>
>> return IRQ_HANDLED;
>> }
>>
>> then dwc3's ->runtime_resume() should check if the event is supposed to
>> be handled by host or peripheral by checking which mode it was before
>> suspend and making the assumption that we don't change modes while
>> suspended. Something like:
>>
>> static int dwc3_runtime_resume(struct device *dev)
>> {
>> struct dwc3 *dwc = dev_get_drvdata(dev);
>>
>> [...]
>>
>> if (dwc->is_host)
>> pm_runtime_resume(dwc->xhci.dev);
>>
>> [...]
>>
>> return 0;
>> }
>
> Yeah, if we don't need to get xhci usage counter in xhci_plat_probe()
> to avoid affecting other controller's runtime PM, we can do like this
> and do not need to get/put counter.
why do you need to get xhci's usage counter in xhci_plat_probe() ?
And why would one xhci affect the other? They are different struct
device instances and, thus, have different pm usage counter. How would
one xhci's pm_runtime affect another?
PM runtime is not per driver, it's per device.
--
balbi
[toc] | [prev] | [next] | [standalone]
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Date | 2017-03-22 11:50 +0100 |
| Message-ID | <tnM02-11I-21@gated-at.bofh.it> |
| In reply to | #1606291 |
Hi,
On 22 March 2017 at 17:00, Felipe Balbi <balbi@kernel.org> wrote:
>
> Hi,
>
> Baolin Wang <baolin.wang@linaro.org> writes:
>>>>>> I don't yet understand why we can't just keep runtime pm disabled as a
>>>>>> default for xhci platform devices.
>>>>>> It could be enabled by whatever creates the platform device by setting some
>>>>>> device property
>>>>>> (or equivalent), which would be checked in xhci_plat_probe() before enabling
>>>>>> runtime pm. It
>>>>>> could then optionally be set in sysfs via power/control entry.
>>>>>
>>>>> I think runtime pm is not one hardware property, is it suitable if we
>>>>> introduce one device property to enable/disable runtime pm?
>>>>
>>>> As I said, runtime pm is not one hardware property, I think it is not
>>>> suitable if we introduce one device property to enable/disable runtime
>>>> pm.
>>>
>>> we already this functionality exposed on sysfs.
>>
>> From my understanding, Mathias suggested me to add one device property
>> (name like "usb-host-runtimePM") by platform_device_add_properties()
>> to enable/disable runtime PM when creating platform device, like
>> usb3_lpm_capable:
>>
>> if (dwc->usb3_lpm_capable)
>> props[prop_idx++].name = "usb3-lpm-capable";
>>
>> ret = platform_device_add_properties(xhci, props);
>> if (ret) {
>> dev_err(dwc->dev, "failed to add properties to xHCI\n");
>> goto err1;
>> }
>>
>> What I think It is not suitable to introduce one device property like
>> above to enable/disable runtime PM, it is not one hardware attribute.
>
> yeah, that's silly. We already have means for doing that:
>
> my_probe()
> {
> [...]
>
> pm_runtime_enable(dev);
> pm_runtime_forbid(dev);
That's same with getting the usage counter.
>
> [...]
>
> return 0;
> }
>
>>>> Secondly, we only can resume the xhci platform device by getting the
>>>> xhci usage counter from gadget driver, since the cable plug in/out
>>>> events only can be notified to glue layer of gadget driver(like dwc3
>>>> glue layer). That means if we want to suspend xhci platform device, we
>>>
>>> this is a problem with the glue layer, IMO. It should be something like
>>> so:
>>>
>>> static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
>>> {
>>> struct dwc3_foobar_glue *glue = _glue;
>>> u32 reg;
>>>
>>> reg = real(glue->base, OFFSET);
>>> if (reg & CONNECT)
>>> pm_runtime_resume(&glue->dwc3);
>>>
>>> return IRQ_HANDLED;
>>> }
>>>
>>> then dwc3's ->runtime_resume() should check if the event is supposed to
>>> be handled by host or peripheral by checking which mode it was before
>>> suspend and making the assumption that we don't change modes while
>>> suspended. Something like:
>>>
>>> static int dwc3_runtime_resume(struct device *dev)
>>> {
>>> struct dwc3 *dwc = dev_get_drvdata(dev);
>>>
>>> [...]
>>>
>>> if (dwc->is_host)
>>> pm_runtime_resume(dwc->xhci.dev);
>>>
>>> [...]
>>>
>>> return 0;
>>> }
>>
>> Yeah, if we don't need to get xhci usage counter in xhci_plat_probe()
>> to avoid affecting other controller's runtime PM, we can do like this
>> and do not need to get/put counter.
>
> why do you need to get xhci's usage counter in xhci_plat_probe() ?
>
> And why would one xhci affect the other? They are different struct
> device instances and, thus, have different pm usage counter. How would
> one xhci's pm_runtime affect another?
What I mean is if another USB controller's driver did not implement
runtime pm callbacks but system enables CONFIG_PM, that will make xhci
device auto-suspended when after probing xhci-plat if we did not get
xhci device usage counter, but gadget driver can not resume xhci
without implementing runtime PM callbacks.
If we want to implement xhci-plat runtime resume/suspend without
getting usage counter, we should assume every driver using xhci-plat
should implement their runtime PM callbacks. Is this right?
>
> PM runtime is not per driver, it's per device.
Correct.
--
Baolin.wang
Best Regards
[toc] | [prev] | [next] | [standalone]
| From | Mathias Nyman <mathias.nyman@linux.intel.com> |
|---|---|
| Date | 2017-03-22 13:50 +0100 |
| Message-ID | <tnNSa-2sZ-29@gated-at.bofh.it> |
| In reply to | #1606348 |
On 22.03.2017 12:40, Baolin Wang wrote:
> Hi,
>
> On 22 March 2017 at 17:00, Felipe Balbi <balbi@kernel.org> wrote:
>>
>> Hi,
>>
>> Baolin Wang <baolin.wang@linaro.org> writes:
>>>>>>> I don't yet understand why we can't just keep runtime pm disabled as a
>>>>>>> default for xhci platform devices.
>>>>>>> It could be enabled by whatever creates the platform device by setting some
>>>>>>> device property
>>>>>>> (or equivalent), which would be checked in xhci_plat_probe() before enabling
>>>>>>> runtime pm. It
>>>>>>> could then optionally be set in sysfs via power/control entry.
>>>>>>
>>>>>> I think runtime pm is not one hardware property, is it suitable if we
>>>>>> introduce one device property to enable/disable runtime pm?
>>>>
>>>> we already this functionality exposed on sysfs.
>>>
>>> From my understanding, Mathias suggested me to add one device property
>>> (name like "usb-host-runtimePM") by platform_device_add_properties()
>>> to enable/disable runtime PM when creating platform device, like
>>> usb3_lpm_capable:
>>>
It was more of generic pondering how to automatically enable runtime PM for platforms
that know their xhci can runtime suspend/resume. But all this can be skipped for now and just
force users to manually enable xhci platform runtime pm in sysfs for now.
For me, and for xhci point of view only, patch 1/2 is quite ok.
Only some minor adjustments like calling runtime_get in the beginning of probe, and runtime_put
at the end end after both hcd's are added.
Probe could additionally call pm_runtime_forbid() to prevent runtime pm frpm being on as
default, (increases usage count, modifies runtime_auto)
This would force the user to explicitly enable runtime pm usin power/control in sysfs.
In my opinion that patch could be a separate one, and how dwc3 deals with it can be a separate
topic.
>>
>> yeah, that's silly. We already have means for doing that:
>>
>> my_probe()
>> {
>> [...]
>>
>> pm_runtime_enable(dev);
>> pm_runtime_forbid(dev);
>
> That's same with getting the usage counter.
>
>>
>> [...]
>>
>> return 0;
>> }
>>
>>>>> Secondly, we only can resume the xhci platform device by getting the
>>>>> xhci usage counter from gadget driver, since the cable plug in/out
>>>>> events only can be notified to glue layer of gadget driver(like dwc3
>>>>> glue layer). That means if we want to suspend xhci platform device, we
>>>>
>>>> this is a problem with the glue layer, IMO. It should be something like
>>>> so:
>>>>
>>>> static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
>>>> {
>>>> struct dwc3_foobar_glue *glue = _glue;
>>>> u32 reg;
>>>>
>>>> reg = real(glue->base, OFFSET);
>>>> if (reg & CONNECT)
>>>> pm_runtime_resume(&glue->dwc3);
>>>>
>>>> return IRQ_HANDLED;
>>>> }
>>>>
>>>> then dwc3's ->runtime_resume() should check if the event is supposed to
>>>> be handled by host or peripheral by checking which mode it was before
>>>> suspend and making the assumption that we don't change modes while
>>>> suspended. Something like:
>>>>
>>>> static int dwc3_runtime_resume(struct device *dev)
>>>> {
>>>> struct dwc3 *dwc = dev_get_drvdata(dev);
>>>>
>>>> [...]
>>>>
>>>> if (dwc->is_host)
>>>> pm_runtime_resume(dwc->xhci.dev);
>>>>
>>>> [...]
>>>>
>>>> return 0;
>>>> }
>>>
>>> Yeah, if we don't need to get xhci usage counter in xhci_plat_probe(
>>> to avoid affecting other controller's runtime PM, we can do like this
>>> and do not need to get/put counter.
>>
>> why do you need to get xhci's usage counter in xhci_plat_probe() ?
>>
>> And why would one xhci affect the other? They are different struct
>> device instances and, thus, have different pm usage counter. How would
>> one xhci's pm_runtime affect another?
>
> What I mean is if another USB controller's driver did not implement
> runtime pm callbacks but system enables CONFIG_PM, that will make xhci
> device auto-suspended when after probing xhci-plat if we did not get
> xhci device usage counter, but gadget driver can not resume xhci
> without implementing runtime PM callbacks.
>
> If we want to implement xhci-plat runtime resume/suspend without
> getting usage counter, we should assume every driver using xhci-plat
> should implement their runtime PM callbacks. Is this right?
That is my understanding as well, Basically the xhci parents driver
should end up calling xhci_plat_runtime_resume() one way or another.
Just like Felipe's glue driver fix above does.
So lets keep pm_runtime_forbid() as default for xhci-plat for now.
-Mathias
[toc] | [prev] | [next] | [standalone]
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Date | 2017-03-23 03:20 +0100 |
| Message-ID | <to0w1-3Qh-3@gated-at.bofh.it> |
| In reply to | #1606436 |
Hi,
On 22 March 2017 at 20:43, Mathias Nyman <mathias.nyman@linux.intel.com> wrote:
> On 22.03.2017 12:40, Baolin Wang wrote:
>>
>> Hi,
>>
>> On 22 March 2017 at 17:00, Felipe Balbi <balbi@kernel.org> wrote:
>>>
>>>
>>> Hi,
>>>
>>> Baolin Wang <baolin.wang@linaro.org> writes:
>>>>>>>>
>>>>>>>> I don't yet understand why we can't just keep runtime pm disabled as
>>>>>>>> a
>>>>>>>> default for xhci platform devices.
>>>>>>>> It could be enabled by whatever creates the platform device by
>>>>>>>> setting some
>>>>>>>> device property
>>>>>>>> (or equivalent), which would be checked in xhci_plat_probe() before
>>>>>>>> enabling
>>>>>>>> runtime pm. It
>>>>>>>> could then optionally be set in sysfs via power/control entry.
>>>>>>>
>>>>>>>
>>>>>>> I think runtime pm is not one hardware property, is it suitable if we
>>>>>>> introduce one device property to enable/disable runtime pm?
>>>>>
>>>>>
>>>>> we already this functionality exposed on sysfs.
>>>>
>>>>
>>>> From my understanding, Mathias suggested me to add one device property
>>>> (name like "usb-host-runtimePM") by platform_device_add_properties()
>>>> to enable/disable runtime PM when creating platform device, like
>>>> usb3_lpm_capable:
>>>>
>
> It was more of generic pondering how to automatically enable runtime PM for
> platforms
> that know their xhci can runtime suspend/resume. But all this can be skipped
> for now and just
> force users to manually enable xhci platform runtime pm in sysfs for now.
>
> For me, and for xhci point of view only, patch 1/2 is quite ok.
> Only some minor adjustments like calling runtime_get in the beginning of
> probe, and runtime_put
> at the end end after both hcd's are added.
>
> Probe could additionally call pm_runtime_forbid() to prevent runtime pm frpm
> being on as
> default, (increases usage count, modifies runtime_auto)
>
> This would force the user to explicitly enable runtime pm usin power/control
> in sysfs.
Fair enough.
>
> In my opinion that patch could be a separate one, and how dwc3 deals with it
> can be a separate
> topic.
OK.
>
>>>
>>> yeah, that's silly. We already have means for doing that:
>>>
>>> my_probe()
>>> {
>>> [...]
>>>
>>> pm_runtime_enable(dev);
>>> pm_runtime_forbid(dev);
>>
>>
>> That's same with getting the usage counter.
>>
>>>
>>> [...]
>>>
>>> return 0;
>>> }
>>>
>>>>>> Secondly, we only can resume the xhci platform device by getting the
>>>>>> xhci usage counter from gadget driver, since the cable plug in/out
>>>>>> events only can be notified to glue layer of gadget driver(like dwc3
>>>>>> glue layer). That means if we want to suspend xhci platform device, we
>>>>>
>>>>>
>>>>> this is a problem with the glue layer, IMO. It should be something like
>>>>> so:
>>>>>
>>>>> static irqreturn_t dwc3_foobar_wakeup(int irq, void *_glue)
>>>>> {
>>>>> struct dwc3_foobar_glue *glue = _glue;
>>>>> u32 reg;
>>>>>
>>>>> reg = real(glue->base, OFFSET);
>>>>> if (reg & CONNECT)
>>>>> pm_runtime_resume(&glue->dwc3);
>>>>>
>>>>> return IRQ_HANDLED;
>>>>> }
>>>>>
>>>>> then dwc3's ->runtime_resume() should check if the event is supposed to
>>>>> be handled by host or peripheral by checking which mode it was before
>>>>> suspend and making the assumption that we don't change modes while
>>>>> suspended. Something like:
>>>>>
>>>>> static int dwc3_runtime_resume(struct device *dev)
>>>>> {
>>>>> struct dwc3 *dwc = dev_get_drvdata(dev);
>>>>>
>>>>> [...]
>>>>>
>>>>> if (dwc->is_host)
>>>>> pm_runtime_resume(dwc->xhci.dev);
>>>>>
>>>>> [...]
>>>>>
>>>>> return 0;
>>>>> }
>>>>
>>>>
>>>> Yeah, if we don't need to get xhci usage counter in xhci_plat_probe(
>>>> to avoid affecting other controller's runtime PM, we can do like this
>>>> and do not need to get/put counter.
>>>
>>>
>>> why do you need to get xhci's usage counter in xhci_plat_probe() ?
>>>
>>> And why would one xhci affect the other? They are different struct
>>> device instances and, thus, have different pm usage counter. How would
>>> one xhci's pm_runtime affect another?
>>
>>
>> What I mean is if another USB controller's driver did not implement
>> runtime pm callbacks but system enables CONFIG_PM, that will make xhci
>> device auto-suspended when after probing xhci-plat if we did not get
>> xhci device usage counter, but gadget driver can not resume xhci
>> without implementing runtime PM callbacks.
>>
>> If we want to implement xhci-plat runtime resume/suspend without
>> getting usage counter, we should assume every driver using xhci-plat
>> should implement their runtime PM callbacks. Is this right?
>
>
> That is my understanding as well, Basically the xhci parents driver
> should end up calling xhci_plat_runtime_resume() one way or another.
> Just like Felipe's glue driver fix above does.
>
> So lets keep pm_runtime_forbid() as default for xhci-plat for now.
I agreed. I will create new patches. Thanks Mathias and Felipe's suggestion.
--
Baolin.wang
Best Regards
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web