Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 367
trace: Runtime filter message handler#3329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -747,6 +747,55 @@ static int ipc_dma_trace_config(uint32_t header) | ||
| return err; | ||
| } | ||
| static int ipc_trace_filter_update(uint32_t header) | ||
| { | ||
| struct sof_ipc_trace_filter_elem *next_elem; | ||
| struct sof_ipc_trace_filter_elem *elem; | ||
| struct sof_ipc_trace_filter_elem *end; | ||
| struct sof_ipc_trace_filter *packet; | ||
| struct trace_filter filter; | ||
| struct ipc *ipc = ipc_get(); | ||
| int ret = 0; | ||
| int cnt; | ||
| packet = ipc->comp_data; | ||
| elem = packet->elems; | ||
| end = &packet->elems[packet->elem_cnt]; | ||
lgirdwood marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| /* validation, packet->hdr.size has already been compared with SOF_IPC_MSG_MAX_SIZE */ | ||
| if (sizeof(*packet) + sizeof(*elem) * packet->elem_cnt != packet->hdr.size) { | ||
| tr_err(&ipc_tr, "trace_filter_update failed, elem_cnt %d is inconsistent with hdr.size %d", | ||
| packet->elem_cnt, packet->hdr.size); | ||
| return -EINVAL; | ||
| } | ||
| tr_info(&ipc_tr, "ipc: trace_filter_update received, size %d elems", | ||
| packet->elem_cnt); | ||
| /* read each filter set and update selected components trace settings */ | ||
| while (elem != end) { | ||
| next_elem = trace_filter_fill(elem, end, &filter); | ||
| if (!next_elem) | ||
| return -EINVAL; | ||
| cnt = trace_filter_update(&filter); | ||
| if (cnt < 0) { | ||
| tr_err(&ipc_tr, "trace_filter_update failed for UUID key 0x%X, comp %d.%d and log level %d", | ||
| filter.uuid_id, filter.pipe_id, filter.comp_id, | ||
| filter.log_level); | ||
| ret = cnt; | ||
| } else { | ||
| tr_info(&ipc_tr, "trace_filter_update for UUID key 0x%X, comp %d.%d affected %d components", | ||
| filter.uuid_id, filter.pipe_id, filter.comp_id, | ||
| cnt); | ||
| } | ||
| elem = next_elem; | ||
| } | ||
| return ret; | ||
| } | ||
| static int ipc_glb_debug_message(uint32_t header) | ||
| { | ||
| uint32_t cmd = iCS(header); | ||
| @@ -757,6 +806,8 @@ static int ipc_glb_debug_message(uint32_t header) | ||
| case SOF_IPC_TRACE_DMA_PARAMS: | ||
| case SOF_IPC_TRACE_DMA_PARAMS_EXT: | ||
| return ipc_dma_trace_config(header); | ||
| case SOF_IPC_TRACE_FILTER_UPDATE: | ||
| return ipc_trace_filter_update(header); | ||
| default: | ||
| tr_err(&ipc_tr, "ipc: unknown debug cmd 0x%x", cmd); | ||
| return -EINVAL; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,8 +4,10 @@ | ||
| // | ||
| // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> | ||
| // Artur Kloniecki <arturx.kloniecki@linux.intel.com> | ||
| // Karol Trzcinski <karolx.trzcinski@linux.intel.com> | ||
| #include <sof/debug/panic.h> | ||
| #include <sof/drivers/ipc.h> | ||
| #include <sof/drivers/timer.h> | ||
| #include <sof/lib/alloc.h> | ||
| #include <sof/lib/cache.h> | ||
| @@ -155,6 +157,147 @@ void trace_log(bool send_atomic, const void *log_entry, | ||
| #endif /* CONFIG_TRACEM */ | ||
| } | ||
| struct sof_ipc_trace_filter_elem *trace_filter_fill(struct sof_ipc_trace_filter_elem *elem, | ||
| struct sof_ipc_trace_filter_elem *end, | ||
| struct trace_filter *filter) | ||
| { | ||
| filter->log_level = -1; | ||
| filter->uuid_id = 0; | ||
| filter->comp_id = -1; | ||
| filter->pipe_id = -1; | ||
| while (elem <= end) { | ||
| switch (elem->key & SOF_IPC_TRACE_FILTER_ELEM_TYPE_MASK) { | ||
| case SOF_IPC_TRACE_FILTER_ELEM_SET_LEVEL: | ||
| filter->log_level = elem->value; | ||
| break; | ||
| case SOF_IPC_TRACE_FILTER_ELEM_BY_UUID: | ||
| filter->uuid_id = elem->value; | ||
| break; | ||
| case SOF_IPC_TRACE_FILTER_ELEM_BY_COMP: | ||
| filter->comp_id = elem->value; | ||
| break; | ||
| case SOF_IPC_TRACE_FILTER_ELEM_BY_PIPE: | ||
| filter->pipe_id = elem->value; | ||
| break; | ||
| default: | ||
| tr_err(&ipc_tr, "Invalid SOF_IPC_TRACE_FILTER_ELEM 0x%x", | ||
| elem->key); | ||
| return NULL; | ||
| } | ||
| /* each filter set must be terminated with FIN flag and have new log level */ | ||
| if (elem->key & SOF_IPC_TRACE_FILTER_ELEM_FIN) { | ||
| if (filter->log_level < 0) { | ||
| tr_err(&ipc_tr, "Each trace filter set must specify new log level"); | ||
| return NULL; | ||
| } else { | ||
| return elem + 1; | ||
| } | ||
| } | ||
| ++elem; | ||
| } | ||
| tr_err(&ipc_tr, "Trace filter elements set is not properly terminated"); | ||
| return NULL; | ||
| } | ||
| /* update global components, which tr_ctx is stored inside special section */ | ||
| static int trace_filter_update_global(int32_t log_level, uint32_t uuid_id) | ||
| { | ||
| extern void *_trace_ctx_start; | ||
| extern void *_trace_ctx_end; | ||
| struct tr_ctx *ptr = (struct tr_ctx *)&_trace_ctx_start; | ||
| struct tr_ctx *end = (struct tr_ctx *)&_trace_ctx_end; | ||
| int cnt = 0; | ||
| /* iterate over global `tr_ctx` entries located in their own section */ | ||
| while (ptr < end) { | ||
| /* | ||
| * when looking for specific uuid element, | ||
| * then find, update and stop searching | ||
| */ | ||
| if ((uint32_t)ptr->uuid_p == uuid_id) { | ||
| ptr->level = log_level; | ||
| return 1; | ||
| } | ||
| /* otherwise each element should be updated */ | ||
| if (!ptr->uuid_p) { | ||
| ptr->level = log_level; | ||
| ++cnt; | ||
| } | ||
| ++ptr; | ||
| } | ||
| return cnt; | ||
| } | ||
| /* return trace context from any ipc component type */ | ||
| static struct tr_ctx *trace_filter_ipc_comp_context(struct ipc_comp_dev *icd) | ||
| { | ||
| switch (icd->type) { | ||
| case COMP_TYPE_COMPONENT: | ||
| return &icd->cd->tctx; | ||
| case COMP_TYPE_BUFFER: | ||
| return &icd->cb->tctx; | ||
| case COMP_TYPE_PIPELINE: | ||
| return &icd->pipeline->tctx; | ||
| /* each COMP_TYPE must be specified */ | ||
| default: | ||
| tr_err(&ipc_tr, "Unknown trace context for ipc component type 0x%X", | ||
| icd->type); | ||
| return NULL; | ||
| } | ||
| } | ||
| /* update ipc components, wchich tr_ctx may be read from ipc_comp_dev structure */ | ||
| static int trace_filter_update_instances(int32_t log_level, uint32_t uuid_id, | ||
| int32_t pipe_id, int32_t comp_id) | ||
| { | ||
| struct ipc *ipc = ipc_get(); | ||
| struct ipc_comp_dev *icd; | ||
| struct list_item *clist; | ||
| struct tr_ctx *ctx; | ||
| bool correct_comp; | ||
| int cnt = 0; | ||
| /* compare each ipc component with filter settings and update log level after pass */ | ||
| list_for_item(clist, &ipc->comp_list) { | ||
| icd = container_of(clist, struct ipc_comp_dev, list); | ||
| ctx = trace_filter_ipc_comp_context(icd); | ||
| correct_comp = comp_id == -1 || icd->id == comp_id; /* todo: icd->topo_id */ | ||
| correct_comp &= uuid_id == 0 || (uint32_t)ctx->uuid_p == uuid_id; | ||
| correct_comp &= pipe_id == -1 || ipc_comp_pipe_id(icd) == pipe_id; | ||
| if (correct_comp) { | ||
| ctx->level = log_level; | ||
| ++cnt; | ||
| } | ||
| platform_shared_commit(icd, sizeof(*icd)); | ||
| } | ||
| return cnt; | ||
| } | ||
| int trace_filter_update(const struct trace_filter *filter) | ||
| { | ||
| int ret = 0; | ||
| /* validate log level, LOG_LEVEL_CRITICAL has low value, LOG_LEVEL_VERBOSE high */ | ||
| if (filter->log_level < LOG_LEVEL_CRITICAL || | ||
lgirdwood marked this conversation as resolved.
Outdated
Uh oh!There was an error while loading. Please reload this page. | ||
| filter->log_level > LOG_LEVEL_VERBOSE) | ||
| return -EINVAL; | ||
| /* update `*`, `name*` or global `name` */ | ||
| if (filter->pipe_id == -1 && filter->comp_id == -1) | ||
| ret = trace_filter_update_global(filter->log_level, filter->uuid_id); | ||
| /* update `*`, `name*`, `nameX.*` or `nameX.Y`, `name` may be '*' */ | ||
| ret += trace_filter_update_instances(filter->log_level, filter->uuid_id, | ||
| filter->pipe_id, filter->comp_id); | ||
| return ret > 0 ? ret : -EINVAL; | ||
| } | ||
| void trace_flush(void) | ||
| { | ||
| struct trace *trace = trace_get(); | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktrzcinx can you confirm this is a debug ABI update only. If so, we can put in in ABI3.17.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change bumps both ABI numbers