ANDROID: usb: Add vendor hook for usb suspend and resume

Add the hook that vendor can design and bypass the suspend/resume.
When the bypass is set, skip the orignal suspend/resume methods.

In mobile, a co-processor can be used with USB audio, and ACPU may
be able to sleep in such condition to improve power consumption.
We will need vendor hook to support this.

Bug: 329345852
Bug: 302982919
Bug: 347134330
Bug: 408097873
Signed-off-by: Puma Hsu <pumahsu@google.com>
Change-Id: I91a9500407939e9c4e0c1fef1f7ccc232d4322c1
(cherry picked from commit 98085b5dd8afd1ec65500eb091d061a3fee21b84)
(cherry picked from commit 358b59f1bce213fe1d83e09ae2e1fba718682e4a)
(cherry picked from commit 41292928f934c3f947f881ea0c51e61200c84d8d)
(cherry picked from commit 26f9f515d1b98fb93c8c797bdedacf05ada5a75a)
Signed-off-by: Hongseock Kim <hongpooh.kim@samsung.com>
This commit is contained in:
Puma Hsu
2021-07-10 16:11:10 +08:00
committed by Daehwan Jung
parent da662aecc8
commit 8760b6e4f5
3 changed files with 44 additions and 0 deletions

View File

@@ -76,6 +76,7 @@
#include <trace/hooks/suspend.h>
#include <trace/hooks/user.h>
#include <trace/hooks/gzvm.h>
#include <trace/hooks/usb.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -580,3 +581,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_vcpu_exit_reason);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_handle_demand_page_pre);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_handle_demand_page_post);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gzvm_destroy_vm_post_process);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_usb_dev_suspend);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_resume);

View File

@@ -34,6 +34,7 @@
#include "usb.h"
#include <trace/hooks/usb.h>
/*
* Adds a new dynamic USBdevice ID to this driver,
@@ -1420,11 +1421,16 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
int status = 0;
int i = 0, n = 0;
struct usb_interface *intf;
bool bypass = false;
if (udev->state == USB_STATE_NOTATTACHED ||
udev->state == USB_STATE_SUSPENDED)
goto done;
trace_android_rvh_usb_dev_suspend(udev, msg, &bypass);
if (bypass)
goto done;
/* Suspend all the interfaces and then udev itself */
if (udev->actconfig) {
n = udev->actconfig->desc.bNumInterfaces;
@@ -1521,11 +1527,17 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
int status = 0;
int i;
struct usb_interface *intf;
bool bypass = false;
if (udev->state == USB_STATE_NOTATTACHED) {
status = -ENODEV;
goto done;
}
trace_android_vh_usb_dev_resume(udev, msg, &bypass);
if (bypass)
goto done;
udev->can_submit = 1;
/* Resume the device */

29
include/trace/hooks/usb.h Normal file
View File

@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM usb
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_USB_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_USB_H
#include <trace/hooks/vendor_hooks.h>
struct usb_device;
/*
* Following tracepoints are not exported in tracefs and provide a
* mechanism for vendor modules to hook and extend functionality
*/
DECLARE_RESTRICTED_HOOK(android_rvh_usb_dev_suspend,
TP_PROTO(struct usb_device *udev, pm_message_t msg, bool *bypass),
TP_ARGS(udev, msg, bypass), 1);
DECLARE_HOOK(android_vh_usb_dev_resume,
TP_PROTO(struct usb_device *udev, pm_message_t msg, bool *bypass),
TP_ARGS(udev, msg, bypass));
#endif /* _TRACE_HOOK_USB_H */
/* This part must be outside protection */
#include <trace/define_trace.h>