Skip to content

Introduce se_service_get_setting_api API to retrieve the runtime clocks - #139

Open
sudhir-alifsemi wants to merge 3 commits into
alifsemi:mainfrom
sudhir-alifsemi:se_service_get_setting_api
Open

Introduce se_service_get_setting_api API to retrieve the runtime clocks#139
sudhir-alifsemi wants to merge 3 commits into
alifsemi:mainfrom
sudhir-alifsemi:se_service_get_setting_api

Conversation

@sudhir-alifsemi

Copy link
Copy Markdown
Contributor

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.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/clear usage 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants