Skip to contentSkip to conversation

usb : musb: Using runtime pm apis for musb.

PATCH In review Hema HK 7 participants 26 messages Sep 22, 2010 – Sep 28, 2010 10 messages not in the archive

Subsystems (6)
lore
Share & tools
lore

Hema HK

author
#0 lore raw

PATCH v3 8/9 usb : musb: Using runtime pm apis for musb.

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle mode when usb not used and set it back to no idle and no stndby after wakeup.
For OMAP3 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>

---

 drivers/usb/musb/musb_core.c |   26 ++++++++++++++++++++++++
 drivers/usb/musb/omap2430.c  |   45 ++++++-------------------------------------
 2 files changed, 33 insertions(+), 38 deletions(-)
drivers/usb/musb/musb_core.c +25 -0
Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================
@@ -98,6 +98,7 @@
 #include <linux/kobject.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/pm_runtime.h>
 
 #ifdef	CONFIG_ARM
 #include <mach/hardware.h>
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif
 	spin_unlock_irqrestore(&musb->lock, flags);
 	return 0;
 }
@@ -2443,12 +2447,16 @@ static int musb_resume_noirq(struct devi
 	if (!musb->clock)
 		return 0;
 
+	pm_runtime_get_sync(dev);
+
+#ifndef CONFIG_PM_RUNTIME
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 1);
 	else
 		clk_enable(musb->clock);
 
 	musb_restore_context(musb);
+#endif
 
 	/* for static cmos like DaVinci, register values were preserved
 	 * unless for some reason the whole soc powered down or the USB
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);
+
+	musb_save_context(musb);
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);
+
+	musb_restore_context(musb);
+	return 0;
+}
 static const struct dev_pm_ops musb_dev_pm_ops = {
 	.suspend	= musb_suspend,
 	.resume_noirq	= musb_resume_noirq,
+	.runtime_suspend = musb_runtime_suspend,
+	.runtime_resume	 = musb_runtime_resume,
 };
 
 #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)
drivers/usb/musb/omap2430.c +7 -36

86 lines not on this page · raw message

#1 lore raw

Hi,

Quoted 8 lines · Hema

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle mode when usb not used and set it back to no idle and no stndby after wakeup.
For OMAP3 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Quoted 7 lines
Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>

these two should a separate series, otherwise it's difficult for different maintainers to decide what they need to pick up :-)

Anyways, let me continue;

Quoted 4 lines
drivers/usb/musb/musb_core.c +0 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 10 lines
drivers/usb/musb/musb_core.c +3 -0
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless other archs (blackfin, davinci) would have problems if we remove those.

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2470

Quoted 7 lines
drivers/usb/musb/musb_core.c +3 -0
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

missing lock ??

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2472

Quoted 1 line
drivers/usb/musb/musb_core.c +1 -0
+	musb_save_context(musb);

shouldn't you disable the clock here ?

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2478

Quoted 6 lines
drivers/usb/musb/musb_core.c +6 -0
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

re-enable clock here and missing lock ??

drivers/usb/musb/omap2430.c int __init musb_platform_init(struct mus · line 243

Quoted 7 lines
drivers/usb/musb/omap2430.c +1 -2
@@ -253,15 +240,13 @@ int __init musb_platform_init(struct mus
 void musb_platform_save_context(struct musb *musb,
 		struct musb_context_registers *musb_context)
 {
-	musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY);
+	musb_writel(musb->mregs, OTG_FORCESTDBY, ENABLEFORCE);

not really saving context anymore :-p but that's ok, we will need change all that mess anyway.

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -1
@@ -277,37 +262,23 @@ static int musb_platform_suspend(struct
 	l |= ENABLEFORCE;	/* enable MSTANDBY */
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 290

Quoted 10 lines
drivers/usb/musb/omap2430.c +0 -8
-	l |= ENABLEWAKEUP;	/* enable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
 	otg_set_suspend(musb->xceiv, 1);
 
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 0);
-	else
-		clk_disable(musb->clock);
-

should you pm_runtime_put_sync(dev) here ??

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 276

Quoted 10 lines
drivers/usb/musb/omap2430.c +1 -0
 	return 0;
 }
 
 static int musb_platform_resume(struct musb *musb)
 {
 	u32 l;
+	struct device *dev = musb->controller;
 
 	if (!musb->clock)
 		return 0;

you're not touching clock anymore, this can go too.

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 281

Quoted 12 lines
drivers/usb/musb/omap2430.c +2 -8
 	otg_set_suspend(musb->xceiv, 0);
 
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 1);
-	else
-		clk_enable(musb->clock);
-
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);

seems like you're going to call pm_runtime_get_sync twice ? once here and another time on musb_resume_noirq(). why ?

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 20100923063604.GE2563-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#3 lore raw
Quoted 33 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Thursday, September 23, 2010 12:06 PM
To: Kalliguddi, Hema
Cc: [email protected]; [email protected]; Basak, Partha; Balbi, Felipe; Tony Lindgren; Kevin Hilman;
Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle mode

when usb not used

Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 9 lines

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
Quoted 3 lines

these two should a separate series, otherwise it's difficult for different maintainers to decide what they need to pick up :-)

I don't mind

Quoted 11 lines

Anyways, let me continue;

Quoted 9 lines
drivers/usb/musb/musb_core.c +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 10 lines

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
drivers/usb/musb/musb_core.c +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless other archs
(blackfin, davinci) would have problems if we remove those.

If we remove this then how the clock will be enabled for the other platforms where runtime pm is not used?

Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2470

Quoted 7 lines
drivers/usb/musb/musb_core.c +3 -0
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

missing lock ??

I am wondering whether we need the lock here? As these functions are supposed to be Called by runtime pm framework only.

Quoted 5 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2472

Quoted 2 lines
drivers/usb/musb/musb_core.c +1 -0
+	musb_save_context(musb);

shouldn't you disable the clock here ?

This hook is called when we call pm_runtime_put_sync api which takes care of disabling clocks and configuring the sysconfig register.

Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2478

Quoted 6 lines
drivers/usb/musb/musb_core.c +6 -0
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

re-enable clock here and missing lock ??

Not required. This hook gets aclled when pm_runtime_get_sync is called by the driver Which will take care of enabling the clock.

I am just wondering whether we need the lock here? As these functions are supposed to be Called by runtime pm framework only.

Quoted 6 lines

drivers/usb/musb/omap2430.c int __init musb_platform_init(struct mus · line 256

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -1
@@ -253,15 +240,13 @@ int __init musb_platform_init(struct mus
 void musb_platform_save_context(struct musb *musb,
 		struct musb_context_registers *musb_context)
 {
-	musb_context->otg_sysconfig = musb_readl(musb->mregs, 

OTG_SYSCONFIG);

Quoted 8 lines

Review int __init musb_platform_init(struct mus · line 257

Quoted 1 line
(quoted diff) +0 -1
-	musb_context->otg_forcestandby = 

musb_readl(musb->mregs, OTG_FORCESTDBY);

drivers/usb/musb/omap2430.c int __init musb_platform_init(struct mus · line 243

Quoted 1 line
drivers/usb/musb/omap2430.c +1 -0
+	musb_writel(musb->mregs, OTG_FORCESTDBY, ENABLEFORCE);

not really saving context anymore :-p but that's ok, we will need change
all that mess anyway.

Yehh :-)

Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/omap2430.c +0 -4
@@ -277,37 +262,23 @@ static int musb_platform_suspend(struct
 	l |= ENABLEFORCE;	/* enable MSTANDBY */
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l |= ENABLEWAKEUP;	/* enable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
 	otg_set_suspend(musb->xceiv, 1);
 
Quoted 8 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 290

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -5
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 0);
-	else
-		clk_disable(musb->clock);
-

should you pm_runtime_put_sync(dev) here ??

Calling pm_runtime_put_sync leading to crash as
driver_detach calls __device_release_driver which intern calls pm_runtime_put_sync function, with this the musb clocks are already disabled And usecount is 0.

Quoted 8 lines
Quoted 8 lines
drivers/usb/musb/omap2430.c +1 -0
 	return 0;
 }
 
 static int musb_platform_resume(struct musb *musb)
 {
 	u32 l;
+	struct device *dev = musb->controller;
 
Quoted 5 lines

Review static int musb_platform_suspend(struct · line 276

Quoted 2 lines
(quoted diff) +0 -0
 	if (!musb->clock)
 		return 0;

you're not touching clock anymore, this can go too.

Yes. This can be removed.

Quoted 15 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 281

Quoted 12 lines
drivers/usb/musb/omap2430.c +2 -8
 	otg_set_suspend(musb->xceiv, 0);
 
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 1);
-	else
-		clk_enable(musb->clock);
-
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);

seems like you're going to call pm_runtime_get_sync twice ? once here and another time on musb_resume_noirq(). why ?

pm_runtime_get_sync is called in the musb_platform_resume function during the initialization of the driver. Where we need to enable the clocks and put the sysconfig registers to known configurations.

pm_runtime_get_sync is called in musb_resume_noirq() to re-enable the cloks and configure the sysconfig because the clocks are disabled in musb_suspend() by calling pm_runtime_put_sync() during global suspend/resume.

Quoted 4 lines
Signature · 3 lines
-- 
balbi
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): E0D41E29EB0DAC4E9F3FF173962E9E94027863D9E5-/tLxBxkBPtCIQmiDNMet8wC/[email protected]

#5 lore raw
Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kalliguddi, Hema
Sent: Thursday, September 23, 2010 1:21 PM
To: Balbi, Felipe
Cc: [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Kevin Hilman; Cousson, Benoit;
Paul Walmsley
Subject: RE: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Quoted 8 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Thursday, September 23, 2010 12:06 PM
To: Kalliguddi, Hema
Cc: [email protected]; [email protected]; Basak, Partha; Balbi, Felipe; Tony Lindgren; Kevin Hilman;
Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis

for musb.

Quoted 23 lines

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle mode

when usb not used

Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 9 lines

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

Cc Felipe Balbi <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Cousson, Benoit <[email protected]>
Cc Paul Walmsley <[email protected]>
Quoted 4 lines
Quoted 3 lines

these two should a separate series, otherwise it's difficult for different maintainers to decide what they need to pick up :-)

I don't mind

I mean I don't mind posting them as separate series. But this will have still the driver And architecture files changes.

Quoted 148 lines
Quoted 11 lines

Anyways, let me continue;

Quoted 9 lines
drivers/usb/musb/musb_core.c +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 10 lines

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
drivers/usb/musb/musb_core.c +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless other archs
(blackfin, davinci) would have problems if we remove those.

If we remove this then how the clock will be enabled for the other platforms where runtime
pm is not used?

Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2470

Quoted 7 lines
drivers/usb/musb/musb_core.c +3 -0
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

missing lock ??

I am wondering whether we need the lock here? As these functions are supposed to be
Called by runtime pm framework only.

Quoted 5 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2472

Quoted 2 lines
drivers/usb/musb/musb_core.c +1 -0
+	musb_save_context(musb);

shouldn't you disable the clock here ?

This hook is called when we call pm_runtime_put_sync api which takes care of disabling
clocks and configuring the sysconfig register.

Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2478

Quoted 6 lines
drivers/usb/musb/musb_core.c +6 -0
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

re-enable clock here and missing lock ??

Not required. This hook gets aclled when pm_runtime_get_sync is called by the driver
Which will take care of enabling the clock.

I am just wondering whether we need the lock here? As these functions are supposed to be
Called by runtime pm framework only.

Quoted 6 lines

drivers/usb/musb/omap2430.c int __init musb_platform_init(struct mus · line 256

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -1
@@ -253,15 +240,13 @@ int __init musb_platform_init(struct mus
 void musb_platform_save_context(struct musb *musb,
 		struct musb_context_registers *musb_context)
 {
-	musb_context->otg_sysconfig = musb_readl(musb->mregs, 

OTG_SYSCONFIG);

Quoted 8 lines

Review int __init musb_platform_init(struct mus · line 257

Quoted 1 line
(quoted diff) +0 -1
-	musb_context->otg_forcestandby = 

musb_readl(musb->mregs, OTG_FORCESTDBY);

drivers/usb/musb/omap2430.c int __init musb_platform_init(struct mus · line 243

Quoted 1 line
drivers/usb/musb/omap2430.c +1 -0
+	musb_writel(musb->mregs, OTG_FORCESTDBY, ENABLEFORCE);

not really saving context anymore :-p but that's ok, we will need change
all that mess anyway.

Yehh :-)

Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/omap2430.c +0 -4
@@ -277,37 +262,23 @@ static int musb_platform_suspend(struct
 	l |= ENABLEFORCE;	/* enable MSTANDBY */
 	musb_writel(musb->mregs, OTG_FORCESTDBY, l);
 
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l |= ENABLEWAKEUP;	/* enable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
-
 	otg_set_suspend(musb->xceiv, 1);
 
Quoted 8 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 290

Quoted 5 lines
drivers/usb/musb/omap2430.c +0 -5
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 0);
-	else
-		clk_disable(musb->clock);
-

should you pm_runtime_put_sync(dev) here ??

Calling pm_runtime_put_sync leading to crash as driver_detach calls __device_release_driver which intern calls pm_runtime_put_sync function, with this the musb clocks are already disabled
And usecount is 0.

Quoted 8 lines
Quoted 8 lines
drivers/usb/musb/omap2430.c +1 -0
 	return 0;
 }
 
 static int musb_platform_resume(struct musb *musb)
 {
 	u32 l;
+	struct device *dev = musb->controller;
 
Quoted 5 lines

Review static int musb_platform_suspend(struct · line 276

Quoted 2 lines
(quoted diff) +0 -0
 	if (!musb->clock)
 		return 0;

you're not touching clock anymore, this can go too.

Yes. This can be removed.

Quoted 15 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 281

Quoted 12 lines
drivers/usb/musb/omap2430.c +2 -8
 	otg_set_suspend(musb->xceiv, 0);
 
-	if (musb->set_clock)
-		musb->set_clock(musb->clock, 1);
-	else
-		clk_enable(musb->clock);
-
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);

seems like you're going to call pm_runtime_get_sync twice ? once here and another time on musb_resume_noirq(). why ?

pm_runtime_get_sync is called in the musb_platform_resume function during the initialization of the driver. Where we need to enable the clocks
and put the sysconfig registers to known configurations.

pm_runtime_get_sync is called in musb_resume_noirq() to re-enable the cloks
and configure the sysconfig because the clocks are disabled in musb_suspend()
by calling pm_runtime_put_sync() during global suspend/resume.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Signature · 2 lines
balbi
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to Kalliguddi, Hema

Hi,

Quoted 4 lines · Hema
Quoted 3 lines

these two should a separate series, otherwise it's difficult for different maintainers to decide what they need to pick up :-)

I don't mind

if you're re-sending already, please do split :-)

Quoted 6 lines
Quoted 4 lines

I would rather remove these, adding ifdefs is bad :-( Unless other archs
(blackfin, davinci) would have problems if we remove those.

If we remove this then how the clock will be enabled for the other platforms where runtime pm is not used?

yeah, let's see what other archs will say...

Quoted 11 lines
Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2470

Quoted 7 lines
drivers/usb/musb/musb_core.c +3 -0
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

missing lock ??

I am wondering whether we need the lock here? As these functions are supposed to be Called by runtime pm framework only.

is that done with IRQs disabled ?

Quoted 6 lines
Quoted 4 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2472

Quoted 1 line
drivers/usb/musb/musb_core.c +1 -0
+	musb_save_context(musb);

shouldn't you disable the clock here ?

This hook is called when we call pm_runtime_put_sync api which takes care of disabling clocks and configuring the sysconfig register.

but those are methods you have provided, right ? I mean, in the end it'll call musb_runtime_suspend() and musb_runtime_resume() ?? Or am I missing something ?

Quoted 6 lines
Quoted 2 lines

should you pm_runtime_put_sync(dev) here ??

Calling pm_runtime_put_sync leading to crash as
driver_detach calls __device_release_driver which intern calls pm_runtime_put_sync function, with this the musb clocks are already disabled And usecount is 0.

looks weird though, I'll have to read that code more carefully when you send another version.

Quoted 9 lines
Quoted 8 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 281

Quoted 5 lines
drivers/usb/musb/omap2430.c +2 -3
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);

seems like you're going to call pm_runtime_get_sync twice ? once here and another time on musb_resume_noirq(). why ?

Quoted 7 lines

pm_runtime_get_sync is called in the musb_platform_resume function during the initialization of the driver. Where we need to enable the clocks and put the sysconfig registers to known configurations.

pm_runtime_get_sync is called in musb_resume_noirq() to re-enable the cloks and configure the sysconfig because the clocks are disabled in musb_suspend() by calling pm_runtime_put_sync() during global suspend/resume.

hmm, also weird logic. I'll wait for next version and read that code with more care.

Signature · 1 line
balbi
#7 lore raw

Hi,

Quoted 11 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Thursday, September 23, 2010 2:22 PM
To: Kalliguddi, Hema
Cc: Balbi, Felipe; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Hi,

Quoted 8 lines
Quoted 4 lines · Hema
Quoted 3 lines

these two should a separate series, otherwise it's difficult for different maintainers to decide what they need to pick up :-)

I don't mind

if you're re-sending already, please do split :-)

Ok. I will do that.

Quoted 18 lines
Quoted 6 lines
Quoted 4 lines

I would rather remove these, adding ifdefs is bad :-( Unless other archs
(blackfin, davinci) would have problems if we remove those.

If we remove this then how the clock will be enabled for the other platforms where runtime pm is not used?

yeah, let's see what other archs will say...

Quoted 9 lines
Quoted 9 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2470

Quoted 7 lines
drivers/usb/musb/musb_core.c +3 -0
@@ -2457,9 +2465,26 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	struct musb	*musb = dev_to_musb(dev);

missing lock ??

Quoted 5 lines
Quoted 1 line

I am wondering whether we need the lock here? As these

functions are supposed to be

Quoted 1 line

Called by runtime pm framework only.

is that done with IRQs disabled ?

At high level it was looking like the irqs are disabled by looking below function.

int pm_runtime_resume(struct device *dev)

{
	int retval;

	spin_lock_irq(&dev->power.lock);
	retval = __pm_runtime_resume(dev, false);
	spin_unlock_irq(&dev->power.lock);

	return retval;
}

But after going through further details, before calling the driver's pm->runtime_suspend/resume functions the irqs are enabled back. So we need to have lock.

Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

drivers/usb/musb/musb_core.c static int musb_resume_noirq(struct devi · line 2472

Quoted 2 lines
drivers/usb/musb/musb_core.c +1 -0
+	musb_save_context(musb);

shouldn't you disable the clock here ?

This hook is called when we call pm_runtime_put_sync api which takes care of disabling clocks and configuring the sysconfig register.

but those are methods you have provided, right ? I mean, in the end it'll call musb_runtime_suspend() and musb_runtime_resume() ?? Or am I missing something ?

The flow when you call pm_runtime_put_sync is as below.

1. Calls the driver's runtime_suspend hook
2. Configures the sysconfig
3. Disable the clocks.

The driver's runtime_suspend/resume hooks are provided to prepare the Device for the idle incase if there is something to be done. For Example you can use it for storing the context and restoring the context. Since framework is taking of diabling the clock when runtime pm funtions are called so there is no need of disabling the clock here.

Quoted 12 lines
Quoted 6 lines
Quoted 3 lines

should you pm_runtime_put_sync(dev) here ??

Calling pm_runtime_put_sync leading to crash as driver_detach calls __device_release_driver which intern calls pm_runtime_put_sync function, with this the musb clocks are

already disabled

Quoted 1 line

And usecount is 0.

looks weird though, I'll have to read that code more carefully when you send another version.

OK.

Quoted 14 lines
Quoted 11 lines
Quoted 8 lines

drivers/usb/musb/omap2430.c static int musb_platform_suspend(struct · line 281

Quoted 5 lines
drivers/usb/musb/omap2430.c +2 -3
-	l = musb_readl(musb->mregs, OTG_SYSCONFIG);
-	l &= ~ENABLEWAKEUP;	/* disable wakeup */
-	musb_writel(musb->mregs, OTG_SYSCONFIG, l);
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);

seems like you're going to call pm_runtime_get_sync twice ? once here and another time on musb_resume_noirq(). why ?

pm_runtime_get_sync is called in the musb_platform_resume function during the initialization of the driver. Where we need to

enable the clocks

Quoted 2 lines

and put the sysconfig registers to known configurations.

Quoted 9 lines
Quoted 1 line

pm_runtime_get_sync is called in musb_resume_noirq() to

re-enable the cloks

Quoted 1 line

and configure the sysconfig because the clocks are disabled

in musb_suspend()

Quoted 1 line

by calling pm_runtime_put_sync() during global suspend/resume.

hmm, also weird logic. I'll wait for next version and read that code with more care.

musb_platform_resume functions gets executed when the driver is loaded. Clock hs to be enabled before accessing the registers so calling the pm_runtime_get_sync api to do the same.

When there is global suspend initiated, driver's pm_ops functions Musb_suspend api is called and the clocks are disabled.
Now when the system resumes after wakeup,
Musb_resume_noirq is called, now need to re-enable the clocks so calling pm_runtime_get_sync function.

Do you see wny problem with it?

Quoted 3 lines
Signature · 1 line
balbi
#8 lore raw

Hi,

Quoted 7 lines · Hema

When there is global suspend initiated, driver's pm_ops functions Musb_suspend api is called and the clocks are disabled.
Now when the system resumes after wakeup,
Musb_resume_noirq is called, now need to re-enable the clocks so calling pm_runtime_get_sync function.

Do you see wny problem with it?

ok, now I get it. It's just that platform_suspend/resume() are actually only used on platform_init/exit() :-p

After we apply this, I'll queue patches to fix up that goofy method name.

Signature · 1 line
balbi
#9 lore raw
In reply to a message not in the archive
Quoted 10 lines · Felipe Balbi

Hi,

Quoted 7 lines · Hema

Calling runtime pm APIs pm_runtime_put_sync() and pm_runtime_get_sync() for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle mode when usb not used and set it back to no idle and no stndby after wakeup.
For OMAP3 auto idle bit has to be disabled because of the errata.So using HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

[...]

Quoted 9 lines
Quoted 9 lines
drivers/usb/musb/musb_core.c +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 8 lines

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
drivers/usb/musb/musb_core.c +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless other archs (blackfin, davinci) would have problems if we remove those.

I didn't like these #ifdefs either, but davinci doesn't have runtime PM, and I don't think blackfin does either.

But, rather than the ifdef here, this could be done with different pointers in struct dev_pm_ops based on the arch.

Also, this shouldn't be based on CONFIG_PM_RUNTIME, but rather on the arch. We can still enable runtime PM on davinci for other subsystems (PCI, USB core, etc.) but not have it supported for on-chip devices.

Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 52 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:00 PM
To: Balbi, Felipe
Cc: Kalliguddi, Hema; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Quoted 4 lines · Felipe Balbi

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines
Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle

mode when usb not used

Quoted 2 lines
Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 1 line
Quoted 1 line

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

[...]

Quoted 9 lines
Quoted 9 lines
drivers/usb/musb/musb_core.c +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 7 lines

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
drivers/usb/musb/musb_core.c +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless

other archs

Quoted 1 line

(blackfin, davinci) would have problems if we remove those.

I didn't like these #ifdefs either, but davinci doesn't have runtime PM,
and I don't think blackfin does either.

Quoted 7 lines

But, rather than the ifdef here, this could be done with different pointers in struct dev_pm_ops based on the arch.

Also, this shouldn't be based on CONFIG_PM_RUNTIME, but rather on the arch. We can still enable runtime PM on davinci for other subsystems (PCI, USB core, etc.) but not have it supported for on-chip devices.

Is it a good idea to use the musb->set_clock function pointer for OMAP architure and call the runtime pm apis from this function defined in the usb platform driver(omap2430)

Quoted 2 lines

Kevin
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw
Quoted 55 lines · Hema
Quoted 55 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:00 PM
To: Balbi, Felipe
Cc: Kalliguddi, Hema; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Quoted 4 lines · Felipe Balbi

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines
Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle

mode when usb not used

Quoted 2 lines
Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 1 line
Quoted 1 line

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

[...]

Quoted 9 lines
Quoted 9 lines
drivers/usb/musb/musb_core.c +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 7 lines

drivers/usb/musb/musb_core.c static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
drivers/usb/musb/musb_core.c +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless

other archs

Quoted 1 line

(blackfin, davinci) would have problems if we remove those.

I didn't like these #ifdefs either, but davinci doesn't have runtime PM,
and I don't think blackfin does either.

But, rather than the ifdef here, this could be done with different pointers in struct dev_pm_ops based on the arch.

Quoted 6 lines
Quoted 4 lines

Also, this shouldn't be based on CONFIG_PM_RUNTIME, but rather on the arch. We can still enable runtime PM on davinci for other subsystems (PCI, USB core, etc.) but not have it supported for on-chip devices.

Is it a good idea to use the musb->set_clock function pointer for OMAP architure and call the runtime pm apis from this function defined in the usb platform driver(omap2430)

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Kevin

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw
Quoted 74 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 11:04 PM
To: Kalliguddi, Hema
Cc: Balbi, Felipe; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Quoted 10 lines · Hema
Quoted 10 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:00 PM
To: Balbi, Felipe
Cc: Kalliguddi, Hema; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm

apis for musb.

Quoted 42 lines
Quoted 42 lines
Quoted 4 lines · Felipe Balbi

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines
Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle

mode when usb not used

Quoted 2 lines
Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 1 line
Quoted 1 line

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

[...]

Quoted 9 lines
Quoted 9 lines
(quoted diff) +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 7 lines

Review static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
(quoted diff) +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless

other archs

Quoted 1 line

(blackfin, davinci) would have problems if we remove those.

I didn't like these #ifdefs either, but davinci doesn't have runtime PM,
and I don't think blackfin does either.

Quoted 8 lines
Quoted 7 lines

But, rather than the ifdef here, this could be done with different pointers in struct dev_pm_ops based on the arch.

Also, this shouldn't be based on CONFIG_PM_RUNTIME, but rather on the arch. We can still enable runtime PM on davinci for other subsystems (PCI, USB core, etc.) but not have it supported for on-chip devices.

Is it a good idea to use the musb->set_clock function

Quoted 9 lines

pointer for OMAP architure and

Quoted 1 line

call the runtime pm apis from this function defined in the

usb platform driver(omap2430)

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

I think the set_clock function was used for setting the platform specific clocks for different architecture. Anyway we need this hook or some other hook once we start handling the optional clocks and internal phy clocks for musb. Since this is already exists I thought of making use of it instand of adding another hook.

Felipe,
What do you say?

~Hema

Quoted 3 lines

Kevin

--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

Hi,

Quoted 5 lines · Hema
Quoted 5 lines

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Quoted 7 lines

I think the set_clock function was used for setting the platform specific clocks for different architecture. Anyway we need this hook or some other hook once we start handling the optional clocks and internal phy clocks for musb. Since this is already exists I thought of making use of it instand of adding another hook.

Felipe, What do you say?

Ideally we will get rid of those. It's only a matter of getting DaVinci to fully support clkdev. We should not have wrappers on top of clk framework neither pass down clock names as platform_data to driver, that's insane.

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 20100924084344.GJ8365-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#17 lore raw

Felipe,

Quoted 25 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Friday, September 24, 2010 2:14 PM
To: Kalliguddi, Hema
Cc: Kevin Hilman; Balbi, Felipe; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Hi,

Quoted 7 lines · Hema
Quoted 5 lines

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

I think the set_clock function was used for setting the platform specific clocks for different architecture. Anyway we need

this hook or

Quoted 1 line

some other hook once we start handling the optional clocks

and internal

Quoted 3 lines

phy clocks for musb. Since this is already exists I thought of making use of it instand of adding another hook.

Quoted 7 lines
Quoted 1 line

Felipe, What do you say?

Ideally we will get rid of those. It's only a matter of getting DaVinci to fully support clkdev. We should not have wrappers on top of clk framework neither pass down clock names as platform_data to driver, that's insane.

I think we will need to have some hooks for handling the clocks for different platform as each platforms will have different clocks.
The way we are using set_clock is not the wrapper on top clock frameowrk, it is a platform hook to enabling the clocks which still uses the clock framework.

~Hema

Quoted 3 lines
Signature · 2 lines
balbi
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#18 lore raw
Quoted 50 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kalliguddi, Hema
Sent: Friday, September 24, 2010 2:23 PM
To: Balbi, Felipe
Cc: Kevin Hilman; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: RE: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Felipe,

Quoted 8 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Friday, September 24, 2010 2:14 PM
To: Kalliguddi, Hema
Cc: Kevin Hilman; Balbi, Felipe; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis

for musb.

Quoted 6 lines

Hi,

Quoted 2 lines · Hema
Quoted 2 lines

I guess that's Felipe's call, but I don't like that option.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

I think the set_clock function was used for setting the platform specific clocks for different architecture. Anyway we need

this hook or

Quoted 1 line

some other hook once we start handling the optional clocks

and internal

Quoted 1 line

phy clocks for musb. Since this is already exists I thought

of making

Quoted 5 lines
Quoted 3 lines

use of it instand of adding another hook.

Felipe, What do you say?

Ideally we will get rid of those. It's only a matter of

getting DaVinci

Quoted 4 lines

to fully support clkdev. We should not have wrappers on top of clk framework neither pass down clock names as platform_data to driver, that's insane.

Quoted 9 lines

I think we will need to have some hooks for handling the clocks for different platform as each platforms will have different clocks. The way we are using set_clock is not the wrapper on top clock frameowrk,
it is a platform hook to enabling the clocks which still uses the clock framework.

~Hema

I just noticed one more think in the code.
there are suspend/resume function pointers in platform_driver structure.
Why can't we use these for platform specific operations like enable/disable clocks, context save/restore?

Quoted 7 lines
Quoted 3 lines
Signature · 2 lines
balbi
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): E0D41E29EB0DAC4E9F3FF173962E9E94027863E128-/tLxBxkBPtCIQmiDNMet8wC/[email protected]

#20 lore raw

Hi,

Quoted 4 lines · Hema

I just noticed one more think in the code. there are suspend/resume function pointers in platform_driver structure. Why can't we use these for platform specific operations like enable/disable clocks, context save/restore?

For doing that properly, we first need to split the HW glue layer to another parent platform_device/driver. Otherwise, we will have all sorts of crazy stuff to change the function pointer depending on the ARCH.

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#21 lore raw

Hi,

Quoted 14 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Friday, September 24, 2010 4:27 PM
To: Kalliguddi, Hema
Cc: Balbi, Felipe; Kevin Hilman; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Hi,

Quoted 2 lines · Hema

I just noticed one more think in the code. there are suspend/resume function pointers in platform_driver structure. Why can't we

Quoted 9 lines

use these

Quoted 2 lines

for platform specific operations like enable/disable clocks, context save/restore?

For doing that properly, we first need to split the HW glue layer to another parent platform_device/driver. Otherwise, we will have all sorts
of crazy stuff to change the function pointer depending on the ARCH.

Agreed,

then for now I can think of using set_clok platform function to call the runtime pm apis, Is there any alternative you are thinking of?

Quoted 3 lines
Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): E0D41E29EB0DAC4E9F3FF173962E9E94027863E212-/tLxBxkBPtCIQmiDNMet8wC/[email protected]

#23 lore raw

Hi,

Quoted 2 lines · Hema

then for now I can think of using set_clok platform function to call the runtime pm apis, Is there any alternative you are thinking of?

how about not pushing a patch which isn't the best way to solve the problem in the first place ? .38 isn't that far away. If we can get all those cleanups by that time, converting to pm_runtime will be a lot simpler and local change.

I mean, if we keep as is for another major release cycle, it won't cause problems to anyone, right ? So it's better to get things right from the beginning and avoid lots of re-work later.

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100924110433.GW8365-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#25 lore raw

Hi,

Quoted 20 lines

-----Original Message-----
From: Balbi, Felipe
Sent: Friday, September 24, 2010 4:35 PM
To: Kalliguddi, Hema
Cc: Balbi, Felipe; Kevin Hilman; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Hi,

Quoted 2 lines · Hema

then for now I can think of using set_clok platform function to call the runtime pm apis, Is there any alternative you are thinking of?

how about not pushing a patch which isn't the best way to solve the problem in the first place ? .38 isn't that far away. If we can get all those cleanups by that time, converting to pm_runtime will be a lot simpler and local change.

Quoted 5 lines

I mean, if we keep as is for another major release cycle, it won't cause
problems to anyone, right ? So it's better to get things right from the beginning and avoid lots of re-work later.

Agreed that it is better to get the things done in the best way from the beginning.
This may not be the best solution for converting usb to use runtime pm apis, but given the current mainline code, without the cleanup, do not have other alternatives.
Do you think the other patches are in good shape to merge after fixing the comments
I got from Kevin and Benoit and you?

Kevin,

Do you have any other comments on the hwmod patches other than runtime pm patch and offmode patch? Do you accept the hwmod patches without the runtime pm conversion?

Quoted 3 lines
Signature · 2 lines
balbi
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw
In reply to a message not in the archive

Hi,

Quoted 4 lines · Kevin Hilman

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100924110129.GV8365-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#28 lore raw

Hello.

Quoted 7 lines · Felipe Balbi
Quoted 4 lines

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

Sure. But DaVinci doesn't use ->set_clock().

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#29 lore raw
Quoted 6 lines · Sergei Shtylyov

Hello.

Quoted 1 line · Felipe Balbi
Quoted 1 line

I guess that's Felipe's call, but I don't like that option.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

   Sure. But DaVinci doesn't use ->set_clock().

Ok, so seems like no-one is actually using that. We can already start patching to remove that thing, later on, we need to remove the clock name via platform_data.

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 20100927060738.GB8365-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org

#31 lore raw

Hello.

Quoted 11 lines · Felipe Balbi
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

Sure. But DaVinci doesn't use ->set_clock().

Ok, so seems like no-one is actually using that.

I thought OMAP does... but I'm seeing now that it doesn't.

Quoted 3 lines

We can already start
patching to remove that thing, later on, we need to remove the clock name via platform_data.

As I've said already, there are cases where two clocks is needed by MUSB
(like AM3517) or where USB 2.0 clock is also needed by the OHCI driver (DA8xx), hence the name seems needed still...

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#32 lore raw
Quoted 18 lines · Sergei Shtylyov

Hello.

Quoted 11 lines · Felipe Balbi
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

Sure. But DaVinci doesn't use ->set_clock().

Ok, so seems like no-one is actually using that.

I thought OMAP does... but I'm seeing now that it doesn't.

Quoted 7 lines
Quoted 3 lines

We can already start
patching to remove that thing, later on, we need to remove the clock name via platform_data.

As I've said already, there are cases where two clocks is needed by MUSB
(like AM3517) or where USB 2.0 clock is also needed by the OHCI driver (DA8xx), hence the name seems needed still...

we can all go through all that discussion with Russell again and will come down to the same conclusion: clock names should never be needed.

Signature · 1 line
balbi
#33 lore raw
In reply to Felipe Balbi
Quoted 10 lines · Felipe Balbi

Hi,

Quoted 4 lines · Kevin Hilman

I guess that's Felipe's call, but I don't like that option.

I think it's cleaner to have the ->set_clock hook be a noop on OMAP and the runtime hooks be noops on the other platforms.

Agreed. We should focus on removing ->set_clock for .38 actually. Is DaVinci already using clkdev, Kevin ?

Yes, it was one of the first to convert.

Kevin

#34 lore raw
In reply to Kalliguddi, Hema

Hi,

Quoted 65 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Kalliguddi, Hema
Sent: Thursday, September 23, 2010 9:10 PM
To: Kevin Hilman; Balbi, Felipe
Cc: [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: RE: [PATCH 8/9 v3] usb : musb: Using runtime pm apis for musb.

Quoted 8 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, September 23, 2010 9:00 PM
To: Balbi, Felipe
Cc: Kalliguddi, Hema; [email protected]; [email protected]; Basak, Partha; Tony Lindgren; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 8/9 v3] usb : musb: Using runtime pm apis

for musb.

Quoted 45 lines
Quoted 4 lines · Felipe Balbi

Hi,

Quoted 1 line · Hema

Calling runtime pm APIs pm_runtime_put_sync() and

pm_runtime_get_sync()

Quoted 3 lines
Quoted 3 lines

for enabling/disabling the clocks,sysconfig settings.

Also need to put the USB in force standby and force idle

mode when usb not used

Quoted 2 lines
Quoted 2 lines

and set it back to no idle and no stndby after wakeup. For OMAP3 auto idle bit has to be disabled because of the

errata.So using

Quoted 1 line
Quoted 1 line

HWMOD_NO_OCP_AUTOIDLE flag for OMAP3430.

[...]

Quoted 9 lines
Quoted 9 lines
(quoted diff) +2 -0
@@ -2424,13 +2425,16 @@ static int musb_suspend(struct device *d
 		 * they will even be wakeup-enabled.
 		 */
 	}
+	pm_runtime_put_sync(dev);
 
+#ifndef CONFIG_PM_RUNTIME
 	musb_save_context(musb);
 
Quoted 7 lines

Review static int musb_suspend(struct device *d · line 2437

Quoted 5 lines
(quoted diff) +1 -0
 	if (musb->set_clock)
 		musb->set_clock(musb->clock, 0);
 	else
 		clk_disable(musb->clock);
+#endif

I would rather remove these, adding ifdefs is bad :-( Unless

other archs

Quoted 1 line

(blackfin, davinci) would have problems if we remove those.

I didn't like these #ifdefs either, but davinci doesn't have runtime PM,
and I don't think blackfin does either.

But, rather than the ifdef here, this could be done with different pointers in struct dev_pm_ops based on the arch.

Quoted 10 lines
Quoted 4 lines

Also, this shouldn't be based on CONFIG_PM_RUNTIME, but rather on the arch. We can still enable runtime PM on davinci for other subsystems (PCI, USB core, etc.) but not have it supported for on-chip devices.

Is it a good idea to use the musb->set_clock function pointer for OMAP architure and
call the runtime pm apis from this function defined in the usb platform driver(omap2430)

Quoted 1 line

Kevin

Here is the patch which is making use of already existing platform set_clock functions pointer. With this we don't need to use #ifdefs.
If it looks good I will post it again along with series.

 arch/arm/mach-omap2/usb-musb.c |   18 +++++++++++++++++
 drivers/usb/musb/musb_core.c   |   12 +++++++++++
 drivers/usb/musb/omap2430.c    |   43 ++++++++++++++---------------------------
 3 files changed, 45 insertions(+), 28 deletions(-)
arch/arm/mach-omap2/usb-musb.c +18 -0
Index: linux-omap-pm/arch/arm/mach-omap2/usb-musb.c
===================================================================
@@ -25,6 +25,7 @@
 #include <linux/io.h>
 
 #include <linux/usb/musb.h>
+#include <linux/pm_runtime.h>
 
 #include <asm/sizes.h>
 
@@ -46,6 +47,7 @@ static struct platform_device dummy_pdev
 
 static void __iomem *otg_base;
 static struct clk *otg_clk;
+static struct omap_hwmod *oh_p;
 
 static void __init usb_musb_pm_init(void)
 {
@@ -129,6 +131,20 @@ static struct omap_device_pm_latency oma
 	},
 };
 
+void omap_set_clock(struct clk *clock , int is_on)
+{
+
+	struct omap_hwmod *oh = oh_p;
+	struct omap_device *od = oh->od;
+	struct platform_device *pdev = &od->pdev;
+	struct device *dev = &pdev->dev;
+
+	if(is_on)
+		pm_runtime_get_sync(dev);
+	else
+		pm_runtime_put_sync(dev);
+}
+
 void __init usb_musb_init(struct omap_musb_board_data *board_data)
 {
 	struct omap_hwmod *oh;
@@ -154,8 +170,10 @@ void __init usb_musb_init(struct omap_mu
 	musb_plat.power = board_data->power >> 1;
 	musb_plat.mode = board_data->mode;
 	musb_plat.extvbus = board_data->extvbus;
+	musb_plat.set_clock = omap_set_clock;
 
 	pdata = &musb_plat;
+	oh_p = oh;
 
 	od = omap_device_build(name, bus_id, oh, pdata,
 			       sizeof(*pdata), omap_musb_latency,
drivers/usb/musb/musb_core.c +12 -0
Index: linux-omap-pm/drivers/usb/musb/musb_core.c
===================================================================
@@ -98,6 +98,7 @@
 #include <linux/kobject.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/pm_runtime.h>
 
 #ifdef	CONFIG_ARM
 #include <mach/hardware.h>
@@ -2457,9 +2458,20 @@ static int musb_resume_noirq(struct devi
 	return 0;
 }
 
+static int musb_runtime_suspend(struct device *dev)
+{
+	return 0;
+}
+
+static int musb_runtime_resume(struct device *dev)
+{
+	return 0;
+}
 static const struct dev_pm_ops musb_dev_pm_ops = {
 	.suspend	= musb_suspend,
 	.resume_noirq	= musb_resume_noirq,
+	.runtime_suspend = musb_runtime_suspend,
+	.runtime_resume	 = musb_runtime_resume,
 };
 
 #define MUSB_DEV_PM_OPS (&musb_dev_pm_ops)
drivers/usb/musb/omap2430.c +15 -28

90 lines not on this page · raw message

Quoted 5 lines
Quoted 1 line

--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#35 lore raw

Hi,

Quoted 3 lines · Hema

Here is the patch which is making use of already existing platform set_clock functions pointer. With this we don't need to use #ifdefs. If it looks good I will post it again along with series.

those weren't even used anymore on omap, it's kinda of a step backwards to get back to using those pointers. I can already see Russell's angry face when he sees this patch. We should not need such artifacts.

Granted, musb is extremely complicated to make any change because it's used by several different platforms, so we need to somehow abstract the platform-specific part and one way is to split the HW glue layer to another platform_device/driver of its own.

I'm still thinking what's the best way to do that, but there's an RFC on linux-usb regarding that. Help is welcome :-D

Signature · 1 line
balbi