From 1bca209df305f86d8e01a7942423648c95900a6a Mon Sep 17 00:00:00 2001 From: Redick_Lin Date: Thu, 10 Nov 2022 23:45:15 +0800 Subject: [PATCH] acpm: support dynamic ctrl of ipc retry logging Also configure retry log dump as default off Bug: 243085956 Change-Id: Ib51d8d6ca3c45415691c313c53f19699cc102376 Signed-off-by: Redick_Lin --- drivers/soc/google/acpm/acpm.c | 17 +++++++++++++++++ drivers/soc/google/acpm/acpm_ipc.c | 23 ++++++++++++++++++----- drivers/soc/google/acpm/acpm_ipc.h | 3 +++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/drivers/soc/google/acpm/acpm.c b/drivers/soc/google/acpm/acpm.c index 10e02f56b482..79fd8f5ea657 100644 --- a/drivers/soc/google/acpm/acpm.c +++ b/drivers/soc/google/acpm/acpm.c @@ -35,6 +35,19 @@ static int debug_log_level_set(void *data, unsigned long long val) return 0; } +static int debug_retry_log_ctrl_get(void *data, unsigned long long *val) +{ + *val = acpm_fw_get_retry_log_ctrl(); + return 0; +} + +static int debug_retry_log_ctrl_set(void *data, unsigned long long val) +{ + acpm_fw_set_retry_log_ctrl(val); + + return 0; +} + static int debug_ipc_loopback_test_get(void *data, unsigned long long *val) { struct acpm_info *acpm = (struct acpm_info *) data; @@ -206,6 +219,8 @@ static int debug_acpm_framework_cmd_set(void *data, u64 val) DEFINE_SIMPLE_ATTRIBUTE(debug_log_level_fops, debug_log_level_get, debug_log_level_set, "0%llu\n"); +DEFINE_SIMPLE_ATTRIBUTE(debug_retry_log_ctrl_fops, + debug_retry_log_ctrl_get, debug_retry_log_ctrl_set, "0%llu\n"); DEFINE_SIMPLE_ATTRIBUTE(debug_ipc_loopback_test_fops, debug_ipc_loopback_test_get, NULL, "%llu\n"); DEFINE_SIMPLE_ATTRIBUTE(debug_uart_gprio_level_fops, @@ -229,6 +244,8 @@ static void acpm_debugfs_init(struct acpm_info *acpm) &debug_ipc_loopback_test_fops); debugfs_create_file("log_level", 0644, den, acpm, &debug_log_level_fops); + debugfs_create_file("retry_log_ctrl", 0644, den, acpm, + &debug_retry_log_ctrl_fops); debugfs_create_file("uart_gprio_level", 0644, den, acpm, &debug_uart_gprio_level_fops); debugfs_create_file("logb_gprio_level", 0644, den, acpm, diff --git a/drivers/soc/google/acpm/acpm_ipc.c b/drivers/soc/google/acpm/acpm_ipc.c index f554467a24fe..ea3b71755bf4 100644 --- a/drivers/soc/google/acpm/acpm_ipc.c +++ b/drivers/soc/google/acpm/acpm_ipc.c @@ -197,6 +197,16 @@ unsigned int acpm_fw_get_log_level(void) return acpm_debug->debug_log_level; } +void acpm_fw_set_retry_log_ctrl(bool enable) +{ + acpm_debug->retry_log = enable; +} + +unsigned int acpm_fw_get_retry_log_ctrl(void) +{ + return acpm_debug->retry_log; +} + void acpm_ramdump(void) { if (acpm_debug->dump_size) @@ -731,6 +741,7 @@ int __acpm_ipc_send_data(unsigned int channel_id, struct ipc_config *cfg, bool w spin_unlock_irqrestore(&channel->tx_lock, flags); if (channel->polling && cfg->response) { + unsigned int saved_debug_log_level = acpm_debug->debug_log_level; retry: timeout = sched_clock() + IPC_TIMEOUT; timeout_flag = false; @@ -764,16 +775,18 @@ int __acpm_ipc_send_data(unsigned int channel_id, struct ipc_config *cfg, bool w __raw_readl(acpm_ipc->intr + INTMSR1)); cpu_irq_info_dump(retry_cnt); + if (retry_cnt == 1) { + acpm_debug->debug_log_level = + acpm_debug->retry_log ? + 2 : saved_debug_log_level; + acpm_log_print(); + acpm_debug->debug_log_level = saved_debug_log_level; + } ++retry_cnt; goto retry; } else { - unsigned int saved_debug_log_level = - acpm_debug->debug_log_level; ++retry_cnt; - acpm_debug->debug_log_level = 2; - acpm_log_print(); - acpm_debug->debug_log_level = saved_debug_log_level; continue; } cnt_10us = 0; diff --git a/drivers/soc/google/acpm/acpm_ipc.h b/drivers/soc/google/acpm/acpm_ipc.h index 669f6737db21..0f90b61c2719 100644 --- a/drivers/soc/google/acpm/acpm_ipc.h +++ b/drivers/soc/google/acpm/acpm_ipc.h @@ -79,6 +79,7 @@ struct acpm_debug_info { unsigned int dump_size; void __iomem *dump_dram_base; unsigned int debug_log_level; + unsigned int retry_log; struct delayed_work acpm_log_work; unsigned int async_id; /* ACPM IPC_AP_ERR_LOG_ASYNC channel id */ unsigned int async_size; /* ACPM IPC_AP_ERR_LOG_ASYNC channel queue sizes */ @@ -142,6 +143,8 @@ extern void timestamp_write(void); extern void acpm_ramdump(void); extern void acpm_fw_set_log_level(unsigned int on); extern unsigned int acpm_fw_get_log_level(void); +extern void acpm_fw_set_retry_log_ctrl(bool enable); +extern unsigned int acpm_fw_get_retry_log_ctrl(void); extern void acpm_ipc_set_waiting_mode(bool mode); extern int acpm_ipc_remove(struct platform_device *pdev);