Skip to contentSkip to conversation

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

DISCUSSION Guenter Roeck 2 participants 6 messages Sep 12, 2016 – Sep 13, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw

Hi Guenter,

Quoted 4 lines · Guenter Roeck

Hi folks,

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

Quoted 8 lines
	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

Quoted 7 lines

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. ;-)

Signature · 1 line
balbi
#2 lore raw

Hi Felipe,

Quoted 13 lines · Felipe Balbi

Hi Guenter,

Quoted 9 lines · Guenter Roeck

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]);
	}
Quoted 8 lines
Quoted 3 lines

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!

Quoted 8 lines
Quoted 7 lines

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

	if (!pm_runtime_status_suspended(dev))
		clk_disable_unprepare();
	else
		clk_unprepare();
Quoted 7 lines

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

#3 lore raw

Hi,

Quoted 12 lines · Guenter Roeck
Quoted 12 lines
Quoted 7 lines

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.

Quoted 7 lines
Quoted 3 lines

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 :-)

Signature · 1 line
balbi
#4 lore raw
Quoted 20 lines · Felipe Balbi

Hi,

Quoted 16 lines · Guenter Roeck
Quoted 15 lines
Quoted 7 lines

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. ;-)

Quoted 7 lines
Quoted 3 lines

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

#5 lore raw

Hi,

Quoted 21 lines · Guenter Roeck
Quoted 20 lines · Felipe Balbi

Hi,

Quoted 16 lines · Guenter Roeck
Quoted 15 lines
Quoted 7 lines

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. ;-)

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

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 ;-)

Signature · 1 line
balbi