-
Notifications
You must be signed in to change notification settings - Fork 349
ipc4: pipeline: Add notification pool and data process error notification #9972
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c5282ef
ipc4: notification: Fix include guard
softwarecki ec8bb13
ipc4: notification: Fix UAOL event notification name
softwarecki 867b79e
ipc4: notification: Separate resource_notif_header_init function
softwarecki 78ee689
ipc4: notification: Add support for data process error notification
softwarecki a918393
ipc4: Add notification pool
softwarecki 95274dd
pipeline: Add data process error notification
softwarecki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* SPDX-License-Identifier: BSD-3-Clause | ||
| * | ||
| * Copyright(c) 2025 Intel Corporation. All rights reserved. | ||
| * | ||
| * Author: Adrian Warecki <adrian.warecki@intel.com> | ||
| */ | ||
|
|
||
| #ifndef __SOF_IPC_NOTIFICATION_POOL_H__ | ||
| #define __SOF_IPC_NOTIFICATION_POOL_H__ | ||
|
|
||
| #include <stdint.h> | ||
| #include <sof/ipc/msg.h> | ||
|
|
||
| /** | ||
| * @brief Retrieves an IPC notification message from the pool. | ||
| * | ||
| * This function retrieves and returns an IPC notification message | ||
| * of the specified size from the notification pool. The size of the | ||
| * message is limited by the maximum size available in the pool. | ||
| * | ||
| * @param size The size of the IPC message to retrieve. | ||
| * @return A pointer to the retrieved IPC message, or NULL if retrieval fails. | ||
| */ | ||
| struct ipc_msg *ipc_notification_pool_get(size_t size); | ||
softwarecki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #endif /* __SOF_IPC_NOTIFICATION_POOL_H__ */ | ||
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 |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ endif() | |
| add_local_sources(sof | ||
| ipc-common.c | ||
| ipc-helper.c | ||
| notification_pool.c | ||
| ) | ||
|
|
||
| is_zephyr(it_is) | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // SPDX-License-Identifier: BSD-3-Clause | ||
| // | ||
| // Copyright(c) 2025 Intel Corporation. All rights reserved. | ||
| // | ||
| // Author: Adrian Warecki <adrian.warecki@intel.com> | ||
| // | ||
|
|
||
| #include <stdint.h> | ||
| #include <sof/common.h> | ||
| #include <sof/list.h> | ||
| #include <sof/ipc/notification_pool.h> | ||
|
|
||
| #define NOTIFICATION_POOL_MAX_PAYLOAD_SIZE 40 /* IPC4 Resource Event needs 10dw */ | ||
| #define NOTIFICATION_POOL_MAX_DEPTH 8 /* Maximum number of notifications | ||
| * in the pool | ||
| */ | ||
|
|
||
| LOG_MODULE_REGISTER(notification_pool, CONFIG_SOF_LOG_LEVEL); | ||
|
|
||
| SOF_DEFINE_REG_UUID(notification_pool); | ||
|
|
||
| DECLARE_TR_CTX(notif_tr, SOF_UUID(notification_pool_uuid), LOG_LEVEL_INFO); | ||
|
|
||
| struct ipc_notif_pool_item { | ||
| struct ipc_msg msg; | ||
| uint32_t payload[SOF_DIV_ROUND_UP(NOTIFICATION_POOL_MAX_PAYLOAD_SIZE, sizeof(uint32_t))]; | ||
| }; | ||
|
|
||
| static struct list_item pool_free_list = LIST_INIT(pool_free_list); | ||
| static struct k_spinlock pool_free_list_lock; | ||
| static int pool_depth; | ||
|
|
||
| static void ipc_notif_free(struct ipc_msg *msg) | ||
| { | ||
| struct ipc_notif_pool_item *item = container_of(msg, struct ipc_notif_pool_item, msg); | ||
| k_spinlock_key_t key; | ||
|
|
||
| key = k_spin_lock(&pool_free_list_lock); | ||
| list_item_append(&item->msg.list, &pool_free_list); | ||
| k_spin_unlock(&pool_free_list_lock, key); | ||
| } | ||
|
|
||
| static struct ipc_msg *ipc_notif_new(size_t size) | ||
| { | ||
| struct ipc_notif_pool_item *item; | ||
|
|
||
| item = rzalloc(SOF_MEM_ZONE_RUNTIME_SHARED, 0, SOF_MEM_CAPS_RAM, sizeof(*item)); | ||
| if (!item) { | ||
| tr_err(¬if_tr, "Unable to allocate memory for notification message"); | ||
| return NULL; | ||
| } | ||
|
|
||
| list_init(&item->msg.list); | ||
| item->msg.tx_data = item->payload; | ||
| item->msg.tx_size = size; | ||
| item->msg.callback = ipc_notif_free; | ||
| return &item->msg; | ||
| } | ||
|
|
||
| struct ipc_msg *ipc_notification_pool_get(size_t size) | ||
| { | ||
| struct ipc_notif_pool_item *item; | ||
| k_spinlock_key_t key; | ||
| struct ipc_msg *new_msg; | ||
|
|
||
| if (size > NOTIFICATION_POOL_MAX_PAYLOAD_SIZE) { | ||
| tr_err(¬if_tr, "Requested size %zu exceeds maximum payload size %u", | ||
| size, NOTIFICATION_POOL_MAX_PAYLOAD_SIZE); | ||
| return NULL; | ||
| } | ||
|
|
||
| /* check if we have a free message */ | ||
| key = k_spin_lock(&pool_free_list_lock); | ||
| if (list_is_empty(&pool_free_list)) { | ||
| /* allocate a new message */ | ||
| if (pool_depth >= NOTIFICATION_POOL_MAX_DEPTH) { | ||
| k_spin_unlock(&pool_free_list_lock, key); | ||
| tr_err(¬if_tr, "Pool depth exceeded"); | ||
| return NULL; | ||
| } | ||
| ++pool_depth; | ||
| k_spin_unlock(&pool_free_list_lock, key); | ||
|
|
||
| new_msg = ipc_notif_new(size); | ||
| if (!new_msg) { | ||
| key = k_spin_lock(&pool_free_list_lock); | ||
| --pool_depth; | ||
| k_spin_unlock(&pool_free_list_lock, key); | ||
softwarecki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return new_msg; | ||
| } | ||
|
|
||
| /* take the first free message */ | ||
| item = list_first_item(&pool_free_list, struct ipc_notif_pool_item, msg.list); | ||
| list_item_del(&item->msg.list); | ||
| k_spin_unlock(&pool_free_list_lock, key); | ||
|
|
||
| item->msg.tx_size = size; | ||
| return &item->msg; | ||
| } | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.