Skip to content

Conversation

@adamkondraciuk
Copy link
Contributor

Due to the possibility of simultaneous accesess to LRCCONF registers, additional management is required.

adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 26, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 26, 2024
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]>
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include <soc/nordic/common/soc_lrcconf.h>
#include <soc_lrcconf.h>

Comment on lines 11 to 12
Copy link
Member

Choose a reason for hiding this comment

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

These should be static.

Copy link
Member

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)

Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#if !IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD)
#if !defined(CONFIG_SOC_NRF54H20_CPURAD)

IS_ENABLED should only be used in C expressions. See:

* 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>

Comment on lines 64 to 69
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

typo: "Pepare"

Copy link
Member

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.

adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 27, 2024
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]>
Copy link
Contributor

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

Copy link
Contributor

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

config ARM_ON_EXIT_CPU_IDLE

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Member

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?

adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 27, 2024
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]>
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

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.

adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 27, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 30, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Sep 30, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 1, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 1, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 2, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 2, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 2, 2024
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]>
adamkondraciuk added a commit to adamkondraciuk/sdk-zephyr that referenced this pull request Oct 2, 2024
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]>
karstenkoenig
karstenkoenig previously approved these changes Oct 28, 2024
@karstenkoenig
Copy link
Contributor

This latest change supporting EngB needs to be applied downstream as well

@adamkondraciuk
Copy link
Contributor Author

This latest change supporting EngB needs to be applied downstream as well

nrfconnect/sdk-nrf#18284

nordic-krch
nordic-krch previously approved these changes Nov 25, 2024
Copy link
Member

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?

Copy link
Contributor

@bjarki-andreasen bjarki-andreasen left a 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 :)

Comment on lines 26 to 28
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: space needed here

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]>
#define HSFLL_NODE DT_NODELABEL(cpurad_hsfll)
#endif

sys_snode_t soc_node;
Copy link
Member

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.

Copy link
Contributor

@bjarki-andreasen bjarki-andreasen Nov 25, 2024

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

Copy link
Contributor

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?

Copy link
Member

@anangl anangl Nov 25, 2024

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.

Copy link
Contributor Author

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?

@bjarki-andreasen bjarki-andreasen dismissed their stale review November 26, 2024 10:55

Not neccesary to block it

@fabiobaltieri fabiobaltieri merged commit be1f405 into zephyrproject-rtos:main Nov 26, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants