Skip to content

Commit

Permalink
debug: debug_stream_slot: Fix circular buffer alignment and update co…
Browse files Browse the repository at this point in the history
…mments

The cache-line alignment was removed from circular buffer descriptors
on last moments of debug_stream_slot PR's review process. This broke
the circular buffer alignment and its now fixed in this PR. The commit
also contains the documentation update for the alignment removal change
that was also forgotten from the original PR.

Since this only affects the offsets of the circular buffers, that are
explicitly written in the debug window slot, there is no need to
update anything on the host side client. Also the unaligned circular
buffers appeared to work just fine, because of that.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
  • Loading branch information
Jyri Sarha committed Sep 9, 2024
1 parent 0df649a commit 09561b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
5 changes: 3 additions & 2 deletions src/debug/debug_stream/debug_stream_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ int debug_stream_slot_send_record(struct debug_stream_record *rec)
static int debug_stream_slot_init(void)
{
struct debug_stream_slot_hdr *hdr = debug_stream_get_slot();
size_t hdr_size = offsetof(struct debug_stream_slot_hdr,
section_desc[CONFIG_MP_MAX_NUM_CPUS]);
size_t hdr_size = ALIGN_UP(offsetof(struct debug_stream_slot_hdr,
section_desc[CONFIG_MP_MAX_NUM_CPUS]),
CONFIG_DCACHE_LINE_SIZE);
size_t section_area_size = ADSP_DW_SLOT_SIZE - hdr_size;
size_t section_size = ALIGN_DOWN(section_area_size /
CONFIG_MP_MAX_NUM_CPUS,
Expand Down
70 changes: 32 additions & 38 deletions src/include/user/debug_stream_slot.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,36 @@
* structure that is initialized once at DSP boot time. All elements
* in bellow example are 32-bit unsigned integers:
*
* -------------------------------------------------- ---
* | id = DEBUG_STREAM_IDENTIFIER | |
* | total_size = 4096 | 64 bytes
* | num_sections = CONFIG_MP_MAX_NUM_CPUS * | |
* | <padding> | |
* -------------------------------------------------- ---
* | section_descriptor [] = { | |
* | { | |
* | core_id = 0 | |
* | size = 1344 | 64 bytes
* | offset = 64 | |
* | } | |
* | <padding> | |
* -------------------------------------------------- ---
* | { | |
* | core_id = 1 | |
* | size = 1344 | 64 bytes
* | offset = 1344+64 | |
* | } | |
* | <padding> | |
* -------------------------------------------------- ---
* | { | |
* | core_id = 2 | |
* | size = 1344 | 64 bytes
* | offset = 2*1344+64 | |
* | } | |
* | } | |
* | <padding> | |
* -------------------------------------------------- ---
* --------------------------------------------------
* | id = DEBUG_STREAM_IDENTIFIER |
* | total_size = 4096 |
* | num_sections = CONFIG_MP_MAX_NUM_CPUS * |
* | section_descriptor [] = { |
* | { |
* | core_id = 0 |
* | size = 1344 |
* | offset = 64 |
* | } |
* | { |
* | core_id = 1 |
* | size = 1344 |
* | offset = 1344+64 |
* | } |
* | { |
* | core_id = 2 |
* | size = 1344 |
* | offset = 2*1344+64 |
* | } |
* | } |
* | <padding> |
* -------------------------------------------------- n * 64 bytes
* * CONFIG_MP_MAX_NUM_CPUS is 3 in this example
*
* The header contains generic information like identifier, total
* size, and number of sections. After the generic fields there is an
* array of section descriptors. Each array element is cacheline
* aligned. The array has 'num_sections' number of elements. Each
* element in the array describes a circular buffer, one for each DSP
* core.
* array of section descriptors. The array has 'num_sections' number
* of elements. Each element in the array describes a circular buffer,
* one for each DSP core.
*
* The remaining memory in the debug window slot is divided between
* those sections. The buffers are not necessarily of equal size, like
Expand All @@ -82,11 +75,12 @@
* The debug stream writes the records of abstract data to the
* circular buffer, and updates the w_ptr when the record is
* completely written. The host side receiver tries to keep up with the
* w_ptr and keeps track of its read position. The size of the record
* is written - again - after each record and before the next. This is
* to allow parsing the stream backwards in an overrun recovery
* situation. The w_ptr value is updated last, when the record is
* completely written.
* w_ptr and keeps track of its read position.
*
* The size of the record is written - again - after each record and
* before the next. This is to allow parsing the stream backwards in
* an overrun recovery situation. The w_ptr value is updated last,
* when the record is completely written.
*/

#include <stdint.h>
Expand Down

0 comments on commit 09561b7

Please sign in to comment.