kernel: add debug-config for debug use

1. gpio status printed before cpu sleep, for debug use.
2. enable dump clk/regulator on suspend for userdebug SW.

Change-Id: Icb45c5bd9300650bba4ab6c8795b492bedaa25de
Signed-off-by: ontim52 <ontim52@motorola.com>
Reviewed-on: https://gerrit.mot.com/2710381
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
ontim52 2023-08-16 10:40:29 +08:00 • committed by Xiaojun Ji
commit ef1ce4231a
6 changed files with 116 additions and 2 deletions

View file

@ -140,3 +140,6 @@ CONFIG_MMC_IPC_LOGGING=y
CONFIG_CRYPTO_SHA1_ARM64_CE=y
CONFIG_DEBUG_PAGEALLOC=y
CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT=y
CONFIG_DUMP_GPIO_ON_SUSPEND=y
CONFIG_DUMP_CLK_ON_SUSPEND=y
CONFIG_DUMP_REGULATOR_ON_SUSPEND=y

View file

@ -3481,7 +3481,7 @@ static const struct file_operations clk_enabled_list_fops = {
.release = seq_release,
};
static u32 debug_suspend;
static u32 debug_suspend = IS_ENABLED(CONFIG_DUMP_CLK_ON_SUSPEND);
/*
* Print the names of all enabled clocks and their parents if

View file

@ -123,6 +123,8 @@ static void cluster_prepare(struct lpm_cluster *cluster,
static bool sleep_disabled;
module_param_named(sleep_disabled, sleep_disabled, bool, 0664);
extern void gpio_debug_print_enabled(void);
#ifdef CONFIG_SMP
static int lpm_cpu_qos_notify(struct notifier_block *nb,
unsigned long val, void *ptr);
@ -1119,6 +1121,7 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
if (!from_idle) {
clock_debug_print_enabled();
regulator_debug_print_enabled();
gpio_debug_print_enabled();
}
cpu = get_next_online_cpu(from_idle);

View file

@ -5063,6 +5063,104 @@ static int gpiolib_seq_show(struct seq_file *s, void *v)
return 0;
}
static u32 debug_gpio = IS_ENABLED(CONFIG_DUMP_GPIO_ON_SUSPEND);
void gpio_debug_print_enabled(void)
{
unsigned long flags;
struct gpio_device *gdev = NULL;
struct seq_file *s;
int back;
if (likely(!debug_gpio))
{
return;
}
printk("======================= Dump GPIO status begin =======================");
spin_lock_irqsave(&gpio_lock, flags);
s = kzalloc(sizeof(struct seq_file), GFP_KERNEL);
if(s == NULL)
{
printk("hxy struct seq file failed to alloc memory");
return;
}
s->index = 0;
s->version = 0;
s->count = s->from = 0;
s->read_pos= 0;
s->private = NULL;
s->file = NULL;
s->op = NULL;
s->private = "";
s->buf = kzalloc(s->size = PAGE_SIZE,GFP_KERNEL_ACCOUNT);
if (!s->buf)
{
printk("hxy seq file buffer failed to alloc memory %d bytes",s->size);
kfree(s );
return ;
}
list_for_each_entry(gdev, &gpio_devices, list)
{
try_again:
s->count = 0;
back=s->count;
gpiolib_seq_show(s,gdev);
if(s->count >= s->size)
{
kfree(s->buf );
s->buf = kzalloc(s->size = (s->size*2),GFP_KERNEL_ACCOUNT);
if (!s->buf)
{
printk("hxy seq file buffer failed to alloc memory %d bytes",s->size);
kfree(s );
return ;
}
goto try_again;
}
s->buf[s->count] = '\0';
{
char tt[256];
char *ptr;
char *ptr1;
int n;
int loop;
ptr1=s->buf+back;
ptr=strstr(ptr1,"\x0a");
loop=0;
while(ptr != NULL && (loop++ < 500) && (ptr < (s->buf+ s->size)))
{
n=ptr-ptr1;
strncpy(tt,ptr1,n);
tt[n]='\0';
printk(" %s",tt);
ptr1 = ptr+strlen("\x0a");
ptr=strstr(ptr1,"\x0a");
}
}
}
if(s->buf != NULL)
{
kfree(s->buf );
s->buf = NULL;
}
if(s != NULL)
{
kfree(s );
s = NULL;
}
spin_unlock_irqrestore(&gpio_lock, flags);
printk("======================= Dump GPIO status end =======================");
}
EXPORT_SYMBOL(gpio_debug_print_enabled);
static const struct seq_operations gpiolib_seq_ops = {
.start = gpiolib_seq_start,
.next = gpiolib_seq_next,
@ -5088,6 +5186,7 @@ static int __init gpiolib_debugfs_init(void)
/* /sys/kernel/debug/gpio */
debugfs_create_file("gpio", S_IFREG | S_IRUGO, NULL, NULL,
&gpiolib_operations);
debugfs_create_u32("debug_gpio", 0644, NULL, &debug_gpio);
return 0;
}
subsys_initcall(gpiolib_debugfs_init);

View file

@ -55,7 +55,7 @@ static LIST_HEAD(regulator_supply_alias_list);
static LIST_HEAD(regulator_coupler_list);
static bool has_full_constraints;
#ifdef CONFIG_DEBUG_FS
static bool debug_suspend;
static bool debug_suspend = IS_ENABLED(CONFIG_DUMP_REGULATOR_ON_SUSPEND);
#endif
static struct dentry *debugfs_root;

View file

@ -639,6 +639,15 @@ config IKHEADERS
or similar programs. If you build the headers as a module, a module called
kheaders.ko is built which can be loaded on-demand to get access to headers.
config DUMP_GPIO_ON_SUSPEND
bool "dump gpio on suspend"
config DUMP_CLK_ON_SUSPEND
bool "dump clk on suspend"
config DUMP_REGULATOR_ON_SUSPEND
bool "dump regulator on suspend"
config LOG_BUF_SHIFT
int "Kernel log buffer size (16 => 64KB, 17 => 128KB)"
range 12 25 if !H8300