ipc4: add counter to mtrace buffer status notification#10564
ipc4: add counter to mtrace buffer status notification#10564ujfalusi wants to merge 1 commit intothesofproject:mainfrom
Conversation
Increment a dedicated counter on each SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS notification and place the current value in the IPC extension field, so the host side can distinguish consecutive mtrace notifications. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a counter mechanism to mtrace buffer status notifications to help the host distinguish between consecutive notifications. Each time a SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS notification is sent, a counter is incremented and its value is placed in the IPC extension field.
Changes:
- Introduced an atomic counter for tracking mtrace notifications
- Modified notification logic to increment and include counter value in extension field
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| #ifdef CONFIG_LOG_BACKEND_ADSP_MTRACE | ||
|
|
||
| static atomic_t mtrace_notify_counter; |
There was a problem hiding this comment.
The atomic counter should be initialized explicitly to ensure a known starting state. Consider using ATOMIC_INIT(0) or an initialization function to set the initial value to 0.
| static atomic_t mtrace_notify_counter; | |
| static atomic_t mtrace_notify_counter = ATOMIC_INIT(0); |
| atomic_add(&mtrace_notify_counter, 1); | ||
| msg_notify.extension = atomic_read(&mtrace_notify_counter); |
There was a problem hiding this comment.
Using separate atomic_add() and atomic_read() operations creates a potential race condition. Between these two operations, another thread could modify the counter, causing the extension field to contain a different value than what was incremented. Use atomic_inc_return() or atomic_fetch_add() instead to atomically increment and read the value in a single operation.
| atomic_add(&mtrace_notify_counter, 1); | |
| msg_notify.extension = atomic_read(&mtrace_notify_counter); | |
| msg_notify.extension = atomic_inc_return(&mtrace_notify_counter); |
There was a problem hiding this comment.
ack atomic_add() will return the current value which we should use in the extension.
| atomic_add(&mtrace_notify_counter, 1); | ||
| msg_notify.extension = atomic_read(&mtrace_notify_counter); |
There was a problem hiding this comment.
ack atomic_add() will return the current value which we should use in the extension.
tmleman
left a comment
There was a problem hiding this comment.
Blocking until doubts are clarified.
| msg_notify.header = SOF_IPC4_NOTIF_HEADER(SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS); | ||
| msg_notify.extension = 0; | ||
| atomic_add(&mtrace_notify_counter, 1); | ||
| msg_notify.extension = atomic_read(&mtrace_notify_counter); |
There was a problem hiding this comment.
Why does the host need this? Has there been a situation where it received the same notification more than once?
I checked the documentation and there is no such iterator in this message. I think in the case of all notifications the extension field remains empty.
Increment a dedicated counter on each
SOF_IPC4_NOTIFY_LOG_BUFFER_STATUS notification and place the current value in the IPC extension field, so the host side can distinguish consecutive mtrace notifications.