Message ID | 1359373348-18320-4-git-send-email-gautam.vivek@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jan 28, 2013 at 05:12:27PM +0530, Vivek Gautam wrote: > Enabling runtime power management on dwc3-exynos to save > power and allow its PHY's power to be managed at runtime. > > Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> > --- > drivers/usb/dwc3/dwc3-exynos.c | 47 ++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 47 insertions(+), 0 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c > index aae5328..c51e8c1 100644 > --- a/drivers/usb/dwc3/dwc3-exynos.c > +++ b/drivers/usb/dwc3/dwc3-exynos.c > @@ -157,11 +157,15 @@ static int dwc3_exynos_probe(struct platform_device *pdev) > goto err4; > } > > + pm_runtime_set_active(&pdev->dev); > + pm_runtime_enable(&pdev->dev); > + > return 0; > > err4: > clk_disable(clk); > clk_put(clk); > + pm_runtime_disable(&pdev->dev); > err3: > platform_device_put(dwc3); > err1: > @@ -174,6 +178,8 @@ static int dwc3_exynos_remove(struct platform_device *pdev) > { > struct dwc3_exynos *exynos = platform_get_drvdata(pdev); > > + pm_runtime_disable(&pdev->dev); > + > platform_device_unregister(exynos->dwc3); > platform_device_unregister(exynos->usb2_phy); > platform_device_unregister(exynos->usb3_phy); > @@ -186,6 +192,46 @@ static int dwc3_exynos_remove(struct platform_device *pdev) > return 0; > } > > +static int dwc3_exynos_runtime_suspend(struct device *dev) > +{ > + struct dwc3_exynos *exynos = dev_get_drvdata(dev); > + struct platform_device *pdev_dwc = exynos->dwc3; > + struct dwc3 *dwc = NULL; > + > + dwc = platform_get_drvdata(pdev_dwc); > + > + if (!dwc) > + return 0; > + > + pm_runtime_put_sync(dwc->usb3_phy->dev); > + > + clk_disable(exynos->clk); > + > + return 0; > +} > +static int dwc3_exynos_runtime_resume(struct device *dev) > +{ > + struct dwc3_exynos *exynos = dev_get_drvdata(dev); > + struct platform_device *pdev_dwc = exynos->dwc3; > + struct dwc3 *dwc = NULL; > + > + dwc = platform_get_drvdata(pdev_dwc); > + > + clk_enable(exynos->clk); > + > + if (!dwc) > + return 0; > + > + pm_runtime_get_sync(dwc->usb3_phy->dev); dude, this is wrong :-) look at this: pm_runtime_get() -> dwc3_exynos_runtime_resume() -> pm_runtime_get_sync() -> dwc3_exynos_runtime_resume() -> ... only your clock enalbe should do
Hi Balbi, On Mon, Jan 28, 2013 at 5:17 PM, Felipe Balbi <balbi@ti.com> wrote: > On Mon, Jan 28, 2013 at 05:12:27PM +0530, Vivek Gautam wrote: >> Enabling runtime power management on dwc3-exynos to save >> power and allow its PHY's power to be managed at runtime. >> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> >> --- >> drivers/usb/dwc3/dwc3-exynos.c | 47 ++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 47 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c >> index aae5328..c51e8c1 100644 >> --- a/drivers/usb/dwc3/dwc3-exynos.c >> +++ b/drivers/usb/dwc3/dwc3-exynos.c >> @@ -157,11 +157,15 @@ static int dwc3_exynos_probe(struct platform_device *pdev) >> goto err4; >> } >> >> + pm_runtime_set_active(&pdev->dev); >> + pm_runtime_enable(&pdev->dev); >> + >> return 0; >> >> err4: >> clk_disable(clk); >> clk_put(clk); >> + pm_runtime_disable(&pdev->dev); >> err3: >> platform_device_put(dwc3); >> err1: >> @@ -174,6 +178,8 @@ static int dwc3_exynos_remove(struct platform_device *pdev) >> { >> struct dwc3_exynos *exynos = platform_get_drvdata(pdev); >> >> + pm_runtime_disable(&pdev->dev); >> + >> platform_device_unregister(exynos->dwc3); >> platform_device_unregister(exynos->usb2_phy); >> platform_device_unregister(exynos->usb3_phy); >> @@ -186,6 +192,46 @@ static int dwc3_exynos_remove(struct platform_device *pdev) >> return 0; >> } >> >> +static int dwc3_exynos_runtime_suspend(struct device *dev) >> +{ >> + struct dwc3_exynos *exynos = dev_get_drvdata(dev); >> + struct platform_device *pdev_dwc = exynos->dwc3; >> + struct dwc3 *dwc = NULL; >> + >> + dwc = platform_get_drvdata(pdev_dwc); >> + >> + if (!dwc) >> + return 0; >> + >> + pm_runtime_put_sync(dwc->usb3_phy->dev); >> + >> + clk_disable(exynos->clk); >> + >> + return 0; >> +} >> +static int dwc3_exynos_runtime_resume(struct device *dev) >> +{ >> + struct dwc3_exynos *exynos = dev_get_drvdata(dev); >> + struct platform_device *pdev_dwc = exynos->dwc3; >> + struct dwc3 *dwc = NULL; >> + >> + dwc = platform_get_drvdata(pdev_dwc); >> + >> + clk_enable(exynos->clk); >> + >> + if (!dwc) >> + return 0; >> + >> + pm_runtime_get_sync(dwc->usb3_phy->dev); > > dude, this is wrong :-) > > look at this: > > pm_runtime_get() -> dwc3_exynos_runtime_resume() -> > pm_runtime_get_sync() -> dwc3_exynos_runtime_resume() -> ... > > only your clock enalbe should do > We want to wake up "dwc->usb3_phy" so tried to call pm_runtime_get_sync() with "dwc->usb3_phy->dev". Missing something ? :-(
Hi, On Mon, Jan 28, 2013 at 05:28:30PM +0530, Vivek Gautam wrote: > >> +static int dwc3_exynos_runtime_resume(struct device *dev) > >> +{ > >> + struct dwc3_exynos *exynos = dev_get_drvdata(dev); > >> + struct platform_device *pdev_dwc = exynos->dwc3; > >> + struct dwc3 *dwc = NULL; > >> + > >> + dwc = platform_get_drvdata(pdev_dwc); > >> + > >> + clk_enable(exynos->clk); > >> + > >> + if (!dwc) > >> + return 0; > >> + > >> + pm_runtime_get_sync(dwc->usb3_phy->dev); > > > > dude, this is wrong :-) > > > > look at this: > > > > pm_runtime_get() -> dwc3_exynos_runtime_resume() -> > > pm_runtime_get_sync() -> dwc3_exynos_runtime_resume() -> ... > > > > only your clock enalbe should do > > > > We want to wake up "dwc->usb3_phy" so tried to call pm_runtime_get_sync() > with "dwc->usb3_phy->dev". > Missing something ? :-( oh, my bad. That's the PHY... But we can't really do that for samsung only. It needs to be done generically for the entire dwc3 core driver, and for that we need to introduce usb_phy_autopm_get(), usb_phy_autopm_get_sync() and friends. Then, from dwc_probe() we call: phy = usb_get_phy(); usb_phy_autopm_enable(phy); usb_phy_autopm_get_sync(phy); or something similar ;-) Bottom line, you shouldn't fiddle with phy->dev directly.
On Mon, Jan 28, 2013 at 5:42 PM, Felipe Balbi <balbi@ti.com> wrote: > Hi, > > On Mon, Jan 28, 2013 at 05:28:30PM +0530, Vivek Gautam wrote: >> >> +static int dwc3_exynos_runtime_resume(struct device *dev) >> >> +{ >> >> + struct dwc3_exynos *exynos = dev_get_drvdata(dev); >> >> + struct platform_device *pdev_dwc = exynos->dwc3; >> >> + struct dwc3 *dwc = NULL; >> >> + >> >> + dwc = platform_get_drvdata(pdev_dwc); >> >> + >> >> + clk_enable(exynos->clk); >> >> + >> >> + if (!dwc) >> >> + return 0; >> >> + >> >> + pm_runtime_get_sync(dwc->usb3_phy->dev); >> > >> > dude, this is wrong :-) >> > >> > look at this: >> > >> > pm_runtime_get() -> dwc3_exynos_runtime_resume() -> >> > pm_runtime_get_sync() -> dwc3_exynos_runtime_resume() -> ... >> > >> > only your clock enalbe should do >> > >> >> We want to wake up "dwc->usb3_phy" so tried to call pm_runtime_get_sync() >> with "dwc->usb3_phy->dev". >> Missing something ? :-( > > oh, my bad. That's the PHY... But we can't really do that for samsung > only. It needs to be done generically for the entire dwc3 core driver, > and for that we need to introduce usb_phy_autopm_get(), > usb_phy_autopm_get_sync() and friends. > aah!! Ok. I definitely missed that part. :-( > Then, from dwc_probe() we call: > > phy = usb_get_phy(); > usb_phy_autopm_enable(phy); > usb_phy_autopm_get_sync(phy); > > or something similar ;-) Bottom line, you shouldn't fiddle with phy->dev > directly. > Ok, the core should actually be handling the 'phy' not the glue layers. Right ? Will try putting these helper functions in place and come up with a solution. :-)
On Mon, Jan 28, 2013 at 05:57:04PM +0530, Vivek Gautam wrote: > On Mon, Jan 28, 2013 at 5:42 PM, Felipe Balbi <balbi@ti.com> wrote: > > Hi, > > > > On Mon, Jan 28, 2013 at 05:28:30PM +0530, Vivek Gautam wrote: > >> >> +static int dwc3_exynos_runtime_resume(struct device *dev) > >> >> +{ > >> >> + struct dwc3_exynos *exynos = dev_get_drvdata(dev); > >> >> + struct platform_device *pdev_dwc = exynos->dwc3; > >> >> + struct dwc3 *dwc = NULL; > >> >> + > >> >> + dwc = platform_get_drvdata(pdev_dwc); > >> >> + > >> >> + clk_enable(exynos->clk); > >> >> + > >> >> + if (!dwc) > >> >> + return 0; > >> >> + > >> >> + pm_runtime_get_sync(dwc->usb3_phy->dev); > >> > > >> > dude, this is wrong :-) > >> > > >> > look at this: > >> > > >> > pm_runtime_get() -> dwc3_exynos_runtime_resume() -> > >> > pm_runtime_get_sync() -> dwc3_exynos_runtime_resume() -> ... > >> > > >> > only your clock enalbe should do > >> > > >> > >> We want to wake up "dwc->usb3_phy" so tried to call pm_runtime_get_sync() > >> with "dwc->usb3_phy->dev". > >> Missing something ? :-( > > > > oh, my bad. That's the PHY... But we can't really do that for samsung > > only. It needs to be done generically for the entire dwc3 core driver, > > and for that we need to introduce usb_phy_autopm_get(), > > usb_phy_autopm_get_sync() and friends. > > > > aah!! Ok. I definitely missed that part. :-( > > > Then, from dwc_probe() we call: > > > > phy = usb_get_phy(); > > usb_phy_autopm_enable(phy); > > usb_phy_autopm_get_sync(phy); > > > > or something similar ;-) Bottom line, you shouldn't fiddle with phy->dev > > directly. > > > > Ok, the core should actually be handling the 'phy' not the glue layers. > Right ? that's right, thanks for doing this ;-) > Will try putting these helper functions in place and come up with a > solution. :-) awesome ;-) cheers
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index aae5328..c51e8c1 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c @@ -157,11 +157,15 @@ static int dwc3_exynos_probe(struct platform_device *pdev) goto err4; } + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + return 0; err4: clk_disable(clk); clk_put(clk); + pm_runtime_disable(&pdev->dev); err3: platform_device_put(dwc3); err1: @@ -174,6 +178,8 @@ static int dwc3_exynos_remove(struct platform_device *pdev) { struct dwc3_exynos *exynos = platform_get_drvdata(pdev); + pm_runtime_disable(&pdev->dev); + platform_device_unregister(exynos->dwc3); platform_device_unregister(exynos->usb2_phy); platform_device_unregister(exynos->usb3_phy); @@ -186,6 +192,46 @@ static int dwc3_exynos_remove(struct platform_device *pdev) return 0; } +static int dwc3_exynos_runtime_suspend(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + struct platform_device *pdev_dwc = exynos->dwc3; + struct dwc3 *dwc = NULL; + + dwc = platform_get_drvdata(pdev_dwc); + + if (!dwc) + return 0; + + pm_runtime_put_sync(dwc->usb3_phy->dev); + + clk_disable(exynos->clk); + + return 0; +} +static int dwc3_exynos_runtime_resume(struct device *dev) +{ + struct dwc3_exynos *exynos = dev_get_drvdata(dev); + struct platform_device *pdev_dwc = exynos->dwc3; + struct dwc3 *dwc = NULL; + + dwc = platform_get_drvdata(pdev_dwc); + + clk_enable(exynos->clk); + + if (!dwc) + return 0; + + pm_runtime_get_sync(dwc->usb3_phy->dev); + + return 0; +} + +static const struct dev_pm_ops dwc3_exynos_pm_ops = { + SET_RUNTIME_PM_OPS(dwc3_exynos_runtime_suspend, + dwc3_exynos_runtime_resume, NULL) +}; + #ifdef CONFIG_OF static const struct of_device_id exynos_dwc3_match[] = { { .compatible = "samsung,exynos-dwc3" }, @@ -200,6 +246,7 @@ static struct platform_driver dwc3_exynos_driver = { .driver = { .name = "exynos-dwc3", .of_match_table = of_match_ptr(exynos_dwc3_match), + .pm = &dwc3_exynos_pm_ops, }, };
Enabling runtime power management on dwc3-exynos to save power and allow its PHY's power to be managed at runtime. Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com> --- drivers/usb/dwc3/dwc3-exynos.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-)