From 5b6a5354d03442ffc30f4939247bd9dc1daec42b Mon Sep 17 00:00:00 2001 From: Hemant Kumar Date: Tue, 15 Nov 2016 19:10:42 -0800 Subject: [PATCH] ANDROID: GKI: USB: Fix ABI diff for struct usb_bus Adds new member skip_resume to struct usb_bus to resolve ABI diff. This patch also adds the capability to skip device resume during system resume. It allows xHC to remain in low power mode and not resume the bus when system wide resume happens. Instead, the controller comes out of low power mode only when usb device issues a remote wakeup or if there is host initiated bus resume. Test: build Bug: 153445212 Change-Id: I96cdcb9e3642906b4afa08d9bde07e123d9b3977 Signed-off-by: Hemant Kumar (cherry picked from commit 567a7ba0cc8c96d8b01ea290417c8397d1acd078) [hridya: partial cherry-pick] Signed-off-by: Hridya Valsaraju --- drivers/usb/core/driver.c | 12 ++++++++++++ include/linux/usb.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 3255b2bb0fd5..60c2ec4daf75 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1458,6 +1458,9 @@ int usb_suspend(struct device *dev, pm_message_t msg) struct usb_device *udev = to_usb_device(dev); int r; + if (udev->bus->skip_resume && udev->state == USB_STATE_SUSPENDED) + return 0; + unbind_no_pm_drivers_interfaces(udev); /* From now on we are sure all drivers support suspend/resume @@ -1494,6 +1497,15 @@ int usb_resume(struct device *dev, pm_message_t msg) struct usb_device *udev = to_usb_device(dev); int status; + /* + * Some buses would like to keep their devices in suspend + * state after system resume. Their resume happen when + * a remote wakeup is detected or interface driver start + * I/O. + */ + if (udev->bus->skip_resume) + return 0; + /* For all calls, take the device back to full power and * tell the PM core in case it was autosuspended previously. * Unbind the interfaces that will need rebinding later, diff --git a/include/linux/usb.h b/include/linux/usb.h index ba7199cc8ff7..27fdb8a0c75b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -466,6 +466,15 @@ struct usb_bus { struct mon_bus *mon_bus; /* non-null when associated */ int monitored; /* non-zero when monitored */ #endif + unsigned skip_resume:1; /* All USB devices are brought into full + * power state after system resume. It + * is desirable for some buses to keep + * their devices in suspend state even + * after system resume. The devices + * are resumed later when a remote + * wakeup is detected or an interface + * driver starts I/O. + */ }; struct usb_dev_state;