Remove all the amazon logging hooks

This commit is contained in:
ggow
2019-04-20 02:52:56 +01:00
parent 55194e165f
commit e53c86b915
33 changed files with 14 additions and 1849 deletions
-5
View File
@@ -1235,8 +1235,6 @@ CONFIG_MTK_RAM_CONSOLE_SIZE=0x1C00
CONFIG_MTK_RAM_CONSOLE_ADDR=0xF900DC00
CONFIG_MTK_RAM_CONSOLE_DRAM_SIZE=0x100000
CONFIG_MTK_RAM_CONSOLE_DRAM_ADDR=0x83F00000
CONFIG_AMAZON_LOW_LEVEL_LOG_DRAM_SIZE=0x00020000
CONFIG_AMAZON_LOW_LEVEL_LOG_DRAM_ADDR=0x82F00000
# CONFIG_PREEMPT_MONITOR is not set
# CONFIG_ISR_MONITOR is not set
# CONFIG_MT_SCHED_MONITOR is not set
@@ -2802,9 +2800,6 @@ CONFIG_ANDROID_TIMED_OUTPUT=y
CONFIG_ANDROID_LOW_MEMORY_KILLER=y
CONFIG_ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES=y
CONFIG_ANDROID_INTF_ALARM_DEV=y
CONFIG_AMAZON_METRICS_LOG=y
CONFIG_AMAZON_LOG=y
CONFIG_AMAZON_LOGD=y
CONFIG_SYNC=y
CONFIG_SW_SYNC=y
CONFIG_SW_SYNC_USER=y
-3
View File
@@ -2797,9 +2797,6 @@ CONFIG_ANDROID_TIMED_OUTPUT=y
CONFIG_ANDROID_LOW_MEMORY_KILLER=y
CONFIG_ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES=y
CONFIG_ANDROID_INTF_ALARM_DEV=y
CONFIG_AMAZON_METRICS_LOG=y
CONFIG_AMAZON_LOG=y
CONFIG_AMAZON_LOGD=y
CONFIG_SYNC=y
CONFIG_SW_SYNC=y
CONFIG_SW_SYNC_USER=y
-17
View File
@@ -35,10 +35,6 @@
#endif
#define SERIALNO_LEN 32
#ifdef CONFIG_MDUMP
#include <linux/mdump.h>
#endif
#include <linux/platform_data/mtk_thermal.h>
static char serial_number[SERIALNO_LEN];
@@ -2504,23 +2500,10 @@ void __init mt_reserve(void)
// aee_dram_console_reserve_memory();
mrdump_reserve_memory();
#if defined(CONFIG_AMAZON_LL_LOG)
memblock_reserve(CONFIG_AMAZON_LOW_LEVEL_LOG_DRAM_ADDR, CONFIG_AMAZON_LOW_LEVEL_LOG_DRAM_SIZE);
#endif
#if defined(CONFIG_MTK_RAM_CONSOLE_USING_DRAM)
memblock_reserve(CONFIG_MTK_RAM_CONSOLE_DRAM_ADDR, CONFIG_MTK_RAM_CONSOLE_DRAM_SIZE);
#endif
#ifdef CONFIG_MDUMP
/* reserve lk memory & mdump buffer */
#ifdef BOOTLOADER_LK_ADDRESS
memblock_reserve(BOOTLOADER_LK_ADDRESS, BOOTLOADER_LK_SIZE);
#endif
#ifdef CONFIG_MDUMP_COMPRESS
memblock_reserve(CONFIG_MDUMP_WITH_COMPRESS_ADDRESS, CONFIG_MDUMP_WITH_COMPRESS_WORKAREA_SIZE);
#endif
#else
mrdump_mini_reserve_memory();
#endif /* CONFIG_MDUMP */
/*
* Dynamic reserved memory (by arm_memblock_steal)
-26
View File
@@ -30,12 +30,6 @@
#define SPM_BYPASS_SYSPWREQ 0
#endif
#if defined(CONFIG_AMAZON_METRICS_LOG)
/* forced trigger system_resume:off_mode metrics log */
int force_gpt = 0;
module_param(force_gpt, int, 0644);
#endif
/* Added by haitaoy@amazon.com for AUSTINPLAT-1413. */
static struct mt_wake_event spm_wake_event = {
.domain = "SPM",
@@ -1195,17 +1189,6 @@ wake_reason_t spm_go_to_sleep(bool cpu_pdn, bool infra_pdn, int pwake_time)
spm_set_sysclk_settle();
#if defined(CONFIG_AMAZON_METRICS_LOG)
/* forced trigger system_resume:off_mode metrics log */
if (force_gpt == 1) {
gpt_set_cmp(GPT4, 1);
start_gpt(GPT4);
/* wait HW GPT trigger */
udelay(200);
spm_sleep_wakesrc |= WAKE_SRC_GPT;
}
#endif
spm_crit2("sec = %u, wakesrc = 0x%x (%u)(%u)\n",
sec, spm_sleep_wakesrc, cpu_pdn, infra_pdn);
@@ -1238,15 +1221,6 @@ wake_reason_t spm_go_to_sleep(bool cpu_pdn, bool infra_pdn, int pwake_time)
last_wr = spm_output_wake_reason(&wakesta, false);
#if defined(CONFIG_AMAZON_METRICS_LOG)
/* forced trigger system_resume:off_mode metrics log */
if (force_gpt == 1) {
if (gpt_check_and_ack_irq(GPT4))
spm_crit2("GPT4 triggered for off_mode metrics test\n");
spm_sleep_wakesrc &= ~WAKE_SRC_GPT;
}
#endif
RESTORE_IRQ:
mt_cirq_flush();
mt_cirq_disable();
-64
View File
@@ -29,10 +29,6 @@
#include <linux/rcupdate.h>
#include "input-compat.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
MODULE_DESCRIPTION("Input core");
MODULE_LICENSE("GPL");
@@ -44,13 +40,6 @@ static DEFINE_IDA(input_ida);
static LIST_HEAD(input_dev_list);
static LIST_HEAD(input_handler_list);
#ifdef CONFIG_AMAZON_METRICS_LOG
static atomic_t vol_up_counter;
static atomic_t vol_down_counter;
static atomic_t touch_tap_counter;
struct delayed_work metrics_work;
#endif
/*
* input_mutex protects access to both input_dev_list and input_handler_list.
* This also causes input_[un]register_device and input_[un]register_handler
@@ -441,20 +430,6 @@ void input_event(struct input_dev *dev,
spin_lock_irqsave(&dev->event_lock, flags);
input_handle_event(dev, type, code, value);
spin_unlock_irqrestore(&dev->event_lock, flags);
#ifdef CONFIG_AMAZON_METRICS_LOG
if (type == EV_ABS && code == ABS_MT_POSITION_Y) {
atomic_inc(&touch_tap_counter);
}
if (type == EV_KEY && code == KEY_VOLUMEDOWN) {
atomic_inc(&vol_down_counter);
}
if (type == EV_KEY && code == KEY_VOLUMEUP) {
atomic_inc(&vol_up_counter);
}
#endif
}
}
EXPORT_SYMBOL(input_event);
@@ -2390,36 +2365,6 @@ void input_free_minor(unsigned int minor)
}
EXPORT_SYMBOL(input_free_minor);
#ifdef CONFIG_AMAZON_METRICS_LOG
static void metrics_count_work(struct work_struct *work)
{
char buf[128] = {0};
struct delayed_work *dw = container_of(work, struct delayed_work, work);
snprintf(buf, sizeof(buf),
"input_event:def:touch_tap=%d;CT;1:NA",
atomic_xchg(&touch_tap_counter, 0));
log_to_metrics(ANDROID_LOG_INFO, "InputEvent", buf);
memset(buf, 0, 128);
snprintf(buf, sizeof(buf),
"input_event:def:key_voldown=%d;CT;1:NA",
atomic_xchg(&vol_down_counter, 0));
log_to_metrics(ANDROID_LOG_INFO, "InputEvent", buf);
memset(buf, 0, 128);
snprintf(buf, sizeof(buf),
"input_event:def:key_volup=%d;CT;1:NA",
atomic_xchg(&vol_up_counter, 0));
log_to_metrics(ANDROID_LOG_INFO, "InputEvent", buf);
schedule_delayed_work(dw, 7200*HZ);
}
#endif
static int __init input_init(void)
{
int err;
@@ -2441,11 +2386,6 @@ static int __init input_init(void)
goto fail2;
}
#ifdef CONFIG_AMAZON_METRICS_LOG
INIT_DELAYED_WORK(&metrics_work, metrics_count_work);
schedule_delayed_work(&metrics_work, 0);
#endif
return 0;
fail2: input_proc_exit();
@@ -2459,10 +2399,6 @@ static void __exit input_exit(void)
unregister_chrdev_region(MKDEV(INPUT_MAJOR, 0),
INPUT_MAX_CHAR_DEVICES);
class_unregister(&input_class);
#ifdef CONFIG_AMAZON_METRICS_LOG
cancel_delayed_work_sync(&metrics_work);
#endif
}
subsys_initcall(input_init);
@@ -46,11 +46,6 @@
#include <linux/input/tmp103_temp_sensor.h>
#include <linux/thermal_framework.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#define TMP103_METRICS_STR_LEN 128
#endif
#define TMP103_TEMP_REG 0x00
#define TMP103_CONF_REG 0x01
@@ -160,22 +155,11 @@ static int tmp103_get_temp(struct thermal_dev *tdev)
static int saved_temp;
int count = 1;
struct i2c_client *client = tmp103->iclient;
#ifdef CONFIG_AMAZON_METRICS_LOG
char *tmp103_metric_prefix = "pcbsensor:def";
char buf[TMP103_METRICS_STR_LEN];
#endif
static int fail_count;
current_temp = tmp103_read_current_temp(tdev->dev);
if (unlikely(current_temp >= TMP103_MAX_TEMP)) {
#ifdef CONFIG_AMAZON_METRICS_LOG
/* Log in metrics */
snprintf(buf, TMP103_METRICS_STR_LEN, "%s:abnormal_temp=%d;CT;1:NR",
tmp103_metric_prefix,
current_temp);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
#endif
pr_info("TMP103 reads abnormal temperature %d", current_temp);
/* switch to shutdown mode, then swtich back to previous mode ( contious conversion mode) */
@@ -185,13 +169,6 @@ static int tmp103_get_temp(struct thermal_dev *tdev)
/* retry */
do {
current_temp = tmp103_read_current_temp(tdev->dev);
#ifdef CONFIG_AMAZON_METRICS_LOG
/* Log in metrics */
snprintf(buf, TMP103_METRICS_STR_LEN,
"%s:pcbtemp=%d;CT;1,retry=%d;CT;1:NR",
tmp103_metric_prefix, current_temp, count);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
#endif
pr_info("TMP103 reads temperature %d, retrying... %d ", current_temp,
count);
} while ((count++ < MAX_RETRY)
@@ -206,13 +183,6 @@ static int tmp103_get_temp(struct thermal_dev *tdev)
return tmp103->therm_fw->current_temp;
}
current_temp = saved_temp;
#ifdef CONFIG_AMAZON_METRICS_LOG
/* Log in metrics */
snprintf(buf, TMP103_METRICS_STR_LEN,
"%s:saved_temp=%d;CT;1,use_saved_temp=1;CT;1:NR",
tmp103_metric_prefix, saved_temp);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
#endif
pr_info("WARNING: TMP103 retry failed, return last saved temperature %d",
saved_temp);
} else { /* less than TMP103_MAX_TEMP read */
@@ -5,9 +5,6 @@
#include <cust_gpio_usage.h>
#include <mach/mt_gpio.h>
#include <mach/eint.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
#define EARPHONE_SWITCH
@@ -266,21 +263,11 @@ static void accdet_FSA8049_disable(void)
#endif
static void inline headset_plug_out(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
#endif
accdet_status = PLUG_OUT;
cable_type = NO_DEVICE;
//update the cable_type
switch_set_state((struct switch_dev *)&accdet_data, cable_type);
ACCDET_DEBUG( " [accdet] set state in cable_type = NO_DEVICE\n");
#ifdef CONFIG_AMAZON_METRICS_LOG
snprintf(buf, sizeof(buf),
"%s:jack:unplugged=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "AudioJackEvent", buf);
#endif
}
@@ -1362,10 +1349,6 @@ static inline void check_cable_type(void)
}
static void accdet_work_callback(struct work_struct *work)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
char *string = NULL;
#endif
wake_lock(&accdet_irq_lock);
check_cable_type();
@@ -1379,25 +1362,6 @@ static void accdet_work_callback(struct work_struct *work)
mutex_unlock(&accdet_eint_irq_sync_mutex);
ACCDET_DEBUG( " [accdet] set state in cable_type status\n");
#ifdef CONFIG_AMAZON_METRICS_LOG
switch (cable_type) {
case HEADSET_MIC:
string = "HEADSET";
break;
case HEADSET_NO_MIC:
string = "HEADPHONES";
break;
default:
string = "NOTHING";
break;
}
snprintf(buf, sizeof(buf),
"%s:jack:plugged=1;CT;1,state_%s=1;CT;1:NR",
__func__, string);
log_to_metrics(ANDROID_LOG_INFO, "AudioJackEvent", buf);
#endif
wake_unlock(&accdet_irq_lock);
}
@@ -32,14 +32,6 @@ extern int dump_localtimer_info(char *buffer, int size);
extern int dump_idle_info(char *buffer, int size);
#endif
#ifdef CONFIG_MDUMP
#include <linux/mdump.h>
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
/* Some chip do not have irq dump, define a weak to avoid build error */
__weak void mt_irq_dump(void)
{
@@ -479,14 +471,6 @@ void aee_wdt_irq_info(void)
xchg(&debug_locks, 0);
aee_rr_rec_fiq_step(AEE_FIQ_STEP_WDT_IRQ_DONE);
#ifdef CONFIG_MDUMP
mdump_mark_reboot_reason(MDUMP_REBOOT_WATCHDOG);
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_boot_reason(WARMBOOT_BY_KERNEL_WATCHDOG);
#endif
rtc_mark_reboot_reason(RTC_REBOOT_REASON_SW_WDT);
BUG();
}
@@ -16,10 +16,6 @@
#endif
#include "lcm_drv.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
@@ -226,12 +222,6 @@ static void lcm_init(void)
static void lcm_suspend(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:suspend=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
mt_set_gpio_out(GPIO_LCD_STB_EN, GPIO_OUT_ZERO);
MDELAY(100);
mt_set_gpio_out(GPIO_LCD_RST_EN, GPIO_OUT_ZERO);
@@ -257,12 +247,6 @@ static void lcm_suspend_power(void)
static void lcm_resume(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:resume=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
lcd_reset(0);
MDELAY(50);
lcd_reset(1);
@@ -16,10 +16,6 @@
#endif
#include "lcm_drv.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
@@ -234,12 +230,6 @@ static void lcm_init_power(void)
static void lcm_suspend(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:suspend=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
mt_set_gpio_out(GPIO_LCD_STB_EN, GPIO_OUT_ZERO);
MDELAY(100);
mt_set_gpio_out(GPIO_LCD_RST_EN, GPIO_OUT_ZERO);
@@ -264,13 +254,7 @@ static void lcm_suspend_power(void)
}
static void lcm_resume(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:resume=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
}
{}
static void lcm_resume_power(void)
{
@@ -16,10 +16,6 @@
#endif
#include "lcm_drv.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
@@ -228,12 +224,6 @@ static void lcm_init(void)
static void lcm_suspend(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:suspend=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
mt_set_gpio_out(GPIO_LCD_STB_EN, GPIO_OUT_ZERO);
MDELAY(100);
mt_set_gpio_out(GPIO_LCD_RST_EN, GPIO_OUT_ZERO);
@@ -259,12 +249,6 @@ static void lcm_suspend_power(void)
static void lcm_resume(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:resume=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
//lcd_reset(0);
MDELAY(10);
//lcd_reset(1);
@@ -16,10 +16,6 @@
#endif
#include "lcm_drv.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
// ---------------------------------------------------------------------------
// Local Constants
// ---------------------------------------------------------------------------
@@ -226,12 +222,6 @@ static void lcm_init(void)
static void lcm_suspend(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:suspend=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
mt_set_gpio_out(GPIO_LCD_STB_EN, GPIO_OUT_ZERO);
MDELAY(100);
mt_set_gpio_out(GPIO_LCD_RST_EN, GPIO_OUT_ZERO);
@@ -257,12 +247,6 @@ static void lcm_suspend_power(void)
static void lcm_resume(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
snprintf(buf, sizeof(buf), "%s:lcd:resume=1;CT;1:NR", __func__);
log_to_metrics(ANDROID_LOG_INFO, "LCDEvent", buf);
#endif
lcd_reset(0);
MDELAY(50);
lcd_reset(1);
@@ -1349,20 +1349,7 @@ struct msdc_host
u32 pc_suspend; /* suspend/resume count */
void (*power_control)(struct msdc_host *host,u32 on);
void (*power_switch)(struct msdc_host *host,u32 on);
#ifdef CONFIG_AMAZON_METRICS_LOG
struct delayed_work metrics_work;
bool metrics_enable;
u32 crc_count_p; /* reported crc count */
u32 crc_invalid_count_p; /* reported crc invalid count eg CMD19 */
u32 req_count_p; /* reported request count */
u32 datatimeout_count_p; /* reported data timeout count */
u32 cmdtimeout_count_p; /* reported cmd timeout count */
u32 reqtimeout_count_p; /* reported req timeout count */
u32 pc_count_p; /* reported power cycle count */
u32 pc_suspend_p; /* reported suspend/resume count */
u32 inserted_p; /* reported card detection count */
u32 inserted; /* total card detection cound */
#endif
};
typedef enum {
TRAN_MOD_PIO,
@@ -1383,18 +1370,6 @@ struct dma_addr{
struct dma_addr *next;
};
#ifdef CONFIG_AMAZON_METRICS_LOG
#define MSDC_LOG_COUNTER_TO_VITALS(name, value) \
do { \
if (value != value##_p) { \
log_counter_to_vitals(ANDROID_LOG_INFO, "Kernel", "Kernel", \
((host->mmc) && (host->mmc->caps & MMC_CAP_SD_HIGHSPEED)) ? "SD" : "EMMC", \
#name, value - value##_p, "count", NULL, VITALS_NORMAL); \
value##_p = value; \
} \
} while (0)
#endif
static inline unsigned int uffs(unsigned int x)
{
unsigned int r = 1;
+1 -67
View File
@@ -64,10 +64,6 @@
#include <mach/mt_storage_logger.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
#define METRICS_DELAY HZ
#define EXT_CSD_BOOT_SIZE_MULT 226 /* R */
#define EXT_CSD_RPMB_SIZE_MULT 168 /* R */
@@ -257,24 +253,6 @@ static void msdc_remove_device_attrs(struct msdc_host *host, struct device_attri
device_remove_file(host->dev, attrs[i]);
}
#ifdef CONFIG_AMAZON_METRICS_LOG
static void msdc_metrics_work(struct work_struct *work)
{
struct msdc_host *host = container_of(work, struct msdc_host,
metrics_work.work);
MSDC_LOG_COUNTER_TO_VITALS(crc, host->crc_count);
MSDC_LOG_COUNTER_TO_VITALS(crc_invalid, host->crc_invalid_count);
MSDC_LOG_COUNTER_TO_VITALS(req, host->req_count);
MSDC_LOG_COUNTER_TO_VITALS(datato, host->datatimeout_count);
MSDC_LOG_COUNTER_TO_VITALS(cmdto, host->cmdtimeout_count);
MSDC_LOG_COUNTER_TO_VITALS(reqto, host->reqtimeout_count);
MSDC_LOG_COUNTER_TO_VITALS(pc_count, host->pc_count);
MSDC_LOG_COUNTER_TO_VITALS(pc_suspend, host->pc_suspend);
MSDC_LOG_COUNTER_TO_VITALS(inserted, host->inserted);
}
#endif
//=================================
#define MSDC_LOWER_FREQ
@@ -1909,9 +1887,6 @@ static void msdc_tasklet_card(unsigned long arg)
if ((host->hw->host_function == MSDC_SD) && inserted) {
host->inserted++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
if(host->block_bad_card){
inserted = 0;
@@ -2622,9 +2597,6 @@ static void msdc_set_power_mode(struct msdc_host *host, u8 mode)
if ((host->hw->host_function == MSDC_SD) && mode) {
host->pc_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
dev_info(host->dev, "crc/total %d/%d invalcrc %d datato %d cmdto %d total_pc %d pc_sus %d\n",
@@ -3377,9 +3349,6 @@ static unsigned int msdc_command_start(struct msdc_host *host,
cmd->error = (unsigned int)-ETIMEDOUT;
if (host->hw->host_function == MSDC_SD) {
host->reqtimeout_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
msdc_reset_hw(host->id);
@@ -3395,9 +3364,6 @@ static unsigned int msdc_command_start(struct msdc_host *host,
cmd->error = (unsigned int)-ETIMEDOUT;
if (host->hw->host_function == MSDC_SD) {
host->reqtimeout_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
msdc_reset_hw(host->id);
@@ -3502,10 +3468,6 @@ static unsigned int msdc_command_resp_polling(struct msdc_host *host,
cmd->error = (unsigned int)-ETIMEDOUT;
if (host->hw->host_function == MSDC_SD) {
host->cmdtimeout_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work,
METRICS_DELAY);
#endif
}
host->sw_timeout++;
@@ -3561,9 +3523,6 @@ static unsigned int msdc_command_resp_polling(struct msdc_host *host,
host->crc_invalid_count++;
else
host->crc_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
} else if (intsts & MSDC_INT_CMDTMO) {
cmd->error = (unsigned int)-ETIMEDOUT;
@@ -3571,9 +3530,6 @@ static unsigned int msdc_command_resp_polling(struct msdc_host *host,
msdc_reset_hw(host->id);
if (host->hw->host_function == MSDC_SD) {
host->cmdtimeout_count++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
}
#ifdef MTK_MSDC_USE_CMD23
@@ -6798,9 +6754,6 @@ retune:
out:
if (host->mclk < 25000000) {
pr_err("CMD 19 tune fail!\n");
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
return -EIO;
}
msdc_set_mclk(host, ddr, host->mclk / 2); /* lower to 50Mhz */
@@ -7711,19 +7664,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
//printk(KERN_INFO "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", host->id, sdr_read32(SDC_CSTS));
}
latest_int_status[host->id] = 0;
#ifdef CONFIG_AMAZON_METRICS_LOG
if ((host->hw->host_function == MSDC_SD) &&
((cmd &&
(unlikely(cmd->error == -ETIMEDOUT) || unlikely(cmd->error == -EIO))) ||
(data &&
(unlikely(data->error == -ETIMEDOUT) || unlikely(data->error == -EIO))) ||
(stop &&
(unlikely(stop->error == -ETIMEDOUT) || unlikely(stop->error == -EIO)))))
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
return IRQ_HANDLED;
return IRQ_HANDLED;
}
/*--------------------------------------------------------------------------*/
@@ -8606,10 +8547,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
msdc_init_hw(host);
#ifdef CONFIG_AMAZON_METRICS_LOG
INIT_DELAYED_WORK(&host->metrics_work, msdc_metrics_work);
#endif
//mt65xx_irq_set_sens(irq, MT65xx_EDGE_SENSITIVE);
//mt65xx_irq_set_polarity(irq, MT65xx_POLARITY_LOW);
ret = request_irq((unsigned int)irq, msdc_irq, IRQF_TRIGGER_LOW, DRV_NAME, host);
@@ -8798,9 +8735,6 @@ static int msdc_drv_resume(struct platform_device *pdev)
if (mmc && (host->hw->flags & MSDC_SYS_SUSPEND)) {/* will set for card */
if (host->hw->host_function == MSDC_SD) {
host->pc_suspend++;
#ifdef CONFIG_AMAZON_METRICS_LOG
mod_delayed_work(system_wq, &host->metrics_work, METRICS_DELAY);
#endif
}
msdc_pm(state, (void*)host);
@@ -69,14 +69,6 @@
extern int Enable_BATDRV_LOG;
//#include <mach/mt_clock_manager.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
//----------------------------------------------------------------------test
#define MT65XX_UPLL 3
void pmic_enable_pll(int id, char *mod_name)
@@ -150,25 +142,6 @@ static unsigned long timer_pos = 0;
static struct hrtimer long_press_pwrkey_shutdown_timer;
#define LONG_PRESS_PWRKEY_SHUTDOWN_TIME (6) /* 6sec */
#ifdef CONFIG_AMAZON_POWEROFF_LOG
static void log_long_press_power_key(void)
{
int rc;
char *argv[] = {
"/sbin/crashreport",
"long_press_power_key",
NULL
};
rc = call_usermodehelper(argv[0], argv, NULL, UMH_WAIT_EXEC);
if (rc < 0)
pr_err("call /sbin/crashreport failed, rc = %d\n", rc);
msleep(6000); /* 6s */
}
#endif /* CONFIG_AMAZON_POWEROFF_LOG */
//==============================================================================
// PMIC lock/unlock APIs
//==============================================================================
@@ -599,23 +572,19 @@ static void deferred_restart(struct work_struct *dummy)
mutex_lock(&pmic_mutex);
pr_notice("[deferred_restart] -- Long key press power off\n");
#ifdef CONFIG_AMAZON_POWEROFF_LOG
log_long_press_power_key();
#endif /* CONFIG_AMAZON_POWEROFF_LOG */
unsigned int pwrkey_deb = 0;
pwrkey_deb = upmu_get_pwrkey_deb();
if (pwrkey_deb == 1) {
pr_err("[deferred_restart] -- pwrkey release, do nothing\n");
} else {
sys_sync();
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_shutdown_reason(SHUTDOWN_BY_SW_LONG_PWR_KEY_PRESS);
#endif /* for metrics */
rtc_mark_enter_sw_lprst(); /* for long press power off */
if (upmu_get_rgs_chrdet())
rtc_mark_enter_kpoc();
orderly_reboot(true);
unsigned int pwrkey_deb = 0;
pwrkey_deb = upmu_get_pwrkey_deb();
if (pwrkey_deb == 1) {
pr_err("[deferred_restart] -- pwrkey release, do nothing\n");
}
else {
sys_sync();
rtc_mark_enter_sw_lprst(); /* for long press power off */
if (upmu_get_rgs_chrdet())
rtc_mark_enter_kpoc();
orderly_reboot(true);
}
mutex_unlock(&pmic_mutex);
}
@@ -711,24 +680,10 @@ void pwrkey_int_handler(void)
ktime_t ktime;
U32 pwrkey_deb = 0;
#ifdef CONFIG_AMAZON_METRICS_LOG
char *action;
#define METRICS_STR_LEN 128
char buf[METRICS_STR_LEN];
#undef METRICS_STR_LEN
#endif
xlog_printk(ANDROID_LOG_INFO, "Power/PMIC", "[pwrkey_int_handler]....\n");
pwrkey_deb = upmu_get_pwrkey_deb();
#ifdef CONFIG_AMAZON_METRICS_LOG
action = (pwrkey_deb == 1) ? "release" : "press";
sprintf(buf, "%s:powi%c:report_action_is_%s=1;CT;1:NR", __func__,
action[0], action);
log_to_metrics(ANDROID_LOG_INFO, "PowerKeyEvent", buf);
#endif
if (pwrkey_deb == 1)
{
xlog_printk(ANDROID_LOG_INFO, "Power/PMIC", "[pwrkey_int_handler] Release pwrkey\n");
@@ -744,9 +699,6 @@ void pwrkey_int_handler(void)
if(long_pwrkey_press) //500ms
{
xlog_printk(ANDROID_LOG_INFO, "Power/PMIC", "[pmic_thread_kthread] Power Key Pressed during kernel power off charging, reboot OS\r\n");
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_boot_reason(WARMBOOT_BY_SW);
#endif
arch_reset(0, NULL);
}
}
@@ -36,9 +36,6 @@
#include <mach/mt_clkmgr.h>
#include <mach/emi_mpu.h>
#include "usb20.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
extern struct musb *mtk_musb;
static DEFINE_SEMAPHORE(power_clock_lock);
@@ -224,19 +221,6 @@ static void mt_usb_disable(struct musb *musb)
musb->power = false;
}
#ifdef CONFIG_AMAZON_METRICS_LOG
void usb_log_metrics(char *usbmsg)
{
struct timespec ts = current_kernel_time();
char buf[512];
snprintf(buf, sizeof(buf),
"usb_connection_status:def:%s=1;CT;1,timestamp=%lu;TI;1:NR",
usbmsg,
ts.tv_sec * 1000 + ts.tv_nsec / NSEC_PER_MSEC);
log_to_metrics(ANDROID_LOG_INFO, "kernel", buf);
}
#endif
/* ================================ */
/* connect and disconnect functions */
/* ================================ */
@@ -275,10 +259,6 @@ void mt_usb_connect(void)
musb_start(mtk_musb);
printk("[MUSB] USB connect\n");
#ifdef CONFIG_AMAZON_METRICS_LOG
usb_log_metrics("usb_connected");
#endif
}
void mt_usb_disconnect(void)
@@ -302,10 +282,6 @@ void mt_usb_disconnect(void)
}
printk("[MUSB] USB disconnect\n");
#ifdef CONFIG_AMAZON_METRICS_LOG
usb_log_metrics("usb_disconnected");
#endif
}
bool usb_cable_connected(void)
@@ -34,10 +34,6 @@
#ifdef CONFIG_USB_MTK_OTG
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
extern struct musb *mtk_musb;
static struct musb_fifo_cfg fifo_cfg_host[] = {
@@ -269,9 +265,6 @@ static void musb_id_pin_work(struct work_struct *data)
{
u8 devctl = 0;
unsigned long flags;
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128];
#endif
spin_lock_irqsave(&mtk_musb->lock, flags);
musb_generic_disable(mtk_musb);
@@ -333,12 +326,6 @@ static void musb_id_pin_work(struct work_struct *data)
musb_start(mtk_musb);
MUSB_HST_MODE(mtk_musb);
switch_int_to_device(mtk_musb);
#ifdef CONFIG_AMAZON_METRICS_LOG
snprintf(buf, sizeof(buf),
"%s:usb20:otg_gnd=1,state=%d;CT;1;DV;1:NR",
__func__, mtk_musb->xceiv->state);
log_to_metrics(ANDROID_LOG_INFO, "USBCableEvent", buf);
#endif
} else {
DBG(0,"devctl is %x\n",musb_readb(mtk_musb->mregs,MUSB_DEVCTL));
musb_writeb(mtk_musb->mregs,MUSB_DEVCTL,0);
@@ -361,13 +348,6 @@ static void musb_id_pin_work(struct work_struct *data)
mtk_musb->xceiv->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(mtk_musb);
switch_int_to_host(mtk_musb);
#ifdef CONFIG_AMAZON_METRICS_LOG
memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf),
"%s:usb20:otg_off=1,state=%d;CT;1;DV;1:NR",
__func__, mtk_musb->xceiv->state);
log_to_metrics(ANDROID_LOG_INFO, "USBCableEvent", buf);
#endif
}
out:
DBG(0, "work end, is_host=%d\n", mtk_musb->is_host);
-4
View File
@@ -486,10 +486,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
host->rest_remove_flags = false;
#endif
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
INIT_DELAYED_WORK(&host->metrics_delay_work,
mmc_host_metrics_work);
#endif /* CONFIG_AMAZON_METRICS_LOG */
spin_lock_init(&host->lock);
init_waitqueue_head(&host->wq);
wake_lock_init(&host->detect_wake_lock, WAKE_LOCK_SUSPEND,
-4
View File
@@ -15,9 +15,5 @@
int mmc_register_host_class(void);
void mmc_unregister_host_class(void);
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
extern void mmc_host_metrics_work(struct work_struct *work);
#endif /* CONFIG_AMAZON_METRICS_LOG */
#endif
-180
View File
@@ -23,12 +23,6 @@
#include "mmc_ops.h"
#include "sd_ops.h"
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
#include <linux/metricslog.h>
#define LMK_METRIC_TAG "kernel"
#define METRICS_samsung_data_LEN 128
#endif /* CONFIG_AMAZON_METRICS_LOG */
static const unsigned int tran_exp[] = {
10000, 100000, 1000000, 10000000,
0, 0, 0, 0
@@ -931,176 +925,6 @@ err:
return err;
}
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
static int emmcmetrics_read(struct mmc_host *host)
{
int err = -1;
int ret = 0;
char logcatsamsung_data[METRICS_samsung_data_LEN];
u32 *samsung_report;
unsigned int *samsung_data;
struct mmc_card *card;
unsigned int minReservedBlocks;
unsigned int minReservedBlocksQuantified;
unsigned int maxEraseCountMLC;
unsigned int maxEraseCountMLCQuantified;
unsigned int avgEraseCountMLC;
unsigned int avgEraseCountMLCQuantified;
unsigned int maxEraseCountSLC;
unsigned int maxEraseCountSLCQuantified;
unsigned int avgEraseCountSLC;
unsigned int avgEraseCountSLCQuantified;
card = host->card;
pr_info("Trying to read Samsung eMMC stats\n");
samsung_report = kmalloc(512, GFP_KERNEL);
if (!samsung_report) {
pr_err("Failed to alloc memory for Smart Report\n");
ret = -ENOMEM;
goto fail;
}
if (card->quirks & MMC_QUIRK_SAMSUNG_SMART)
err = mmc_samsung_report(card, (u8 *)samsung_report);
if (!err) {
int i;
samsung_data = (unsigned int *)samsung_report;
pr_info("Samsung data [20 dwords]:");
for (i = 0; i < 10; ++i)
pr_info(" %08X", samsung_data[i]);
pr_info("\n");
for (i = 10; i < 20; ++i)
pr_info(" %08X", samsung_data[i]);
pr_info("\n");
for (i = 20; i < 30; ++i)
pr_info(" %08X", samsung_data[i]);
pr_info("\n");
for (i = 30; i < 36; ++i)
pr_info(" %08X", samsung_data[i]);
pr_info("\n");
} else {
pr_info("...Read Samsung eMMC stats failed...");
ret = -1;
goto fail_read;
}
minReservedBlocks = samsung_data[7]; /*bank0*/
if (minReservedBlocks > samsung_data[10] && samsung_data[10] > 0)
minReservedBlocks = samsung_data[10]; /*bank1*/
if (minReservedBlocks > samsung_data[13] && samsung_data[13] > 0)
minReservedBlocks = samsung_data[13]; /*bank2*/
if (minReservedBlocks > samsung_data[16] && samsung_data[16] > 0)
minReservedBlocks = samsung_data[16]; /*bank3*/
minReservedBlocksQuantified = /*6 bands with 2^n gap*/
(minReservedBlocks >= 32) ? 5 :
(minReservedBlocks >= 16) ? 4 :
(minReservedBlocks >= 8) ? 3 :
(minReservedBlocks >= 4) ? 2 :
(minReservedBlocks >= 2) ? 1 : 0;
/*report minReservedBlocksQuantified as metrics*/
snprintf(logcatsamsung_data, METRICS_samsung_data_LEN,
"emmc:info:minReservedBlocksQuantified_%d=1;CT;1:NR",
minReservedBlocksQuantified);
log_to_metrics(ANDROID_LOG_INFO, LMK_METRIC_TAG, logcatsamsung_data);
card->minReservedBlocks = minReservedBlocks;
maxEraseCountMLC = samsung_data[33];
maxEraseCountMLCQuantified = /*6 bands in linear gap*/
(maxEraseCountMLC >= 3000) ? 5 :
(maxEraseCountMLC >= 2500) ? 4 :
(maxEraseCountMLC >= 2000) ? 3 :
(maxEraseCountMLC >= 1500) ? 2 :
(maxEraseCountMLC >= 100) ? 1 : 0;
/*report maxEraseCountMLCQuantified as metrics*/
snprintf(logcatsamsung_data, METRICS_samsung_data_LEN,
"emmc:info:maxEraseCountMLCQuantified_%d=1;CT;1:NR",
maxEraseCountMLCQuantified);
log_to_metrics(ANDROID_LOG_INFO, LMK_METRIC_TAG, logcatsamsung_data);
card->maxEraseCountMLC = maxEraseCountMLC;
avgEraseCountMLC = samsung_data[35];
avgEraseCountMLCQuantified = /*6 bands in linear gap*/
(avgEraseCountMLC >= 1500) ? 5 :
(avgEraseCountMLC >= 1250) ? 4 :
(avgEraseCountMLC >= 1000) ? 3 :
(avgEraseCountMLC >= 750) ? 2 :
(avgEraseCountMLC >= 50) ? 1 : 0;
/*report avgEraseCountMLCQuantified as metrics*/
snprintf(logcatsamsung_data, METRICS_samsung_data_LEN,
"emmc:info:avgEraseCountMLCQuantified_%d=1;CT;1:NR",
avgEraseCountMLCQuantified);
log_to_metrics(ANDROID_LOG_INFO, LMK_METRIC_TAG, logcatsamsung_data);
card->avgEraseCountMLC = avgEraseCountMLC;
maxEraseCountSLC = samsung_data[30];
maxEraseCountSLCQuantified = /*6 bands in linear gap*/
(maxEraseCountSLC >= 2100) ? 5 :
(maxEraseCountSLC >= 1750) ? 4 :
(maxEraseCountSLC >= 1400) ? 3 :
(maxEraseCountSLC >= 1050) ? 2 :
(maxEraseCountSLC >= 70) ? 1 : 0;
/*report maxEraseCountSLCQuantified as metrics*/
snprintf(logcatsamsung_data, METRICS_samsung_data_LEN,
"emmc:info:maxEraseCountSLCQuantified_%d=1;CT;1:NR",
maxEraseCountSLCQuantified);
log_to_metrics(ANDROID_LOG_INFO, LMK_METRIC_TAG, logcatsamsung_data);
card->maxEraseCountSLC = maxEraseCountSLC;
avgEraseCountSLC = samsung_data[32];
avgEraseCountSLCQuantified = /*6 bands in linear gap*/
(avgEraseCountSLC >= 1050) ? 5 :
(avgEraseCountSLC >= 875) ? 4 :
(avgEraseCountSLC >= 700) ? 3 :
(avgEraseCountSLC >= 525) ? 2 :
(avgEraseCountSLC >= 35) ? 1 : 0;
/*report avgEraseCountSLCQuantified as metrics*/
snprintf(logcatsamsung_data, METRICS_samsung_data_LEN,
"emmc:info:avgEraseCountSLCQuantified_%d=1;CT;1:NR",
avgEraseCountSLCQuantified);
log_to_metrics(ANDROID_LOG_INFO, LMK_METRIC_TAG, logcatsamsung_data);
card->avgEraseCountSLC = avgEraseCountSLC;
fail_read:
kfree(samsung_report);
fail:
return ret;
}
/*
* Internal work. Work to output metrics at some later point.
*/
void mmc_host_metrics_work(struct work_struct *work)
{
struct mmc_host *host = container_of(work, struct mmc_host,
metrics_delay_work.work);
emmcmetrics_read(host);
}
static void metrics_delaywork_queue(struct mmc_host *host)
{
/* delay 5 seconds to output metrics */
queue_delayed_work(system_nrt_wq, &host->metrics_delay_work,
msecs_to_jiffies(5000));
}
#endif /* CONFIG_AMAZON_METRICS_LOG */
/*
* Handle the detection and initialisation of a card.
*
@@ -1945,10 +1769,6 @@ int mmc_attach_mmc(struct mmc_host *host)
if (err)
goto err;
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
metrics_delaywork_queue(host);
#endif /* CONFIG_AMAZON_METRICS_LOG */
mmc_release_host(host);
err = mmc_add_card(host->card);
-16
View File
@@ -858,20 +858,4 @@ ssize_t mmc_samsung_smart_handle(struct mmc_card *card, char *buf)
kfree(buffer);
return len;
}
#if (defined(CONFIG_AMAZON_METRICS_LOG) && defined(ENABLE_SAMSUNG_EMMC_METRICS))
int mmc_samsung_report(struct mmc_card *card, u8 *buf)
{
int err;
mmc_claim_host(card->host);
err = mmc_samsung_smart_read(card, buf);
mmc_release_host(card->host);
if (err)
return err;
return 0;
}
#endif /* CONFIG_AMAZON_METRICS_LOG */
#endif /* CONFIG_MMC_SAMSUNG_SMART */
-601
View File
@@ -84,47 +84,6 @@
#if defined(CONFIG_MTK_PUMP_EXPRESS_PLUS_SUPPORT)
#include "cust_pe.h"
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
#if defined(CONFIG_EARLYSUSPEND)
#include <linux/earlysuspend.h>
#endif
#include <linux/metricslog.h>
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
enum BQ_FLAGS {
BQ_STATUS_RESUMING = 0x2,
};
struct battery_info {
struct mutex lock;
int flags;
/* Time when system enters full suspend */
struct timespec suspend_time;
/* Time when system enters early suspend */
struct timespec early_suspend_time;
/* Battery capacity when system enters full suspend */
int suspend_capacity;
/* Battery capacity when system enters early suspend */
int early_suspend_capacity;
#if defined(CONFIG_EARLYSUSPEND)
struct early_suspend early_suspend;
#endif
};
struct battery_info BQ_info;
/* set max time interval for metric to 10 years*/
#define MAX_TIME_INTERVAL (3600*24*365*10)
#endif
/* ////////////////////////////////////////////////////////////////////////////// */
/* Battery Logging Entry */
/* ////////////////////////////////////////////////////////////////////////////// */
@@ -276,39 +235,6 @@ static int cmd_discharging = -1;
static int adjust_power = -1;
static int suspend_discharging = -1;
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
struct metrics_charge {
struct timespec charger_time;
int battery_charge_ticks;
unsigned int init_charging_vol;
unsigned long battery_peak_virtual_temp;
unsigned long battery_peak_battery_temp;
unsigned long battery_average_virtual_temp;
unsigned long battery_average_battery_temp;
unsigned long usb_charger_voltage_peak;
};
static struct metrics_charge metrics_charge_info;
struct metrics_capacity {
struct timespec above_95_time;
struct timespec below_15_time;
bool bat_15_flag;
bool bat_95_flag;
bool battery_below_15_fired;
int low_battery_initial_soc;
unsigned int low_battery_initial_voltage;
int battery_low_ticks;
};
extern unsigned long get_virtualsensor_temp(void);
extern signed int gFG_battery_cycle;
#endif
/* ////////////////////////////////////////////////////////////////////////////// */
/* FOR ANDROID BATTERY SERVICE */
/* ////////////////////////////////////////////////////////////////////////////// */
@@ -413,280 +339,6 @@ static char *battery_vendor_name = NULL;
extern kal_uint32 g_fg_battery_id;
#endif
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
void metrics_battery_save_data(void)
{
unsigned long temp = get_virtualsensor_temp();
/* Save Data for Next Metric */
metrics_charge_info.init_charging_vol = BMT_status.bat_vol;
/* Set Peak temperatures to current temperature */
metrics_charge_info.battery_peak_battery_temp = BMT_status.temperature;
metrics_charge_info.battery_peak_virtual_temp = get_virtualsensor_temp();
/* Save Current USB Charging Voltage as Peak */
metrics_charge_info.usb_charger_voltage_peak = BMT_status.charger_vol;
metrics_charge_info.battery_average_virtual_temp = temp;
metrics_charge_info.battery_average_battery_temp = BMT_status.temperature;
/* Set Charging Ticks to 1 */
metrics_charge_info.battery_charge_ticks = 1;
/* Set Time start for Next Metric */
metrics_charge_info.charger_time = current_kernel_time();
}
static void battery_capacity_check(void)
{
char buf[256];
long elaps_sec;
struct timespec diff;
struct timespec curr;
static struct metrics_capacity metrics_cap_info;
if (BMT_status.SOC > 95 && !metrics_cap_info.bat_95_flag) {
metrics_cap_info.bat_95_flag = true;
metrics_cap_info.above_95_time = current_kernel_time();
}
if (BMT_status.SOC < 95 && metrics_cap_info.bat_95_flag) {
metrics_cap_info.bat_95_flag = false;
curr = current_kernel_time();
diff = timespec_sub(curr, metrics_cap_info.above_95_time);
elaps_sec = diff.tv_sec + diff.tv_nsec / NSEC_PER_SEC;
if (elaps_sec > 0 && elaps_sec < MAX_TIME_INTERVAL) {
snprintf(buf,sizeof(buf),
"bq24296:def:time_soc95=1;CT;1,Elaps_Sec=%ld;CT;1:NA", elaps_sec);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
memset(buf, 0, sizeof(buf));
}
}
if (BMT_status.SOC < 15 && !metrics_cap_info.bat_15_flag) {
metrics_cap_info.bat_15_flag = true;
metrics_cap_info.below_15_time = current_kernel_time();
metrics_cap_info.battery_low_ticks = 0;
metrics_cap_info.low_battery_initial_voltage = BMT_status.bat_vol;
metrics_cap_info.low_battery_initial_soc = BMT_status.SOC;
} else if (BMT_status.SOC < 15) {
/* Count Tickes for case when system
* starts up from dead battery
*/
metrics_cap_info.battery_low_ticks++;
}
if (BMT_status.SOC > 15 && metrics_cap_info.bat_15_flag) {
metrics_cap_info.bat_15_flag = false;
metrics_cap_info.battery_below_15_fired = false;
curr = current_kernel_time();
diff = timespec_sub(curr, metrics_cap_info.below_15_time);
elaps_sec = diff.tv_sec + diff.tv_nsec / NSEC_PER_SEC;
/* If system clock changed drastically use ticks instead.
* If not clock is probably more accurate
*/
if (elaps_sec > metrics_cap_info.battery_low_ticks * 20)
elaps_sec = metrics_cap_info.battery_low_ticks * 10;
if (elaps_sec > 0 && elaps_sec < MAX_TIME_INTERVAL) {
snprintf(buf,sizeof(buf),
"bq24296:def:time_soc15_soc20=1;CT;1,Init_Vol=%u;CT;1,Init_SOC=%d;CT;1,Elaps_Sec=%ld;CT;1:NA",
metrics_cap_info.low_battery_initial_voltage, metrics_cap_info.low_battery_initial_soc, elaps_sec);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
memset(buf, 0, sizeof(buf));
}
}
/* Catch Events for devices that may power off */
if (BMT_status.SOC <= 2 && metrics_cap_info.battery_below_15_fired == false)
{
metrics_cap_info.battery_below_15_fired = true;
diff = timespec_sub(current_kernel_time(), metrics_cap_info.below_15_time);
elaps_sec = diff.tv_sec + diff.tv_nsec/NSEC_PER_SEC;
if (elaps_sec > 0 && elaps_sec < MAX_TIME_INTERVAL) {
snprintf(buf,sizeof(buf),
"bq24296:def:time_soc15_soc0=1;CT;1,Init_Vol=%u;CT;1,Init_SOC=%d;CT;1,Elaps_Sec=%ld;CT;1:NA",
metrics_cap_info.low_battery_initial_voltage, metrics_cap_info.low_battery_initial_soc, elaps_sec);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
memset(buf, 0, sizeof(buf));
}
}
}
#endif
#if defined(CONFIG_AMAZON_METRICS_LOG)
void metrics_charger(bool connect)
{
int cap = BMT_status.UI_SOC;
char buf[128];
if (connect == true) {
snprintf(buf, sizeof(buf),
"bq24296:def:POWER_STATUS_CHARGING=1;CT;1,"
"cap=%u;CT;1:NR", cap);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
} else {
snprintf(buf, sizeof(buf),
"bq24296:def:POWER_STATUS_DISCHARGING=1;CT;1,"
"cap=%u;CT;1:NR", cap);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
}
}
void metrics_charger_update(int ac, int usb)
{
static bool ischargeronline;
int onceonline = 0;
if (ac == 1)
onceonline = 1;
else if (usb == 1)
onceonline = 1;
if (ischargeronline != onceonline) {
ischargeronline = onceonline;
metrics_charger(ischargeronline);
}
}
static void battery_critical_voltage_check(void)
{
static bool written;
if (BMT_status.charger_exist == KAL_TRUE)
return;
if (BMT_status.bat_exist != KAL_TRUE)
return;
if (BMT_status.UI_SOC != 0)
return;
if (written == false && BMT_status.bat_vol <= SYSTEM_OFF_VOLTAGE) {
written = true;
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_special_mode(LIFE_CYCLE_SMODE_LOW_BATTERY);
#endif
}
}
static void battery_metrics_locked(struct battery_info *info);
static void metrics_handle(void)
{
struct battery_info *info = &BQ_info;
mutex_lock(&info->lock);
/* Check for critical battery voltage */
battery_critical_voltage_check();
if ((info->flags & BQ_STATUS_RESUMING)) {
info->flags &= ~BQ_STATUS_RESUMING;
battery_metrics_locked(info);
}
mutex_unlock(&info->lock);
#if defined(CONFIG_AUSTIN_PROJECT)
battery_capacity_check();
#endif
return;
}
#if defined(CONFIG_EARLYSUSPEND)
static void bq_log_metrics(struct battery_info *info, char *msg,
char *metricsmsg)
{
int value = BMT_status.UI_SOC;
struct timespec curr = current_kernel_time();
/* Compute elapsed time and determine screen off or on drainage */
struct timespec diff = timespec_sub(curr,
info->early_suspend_time);
if (diff.tv_sec > 0 && diff.tv_sec < MAX_TIME_INTERVAL) {
if (info->early_suspend_capacity != -1) {
char buf[512];
snprintf(buf, sizeof(buf),
"%s:def:value=%d;CT;1,elapsed=%ld;TI;1:NR",
metricsmsg,
info->early_suspend_capacity - value,
diff.tv_sec * 1000 + diff.tv_nsec / NSEC_PER_MSEC);
log_to_metrics(ANDROID_LOG_INFO, "drain_metrics", buf);
}
}
/* Cache the current capacity */
info->early_suspend_capacity = BMT_status.UI_SOC;
/* Mark the suspend or resume time */
info->early_suspend_time = curr;
}
static void battery_early_suspend(struct early_suspend *handler)
{
struct battery_info *info = &BQ_info;
bq_log_metrics(info, "Screen on drainage", "screen_on_drain");
}
static void battery_late_resume(struct early_suspend *handler)
{
struct battery_info *info = &BQ_info;
bq_log_metrics(info, "Screen off drainage", "screen_off_drain");
}
#endif
static int metrics_init(void)
{
struct battery_info *info = &BQ_info;
mutex_init(&info->lock);
info->suspend_capacity = -1;
info->early_suspend_capacity = -1;
#if defined(CONFIG_EARLYSUSPEND)
info->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1;
info->early_suspend.suspend = battery_early_suspend;
info->early_suspend.resume = battery_late_resume;
register_early_suspend(&info->early_suspend);
#endif
mutex_lock(&info->lock);
info->flags = 0;
mutex_unlock(&info->lock);
return 0;
}
static void metrics_uninit(void)
{
struct battery_info *info = &BQ_info;
unregister_early_suspend(&info->early_suspend);
}
static void metrics_suspend(void)
{
struct battery_info *info = &BQ_info;
/* Cache the current capacity */
info->suspend_capacity = BMT_status.UI_SOC;
battery_critical_voltage_check();
/* Mark the suspend time */
info->suspend_time = current_kernel_time();
}
#endif
/* ///////////////////////////////////////////////////////////////////////////////////////// */
/* // extern function */
/* ///////////////////////////////////////////////////////////////////////////////////////// */
@@ -1101,46 +753,6 @@ static struct battery_data battery_main = {
#endif
};
#ifdef CONFIG_AMAZON_METRICS_LOG
/* must be called with info->lock held */
static void battery_metrics_locked(struct battery_info *info)
{
struct timespec diff;
diff = timespec_sub(current_kernel_time(), info->suspend_time);
if (diff.tv_sec > 0 && diff.tv_sec < MAX_TIME_INTERVAL) {
if (info->suspend_capacity != -1) {
char buf[256];
int drain_diff;
snprintf(buf, sizeof(buf),
"suspend_drain:def:value=%d;CT;1,elapsed=%ld;TI;1:NR",
info->suspend_capacity - BMT_status.UI_SOC,
diff.tv_sec * 1000 + diff.tv_nsec / NSEC_PER_MSEC);
log_to_metrics(ANDROID_LOG_INFO, "drain_metrics", buf);
snprintf(buf, sizeof(buf),
"batt:def:cap=%d;CT;1,mv=%d;CT;1,current_avg=%d;CT;1,"
"temp_g=%d;CT;1,charge=%d;CT;1,charge_design=%d;CT;1:NR",
BMT_status.UI_SOC, BMT_status.bat_vol,
BMT_status.ICharging, BMT_status.temperature,
gFG_BATT_CAPACITY_aging, /*battery_remaining_charge,?*/
gFG_BATT_CAPACITY /*battery_remaining_charge_design*/
);
log_to_metrics(ANDROID_LOG_INFO, "bq24296", buf);
/* This delta will be negative when charging on AC, and
* possibly also in the case of an SOC jump. */
drain_diff = info->suspend_capacity - BMT_status.UI_SOC;
if (drain_diff >= 0) {
battery_main.BAT_SuspendDrain += drain_diff;
battery_main.BAT_SuspendRealtime += diff.tv_sec;
}
}
}
}
#endif
#if !defined(CONFIG_POWER_EXT)
/* ///////////////////////////////////////////////////////////////////////////////////////// */
@@ -2392,10 +2004,6 @@ static void battery_update(struct battery_data *bat_data)
mt_battery_update_EM(bat_data);
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_handle();
#endif
if (cmd_discharging == 1) {
bat_data->BAT_STATUS = POWER_SUPPLY_STATUS_CMD_DISCHARGING;
}
@@ -3160,7 +2768,6 @@ static void mt_battery_thermal_check(void)
/* ignore default rule */
if (BMT_status.temperature <= -10) {
pr_notice("[Battery] Tbat(%d)<= -10, system need power down.\n", BMT_status.temperature);
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_BATTERY);
orderly_poweroff(true);
}
#else
@@ -3206,109 +2813,6 @@ static void mt_battery_thermal_check(void)
}
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
static void battery_charge_metric(void)
{
unsigned long virtual_temp = get_virtualsensor_temp();
char buf[512];
long elaps_sec;
struct timespec diff;
static unsigned int last_vol;
static bool batt_metrics_first_run = true;
static int battery_was_charging;
static int battery_was_charging_ticks;
static unsigned int usb_charger_voltage_previous;
if (batt_metrics_first_run)
{
batt_metrics_first_run = false;
/* Default data for first boot */
metrics_battery_save_data();
}
/* Record Peak Battery temperature during charge or discharge cycle */
if (BMT_status.temperature > metrics_charge_info.battery_peak_battery_temp)
metrics_charge_info.battery_peak_battery_temp = BMT_status.temperature;
/* Record Peak Virtual temperature during charge or discharge cycle */
if (virtual_temp > metrics_charge_info.battery_peak_virtual_temp)
metrics_charge_info.battery_peak_virtual_temp = virtual_temp;
if (metrics_charge_info.usb_charger_voltage_peak < BMT_status.charger_vol)
metrics_charge_info.usb_charger_voltage_peak = BMT_status.charger_vol;
/* Record Average Temperature Values */
metrics_charge_info.battery_average_virtual_temp =(((metrics_charge_info.battery_average_virtual_temp * metrics_charge_info.battery_charge_ticks) + virtual_temp) / (metrics_charge_info.battery_charge_ticks + 1));
metrics_charge_info.battery_average_battery_temp = ((metrics_charge_info.battery_average_battery_temp * metrics_charge_info.battery_charge_ticks) + BMT_status.temperature) / (metrics_charge_info.battery_charge_ticks + 1);
/* Increase Charging Ticks */
metrics_charge_info.battery_charge_ticks++;
/* Check to see of Charging event Status has changed. Add a 6 cycle (1 min) de-bounce to prevent extra events from firing. */
if (battery_was_charging != battery_main.BAT_STATUS)
battery_was_charging_ticks++;
else {
if (battery_was_charging_ticks > 0)
battery_was_charging_ticks--;
else
{
/* Save Last Voltage - Most of the time this voltage will be from Before Charge Started, or Before Charge Stopped. On average 8 seconds before. Since there is a few microscend delay */
/* between Actual charge start/Stop and FW knowing charge start/stop less then 1% of devices */
last_vol = BMT_status.bat_vol;
usb_charger_voltage_previous = BMT_status.charger_vol;
}
}
if (battery_was_charging_ticks > 5)
{
/* Reset ticks to 0; */
battery_was_charging_ticks = 0;
/* Calculate Elapsed Time */
diff = timespec_sub(current_kernel_time(), metrics_charge_info.charger_time);
elaps_sec = diff.tv_sec + diff.tv_nsec/NSEC_PER_SEC;
/* Handle Case where Clock changes during Charging,
* be very generous with timing as clock may be
* more accurate then ticks.
*/
if (elaps_sec > metrics_charge_info.battery_charge_ticks * 30)
elaps_sec = metrics_charge_info.battery_charge_ticks * 15;
if (elaps_sec > 0 && elaps_sec < MAX_TIME_INTERVAL) {
/* Log Metric for Charge / Discharge Cycle */
snprintf(buf, sizeof(buf),
"bq24296:def:Charger_Status=%d;CT;1,Elaps_Sec=%ld;CT;1,"
"iVol=%d;CT;1,fVol=%d;CT;1,lVol=%d;CT;1,SOC=%d;CT;1,"
"Bat_aTemp=%d;CT;1,Vir_aTemp=%d;CT;1,Bat_pTemp=%ld;CT;1,"
"Vir_pTemp=%ld;CT;1,bTemp=%d;CT;1,Cycles=%d;CT;1,"
"pVUsb=%ld;CT;1,fVUsb=%d;CT;1:NA", battery_was_charging,
elaps_sec, metrics_charge_info.init_charging_vol,
BMT_status.bat_vol, last_vol, BMT_status.SOC,
(int)metrics_charge_info.battery_average_battery_temp,
(int)metrics_charge_info.battery_average_virtual_temp,
metrics_charge_info.battery_peak_battery_temp,
metrics_charge_info.battery_peak_virtual_temp,
BMT_status.temperature, gFG_battery_cycle,
metrics_charge_info.usb_charger_voltage_peak,
usb_charger_voltage_previous);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
memset(buf, 0, sizeof(buf));
}
/*Save data for Next Metric */
metrics_battery_save_data();
/* Set Was charging Status */
battery_was_charging = battery_main.BAT_STATUS;
}
}
#endif
static void mt_battery_update_status(void)
{
@@ -3320,12 +2824,6 @@ static void mt_battery_update_status(void)
battery_update(&battery_main);
ac_update(&ac_main);
usb_update(&usb_main);
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_charger_update(ac_main.AC_ONLINE, usb_main.USB_ONLINE);
#ifdef CONFIG_AUSTIN_PROJECT
battery_charge_metric();
#endif
#endif
}
#endif
@@ -3483,10 +2981,6 @@ void update_battery_2nd_info(int status_smb, int capacity_smb, int present_smb)
void do_chrdet_int_task(void)
{
#ifdef CONFIG_AMAZON_METRICS_LOG
char buf[128] = {0};
#endif
if (g_bat_init_flag == KAL_TRUE) {
#if !defined(CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT)
if (upmu_is_chr_det() == KAL_TRUE) {
@@ -3498,13 +2992,6 @@ void do_chrdet_int_task(void)
battery_xlog_printk(BAT_LOG_CRTI, "[do_chrdet_int_task] charger exist!\n");
BMT_status.charger_exist = KAL_TRUE;
#ifdef CONFIG_AMAZON_METRICS_LOG
snprintf(buf, sizeof(buf),
"%s:bq24296:vbus_on=1;CT;1;DV;1:NR",
__func__);
log_to_metrics(ANDROID_LOG_INFO, "USBCableEvent", buf);
#endif
wake_lock(&battery_suspend_lock);
#if defined(CONFIG_POWER_EXT)
@@ -3524,14 +3011,6 @@ void do_chrdet_int_task(void)
"[do_chrdet_int_task] charger NOT exist!\n");
BMT_status.charger_exist = KAL_FALSE;
#ifdef CONFIG_AMAZON_METRICS_LOG
memset(buf, '\0', sizeof(buf));
snprintf(buf, sizeof(buf),
"%s:bq24296:vbus_off=1;CT;1;DV;1:NR",
__func__);
log_to_metrics(ANDROID_LOG_INFO, "USBCableEvent", buf);
#endif
#if defined(CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT)
battery_xlog_printk(BAT_LOG_CRTI,
"turn off charging for no avaliable charging source\n");
@@ -3573,17 +3052,6 @@ void do_chrdet_int_task(void)
/* Place charger detection and battery update here is used to speed up charging icon display. */
mt_battery_charger_detect_check();
#ifdef CONFIG_AMAZON_METRICS_LOG
memset(buf, '\0', sizeof(buf));
if (BMT_status.charger_type > CHARGER_UNKNOWN) {
snprintf(buf, sizeof(buf),
"%s:bq24296:detect=1;CT;1;type=%d;DV;1:NR",
__func__, BMT_status.charger_type);
log_to_metrics(ANDROID_LOG_INFO, "USBCableEvent", buf);
}
#endif
if (BMT_status.UI_SOC == 100 && BMT_status.charger_exist == KAL_TRUE) {
BMT_status.bat_charging_state = CHR_BATFULL;
BMT_status.bat_full = KAL_TRUE;
@@ -3622,12 +3090,6 @@ void BAT_thread(void)
static kal_bool battery_meter_initilized = KAL_FALSE;
struct timespec now_time;
unsigned long total_time_plug_in;
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
char buf[256] = {0};
unsigned long virtual_temp = get_virtualsensor_temp();
static bool bat_14days_flag;
static bool bat_demo_flag;
#endif
if (battery_meter_initilized == KAL_FALSE) {
battery_meter_initial(); /* move from battery_probe() to decrease booting time */
@@ -3653,44 +3115,10 @@ void BAT_thread(void)
if (total_time_plug_in > PLUGIN_THRESHOLD) {
g_custom_charging_cv = BATTERY_VOLT_04_100000_V;
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
if (!bat_14days_flag) {
bat_14days_flag = true;
snprintf(buf, sizeof(buf),
"bq24296:def:Charing_Over_14days=%d;CT;1,Total_Plug_Time=%ld;CT;1,"
"Bat_Vol=%d;CT;1,UI_SOC=%d;CT;1,SOC=%d;CT;1,Bat_Temp=%d;CT;1,"
"Vir_Avg_Temp=%ld;CT;1,Bat_Cycle_Count=%d;CT;1:NA",
1, total_time_plug_in, BMT_status.bat_vol, BMT_status.UI_SOC, BMT_status.SOC, BMT_status.temperature,
virtual_temp, gFG_battery_cycle);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
memset(buf, 0, 256);
}
if (total_time_plug_in <= PLUGIN_THRESHOLD && bat_14days_flag)
bat_14days_flag = false;
#endif
}
else
g_custom_charging_cv = -1;
#if defined(CONFIG_AMAZON_METRICS_LOG) && defined(CONFIG_AUSTIN_PROJECT)
if (g_custom_charging_mode == 1 && !bat_demo_flag) {
bat_demo_flag = true;
snprintf(buf, sizeof(buf),
"bq24296:def:Store_Demo_Mode=%d;CT;1,Total_Plug_Time=%ld;CT;1,"
"Bat_Vol=%d;CT;1,UI_SOC=%d;CT;1,SOC=%d;CT;1,Bat_Temp=%d;CT;1,"
"Vir_Avg_Temp=%ld;CT;1,Bat_Cycle_Count=%d;CT;1:NA",
g_custom_charging_mode, total_time_plug_in, BMT_status.bat_vol, BMT_status.UI_SOC, BMT_status.SOC, BMT_status.temperature,
virtual_temp, gFG_battery_cycle);
log_to_metrics(ANDROID_LOG_INFO, "battery", buf);
}
if (g_custom_charging_mode != 1 && bat_demo_flag)
bat_demo_flag = false;
#endif
battery_xlog_printk(BAT_LOG_FULL, "total plug-in time(%lu), cv(%d)\r\n",
total_time_plug_in, g_custom_charging_cv);
@@ -3761,19 +3189,6 @@ void bat_thread_wakeup(void)
wake_up(&bat_thread_wq);
}
#if defined(CONFIG_AMAZON_METRICS_LOG)
static void metrics_resume(void)
{
struct battery_info *info = &BQ_info;
/* invalidate all the measurements */
mutex_lock(&info->lock);
info->flags |= BQ_STATUS_RESUMING;
mutex_unlock(&info->lock);
bat_thread_wakeup();
}
#endif
/* ///////////////////////////////////////////////////////////////////////////////////////// */
/* // fop API */
/* ///////////////////////////////////////////////////////////////////////////////////////// */
@@ -4257,10 +3672,6 @@ static int battery_probe(struct platform_device *dev)
}
battery_xlog_printk(BAT_LOG_CRTI, "[BAT_probe] power_supply_register Battery Success !!\n");
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_init();
#endif
#if !defined(CONFIG_POWER_EXT)
#ifdef CONFIG_MTK_POWER_EXT_DETECT
@@ -4474,10 +3885,6 @@ static void battery_timer_resume(void)
static int battery_remove(struct platform_device *dev)
{
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_uninit();
#endif
battery_xlog_printk(BAT_LOG_CRTI, "******** battery driver remove!! ********\n");
return 0;
@@ -4768,10 +4175,6 @@ static int battery_pm_suspend(struct device *device)
struct platform_device *pdev = to_platform_device(device);
BUG_ON(pdev == NULL);
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_suspend();
#endif
return ret;
}
@@ -4781,10 +4184,6 @@ static int battery_pm_resume(struct device *device)
struct platform_device *pdev = to_platform_device(device);
BUG_ON(pdev == NULL);
#if defined(CONFIG_AMAZON_METRICS_LOG)
metrics_resume();
#endif
return ret;
}
-17
View File
@@ -89,17 +89,6 @@ config ANDROID_INTF_ALARM_DEV
elapsed realtime, and a non-wakeup alarm on the monotonic clock.
Also exports the alarm interface to user-space.
config AMAZON_METRICS_LOG
bool "Amazon metrics logging support"
depends on ANDROID_LOGGER
default y
help
Enables a new metrics log for collecting
metrics information.
These logs will be present at
/dev/log/metrics.
config SYNC
bool "Synchronization framework"
default n
@@ -127,12 +116,6 @@ config SW_SYNC_USER
*WARNING* improper use of this can result in deadlocking kernel
drivers from userspace.
config AMAZON_LOG
bool "Amazon Log"
---help---
Create a special Amazon Log area for all Amazon applications
default y
config MTK_LCA_RAM_OPTIMIZE
bool "MTK LCA ram optimize"
default n
-308
View File
@@ -29,18 +29,10 @@
#include <linux/time.h>
#include <linux/vmalloc.h>
#include <linux/aio.h>
#include <linux/irq_work.h>
#include "logger.h"
#include <asm/ioctls.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
static int metrics_init;
#define VITAL_ENTRY_MAX_PAYLOAD 512
#endif
static int s_fake_read;
module_param_named(fake_read, s_fake_read, int, 0660);
@@ -945,183 +937,6 @@ static const struct file_operations logger_fops = {
.release = logger_release,
};
#ifdef CONFIG_AMAZON_METRICS_LOG
static void logger_kernel_write(struct logger_log *log, const struct iovec *iov, unsigned long nr_segs)
{
struct logger_entry header;
struct timespec now;
unsigned long count = nr_segs;
size_t total_len = 0;
if (log == NULL)
return;
while (count-- > 0)
total_len += iov[count].iov_len;
now = current_kernel_time();
header.pid = current->tgid;
header.tid = current->pid;
header.sec = now.tv_sec;
header.nsec = now.tv_nsec;
header.len = min_t(size_t, total_len, LOGGER_ENTRY_MAX_PAYLOAD);
/* null writes succeed, return zero */
if (unlikely(!header.len))
return;
mutex_lock(&log->mutex);
/*
* Fix up any readers, pulling them forward to the first readable
* entry after (what will be) the new write offset. We do this now
* because if we partially fail, we can end up with clobbered log
* entries that encroach on readable buffer.
*/
fix_up_readers(log, sizeof(struct logger_entry) + header.len);
do_write_log(log, &header, sizeof(struct logger_entry));
total_len = 0;
while (nr_segs-- > 0) {
size_t len;
/* figure out how much of this vector we can keep */
len = min_t(size_t, iov->iov_len, header.len - total_len);
/* write out this segment's payload */
do_write_log(log, iov->iov_base, len);
iov++;
total_len += len;
}
mutex_unlock(&log->mutex);
/* wake up any blocked readers */
wake_up_interruptible(&log->wq);
}
void log_to_metrics(enum android_log_priority priority,
const char *domain, const char *log_msg)
{
static struct logger_log *log;
if (log == NULL) {
struct logger_log *t;
list_for_each_entry(t, &log_list, logs)
if (strncmp(t->misc.name, LOGGER_LOG_METRICS, strlen(LOGGER_LOG_METRICS)) == 0)
log = t;
}
if (metrics_init != 0 && log_msg != NULL) {
struct iovec vec[3];
if (domain == NULL)
domain = "kernel";
vec[0].iov_base = (unsigned char *)&priority;
vec[0].iov_len = 1;
vec[1].iov_base = (void *)domain;
vec[1].iov_len = strlen(domain) + 1;
vec[2].iov_base = (void *)log_msg;
vec[2].iov_len = strlen(log_msg) + 1;
logger_kernel_write(log, vec, 3);
}
}
void log_to_vitals(enum android_log_priority priority,
const char *domain, const char *log_msg)
{
static struct logger_log *log;
if (log == NULL) {
struct logger_log *t;
list_for_each_entry(t, &log_list, logs)
if (strncmp(t->misc.name, LOGGER_LOG_AMAZON_VITALS, strlen(LOGGER_LOG_AMAZON_VITALS)) == 0)
log = t;
}
if (metrics_init != 0 && log_msg != NULL) {
struct iovec vec[3];
if (domain == NULL)
domain = "kernel";
vec[0].iov_base = (unsigned char *)&priority;
vec[0].iov_len = 1;
vec[1].iov_base = (void *)domain;
vec[1].iov_len = strlen(domain) + 1;
vec[2].iov_base = (void *)log_msg;
vec[2].iov_len = strlen(log_msg) + 1;
logger_kernel_write(log, vec, 3);
}
}
void log_counter_to_vitals(enum android_log_priority priority,
const char *domain, const char *program,
const char *source, const char *key,
long counter_value, const char *unit,
const char *metadata, vitals_type type)
{
char str[VITAL_ENTRY_MAX_PAYLOAD];
char metadata_msg[VITAL_ENTRY_MAX_PAYLOAD];
if (metadata != NULL && strlen(metadata))
snprintf(metadata_msg, VITAL_ENTRY_MAX_PAYLOAD,
",metadata=%s;DV;1", metadata);
else
metadata_msg[0] = '\0';
/* format (program):(source):[key=(key);
DV;1,]counter=(counter_value);1,unit=(unit);
DV;1,metadata=(metadata);DV;1:HI */
if (key != NULL) {
snprintf(str, VITAL_ENTRY_MAX_PAYLOAD,
"%s:%s:type=%d;DV;1,key=%s;DV;1,counter=%ld;CT;1,unit=%s;DV;1%s:HI",
program, source, type,
key, counter_value, unit,
metadata_msg);
} else {
snprintf(str, VITAL_ENTRY_MAX_PAYLOAD,
"%s:%s:type=%d;DV;1,counter=%ld;CT;1,unit=%s;DV;1%s:HI",
program, source, type,
counter_value, unit,
metadata_msg);
}
log_to_vitals(priority, domain, str);
}
void log_timer_to_vitals(enum android_log_priority priority,
const char *domain, const char *program,
const char *source, const char *key,
long timer_value, const char *unit, vitals_type type)
{
char str[VITAL_ENTRY_MAX_PAYLOAD];
/* format (program):(source):[key=(key);
DV;1,]timer=(timer_value);1,unit=(unit);DV;1:HI */
if (key != NULL) {
snprintf(str, VITAL_ENTRY_MAX_PAYLOAD,
"%s:%s:type=%d;DV;1,key=%s;DV;1,timer=%ld;TI;1,unit=%s;DV;1:HI",
program, source, type,
key, timer_value, unit);
} else {
snprintf(str, VITAL_ENTRY_MAX_PAYLOAD,
"%s:%s:type=%d;DV;1,timer=%ld;TI;1,unit=%s;DV;1:HI",
program, source, type,
timer_value, unit);
}
log_to_vitals(priority, domain, str);
}
#endif
/*
* Log size must must be a power of two, and greater than
* (LOGGER_ENTRY_MAX_PAYLOAD + sizeof(struct logger_entry)).
@@ -1184,106 +999,10 @@ out_free_buffer:
return ret;
}
#ifdef CONFIG_AMAZON_KLOG_CONSOLE
#define KERNEL_DOMAIN "Kernel"
#define ANDROID_LOG_INFO (4)
struct kmsg_write_priv {
struct logger_log *log;
struct irq_work kmsg_write_work;
};
static void kmsg_write_work_func(struct irq_work *irq_work)
{
struct kmsg_write_priv *priv = container_of(irq_work, struct kmsg_write_priv,
kmsg_write_work);
/* wake up any blocked readers */
wake_up_interruptible(&priv->log->wq);
}
static DEFINE_PER_CPU(struct kmsg_write_priv, priv_data) = {
.kmsg_write_work = {
.func = kmsg_write_work_func,
.flags = IRQ_WORK_LAZY,
},
};
void logger_kmsg_write(const char *log_msg, size_t len)
{
static struct logger_log *log;
struct logger_entry header;
struct timespec now;
unsigned long count = 3;
size_t total_len = 0;
struct iovec iov[3];
struct iovec *piov = &iov[0];
unsigned char log_level = ANDROID_LOG_INFO;
/* get the main log handler */
if (!log) {
list_for_each_entry(log, &log_list, logs)
if (0 == strcmp(log->misc.name, LOGGER_LOG_KERNEL))
break;
}
iov[0].iov_base = (unsigned char *)&log_level;
iov[0].iov_len = 1;
iov[1].iov_base = (void *)KERNEL_DOMAIN;
iov[1].iov_len = strlen(KERNEL_DOMAIN) + 1;
iov[2].iov_base = (void *)log_msg;
iov[2].iov_len = len;
while (count-- > 0) {
total_len += iov[count].iov_len;
}
now = current_kernel_time();
header.pid = current->tgid;
header.tid = current->pid;
header.sec = now.tv_sec;
header.nsec = now.tv_nsec;
header.len = min_t(size_t, total_len, LOGGER_ENTRY_MAX_PAYLOAD);
/* null writes succeed, return zero */
if (unlikely(!header.len))
return;
/*
* Fix up any readers, pulling them forward to the first readable
* entry after (what will be) the new write offset. We do this now
* because if we partially fail, we can end up with clobbered log
* entries that encroach on readable buffer.
*/
fix_up_readers(log, sizeof(struct logger_entry) + header.len);
do_write_log(log, &header, sizeof(struct logger_entry));
total_len = 0;
count = 3;
while (count-- > 0) {
size_t len;
/* figure out how much of this vector we can keep */
len = min_t(size_t, piov->iov_len, header.len - total_len);
/* write out this segment's payload */
do_write_log(log, piov->iov_base, len);
piov++;
total_len += len;
}
__get_cpu_var(priv_data).log = log;
irq_work_queue(&(__get_cpu_var(priv_data).kmsg_write_work));
}
#endif
static int __init logger_init(void)
{
int ret;
#ifndef CONFIG_AMAZON_LOGD
ret = create_log(LOGGER_LOG_MAIN, __MAIN_BUF_SIZE);
if (unlikely(ret))
goto out;
@@ -1299,33 +1018,6 @@ static int __init logger_init(void)
ret = create_log(LOGGER_LOG_SYSTEM, __SYSTEM_BUF_SIZE);
if (unlikely(ret))
goto out;
#endif /* CONFIG_AMAZON_LOGD */
#ifdef CONFIG_AMAZON_METRICS_LOG
ret = create_log(LOGGER_LOG_METRICS, __METRICS_BUF_SIZE);
if (unlikely(ret))
goto out;
metrics_init = 1;
#endif
#ifdef CONFIG_AMAZON_LOG
#ifndef CONFIG_AMAZON_LOGD
ret = create_log(LOGGER_LOG_AMAZON_MAIN, 256*1024);
if (unlikely(ret))
goto out;
#endif /* CONFIG_AMAZON_LOGD */
ret = create_log(LOGGER_LOG_AMAZON_VITALS, __VITALS_BUF_SIZE);
if (unlikely(ret))
goto out;
#endif
#ifdef CONFIG_AMAZON_KLOG_CONSOLE
ret = create_log(LOGGER_LOG_KERNEL, __KERNEL_BUF_SIZE);
if (unlikely(ret))
goto out;
#endif
out:
return ret;
-59
View File
@@ -20,10 +20,6 @@
#include <linux/types.h>
#include <linux/ioctl.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
/**
* struct user_logger_entry_compat - defines a single entry that is given to a logger
* @len: The length of the payload
@@ -96,29 +92,7 @@ struct logger_entry {
#ifndef __SYSTEM_BUF_SIZE
#define __SYSTEM_BUF_SIZE 256*1024
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
#ifndef __METRICS_BUF_SIZE
#ifdef CONFIG_AMAZON_LOGD
#define __METRICS_BUF_SIZE (32*1024)
#else
#define __METRICS_BUF_SIZE (128*1024)
#endif /* CONFIG_AMAZON_LOGD */
#endif /* __METRICS_BUF_SIZE */
#ifndef __VITALS_BUF_SIZE
#define __VITALS_BUF_SIZE (16*1024)
#endif
#endif
#ifdef CONFIG_AMAZON_KLOG_CONSOLE
#ifndef __KERNEL_BUF_SIZE
#define __KERNEL_BUF_SIZE (256*1024)
#endif
#endif
#else
#ifndef __MAIN_BUF_SIZE
#define __MAIN_BUF_SIZE 256*1024
#endif
@@ -134,45 +108,12 @@ struct logger_entry {
#ifndef __SYSTEM_BUF_SIZE
#define __SYSTEM_BUF_SIZE 64*1024
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
#ifndef __METRICS_BUF_SIZE
#ifdef CONFIG_AMAZON_LOGD
#define __METRICS_BUF_SIZE (32*1024)
#else
#define __METRICS_BUF_SIZE (128*1024)
#endif /* CONFIG_AMAZON_LOGD */
#endif /* __METRICS_BUF_SIZE */
#ifndef __VITALS_BUF_SIZE
#define __VITALS_BUF_SIZE (16*1024)
#endif
#endif
#ifdef CONFIG_AMAZON_KLOG_CONSOLE
#ifndef __KERNEL_BUF_SIZE
#define __KERNEL_BUF_SIZE (128*1024)
#endif
#endif
#endif
#define LOGGER_LOG_RADIO "log_radio" /* radio-related messages */
#define LOGGER_LOG_EVENTS "log_events" /* system/hardware events */
#define LOGGER_LOG_SYSTEM "log_system" /* system/framework messages */
#define LOGGER_LOG_MAIN "log_main" /* everything else */
#ifdef CONFIG_AMAZON_LOG
#define LOGGER_LOG_AMAZON_MAIN "log_amazon_main" /* private buffer for amazon signed apk */
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
#define LOGGER_LOG_METRICS "log_metrics" /* metrics logs */
#define LOGGER_LOG_AMAZON_VITALS "log_vitals" /* vitals log */
#endif
#ifdef CONFIG_AMAZON_KLOG_CONSOLE
#define LOGGER_LOG_KERNEL "log_kernel" /* kernel message */
#endif
#define LOGGER_ENTRY_MAX_PAYLOAD 4076
-53
View File
@@ -38,17 +38,6 @@
#include "thermal_core.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#ifndef THERMO_METRICS_STR_LEN
#define THERMO_METRICS_STR_LEN 128
#endif
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
MODULE_AUTHOR("Zhang Rui");
MODULE_DESCRIPTION("Generic thermal management sysfs support");
MODULE_LICENSE("GPL v2");
@@ -345,10 +334,6 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
int trip, enum thermal_trip_type trip_type)
{
long trip_temp;
#ifdef CONFIG_AMAZON_METRICS_LOG
char *thermal_metric_prefix = "thermzone:def:monitor=1;CT;1";
char buf[THERMO_METRICS_STR_LEN];
#endif
tz->ops->get_trip_temp(tz, trip, &trip_temp);
@@ -360,30 +345,6 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
tz->ops->notify(tz, trip, trip_type);
if (trip_type == THERMAL_TRIP_CRITICAL) {
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
if (!strncmp(tz->type, "mtktspmic", sizeof("mtktspmic") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_PMIC);
else if (!strncmp(tz->type, "mtktsbattery", sizeof("mtktsbattery") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_BATTERY);
else if (!strncmp(tz->type, "mtktscpu", sizeof("mtktscpu") - 1) ||
!strncmp(tz->type, "mtktsabb", sizeof("mtktsabb") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_SOC);
else if (!strncmp(tz->type, "mtktswmt", sizeof("mtktswmt") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_WIFI );
else if (!strncmp(tz->type, "mtkts_bts", sizeof("mtkts_bts") - 1) ||
!strncmp(tz->type, "virtual_sensor", sizeof("virtual_sensor") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_PCB);
else if (!strncmp(tz->type, "mtktspa", sizeof("mtktspa") - 1))
life_cycle_set_thermal_shutdown_reason(THERMAL_SHUTDOWN_REASON_MODEM);
else
dev_err(&tz->device, "Thermal zone: %s reaching critial", tz->type);
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
snprintf(buf, THERMO_METRICS_STR_LEN,
"%s,thermal_temp=%d;CT;1,thermal_caught_shutdown=1;CT;1:NR",
thermal_metric_prefix, tz->temperature / 1000);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
#endif
dev_emerg(&tz->device,
"%s: critical temperature reached(%d C),shutting down\n",
tz->type, tz->temperature / 1000);
@@ -394,10 +355,6 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
{
enum thermal_trip_type type;
#ifdef CONFIG_AMAZON_METRICS_LOG
char *thermal_metric_prefix = "thermzone:def:monitor=1;CT;1";
char buf[THERMO_METRICS_STR_LEN];
#endif
tz->ops->get_trip_type(tz, trip, &type);
@@ -405,16 +362,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
handle_critical_trips(tz, trip, type);
else
handle_non_critical_trips(tz, trip, type);
#ifdef CONFIG_AMAZON_METRICS_LOG
if (type == THERMAL_TRIP_PASSIVE || type == THERMAL_TRIP_HOT) {
snprintf(buf, THERMO_METRICS_STR_LEN,
"%s,thermal_zone=%d;CT;1,temp=%d;DV;1:NR",
thermal_metric_prefix, trip, tz->temperature / 1000);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
}
#endif
/*
* Alright, we handled this trip successfully.
* So, start monitoring again.
-55
View File
@@ -37,12 +37,6 @@
#include <linux/platform_data/mtk_thermal.h>
#include <linux/thermal_framework.h>
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#define TMP103_METRICS_STR_LEN 128
static unsigned long virtual_sensor_temp = 25000;
#endif
#include "thermal_core.h"
#define DRIVER_NAME "virtual_sensor-thermal"
@@ -55,14 +49,6 @@ static unsigned long virtual_sensor_temp = 25000;
static LIST_HEAD(thermal_sensor_list);
static DEFINE_MUTEX(therm_lock);
#ifdef CONFIG_AMAZON_METRICS_LOG
unsigned long get_virtualsensor_temp(void)
{
return virtual_sensor_temp/1000;
}
EXPORT_SYMBOL(get_virtualsensor_temp);
#endif
struct virtual_sensor_thermal_zone {
struct thermal_zone_device *tz;
struct work_struct therm_work;
@@ -154,38 +140,15 @@ static int virtual_sensor_thermal_get_temp(struct thermal_zone_device *thermal,
int alpha, offset, weight;
static unsigned sec_counter = 0; /* Timer counter: 1sec */
#ifdef CONFIG_AMAZON_METRICS_LOG
#define PREFIX "thermalsensor:def"
char buf[TMP103_METRICS_STR_LEN];
static unsigned int mask = 0x1FFF;
unsigned int count;
static atomic_t query_count;
int i;
#endif
if (!tzone || !pdata)
return -EINVAL;
#ifdef CONFIG_AMAZON_METRICS_LOG
count = atomic_read(&query_count);
atomic_inc(&query_count);
i = 0;
#endif
list_for_each_entry(tdev, &thermal_sensor_list, node) {
temp = tdev->dev_ops->get_temp(tdev);
alpha = tdev->tdp->alpha;
offset = tdev->tdp->offset;
weight = tdev->tdp->weight;
#ifdef CONFIG_AMAZON_METRICS_LOG
if (!(count & mask)) {
snprintf(buf, TMP103_METRICS_STR_LEN,
"%s:pcbmonitor=%d;CT;1,%s_temp=%lu;CT;1:NA",
PREFIX, i++, tdev->name, temp);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
}
#endif
if (0 == sec_counter)
pr_warning("%s %s t=%ld a=%d o=%d w=%d\n",
__func__,
@@ -211,24 +174,6 @@ static int virtual_sensor_thermal_get_temp(struct thermal_zone_device *thermal,
if (TEMPERATURE_PRINT_INTERVAL_SECONDS == sec_counter)
sec_counter = 0;
#ifdef CONFIG_AMAZON_METRICS_LOG
if (!(count & mask)) {
snprintf(buf, TMP103_METRICS_STR_LEN,
"%s:pcbmonitor=%d;CT;1,pcb_virtual_sensor_temp=%lu;CT;1:NR",
PREFIX, i++, tempv);
log_to_metrics(ANDROID_LOG_INFO, "ThermalEvent", buf);
}
if (tempv > pdata->trips[0].temp)
/* Log in metrics around every 4 mins */
mask = 0xFF;
else
/* Log in metrics around every 2 hours */
mask = 0x1FFF;
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
virtual_sensor_temp = (unsigned long) tempv;
#endif
*t = tempv; /* back to unsigned expected by linux framework */
return 0;
}
-8
View File
@@ -312,14 +312,6 @@ struct mmc_card {
struct dentry *debugfs_root;
struct mmc_part part[MMC_NUM_PHY_PARTITION]; /* physical partitions */
unsigned int nr_parts;
#ifdef CONFIG_AMAZON_METRICS_LOG /* for attribute */
unsigned int minReservedBlocks;
unsigned int maxEraseCountMLC;
unsigned int avgEraseCountMLC;
unsigned int maxEraseCountSLC;
unsigned int avgEraseCountSLC;
#endif /* CONFIG_AMAZON_METRICS_LOG */
};
/*
-4
View File
@@ -338,10 +338,6 @@ struct mmc_host {
unsigned long clkgate_delay;
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
struct delayed_work metrics_delay_work; /* delayed metrics output */
#endif /* CONFIG_AMAZON_METRICS_LOG */
#ifdef CONFIG_MMC_ERR_REMOVE
bool rest_remove_flags;
#endif
-4
View File
@@ -27,10 +27,6 @@ typedef struct {
/* ============================================================ */
/* External Variables */
/* ============================================================ */
#if defined(CONFIG_AMAZON_METRICS_LOG)
extern kal_int32 gFG_BATT_CAPACITY_aging;
extern kal_int32 gFG_BATT_CAPACITY;
#endif
/* ============================================================ */
/* External function */
-13
View File
@@ -26,13 +26,6 @@
#ifdef CONFIG_MTK_RTC
#include <mach/mtk_rtc.h>
#endif
#ifdef CONFIG_MDUMP
#include <linux/mdump.h>
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
#define PANIC_TIMER_STEP 100
#define PANIC_BLINK_SPD 18
@@ -121,13 +114,7 @@ void panic(const char *fmt, ...)
if (rtc_get_reboot_reason() != RTC_REBOOT_REASON_SW_WDT)
rtc_mark_reboot_reason(RTC_REBOOT_REASON_PANIC);
#endif
#ifdef CONFIG_MDUMP
mdump_mark_reboot_reason(MDUMP_REBOOT_PANIC);
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_boot_reason(WARMBOOT_BY_KERNEL_PANIC);
#endif
printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);
#ifdef CONFIG_DEBUG_BUGVERBOSE
/*
-45
View File
@@ -18,10 +18,6 @@
#include "power.h"
#ifdef CONFIG_AMAZON_METRICS_LOG
#include <linux/metricslog.h>
#endif
#define HIB_PM_DEBUG 1
#define _TAG_HIB_M "HIB/PM"
#if (HIB_PM_DEBUG)
@@ -33,10 +29,6 @@
#undef hib_warn
#define hib_warn(fmt, ...) pr_warn("[%s][%s]" fmt, _TAG_HIB_M, __func__, ##__VA_ARGS__);
#ifdef CONFIG_AMAZON_METRICS_LOG
struct delayed_work suspend_work;
#endif
DEFINE_MUTEX(pm_mutex);
EXPORT_SYMBOL_GPL(pm_mutex);
@@ -735,38 +727,6 @@ static int __init pm_start_workqueue(void)
static inline int pm_start_workqueue(void) { return 0; }
#endif
#ifdef CONFIG_AMAZON_METRICS_LOG
static void suspend_metrics_work(struct work_struct *work)
{
char buf[400] = {0};
struct delayed_work *dw = container_of(work, struct delayed_work, work);
int last_dev, last_errno, last_step;
last_dev = suspend_stats.last_failed_dev + REC_FAILED_NUM - 1;
last_dev %= REC_FAILED_NUM;
last_errno = suspend_stats.last_failed_errno + REC_FAILED_NUM - 1;
last_errno %= REC_FAILED_NUM;
last_step = suspend_stats.last_failed_step + REC_FAILED_NUM - 1;
last_step %= REC_FAILED_NUM;
snprintf(buf, sizeof(buf),"suspend_event:def:success=%d;CT;1,fail=%d;CT;1,"
"failed_freeze=%d;CT;1,failed_prepare=%d;CT;1,failed_suspend=%d;CT;1,"
"failed_suspend_late=%d;CT;1,failed_suspend_noirq=%d;CT;1,"
"failed_resume=%d;CT;1,failed_resume_early=%d;CT;1,"
"failed_resume_noirq=%d;CT;1,last_failed_dev=%s;DV;1,"
"last_failed_errno=%d;CT;1,last_failed_step=%d;CT;1:NR",
suspend_stats.success, suspend_stats.fail, suspend_stats.failed_freeze,
suspend_stats.failed_prepare, suspend_stats.failed_suspend,
suspend_stats.failed_suspend_late, suspend_stats.failed_suspend_noirq,
suspend_stats.failed_resume, suspend_stats.failed_resume_early,
suspend_stats.failed_resume_noirq, suspend_stats.failed_devs[last_dev],
suspend_stats.errno[last_errno], suspend_stats.failed_steps[last_step]);
log_to_metrics(ANDROID_LOG_INFO, "SuspendEvent", buf);
schedule_delayed_work(dw, 12*3600*HZ);
}
#endif
static int __init pm_init(void)
{
int error = pm_start_workqueue();
@@ -781,11 +741,6 @@ static int __init pm_init(void)
if (error)
return error;
pm_print_times_init();
#ifdef CONFIG_AMAZON_METRICS_LOG
INIT_DELAYED_WORK(&suspend_work, suspend_metrics_work);
schedule_delayed_work(&suspend_work, 3600*HZ);
#endif
return pm_autosleep_init();
}
-20
View File
@@ -65,18 +65,10 @@
#include <asm/io.h>
#include <asm/unistd.h>
#ifdef CONFIG_MDUMP
#include <linux/mdump.h>
#endif
#ifdef CONFIG_MT_PRIO_TRACER
# include <linux/prio_tracer.h>
#endif
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
#include <linux/sign_of_life.h>
#endif
#ifndef SET_UNALIGN_CTL
# define SET_UNALIGN_CTL(a,b) (-EINVAL)
#endif
@@ -422,9 +414,6 @@ void kernel_restart(char *cmd)
else
printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd);
kmsg_dump(KMSG_DUMP_RESTART);
#ifdef CONFIG_MDUMP
mdump_mark_reboot_reason(MDUMP_REBOOT_NORMAL);
#endif
machine_restart(cmd);
}
EXPORT_SYMBOL_GPL(kernel_restart);
@@ -461,9 +450,6 @@ EXPORT_SYMBOL_GPL(kernel_halt);
*/
void kernel_power_off(void)
{
#ifdef CONFIG_MDUMP
mdump_mark_reboot_reason(MDUMP_COLD_RESET);
#endif
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
if (pm_power_off_prepare)
pm_power_off_prepare();
@@ -539,17 +525,11 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
panic("cannot halt");
case LINUX_REBOOT_CMD_POWER_OFF:
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_shutdown_reason(SHUTDOWN_BY_SW);
#endif
kernel_power_off();
do_exit(0);
break;
case LINUX_REBOOT_CMD_RESTART2:
#ifdef CONFIG_AMAZON_SIGN_OF_LIFE
life_cycle_set_boot_reason(WARMBOOT_BY_SW);
#endif
if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) {
ret = -EFAULT;
break;