Skip to content

Commit 26cb10a

Browse files
committed
feat(esp_hw_support): optimize retention link info dump
1 parent a27aa02 commit 26cb10a

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

components/esp_hw_support/include/esp_private/esp_regdma.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ extern "C" {
2222
#if SOC_PAU_SUPPORTED
2323
#include "hal/pau_types.h"
2424

25-
#define REGDMA_LINK_DBG 0 /* Enable REGDMA link info dump apis*/
26-
2725
/**
2826
* @brief Create a REGDMA continuous type linked list node without retention buffer and the retention buffer is passed in by the caller
2927
* @param backup Register address to be backed up by REGDMA

components/esp_hw_support/port/regdma_link.c

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -8,6 +8,7 @@
88
#include <string.h>
99
#include <assert.h>
1010
#include <sys/cdefs.h>
11+
#include <inttypes.h>
1112

1213
#include "esp_private/regdma_link.h"
1314

@@ -713,13 +714,17 @@ void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint
713714
return NULL;
714715
}
715716

716-
#if REGDMA_LINK_DBG
717717
static __attribute__((unused)) const char *TAG = "regdma_link";
718+
static const char* s_link_mode_str[] = { "CONTINUOUS", "ADDR_MAP", "WRITE", "WAIT" };
719+
static const char* s_boolean_str[] = { "false", "true" };
718720

719721
static void print_info_link_data(FILE *out, const uint32_t buf[], int len)
720722
{
721723
for (int i = 0; i < len; i++) {
722-
fprintf(out, ((i + 1) % 8) ? "%08lx " : "%08lx\n", buf[i]);
724+
if (i % 8 == 0) {
725+
fprintf(out, "\t\t");
726+
}
727+
fprintf(out, ((i + 1) % 8) ? "%08"PRIx32" " : "%08"PRIx32"\n", buf[i]);
723728
}
724729
if (len % 8) {
725730
fprintf(out, "\n");
@@ -730,38 +735,50 @@ static void print_info_continuous_wrapper(FILE *out, void *link)
730735
{
731736
regdma_link_head_t head = REGDMA_LINK_HEAD(link);
732737
regdma_link_continuous_t *cons = __containerof(link, regdma_link_continuous_t, head);
733-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, restore:%p, buff:%p\n",
734-
cons->stat.module, cons->stat.id, link, *(uint32_t *)&cons->head, cons->body.next,
735-
cons->body.backup, cons->body.restore, cons->body.mem);
738+
assert((cons->stat.module & (cons->stat.module - 1)) == 0);
739+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p\n" LOG_RESET_COLOR,
740+
__builtin_ffs(cons->stat.module) - 1, cons->stat.id, link,
741+
s_link_mode_str[cons->head.mode], cons->head.length, s_boolean_str[cons->head.branch], s_boolean_str[cons->head.skip_r], s_boolean_str[cons->head.skip_b], s_boolean_str[cons->head.eof],
742+
cons->body.next,
743+
cons->body.backup, cons->body.restore,
744+
cons->body.mem);
736745
print_info_link_data(out, (const uint32_t *)cons->body.mem, head.length);
737746
}
738747

739748
static void print_info_addr_map_wrapper(FILE *out, void *link)
740749
{
741750
regdma_link_head_t head = REGDMA_LINK_HEAD(link);
742751
regdma_link_addr_map_t *map = __containerof(link, regdma_link_addr_map_t, head);
743-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, restore:%p, buff:%p, map:{%lx,%lx,%lx,%lx}\n",
744-
map->stat.module, map->stat.id, link, *(uint32_t *)&map->head, map->body.next, map->body.backup,
745-
map->body.restore, map->body.mem, map->body.map[0], map->body.map[1],
746-
map->body.map[2], map->body.map[3]);
752+
assert((map->stat.module & (map->stat.module - 1)) == 0);
753+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p, map:{%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"}\n" LOG_RESET_COLOR,
754+
__builtin_ffs(map->stat.module) - 1, map->stat.id, link,
755+
s_link_mode_str[map->head.mode], map->head.length, s_boolean_str[map->head.branch], s_boolean_str[map->head.skip_r], s_boolean_str[map->head.skip_b], s_boolean_str[map->head.eof],
756+
map->body.next,
757+
map->body.backup, map->body.restore,
758+
map->body.mem, map->body.map[0], map->body.map[1], map->body.map[2], map->body.map[3]);
747759
print_info_link_data(out, (const uint32_t *)map->body.mem, head.length);
748760
}
749761

750762
static void print_info_write_wait_wrapper(FILE *out, void *link)
751763
{
752764
regdma_link_write_wait_t *ww = __containerof(link, regdma_link_write_wait_t, head);
753-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, value:%lx, mask:%lx\n",
754-
ww->stat.module, ww->stat.id, link, *(uint32_t *)&ww->head, ww->body.next,
765+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, value:%"PRIx32", mask:%"PRIx32"\n" LOG_RESET_COLOR,
766+
__builtin_ffs(ww->stat.module) - 1, ww->stat.id, link,
767+
s_link_mode_str[ww->head.mode], ww->head.length, s_boolean_str[ww->head.branch], s_boolean_str[ww->head.skip_r], s_boolean_str[ww->head.skip_b], s_boolean_str[ww->head.eof],
768+
ww->body.next,
755769
ww->body.backup, ww->body.value, ww->body.mask);
756770
}
757771

758772
static void print_info_branch_continuous_wrapper(FILE *out, void *link)
759773
{
760774
regdma_link_head_t head = REGDMA_LINK_HEAD(link);
761775
regdma_link_branch_continuous_t *cons = __containerof(link, regdma_link_branch_continuous_t, head);
762-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, restore:%p, buff:%p\n",
763-
cons->stat.module, cons->stat.id, link, *(uint32_t *)&cons->head, cons->body.next[0], cons->body.next[1],
764-
cons->body.next[2], cons->body.next[3], cons->body.backup, cons->body.restore,
776+
assert((cons->stat.module & (cons->stat.module - 1)) == 0);
777+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p\n" LOG_RESET_COLOR,
778+
__builtin_ffs(cons->stat.module) - 1, cons->stat.id, link,
779+
s_link_mode_str[cons->head.mode], cons->head.length, s_boolean_str[cons->head.branch], s_boolean_str[cons->head.skip_r], s_boolean_str[cons->head.skip_b], s_boolean_str[cons->head.eof],
780+
cons->body.next,
781+
cons->body.backup, cons->body.restore,
765782
cons->body.mem);
766783
print_info_link_data(out, (const uint32_t *)cons->body.mem, head.length);
767784
}
@@ -770,20 +787,24 @@ static void print_info_branch_addr_map_wrapper(FILE *out, void *link)
770787
{
771788
regdma_link_head_t head = REGDMA_LINK_HEAD(link);
772789
regdma_link_branch_addr_map_t *map = __containerof(link, regdma_link_branch_addr_map_t, head);
773-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, restore:%p, buff:%p, map:{%lx,%lx,%lx,%lx}\n",
774-
map->stat.module, map->stat.id, link, *(uint32_t *)&map->head, map->body.next[0], map->body.next[1], map->body.next[2],
775-
map->body.next[3], map->body.backup, map->body.restore, map->body.mem, map->body.map[0],
776-
map->body.map[1], map->body.map[2], map->body.map[3]);
790+
assert((map->stat.module & (map->stat.module - 1)) == 0);
791+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p, map:{%"PRIx32",%"PRIx32",%"PRIx32",%"PRIx32"}\n" LOG_RESET_COLOR,
792+
__builtin_ffs(map->stat.module) - 1, map->stat.id, link,
793+
s_link_mode_str[map->head.mode], map->head.length, s_boolean_str[map->head.branch], s_boolean_str[map->head.skip_r], s_boolean_str[map->head.skip_b], s_boolean_str[map->head.eof],
794+
map->body.next,
795+
map->body.backup, map->body.restore,
796+
map->body.mem, map->body.map[0], map->body.map[1], map->body.map[2], map->body.map[3]);
777797
print_info_link_data(out, (const uint32_t *)map->body.mem, head.length);
778798
}
779799

780800
static void print_info_branch_write_wait_wrapper(FILE *out, void *link)
781801
{
782802
regdma_link_branch_write_wait_t *ww = __containerof(link, regdma_link_branch_write_wait_t, head);
783-
fprintf(out, "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, value:%lx, mask:%lx\n",
784-
ww->stat.module, ww->stat.id, link, *(uint32_t *)&ww->head, ww->body.next[0], ww->body.next[1],
785-
ww->body.next[2], ww->body.next[3], ww->body.backup, ww->body.value,
786-
ww->body.mask);
803+
fprintf(out, LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, value:%"PRIx32", mask:%"PRIx32"\n" LOG_RESET_COLOR,
804+
__builtin_ffs(ww->stat.module) - 1, ww->stat.id, link,
805+
s_link_mode_str[ww->head.mode], ww->head.length, s_boolean_str[ww->head.branch], s_boolean_str[ww->head.skip_r], s_boolean_str[ww->head.skip_b], s_boolean_str[ww->head.eof],
806+
ww->body.next,
807+
ww->body.backup, ww->body.value, ww->body.mask);
787808
}
788809

789810
static void print_link_info(FILE *out, void *args, int entry, int depth)
@@ -821,4 +842,3 @@ void regdma_link_dump(FILE *out, void *link, int entry)
821842
fprintf(out, "This REGDMA linked list is empty!\n");
822843
}
823844
}
824-
#endif

components/esp_hw_support/sleep_retention.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ static void sleep_retention_entries_stats(void)
303303
_lock_release_recursive(&s_retention.lock);
304304
}
305305

306-
#if REGDMA_LINK_DBG
307306
void sleep_retention_dump_entries(FILE *out)
308307
{
309308
_lock_acquire_recursive(&s_retention.lock);
@@ -315,7 +314,6 @@ void sleep_retention_dump_entries(FILE *out)
315314
}
316315
_lock_release_recursive(&s_retention.lock);
317316
}
318-
#endif
319317

320318
void * sleep_retention_find_link_by_id(int id)
321319
{

0 commit comments

Comments
 (0)