-
Notifications
You must be signed in to change notification settings - Fork 8.4k
soc: nordic: Add LRCCONF management #79067
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
soc: nordic: Add LRCCONF management #79067
Conversation
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
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.
Please remove also the struct clock_lrcconf_sink definition. There is no need to keep it as it can be replaced with just sys_snode_t.
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.
| #include <soc/nordic/common/soc_lrcconf.h> | |
| #include <soc_lrcconf.h> |
soc/nordic/common/soc_lrcconf.c
Outdated
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.
These should be static.
soc/nordic/nrf54h/CMakeLists.txt
Outdated
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.
Why is it added only for ARM cores?
I think that instead of the above entry, the following should be added in soc/nordic/common/CMakeLists.txt (so that nRF92 could also use it):
zephyr_library_sources_ifdef(NRF_PLATFORM_HALTIUM soc_lrcconf.c)
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.
It was correct to only have it for arm cores, or rather for local domains, as global domains don't have an NRF_LRCCONF010 instance and it breaks their builds.
soc/nordic/nrf54h/power.c
Outdated
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.
| #if !IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD) | |
| #if !defined(CONFIG_SOC_NRF54H20_CPURAD) |
IS_ENABLED should only be used in C expressions. See:
zephyr/include/zephyr/sys/util_macro.h
Lines 117 to 118 in 7e892f8
| * Note: Use of IS_ENABLED in a <tt>\#if</tt> statement is discouraged | |
| * as it doesn't provide any benefit vs plain <tt>\#if defined()</tt> |
soc/nordic/nrf54h/soc.c
Outdated
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 looks like a leftover from some previous approach. node is not used by the code below.
soc/nordic/nrf54h/power.h
Outdated
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.
typo: "Pepare"
soc/nordic/nrf54h/power.h
Outdated
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 sentence seems to need rephrasing.
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
46ac139 to
f7ea669
Compare
soc/nordic/nrf54h/power.c
Outdated
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 only releases the poweron request when PM_STATE_SUSPEND_TO_IDLE was used to call k_cpu_idle() via the pm subsystem, but if the pm subsystem decided against suspending the system it will call k_cpu_idle() here instead and then not call the release.
This can happen if the is no suspend-to-idle state defined in devicetree or it has a minimum residency time that isn't met, e.g. a k_msleep(10) for with this pm configuration https://github.com/nrfconnect/sdk-nrf/blob/84492d6d9264745050a018d01f4f333b285864c1/tests/benchmarks/multicore/idle/boards/nrf54h20dk_nrf54h20_cpuapp_s2ram.overlay#L12C39-L12C39
This is still way better than losing power, but needs to be followed up to have all paths covered eventually
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.
There is a mechanism to supply an exit hook on arm cores
Line 56 in abd9008
| config ARM_ON_EXIT_CPU_IDLE |
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.
there is this mechanism but it is quite ugly and requires special header with a macro. It was added as a workaround for PAN where code need to be executed immediately after WFI (so function cannot be used). I have #71667 which adds function hook symmetric to on_enter hook but PR stuck.
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.
Maybe your PR would have a clean usecase now and it could be argued for again to avoid that assembly mess?
soc/nordic/nrf54h/power.h
Outdated
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 function does not seem to be needed anymore. It looks a bit like a hack actually.
soc/nordic/nrf54h/Kconfig
Outdated
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.
Shouldn't this be selected only when actually needed, so if PM || POWEROFF?
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
soc/nordic/common/soc_lrcconf.c
Outdated
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.
any reason why simple reference counter is not used here? I only see that the difference is that you keep list of clients (but its not used anywhere) and allow to have non-symmetric requests (second request from the same client is not counted) but it can potentially cause some issues. Reference counter would be simpler and use less resources.
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.
At least right now there is non-symmetric requests so it couldn't be dropped
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.
I think the code is symmetric now, maybe this would benefit from an onoff manager style thing for reference counting instead of manually tracking the references?
soc/nordic/nrf54h/power.c
Outdated
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.
there is this mechanism but it is quite ugly and requires special header with a macro. It was added as a workaround for PAN where code need to be executed immediately after WFI (so function cannot be used). I have #71667 which adds function hook symmetric to on_enter hook but PR stuck.
f7ea669 to
c13c926
Compare
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
c13c926 to
f046e9a
Compare
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Add `idle` and `s2ram` power states for nRF54H20 cpuapp and cpurad. Also the substate `idle_cache_disable` added. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Add `idle` and `s2ram` power states for nRF54H20 cpuapp and cpurad. Also the substate `idle_cache_disable` added. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
Add `idle` and `s2ram` power states for nRF54H20 cpuapp and cpurad. Also the substate `idle_cache_disable` added. Upstream PR: zephyrproject-rtos/zephyr#79067 Signed-off-by: Adam Kondraciuk <[email protected]>
aec753f to
19a2be2
Compare
|
This latest change supporting EngB needs to be applied downstream as well |
|
8a27e3d to
a65320d
Compare
soc/nordic/nrf54h/soc.h
Outdated
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 looks quite weird. Why not just use extern sys_snode_t soc_node; in power.c, for example? Is this node intended to be used by any other modules/subsystems?
bjarki-andreasen
left a comment
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.
With the added lrcconf API being reference tracking, one node should not be shared between modules, like soc_pd_sys_snode_get(). Each module creates their own sys_snode_t and calls soc_lrcconf_poweron_request independently, soc_lrcconf_poweron_request tracks both and ensures thread safety :)
soc/nordic/common/soc_lrcconf.c
Outdated
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.
nit: space needed here
a65320d to
2e39284
Compare
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required. Signed-off-by: Adam Kondraciuk <[email protected]>
Add `idle` and `s2ram` power states for nRF54H20 cpuapp and cpurad. Also the substate `idle_cache_disable` added. Signed-off-by: Adam Kondraciuk <[email protected]>
IRQs must be disabled before starting any procedures to prepare for low-power states. Signed-off-by: Adam Kondraciuk <[email protected]>
2e39284 to
2dc89a7
Compare
| #define HSFLL_NODE DT_NODELABEL(cpurad_hsfll) | ||
| #endif | ||
|
|
||
| sys_snode_t soc_node; |
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.
A comment explaining that this is not static because it is also accessed from power.c would not hurt.
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 node really should not be shared in the first place... Instead, add a power_init() function to power.c which requests the power domain, moving the node to power.c and making it static, and call power_init() from soc.c
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.
or, just move power_domain_init() to power.c?
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 is a bit complicated, because power.c is only included in the build for CONFIG_PM OR CONFIG_POWEROFF. That's why I suggested this shortcut with extern.
But I agree, it's probably worth putting a little more effort to do it cleanly.
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.
How about #ifdefed power_init() call?
Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required.