Skip to content

Commit

Permalink
Asus Power Debug: Prepare to disable this
Browse files Browse the repository at this point in the history
  • Loading branch information
freak07 committed May 30, 2021
1 parent 0914be0 commit 33511f2
Show file tree
Hide file tree
Showing 21 changed files with 8,945 additions and 85 deletions.
24 changes: 12 additions & 12 deletions drivers/base/power/main.c
Expand Up @@ -37,7 +37,7 @@

#include "../base.h"
#include "power.h"
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
#include <linux/pm_debug.h>

Expand Down Expand Up @@ -460,7 +460,7 @@ static void pm_dev_dbg(struct device *dev, pm_message_t state, const char *info)
static void pm_dev_err(struct device *dev, pm_message_t state, const char *info,
int error)
{
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
//pr_err("Device %s failed to %s%s: error %d\n",
Expand All @@ -471,7 +471,7 @@ static void pm_dev_err(struct device *dev, pm_message_t state, const char *info,
pr_err("Device %s failed to %s%s: error %d\n",
dev_name(dev), pm_verb(state.event), info, error);
#endif
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
ASUSEvtlog("PM: Device %s failed to %s%s: error %d\n",
Expand All @@ -495,7 +495,7 @@ static void dpm_show_time(ktime_t starttime, pm_message_t state, int error,
usecs = 1;

pm_pr_dbg("%s%s%s of devices %s after %ld.%03ld msecs\n",
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
info ?: "", info ? " " : "", pm_verb(state.event),
error ? "aborted" : "complete",
usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC);
Expand Down Expand Up @@ -1098,15 +1098,15 @@ static void async_resume(void *data, async_cookie_t cookie)
void dpm_resume(pm_message_t state)
{
struct device *dev;
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
ktime_t device_starttime;
ktime_t device_endtime;
u64 usecs64 = 0;
int usecs = 0;
//[PM_debug---]
#endif
ktime_t starttime = ktime_get();
ktime_t starttime = ktime_get();

trace_suspend_resume(TPS("dpm_resume"), state.event, true);
might_sleep();
Expand All @@ -1125,7 +1125,7 @@ void dpm_resume(pm_message_t state)
int error;

mutex_unlock(&dpm_list_mtx);
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
device_starttime = ktime_get();
//[PM_debug---]
Expand All @@ -1138,7 +1138,7 @@ void dpm_resume(pm_message_t state)
dpm_save_failed_dev(dev_name(dev));
pm_dev_err(dev, state, "", error);
}
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
device_endtime = ktime_get();
usecs64 = ktime_to_ns(ktime_sub(device_endtime, device_starttime));
Expand Down Expand Up @@ -1929,7 +1929,7 @@ static int device_suspend(struct device *dev)
*/
int dpm_suspend(pm_message_t state)
{
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
ktime_t device_starttime;
ktime_t device_endtime;
Expand All @@ -1954,7 +1954,7 @@ int dpm_suspend(pm_message_t state)

get_device(dev);
mutex_unlock(&dpm_list_mtx);
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
device_starttime = ktime_get();
//[PM_debug---]
Expand All @@ -1969,7 +1969,7 @@ int dpm_suspend(pm_message_t state)
put_device(dev);
break;
}
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
device_endtime = ktime_get();
usecs64 = ktime_to_ns(ktime_sub(device_endtime, device_starttime));
Expand All @@ -1990,7 +1990,7 @@ int dpm_suspend(pm_message_t state)
if (async_error)
break;
}
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
//This flag can check dpm_suspend state for resume_console in printk.c
Expand Down
17 changes: 9 additions & 8 deletions drivers/base/power/wakeup.c
Expand Up @@ -25,7 +25,7 @@

#include "power.h"

#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
#include <linux/pm_debug.h>
//Extern: this flag to check dpm_suspend has been callback for resume_console
Expand All @@ -41,7 +41,7 @@ struct work_struct pm_cpuinfo_printer;
suspend_state_t pm_suspend_target_state;
#define pm_suspend_target_state (PM_SUSPEND_ON)
#endif
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
void pmsp_print(void)
{
schedule_work(&pms_printer);
Expand Down Expand Up @@ -914,12 +914,13 @@ void pm_print_active_wakeup_sources(void)
srcuidx = srcu_read_lock(&wakeup_srcu);
list_for_each_entry_rcu(ws, &wakeup_sources, entry) {
if (ws->active) {
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//pm_pr_dbg("active wakeup source: %s\n", ws->name);
pm_printk("active wakeup source: %s\n", ws->name);
//[PM_debug ---]
#endif
pm_pr_dbg("active wakeup source: %s\n", ws->name);
active = 1;
} else if (!active &&
(!last_activity_ws ||
Expand All @@ -930,7 +931,7 @@ void pm_print_active_wakeup_sources(void)
}

if (!active && last_activity_ws)
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//pm_pr_dbg("last active wakeup source: %s\n",
pm_printk("last active wakeup source: %s\n",
Expand All @@ -944,7 +945,7 @@ void pm_print_active_wakeup_sources(void)
}
EXPORT_SYMBOL_GPL(pm_print_active_wakeup_sources);

#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
void asus_uts_print_active_locks(void)
{
Expand Down Expand Up @@ -1014,7 +1015,7 @@ bool pm_wakeup_pending(void)

if (ret) {
pm_pr_dbg("Wakeup pending, aborting suspend\n");
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug+++]
pm_printk("Wakeup pending, aborting suspend\n");
//[PM_debug ---]
Expand All @@ -1023,7 +1024,7 @@ bool pm_wakeup_pending(void)
pm_get_active_wakeup_sources(suspend_abort,
MAX_SUSPEND_ABORT_LEN);
log_suspend_abort_reason(suspend_abort);
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
pr_info("%s\n", suspend_abort);
#else
pr_info("PM: %s\n", suspend_abort);
Expand Down Expand Up @@ -1066,7 +1067,7 @@ void pm_system_irq_wakeup(unsigned int irq_number)
name = desc->action->name;

log_irq_wakeup_reason(irq_number);
#ifdef CONFIG_MACH_ASUS
#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
//pr_warn("%s: %d triggered %s\n", __func__,
Expand Down
18 changes: 17 additions & 1 deletion drivers/clk/clk.c
Expand Up @@ -5,9 +5,12 @@
*
* Standard functionality for the common clock API. See Documentation/driver-api/clk.rst
*/

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
#define pr_fmt(fmt) "CLK: " fmt
//[PM_debug ---]
#endif

#include <linux/clk.h>
#include <linux/clk-provider.h>
Expand All @@ -27,10 +30,12 @@

#include "clk.h"

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//#define CLK_COUNT 17 //precs codebase
#define CLK_COUNT 7 //cs codebase
//[PM_debug ---]
//[PM_debug ---]
#endif

static DEFINE_SPINLOCK(enable_lock);
static DEFINE_MUTEX(prepare_lock);
Expand Down Expand Up @@ -2966,10 +2971,14 @@ EXPORT_SYMBOL_GPL(clk_is_match);

static struct dentry *rootdir;
static int inited = 0;

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//clock debug
static u32 debug_suspend = 1;
//[PM_debug ---]
#endif

static DEFINE_MUTEX(clk_debug_lock);
static HLIST_HEAD(clk_debug_list);

Expand Down Expand Up @@ -3416,6 +3425,8 @@ static int clock_debug_print_clock(struct clk_core *c, struct seq_file *s)

return 1;
}

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//clock debug
static int clock_debug_get_clock_count(struct clk_core *c, struct seq_file *s)
Expand All @@ -3425,6 +3436,7 @@ static int clock_debug_get_clock_count(struct clk_core *c, struct seq_file *s)
return 1;
}
//[PM_debug ---]
#endif

/*
* clock_debug_print_enabled_clocks() - Print names of enabled clocks
Expand All @@ -3437,6 +3449,8 @@ static void clock_debug_print_enabled_clocks(struct seq_file *s)
clock_debug_output(s, 0, "Enabled clocks:\n");

hlist_for_each_entry(core, &clk_debug_list, debug_node)

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//clock debug
//cnt += clock_debug_print_clock(core, s);
Expand All @@ -3446,6 +3460,8 @@ static void clock_debug_print_enabled_clocks(struct seq_file *s)
clock_debug_print_clock(core, s);
}
//[PM_debug ---]
#endif

if (cnt)
clock_debug_output(s, 0, "Enabled clock count: %d\n", cnt);
else
Expand Down
5 changes: 0 additions & 5 deletions drivers/input/misc/qpnp-power-on.c
Expand Up @@ -602,7 +602,6 @@ void wait_for_power_key_6s_work(struct work_struct *work)

#define TIMEOUT_SLOW 30

extern int boot_after_60sec;
void wait_for_slowlog_work(struct work_struct *work)
{
static int one_slowlog_instance_running = 0;
Expand Down Expand Up @@ -1347,7 +1346,6 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
#ifdef CONFIG_MACH_ASUS
/* for phone hang debug */
pon_for_powerkey = pon;
if (boot_after_60sec) {
if (is_holding_power_key()) {
press_time = jiffies;
/* if ((g_ASUS_hwID < ZS660KL_PR1) ||
Expand All @@ -1365,7 +1363,6 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
del_timer(&pwr_press_timer);
press_time = 0xFFFFFFFF;
}
}
#endif
break;
case PON_RESIN:
Expand Down Expand Up @@ -1409,15 +1406,13 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
}
}

if (boot_after_60sec) {
if (cfg->key_code == 114) {
if (key_status)
mod_timer(&voldown_press_timer, jiffies + msecs_to_jiffies(3000));
else {
voldown_key_6s_running = 0;
voldown_key_3s_running = 0;
del_timer(&voldown_press_timer);
}
}
}
#endif
Expand Down
12 changes: 12 additions & 0 deletions drivers/irqchip/irq-gic-v3.c
Expand Up @@ -40,10 +40,13 @@

#define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0)

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
int gic_irq_cnt,gic_resume_irq;//Add these values to save IRQ's counts and number
//[PM_debug ---]
#endif

struct redist_region {
void __iomem *redist_base;
phys_addr_t phys_base;
Expand Down Expand Up @@ -591,12 +594,16 @@ static void gic_show_resume_irq(struct gic_chip_data *gic)
u32 enabled;
u32 pending[32];
void __iomem *base = gic_data.dist_base;

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irg debug
//reset IRQ count and IRQ number every time.
gic_resume_irq=0;
gic_irq_cnt=0;
//[PM_debug ---]
#endif

if (!msm_show_resume_irq_mask)
return;

Expand All @@ -617,16 +624,21 @@ static void gic_show_resume_irq(struct gic_chip_data *gic)
name = "stray irq";
else if (desc->action && desc->action->name)
name = desc->action->name;

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//irq debug
//save IRQ's counts and number
gic_resume_irq = irq;
gic_irq_cnt++;
#endif
pr_warn("%s: irq:%d hwirq:%u triggered %s\n",
__func__, irq, i, name);
}
#ifdef CONFIG_ASUS_POWER_DEBUG
printk("irq count: %d\n", gic_irq_cnt);
//[PM_debug ---]
#endif
}

static void gic_resume_one(struct gic_chip_data *gic)
Expand Down
4 changes: 4 additions & 0 deletions drivers/irqchip/msm_show_resume_irq.c
Expand Up @@ -7,11 +7,15 @@
#include <linux/kernel.h>
#include <linux/init.h>

#ifdef CONFIG_ASUS_POWER_DEBUG
//[PM_debug +++]
//int msm_show_resume_irq_mask;
/*Mask IRQ triggered number during gic_show_resume_irq() in kernel/drivers/irqchip/irq-gic-v3.c */
int msm_show_resume_irq_mask = 1;
//[PM_debug ---]
#endif

int msm_show_resume_irq_mask;

module_param_named(
debug_mask, msm_show_resume_irq_mask, int, 0664);

0 comments on commit 33511f2

Please sign in to comment.