Introduce se_service_get_setting_api API to retrieve the runtime clocks - #139
Open
sudhir-alifsemi wants to merge 3 commits into
Open
Introduce se_service_get_setting_api API to retrieve the runtime clocks#139sudhir-alifsemi wants to merge 3 commits into
sudhir-alifsemi wants to merge 3 commits into
Conversation
The polling path in send_msg_to_se() returned early when ipm_poll_out() or ipm_poll_in() failed, leaving the receiver MHU interrupts disabled. Any subsequent IRQ-mode SE call would then miss its response because the Rx interrupts were left off from the prior failure. Route both failure paths through a single exit so ipm_set_enabled(true) always runs before the function returns. Signed-off-by: Sudhir Sreedharan <sudhir@alifsemi.com>
The yielding path in send_msg_to_se() used pm_device_busy_set/clear on the MHU send/recv devices to inhibit PM entry. Those calls are no-ops without CONFIG_PM_NEED_ALL_DEVICES_IDLE. When the mutex-holding thread yields on svc_send_sem or svc_recv_sem, the idle thread can pick a low-power state whose device-suspend callbacks re-enter SE service. Replace the busy flags with pm_policy_state_lock_get/put for PM_STATE_SUSPEND_TO_RAM and PM_STATE_SOFT_OFF (all substates) held across ipm_send and both k_sem_take calls. Route error paths through a single unlock label so the locks are always released. Signed-off-by: Sudhir Sreedharan <sudhir@alifsemi.com>
Wrap the SE SERVICE_CLOCK_SETTING_GET_REQ_ID request so callers can query the actual clock frequency configured by SE firmware for a given clock_setting_t (AXI, AHB, APB, SYSREF, HFOSC, EXTSYS0, EXTSYS1, etc) at runtime. Signed-off-by: Sudhir Sreedharan <sudhir@alifsemi.com>
sudhir-alifsemi
requested review from
RupeshKumar-AlifSemi,
petrih-alifsemi and
silesh-alifsemi
July 31, 2026 11:58
There was a problem hiding this comment.
Pull request overview
This PR adds a new SE service API to query clock frequency settings at runtime and updates the SE mailbox transaction path to prevent system suspend/soft-off during blocking service calls, with improved cleanup on error paths.
Changes:
- Added
se_service_*_setting_get()API and service struct support to fetch clock frequencies configured by SE firmware. - Replaced
pm_device_busy_set/clearusage with PM policy state locks around interrupt-driven SE mailbox transactions. - Hardened polling-mode error handling to always re-enable RX interrupts before returning.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| se_services/zephyr/src/se_service.c | Adds clock setting service support + new getter API; replaces device-busy flags with PM policy locks and improves error cleanup. |
| se_services/zephyr/include/se_service.h | Exposes the new public API with Doxygen documentation. |
Suppressed comments (1)
se_services/zephyr/src/se_service.c:437
- pm_policy_state_lock_put() should be gated the same way as the corresponding lock_get calls, otherwise builds without CONFIG_PM may fail (or the code may imply a lock was taken when it wasn't).
unlock:
pm_policy_state_lock_put(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES);
pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_RAM, PM_ALL_SUBSTATES);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+406
to
+412
| /* | ||
| * Block SUSPEND_TO_RAM / SOFT_OFF while we hold svc_mutex and | ||
| * wait on the SE mailbox response. Otherwise the idle thread | ||
| * may run PM device-suspend callbacks | ||
| */ | ||
| pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_RAM, PM_ALL_SUBSTATES); | ||
| pm_policy_state_lock_get(PM_STATE_SOFT_OFF, PM_ALL_SUBSTATES); |
| * @retval -EBUSY SE is busy. Retry after a delay. | ||
| * @return Positive error code returned by SE for a failed service request. | ||
| */ | ||
| int se_service_clocks_setting_get(clock_setting_t setting, uint32_t *freq); |
| return 0; | ||
| } | ||
|
|
||
| int se_service_clocks_setting_get(clock_setting_t setting, uint32_t *freq) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces a new API for querying clock frequency settings from the SE firmware.
Use PM policy locks (pm_policy_state_lock_get/put) instead of device busy flags, preventing the system from entering suspend or soft-off states during SE service calls. Also, improved error handling to ensure locks are always released.