diff options
author | Puma Hsu <pumahsu@google.com> | 2021-07-10 16:11:10 +0800 |
---|---|---|
committer | Puma Hsu <pumahsu@google.com> | 2021-07-12 09:06:49 +0000 |
commit | 98085b5dd8afd1ec65500eb091d061a3fee21b84 (patch) | |
tree | ee05f30865501aa8477158271d4a82f3d3cf1dc2 | |
parent | 956db89e711f9ab3d608f3b2bafc6cefef9cc347 (diff) | |
download | common-android12-5.10-m2107-release.tar.gz |
ANDROID: usb: Add vendor hook for usb suspend and resumeandroid12-5.10-m2107-release
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: 192774581
Signed-off-by: Puma Hsu <pumahsu@google.com>
Change-Id: Ic62a8a1e662bbe3fb0aa17af7491daace0b9f18a
-rw-r--r-- | drivers/android/vendor_hooks.c | 3 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 12 | ||||
-rw-r--r-- | include/trace/hooks/usb.h | 27 |
3 files changed, 42 insertions, 0 deletions
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index a3225fd58f8a..07eb8efd7c40 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -67,6 +67,7 @@ #include <trace/hooks/shmem_fs.h> #include <trace/hooks/net.h> #include <trace/hooks/syscall_check.h> +#include <trace/hooks/usb.h> /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -350,3 +351,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kfree_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_mmap_file); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_file_open); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_suspend); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_usb_dev_resume); diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 4dfa44d6cc3c..6253dce08cc6 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -34,6 +34,7 @@ #include "usb.h" +#include <trace/hooks/usb.h> /* * Adds a new dynamic USBdevice ID to this driver, @@ -1403,11 +1404,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; + int bypass = 0; if (udev->state == USB_STATE_NOTATTACHED || udev->state == USB_STATE_SUSPENDED) goto done; + trace_android_vh_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; @@ -1504,11 +1510,17 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg) int status = 0; int i; struct usb_interface *intf; + int bypass = 0; 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 */ diff --git a/include/trace/hooks/usb.h b/include/trace/hooks/usb.h new file mode 100644 index 000000000000..f8459473042e --- /dev/null +++ b/include/trace/hooks/usb.h @@ -0,0 +1,27 @@ +/* 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 <linux/tracepoint.h> +#include <linux/usb.h> +#include <trace/hooks/vendor_hooks.h> +/* + * Following tracepoints are not exported in tracefs and provide a + * mechanism for vendor modules to hook and extend functionality + */ + +DECLARE_HOOK(android_vh_usb_dev_suspend, + TP_PROTO(struct usb_device *udev, pm_message_t msg, int *bypass), + TP_ARGS(udev, msg, bypass)); + +DECLARE_HOOK(android_vh_usb_dev_resume, + TP_PROTO(struct usb_device *udev, pm_message_t msg, int *bypass), + TP_ARGS(udev, msg, bypass)); + +#endif /* _TRACE_HOOK_USB_H */ +/* This part must be outside protection */ +#include <trace/define_trace.h> + |