linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
@ 2014-09-02 11:49 Kiran Kumar Raparthy
  2014-09-02 14:54 ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Kiran Kumar Raparthy @ 2014-09-02 11:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Todd Poynor, Felipe Balbi, Greg Kroah-Hartman, linux-usb,
	Android Kernel Team, John Stultz, Kiran Raparthy

From: Todd Poynor <toddpoynor@google.com>

usb: phy: Temporarily hold wakeupsource on charger connect and disconnect
events

Allow other parts of the system to react to the charger connect/disconnect
event without allowing the system to suspend before the other parts can process
the event. This wakeup_source times out after 2 seconds; if nobody else holds a
wakeup_source by that time then the device can sleep.

Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: Android Kernel Team <kernel-team@android.com>
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
[kiran: Added context to commit message
	wakeupsource handling implemented per PHY in phy core]
Signed-off-by: Kiran Raparthy <kiran.kumar@linaro.org>
---
 drivers/usb/phy/otg-wakeupsource.c |  2 +-
 drivers/usb/phy/phy.c              | 10 ++++++++++
 include/linux/usb/phy.h            |  3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c
index fca2010..70fa05e 100644
--- a/drivers/usb/phy/otg-wakeupsource.c
+++ b/drivers/usb/phy/otg-wakeupsource.c
@@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)
 	case USB_EVENT_NONE:
 	case USB_EVENT_ID:
 	case USB_EVENT_CHARGER:
-		usb_drop_wsource(otgws_xceiv);
+		usb_temporary_hold_wsource(otgws_xceiv);
 		break;
 
 	default:
diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c
index 659b1e8..c488716 100644
--- a/drivers/usb/phy/phy.c
+++ b/drivers/usb/phy/phy.c
@@ -483,3 +483,13 @@ void usb_drop_wsource(struct usb_phy *x)
 	__pm_relax(&x->wsource);
 }
 EXPORT_SYMBOL_GPL(usb_drop_wsource);
+
+/**
+ * usb_temporary_hold_wsource - temporarily hold wakeupsource
+ * @usb_phy: the phy returned by usb_get_phy()
+ */
+void usb_temporary_hold_wsource(struct usb_phy *x)
+{
+	__pm_wakeup_event(&x->wsource, msecs_to_jiffies(TEMPORARY_HOLD_TIME));
+}
+EXPORT_SYMBOL_GPL(usb_temporary_hold_wsource);
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 6c680e6..5f9b70e 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -13,6 +13,8 @@
 #include <linux/usb.h>
 #include <linux/pm_wakeup.h>
 
+#define TEMPORARY_HOLD_TIME    2000
+
 enum usb_phy_interface {
 	USBPHY_INTERFACE_MODE_UNKNOWN,
 	USBPHY_INTERFACE_MODE_UTMI,
@@ -218,6 +220,7 @@ void usb_wsource_init(struct usb_phy *x, char *phy_dev_name);
 void usb_wsource_trash(struct usb_phy *x);
 void usb_grab_wsource(struct usb_phy *x);
 void usb_drop_wsource(struct usb_phy *x);
+void usb_temporary_hold_wsource(struct usb_phy *x);
 #else
 static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
 {
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
  2014-09-02 11:49 [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events Kiran Kumar Raparthy
@ 2014-09-02 14:54 ` Felipe Balbi
  2014-09-05  7:40   ` Todd Poynor
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2014-09-02 14:54 UTC (permalink / raw)
  To: Kiran Kumar Raparthy
  Cc: linux-kernel, Todd Poynor, Felipe Balbi, Greg Kroah-Hartman,
	linux-usb, Android Kernel Team, John Stultz

[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]

Hi,

On Tue, Sep 02, 2014 at 05:19:18PM +0530, Kiran Kumar Raparthy wrote:
> From: Todd Poynor <toddpoynor@google.com>
> 
> usb: phy: Temporarily hold wakeupsource on charger connect and disconnect
> events
> 
> Allow other parts of the system to react to the charger connect/disconnect
> event without allowing the system to suspend before the other parts can process
> the event. This wakeup_source times out after 2 seconds; if nobody else holds a
> wakeup_source by that time then the device can sleep.
> 
> Cc: Felipe Balbi <balbi@ti.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-usb@vger.kernel.org
> Cc: Android Kernel Team <kernel-team@android.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Todd Poynor <toddpoynor@google.com>
> [kiran: Added context to commit message
> 	wakeupsource handling implemented per PHY in phy core]
> Signed-off-by: Kiran Raparthy <kiran.kumar@linaro.org>
> ---
>  drivers/usb/phy/otg-wakeupsource.c |  2 +-
>  drivers/usb/phy/phy.c              | 10 ++++++++++
>  include/linux/usb/phy.h            |  3 +++
>  3 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c
> index fca2010..70fa05e 100644
> --- a/drivers/usb/phy/otg-wakeupsource.c
> +++ b/drivers/usb/phy/otg-wakeupsource.c
> @@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)
>  	case USB_EVENT_NONE:
>  	case USB_EVENT_ID:
>  	case USB_EVENT_CHARGER:
> -		usb_drop_wsource(otgws_xceiv);
> +		usb_temporary_hold_wsource(otgws_xceiv);

looks like this won't work. You're holding the lock even on
USB_EVEN_NONE. Why ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
  2014-09-02 14:54 ` Felipe Balbi
@ 2014-09-05  7:40   ` Todd Poynor
  2014-09-05 14:19     ` Felipe Balbi
  0 siblings, 1 reply; 4+ messages in thread
From: Todd Poynor @ 2014-09-05  7:40 UTC (permalink / raw)
  To: balbi
  Cc: Kiran Kumar Raparthy, LKML, Greg Kroah-Hartman, linux-usb,
	Android Kernel Team, John Stultz, Badhri Jagan Sridharan,
	Ruchi Kandoi

On Tue, Sep 2, 2014 at 7:54 AM, Felipe Balbi <balbi@ti.com> wrote:
> Hi,
>
> On Tue, Sep 02, 2014 at 05:19:18PM +0530, Kiran Kumar Raparthy wrote:
...
>> diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c
>> index fca2010..70fa05e 100644
>> --- a/drivers/usb/phy/otg-wakeupsource.c
>> +++ b/drivers/usb/phy/otg-wakeupsource.c
>> @@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)
>>       case USB_EVENT_NONE:
>>       case USB_EVENT_ID:
>>       case USB_EVENT_CHARGER:
>> -             usb_drop_wsource(otgws_xceiv);
>> +             usb_temporary_hold_wsource(otgws_xceiv);
>
> looks like this won't work. You're holding the lock even on
> USB_EVEN_NONE. Why ?

It temporarily holds a timed wakeup source on USB disconnect events,
to allow the rest of the system time to react to the USB disconnection
(dropping host sessions, updating charger status, etc.) prior to
re-allowing suspend.


Todd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
  2014-09-05  7:40   ` Todd Poynor
@ 2014-09-05 14:19     ` Felipe Balbi
  0 siblings, 0 replies; 4+ messages in thread
From: Felipe Balbi @ 2014-09-05 14:19 UTC (permalink / raw)
  To: Todd Poynor
  Cc: balbi, Kiran Kumar Raparthy, LKML, Greg Kroah-Hartman, linux-usb,
	Android Kernel Team, John Stultz, Badhri Jagan Sridharan,
	Ruchi Kandoi

[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]

On Fri, Sep 05, 2014 at 12:40:22AM -0700, Todd Poynor wrote:
> On Tue, Sep 2, 2014 at 7:54 AM, Felipe Balbi <balbi@ti.com> wrote:
> > Hi,
> >
> > On Tue, Sep 02, 2014 at 05:19:18PM +0530, Kiran Kumar Raparthy wrote:
> ...
> >> diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c
> >> index fca2010..70fa05e 100644
> >> --- a/drivers/usb/phy/otg-wakeupsource.c
> >> +++ b/drivers/usb/phy/otg-wakeupsource.c
> >> @@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)
> >>       case USB_EVENT_NONE:
> >>       case USB_EVENT_ID:
> >>       case USB_EVENT_CHARGER:
> >> -             usb_drop_wsource(otgws_xceiv);
> >> +             usb_temporary_hold_wsource(otgws_xceiv);
> >
> > looks like this won't work. You're holding the lock even on
> > USB_EVEN_NONE. Why ?
> 
> It temporarily holds a timed wakeup source on USB disconnect events,
> to allow the rest of the system time to react to the USB disconnection
> (dropping host sessions, updating charger status, etc.) prior to
> re-allowing suspend.

alright, please add a note like this to commit log.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-05 14:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 11:49 [RFC v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events Kiran Kumar Raparthy
2014-09-02 14:54 ` Felipe Balbi
2014-09-05  7:40   ` Todd Poynor
2014-09-05 14:19     ` Felipe Balbi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).