usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
RFC v2 2/2 usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events
From: Todd Poynor <[email protected]>
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.
[kiran: Added context to commit message
wakeupsource handling implemented per PHY in phy core]
--- 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(-)
drivers/usb/phy/otg-wakeupsource.c +1 -1
@@ -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 :
drivers/usb/phy/phy.c +10 -0
@@ -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);
include/linux/usb/phy.h +3 -0
@@ -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) {
Signature · 1 line
1.8.2.1
Hi,
Quoted 31 lines · Kiran Kumar Raparthy
From: Todd Poynor <[email protected]>
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_sourcetimes out after 2 seconds; if nobody else holds awakeup_sourceby that time then the device can sleep.Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Android Kernel Team <[email protected]>Cc John Stultz <[email protected]>Signed-off-by Todd Poynor <[email protected]>[kiran: Added context to commit message
wakeupsource handling implemented per PHY in phy core]Signed-off-by Kiran Raparthy <[email protected]>--- 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(-)drivers/usb/phy/otg-wakeupsource.c +0
-0
drivers/usb/phy/otg-wakeupsource.c static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event) · line 51
Quoted 5 lines
drivers/usb/phy/otg-wakeupsource.c +1
-1@@ -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 ?
Signature · 1 line
balbi
Quoted 3 lines · Felipe Balbi
Hi,
On Tue, Sep 02, 2014 at 05:19:18PM +0530, Kiran Kumar Raparthy wrote:
...
Quoted 5 lines
Quoted 5 lines
drivers/usb/phy/otg-wakeupsource.c +0
-0@@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)
Quoted 8 lines
drivers/usb/phy/otg-wakeupsource.c static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event) · line 51
Quoted 5 lines
drivers/usb/phy/otg-wakeupsource.c +1
-1case 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
Quoted 19 lines · Todd Poynor
Quoted 3 lines · Felipe Balbi
Hi,
On Tue, Sep 02, 2014 at 05:19:18PM +0530, Kiran Kumar Raparthy wrote:
...
Quoted 5 lines
Quoted 5 lines
drivers/usb/phy/otg-wakeupsource.c +0
-0@@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event)Quoted 8 lines
drivers/usb/phy/otg-wakeupsource.c static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event) · line 51
Quoted 5 lines
drivers/usb/phy/otg-wakeupsource.c +1
-1case 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 ?
Quoted 4 lines
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.
Signature · 1 line
balbi