ANDROID: wakeupbypass: Add vendor hook for batteryswap
Implemented a hook to check if battery swap is enabled in alarm timer suspend routine. During a battery swap, it is crucial to ensure that the device remains in a suspended state, relying on a limited backup power source. It is essential to prevent any unintended awakenings in this state, as they could potentially lead to sudden surges in the power consumption, ultimately resulting in a device shutdown. Hence, we disable alarmtimer IRQs when in batteryswap mode. Bug: 290881352 Change-Id: I31dc30d9a3168bb1356cccba49f0a70fd6b73782 Signed-off-by: Vatsal Parasrampuria <vp9924@zebra.com>
This commit is contained in:
@@ -76,6 +76,7 @@
|
|||||||
#include <trace/hooks/ipv4.h>
|
#include <trace/hooks/ipv4.h>
|
||||||
#include <trace/hooks/pci.h>
|
#include <trace/hooks/pci.h>
|
||||||
#include <trace/hooks/dmabuf.h>
|
#include <trace/hooks/dmabuf.h>
|
||||||
|
#include <trace/hooks/wakeupbypass.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
* Export tracepoints that act as a bare tracehook (ie: have no trace event
|
||||||
@@ -490,6 +491,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_test_clear_look_around_ref);
|
|||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wakeup_bypass);
|
||||||
/*
|
/*
|
||||||
* For type visibility
|
* For type visibility
|
||||||
*/
|
*/
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include <linux/of_irq.h>
|
#include <linux/of_irq.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <dt-bindings/input/gpio-keys.h>
|
#include <dt-bindings/input/gpio-keys.h>
|
||||||
|
#include <trace/hooks/wakeupbypass.h>
|
||||||
|
|
||||||
struct gpio_button_data {
|
struct gpio_button_data {
|
||||||
const struct gpio_keys_button *button;
|
const struct gpio_keys_button *button;
|
||||||
@@ -958,11 +959,16 @@ static int __maybe_unused gpio_keys_suspend(struct device *dev)
|
|||||||
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
||||||
struct input_dev *input = ddata->input;
|
struct input_dev *input = ddata->input;
|
||||||
int error;
|
int error;
|
||||||
|
int wakeup_bypass_enabled = 0;
|
||||||
|
|
||||||
|
trace_android_vh_wakeup_bypass(&wakeup_bypass_enabled);
|
||||||
|
|
||||||
if (device_may_wakeup(dev)) {
|
if (device_may_wakeup(dev)) {
|
||||||
error = gpio_keys_enable_wakeup(ddata);
|
if (!wakeup_bypass_enabled) {
|
||||||
if (error)
|
error = gpio_keys_enable_wakeup(ddata);
|
||||||
return error;
|
if (error)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mutex_lock(&input->mutex);
|
mutex_lock(&input->mutex);
|
||||||
if (input->users)
|
if (input->users)
|
||||||
@@ -978,9 +984,13 @@ static int __maybe_unused gpio_keys_resume(struct device *dev)
|
|||||||
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev);
|
||||||
struct input_dev *input = ddata->input;
|
struct input_dev *input = ddata->input;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
int wakeup_bypass_enabled = 0;
|
||||||
|
|
||||||
|
trace_android_vh_wakeup_bypass(&wakeup_bypass_enabled);
|
||||||
|
|
||||||
if (device_may_wakeup(dev)) {
|
if (device_may_wakeup(dev)) {
|
||||||
gpio_keys_disable_wakeup(ddata);
|
if (!wakeup_bypass_enabled)
|
||||||
|
gpio_keys_disable_wakeup(ddata);
|
||||||
} else {
|
} else {
|
||||||
mutex_lock(&input->mutex);
|
mutex_lock(&input->mutex);
|
||||||
if (input->users)
|
if (input->users)
|
||||||
|
17
include/trace/hooks/wakeupbypass.h
Normal file
17
include/trace/hooks/wakeupbypass.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#undef TRACE_SYSTEM
|
||||||
|
#define TRACE_SYSTEM wakeupbypass
|
||||||
|
|
||||||
|
#define TRACE_INCLUDE_PATH trace/hooks
|
||||||
|
|
||||||
|
#if !defined(_TRACE_HOOK_WAKEUPBYPASS_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||||
|
#define _TRACE_HOOK_WAKEUPBYPASS_H
|
||||||
|
#include <trace/hooks/vendor_hooks.h>
|
||||||
|
|
||||||
|
DECLARE_HOOK(android_vh_wakeup_bypass,
|
||||||
|
TP_PROTO(int *is_wakeup_bypassed),
|
||||||
|
TP_ARGS(is_wakeup_bypassed));
|
||||||
|
|
||||||
|
#endif /* _TRACE_HOOK_WAKEUPBYPASS_H */
|
||||||
|
/* This part must be outside protection */
|
||||||
|
#include <trace/define_trace.h>
|
@@ -33,6 +33,8 @@
|
|||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include <trace/events/alarmtimer.h>
|
#include <trace/events/alarmtimer.h>
|
||||||
|
|
||||||
|
#undef CREATE_TRACE_POINTS
|
||||||
|
#include <trace/hooks/wakeupbypass.h>
|
||||||
/**
|
/**
|
||||||
* struct alarm_base - Alarm timer bases
|
* struct alarm_base - Alarm timer bases
|
||||||
* @lock: Lock for syncrhonized access to the base
|
* @lock: Lock for syncrhonized access to the base
|
||||||
@@ -246,6 +248,7 @@ static int alarmtimer_suspend(struct device *dev)
|
|||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
|
int wakeup_bypass_enabled = 0;
|
||||||
|
|
||||||
spin_lock_irqsave(&freezer_delta_lock, flags);
|
spin_lock_irqsave(&freezer_delta_lock, flags);
|
||||||
min = freezer_delta;
|
min = freezer_delta;
|
||||||
@@ -254,6 +257,10 @@ static int alarmtimer_suspend(struct device *dev)
|
|||||||
freezer_delta = 0;
|
freezer_delta = 0;
|
||||||
spin_unlock_irqrestore(&freezer_delta_lock, flags);
|
spin_unlock_irqrestore(&freezer_delta_lock, flags);
|
||||||
|
|
||||||
|
trace_android_vh_wakeup_bypass(&wakeup_bypass_enabled);
|
||||||
|
if (wakeup_bypass_enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
rtc = alarmtimer_get_rtcdev();
|
rtc = alarmtimer_get_rtcdev();
|
||||||
/* If we have no rtcdev, just return */
|
/* If we have no rtcdev, just return */
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
|
Reference in New Issue
Block a user