summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-16 00:15:47 +0300
committerTom Rini <trini@konsulko.com>2023-02-11 20:22:35 +0300
commitc3d91812a2b69fbc73eccdcec70d7ea510d7c8bd (patch)
tree5ae0a2527e8e8541c41c53159fd9a89bc79b861f /lib
parentd9044e5363bb0b32a7aff00adf47c227f78f0f32 (diff)
downloadu-boot-c3d91812a2b69fbc73eccdcec70d7ea510d7c8bd.tar.xz
trace: Reduce the number of function sites
Given that the compiler adds two function calls into each function, the current spacing is overkill. Drop it down to 16 bytes per function, which is still plenty. This saves some space in the trace buffer. Also move the calculation into a function, so it is common code. Add a check for gd->mon_len being unset, which breaks tracing. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/trace.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/trace.c b/lib/trace.c
index 2e2c1bed54..12dae2089a 100644
--- a/lib/trace.c
+++ b/lib/trace.c
@@ -321,6 +321,17 @@ void notrace trace_set_enabled(int enabled)
trace_enabled = enabled != 0;
}
+static int get_func_count(void)
+{
+ /* Detect no support for mon_len since this means tracing cannot work */
+ if (IS_ENABLED(CONFIG_SANDBOX) && !gd->mon_len) {
+ puts("Tracing is not supported on this board\n");
+ return -ENOTSUPP;
+ }
+
+ return gd->mon_len / FUNC_SITE_SIZE;
+}
+
/**
* trace_init() - initialize the tracing system and enable it
*
@@ -330,10 +341,12 @@ void notrace trace_set_enabled(int enabled)
*/
int notrace trace_init(void *buff, size_t buff_size)
{
- ulong func_count = gd->mon_len / FUNC_SITE_SIZE;
+ int func_count = get_func_count();
size_t needed;
int was_disabled = !trace_enabled;
+ if (func_count < 0)
+ return func_count;
trace_save_gd();
if (!was_disabled) {
@@ -393,10 +406,12 @@ int notrace trace_init(void *buff, size_t buff_size)
*/
int notrace trace_early_init(void)
{
- ulong func_count = gd->mon_len / FUNC_SITE_SIZE;
+ int func_count = get_func_count();
size_t buff_size = CONFIG_TRACE_EARLY_SIZE;
size_t needed;
+ if (func_count < 0)
+ return func_count;
/* We can ignore additional calls to this function */
if (trace_enabled)
return 0;