Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1481847 > unrolled thread

Question about suspend/resume clock handling in dwc3-of-simple.c

Started byGuenter Roeck <linux@roeck-us.net>
First post2016-09-12 21:00 +0200
Last post2016-09-13 16:10 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  Question about suspend/resume clock handling in dwc3-of-simple.c Guenter Roeck <linux@roeck-us.net> - 2016-09-12 21:00 +0200
    Re: Question about suspend/resume clock handling in dwc3-of-simple.c Felipe Balbi <balbi@kernel.org> - 2016-09-12 21:10 +0200
      Re: Question about suspend/resume clock handling in dwc3-of-simple.c Guenter Roeck <linux@roeck-us.net> - 2016-09-12 21:50 +0200
        Re: Question about suspend/resume clock handling in dwc3-of-simple.c Felipe Balbi <balbi@kernel.org> - 2016-09-13 07:40 +0200
          Re: Question about suspend/resume clock handling in dwc3-of-simple.c Guenter Roeck <linux@roeck-us.net> - 2016-09-13 15:20 +0200
            Re: Question about suspend/resume clock handling in dwc3-of-simple.c Felipe Balbi <balbi@kernel.org> - 2016-09-13 16:10 +0200

#1481847 — Question about suspend/resume clock handling in dwc3-of-simple.c

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-12 21:00 +0200
SubjectQuestion about suspend/resume clock handling in dwc3-of-simple.c
Message-ID<sgECu-7at-43@gated-at.bofh.it>
Hi folks,

In dwc3-of-simple.c:dwc3_of_simple_remove(), I see the following code.

	for (i = 0; i < simple->num_clocks; i++) {
                clk_unprepare(simple->clks[i]);
		clk_put(simple->clks[i]);
	}

What I don't understand is why clk_unprepare() is called instead
of clk_disable_unprepare(). Someone told me that it was due to
dwc3_of_simple_runtime_suspend(), which would call clk_disable().

That doesn't really make sense to me, since after all CONFIG_PM
can be disabled.

Should it be clk_disable_unprepare(), or maybe something like the
following

	if (!pm_runtime_status_suspended(dev))
		clk_disable_unprepare();
	else
		clk_unprepare();

or am I missing something ?

Thanks,
Guenter

[toc] | [next] | [standalone]


#1481869

FromFelipe Balbi <balbi@kernel.org>
Date2016-09-12 21:10 +0200
Message-ID<sgEMb-7tX-39@gated-at.bofh.it>
In reply to#1481847

[Multipart message — attachments visible in raw view] — view raw

Hi Guenter,

Guenter Roeck <linux@roeck-us.net> writes:
> Hi folks,
>
> In dwc3-of-simple.c:dwc3_of_simple_remove(), I see the following code.
>
> 	for (i = 0; i < simple->num_clocks; i++) {
>                 clk_unprepare(simple->clks[i]);
> 		clk_put(simple->clks[i]);
> 	}
>
> What I don't understand is why clk_unprepare() is called instead
> of clk_disable_unprepare(). Someone told me that it was due to
> dwc3_of_simple_runtime_suspend(), which would call clk_disable().

good eyes :-) That was fixed though:

https://marc.info/?l=linux-usb&m=147343692631868&w=2

> Should it be clk_disable_unprepare(), or maybe something like the
> following
>
> 	if (!pm_runtime_status_suspended(dev))
> 		clk_disable_unprepare();
> 	else
> 		clk_unprepare();

I'm not sure how balanced those calls are, yeah. I don't have HW to test
PM with. But note that as it is, there is no actual runtime PM support,
so clk_disable_unprepare() will always be necessary.

Perhaps we will find further issues when someone tries to use runtime PM
with dwc3-of-simple. ;-)

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1481928

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-12 21:50 +0200
Message-ID<sgFoR-7LG-1@gated-at.bofh.it>
In reply to#1481869
Hi Felipe,

On Mon, Sep 12, 2016 at 10:05:00PM +0300, Felipe Balbi wrote:
> 
> Hi Guenter,
> 
> Guenter Roeck <linux@roeck-us.net> writes:
> > Hi folks,
> >
> > In dwc3-of-simple.c:dwc3_of_simple_remove(), I see the following code.
> >
> > 	for (i = 0; i < simple->num_clocks; i++) {
> >                 clk_unprepare(simple->clks[i]);
> > 		clk_put(simple->clks[i]);
> > 	}
> >
> > What I don't understand is why clk_unprepare() is called instead
> > of clk_disable_unprepare(). Someone told me that it was due to
> > dwc3_of_simple_runtime_suspend(), which would call clk_disable().
> 
> good eyes :-) That was fixed though:
> 
> https://marc.info/?l=linux-usb&m=147343692631868&w=2
> 

Great, thanks!

> > Should it be clk_disable_unprepare(), or maybe something like the
> > following
> >
> > 	if (!pm_runtime_status_suspended(dev))
> > 		clk_disable_unprepare();
> > 	else
> > 		clk_unprepare();
> 
> I'm not sure how balanced those calls are, yeah. I don't have HW to test
> PM with. But note that as it is, there is no actual runtime PM support,
> so clk_disable_unprepare() will always be necessary.
> 
> Perhaps we will find further issues when someone tries to use runtime PM
> with dwc3-of-simple. ;-)
> 

We are working on code derived from it, so unless I can convince the author
that he can not just use clk_unprepare() I suspect we'll hit the problem.
If so, I'll let you know.

Thanks!
Guenter

[toc] | [prev] | [next] | [standalone]


#1482143

FromFelipe Balbi <balbi@kernel.org>
Date2016-09-13 07:40 +0200
Message-ID<sgOBP-5N0-1@gated-at.bofh.it>
In reply to#1481928

[Multipart message — attachments visible in raw view] — view raw

Hi,

Guenter Roeck <linux@roeck-us.net> writes:
>> > Should it be clk_disable_unprepare(), or maybe something like the
>> > following
>> >
>> > 	if (!pm_runtime_status_suspended(dev))
>> > 		clk_disable_unprepare();
>> > 	else
>> > 		clk_unprepare();
>> 
>> I'm not sure how balanced those calls are, yeah. I don't have HW to test
>> PM with. But note that as it is, there is no actual runtime PM support,
>> so clk_disable_unprepare() will always be necessary.
>> 
>> Perhaps we will find further issues when someone tries to use runtime PM
>> with dwc3-of-simple. ;-)
>> 
>
> We are working on code derived from it, so unless I can convince the author
> that he can not just use clk_unprepare() I suspect we'll hit the problem.
> If so, I'll let you know.

Are you sending that upstream? Depending on your requirements, it might
be easier to patch dwc3-of-simple.c then adding yet another glue layer :-)

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1482461

FromGuenter Roeck <linux@roeck-us.net>
Date2016-09-13 15:20 +0200
Message-ID<sgVN0-2qI-35@gated-at.bofh.it>
In reply to#1482143
On 09/12/2016 10:35 PM, Felipe Balbi wrote:
>
> Hi,
>
> Guenter Roeck <linux@roeck-us.net> writes:
>>>> Should it be clk_disable_unprepare(), or maybe something like the
>>>> following
>>>>
>>>> 	if (!pm_runtime_status_suspended(dev))
>>>> 		clk_disable_unprepare();
>>>> 	else
>>>> 		clk_unprepare();
>>>
>>> I'm not sure how balanced those calls are, yeah. I don't have HW to test
>>> PM with. But note that as it is, there is no actual runtime PM support,
>>> so clk_disable_unprepare() will always be necessary.
>>>
>>> Perhaps we will find further issues when someone tries to use runtime PM
>>> with dwc3-of-simple. ;-)
>>>
>>
>> We are working on code derived from it, so unless I can convince the author
>> that he can not just use clk_unprepare() I suspect we'll hit the problem.
>> If so, I'll let you know.
>
> Are you sending that upstream? Depending on your requirements, it might
> be easier to patch dwc3-of-simple.c then adding yet another glue layer :-)
>
Yes. It will be a glue layer. So far that looks like the cleanest solution.

Thanks,
Guenter

[toc] | [prev] | [next] | [standalone]


#1482515

FromFelipe Balbi <balbi@kernel.org>
Date2016-09-13 16:10 +0200
Message-ID<sgWzn-2Yc-3@gated-at.bofh.it>
In reply to#1482461
Hi,

Guenter Roeck <linux@roeck-us.net> writes:
> On 09/12/2016 10:35 PM, Felipe Balbi wrote:
>>
>> Hi,
>>
>> Guenter Roeck <linux@roeck-us.net> writes:
>>>>> Should it be clk_disable_unprepare(), or maybe something like the
>>>>> following
>>>>>
>>>>> 	if (!pm_runtime_status_suspended(dev))
>>>>> 		clk_disable_unprepare();
>>>>> 	else
>>>>> 		clk_unprepare();
>>>>
>>>> I'm not sure how balanced those calls are, yeah. I don't have HW to test
>>>> PM with. But note that as it is, there is no actual runtime PM support,
>>>> so clk_disable_unprepare() will always be necessary.
>>>>
>>>> Perhaps we will find further issues when someone tries to use runtime PM
>>>> with dwc3-of-simple. ;-)
>>>>
>>>
>>> We are working on code derived from it, so unless I can convince the author
>>> that he can not just use clk_unprepare() I suspect we'll hit the problem.
>>> If so, I'll let you know.
>>
>> Are you sending that upstream? Depending on your requirements, it might
>> be easier to patch dwc3-of-simple.c then adding yet another glue layer :-)
>>
> Yes. It will be a glue layer. So far that looks like the cleanest solution.

fair enough, take your time ;-)

-- 
balbi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web