From ddc2be88c6b0ca6a42009482a26dc057da98e5ed Mon Sep 17 00:00:00 2001 From: Anvesh Salveru Date: Thu, 31 Mar 2022 13:34:00 +0000 Subject: [PATCH] tegra_bootloader_debug: sysfs to add profile point This change creates a sysfs entry to add a new profiling record in bootloader profiler memory. Bug 3512531 Change-Id: I580efe0872e1801b1d3b61fa7698ed7aed7fa9ec Signed-off-by: Anvesh Salveru Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2691788 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2864627 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: svcacv Reviewed-by: Bharat Nihalani Tested-by: Bharat Nihalani GVS: Gerrit_Virtual_Submit --- .../platform/tegra/tegra_bootloader_debug.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/platform/tegra/tegra_bootloader_debug.c b/drivers/platform/tegra/tegra_bootloader_debug.c index 10390efa..3c2c426d 100644 --- a/drivers/platform/tegra/tegra_bootloader_debug.c +++ b/drivers/platform/tegra/tegra_bootloader_debug.c @@ -226,6 +226,18 @@ size_t tegra_bl_add_profiler_entry(const char *buf, size_t len) } EXPORT_SYMBOL(tegra_bl_add_profiler_entry); +static ssize_t add_profiler_record_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t len) +{ + if (tegra_bl_add_profiler_entry(buf, len)) + pr_err("Error adding profiler entry failed\n"); + + return len; +} + +static struct kobj_attribute add_profiler_record_attribute = + __ATTR_WO(add_profiler_record); #ifdef CONFIG_DEBUG_FS static int dbg_golden_register_show(struct seq_file *s, void *unused) @@ -397,6 +409,14 @@ static int __init tegra_bootloader_debuginit(void) goto out_err; } + bl_debug_verify_file_entry = sysfs_create_file(boot_profiler_kobj, + &add_profiler_record_attribute.attr); + if (bl_debug_verify_file_entry) { + pr_err("%s: failed to create sysfs file : %d\n", + module_name, bl_debug_verify_file_entry); + goto out_err; + } + if (tegra_bl_prof_start != 0 && !pfn_valid(__phys_to_pfn(tegra_bl_prof_start))) { ptr_bl_prof_start = ioremap(tegra_bl_prof_start, tegra_bl_prof_size); @@ -441,6 +461,8 @@ out_err: if (boot_profiler_kobj) { sysfs_remove_file(boot_profiler_kobj, &profiler_attribute.attr); + sysfs_remove_file(boot_profiler_kobj, + &add_profiler_record_attribute.attr); kobject_put(boot_profiler_kobj); boot_profiler_kobj = NULL; } @@ -518,6 +540,8 @@ static void __exit tegra_bl_debuginit_module_exit(void) if (boot_profiler_kobj) { sysfs_remove_file(boot_profiler_kobj, &profiler_attribute.attr); + sysfs_remove_file(boot_profiler_kobj, + &add_profiler_record_attribute.attr); kobject_put(boot_profiler_kobj); boot_profiler_kobj = NULL; }