Skip to content
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

intel_adsp: ace: Refactor HPSRAM power-down mechanism for Intel ADSP ACE platforms #78342

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

tmleman
Copy link
Collaborator

@tmleman tmleman commented Sep 12, 2024

This pull request introduces a series of changes to the HPSRAM power-down mechanism for Intel ADSP ACE platforms, improving code maintainability and readability. The updates include the introduction of a new assembly macro, cleanup of obsolete code, and refactoring of the power_down function to align with the new approach.

Key Changes:

  1. Introduce L2 Memory Capabilities Register Node: Adds the L2 Memory Capabilities (hsbcap) register node to the Devicetree specifications for ACE platforms, providing essential information for system configuration and resource management.
  2. New Assembly Macro for HPSRAM Power-Down: Implements a new macro m_ace_hpsram_power_down_entire using Zephyr Devicetree macros to dynamically retrieve HPSRAM bank count and control register address, simplifying the power-down process.
  3. Refactor power_down Function: Updates the power_down function to use the new m_ace_hpsram_power_down_entire macro, replacing the previous segment-based power gating mask approach with a single boolean flag.
  4. Cleanup of Obsolete Code: Removes the no longer used m_ace_hpsram_power_change macro from asm_memory_management.h, streamlining the codebase.

@tmleman
Copy link
Collaborator Author

tmleman commented Sep 12, 2024

The changes will remain in draft until they are fully tested.

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

yes, the current power_down() -> m_ace_hpsram_power_change() seem to be... more complex than they need to, and this looks like a good direction to simplify them, but (1) we need to make sure that while simplifying we don't lose required flexibility, and (2) I'd propose to first fix the current issue and then optimise the power-down flow

soc/intel/intel_adsp/ace/asm_memory_management.h Outdated Show resolved Hide resolved
@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from 0233828 to ce954ac Compare September 18, 2024 09:45
@tmleman
Copy link
Collaborator Author

tmleman commented Sep 18, 2024

Update: rebase + commit refactoring the disabling of lpsram (change made on the occasion of debugging, removes the definitions of registers from this header).

@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from ce954ac to 9649f96 Compare September 18, 2024 09:51
@tmleman tmleman marked this pull request as ready for review September 18, 2024 09:52
@tmleman tmleman added the DNM This PR should not be merged (Do Not Merge) label Sep 18, 2024
@zephyrbot zephyrbot added area: Xtensa Xtensa Architecture platform: Intel ADSP Intel Audio platforms labels Sep 18, 2024
@tmleman
Copy link
Collaborator Author

tmleman commented Sep 18, 2024

The changes are ready for review. Earlier tests did not show any problems on MTL and LNL. However, a strange problem appeared on PTL, so I added the DNM label.
The problems on PTL are the LoadStoreTLBMissCause exception (0x18) when trying to read the value of the hsbcap register. I still don't understand how the removal of the array and the memory shift caused by it leads to a TLB miss.

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

In general it does look cleaner to just count banks instead of bit-toggling a mask, but what about multiple segments? I know that currently they aren't really supported but if we hard-fix 1 segment, we should document that? Also not sure if we really need that register in DT? Have you submitted a SOF PR to test this? If not - please do!

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks @tmleman . I think this looks very nice and easier codebase to maintain in the future. So if the test runs are positive, I'd be ok to let this through.

@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from 9649f96 to f97015d Compare October 15, 2024 09:25
@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from 493d759 to d5349e7 Compare October 23, 2024 11:01
@tmleman
Copy link
Collaborator Author

tmleman commented Oct 25, 2024

SOF CI passes, both on this version and on @dcpleung version. The second will most likely be the final one, so I will wait for a new PR with changes for the MMU and then do a rebase.

@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from d5349e7 to 52dfb96 Compare October 30, 2024 20:12
…down

This commit addresses an issue on platforms with an MMU where a
LoadStoreTLBMissCause exception occurs when accessing hardware registers
during the power-down process. The exception arises when attempting to
access the IPC register after HPSRAM has been powered down, leading to a
double exception: LoadStoreTLBMissCause followed by
InstrPIFDataErrorCause.

To resolve this, we preload the IPC register before shutting down
LPSRAM. This change prevents the double exception by ensuring that the
page table entries are correctly managed in the TLB before HPSRAM is
powered down and allowing the power-down sequence to complete
successfully.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This commit improves the readability of the power_down.S assembly file
by standardizing the indentation of the preprocessor definitions.

No functional changes have been made; this is purely a cosmetic update
to the code formatting.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This commit introduces the L2 Memory Capabilities (hsbcap) register node
to the Devicetree specifications for Intel ADSP ACE platforms. The
hsbcap register provides information on the general capabilities
associated with the L2 memory, which is critical for system
configuration and resource management. The hsbcap node has been added to
the Devicetree source files for ACE 1.5 (MTPM), ACE 2.0 (LNL), and ACE
3.0 (PTL) platforms.

In addition, the DFL2MM_REG macro in adsp_memory.h has been updated to
use the Devicetree node label for hsbcap, ensuring a consistent and
maintainable approach to accessing this register across the codebase.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Introduce a new assembly macro, m_ace_hpsram_power_down_entire, which
utilizes Zephyr Devicetree macros to power down the entire HPSRAM on
Intel ADSP ACE platforms.

This macro dynamically retrieves the HPSRAM bank count and control
register address from the Devicetree, streamlining the power-down
process. The macro is designed to iterate over all HPSRAM banks and
issue a power down command to each, ensuring a complete shutdown of the
HPSRAM when required by the system's power management policy.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
…macro

Refactor the power_down function to utilize the newly introduced
m_ace_hpsram_power_down_entire macro for shutting down the entire
HPSRAM. This change simplifies the power-down process by replacing the
previous segment-based power gating mask approach with a single boolean
flag that indicates whether the entire HPSRAM should be disabled.

The function signature of power_down has been updated to accept the new
boolean flag, and the corresponding call sites have been modified to
pass the flag based on the CONFIG_ADSP_POWER_DOWN_HPSRAM Kconfig option.

Additionally, the assembly code has been cleaned up to remove the
now-obsolete hpsram_mask array and related logic.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Remove the m_ace_hpsram_power_change macro from asm_memory_management.h
as it is no longer used after refactoring the power_down function to
utilize the new m_ace_hpsram_power_down_entire macro. This cleanup helps
to reduce code complexity and maintainability.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Replace hardcoded register addresses and values in
asm_memory_management.h with Devicetree (DT) macros for LPSRAM
power-down operations. This change ensures that register addresses and
bank counts are dynamically obtained from the Devicetree, improving code
portability and reducing the risk of errors due to manual updates.

- Removed hardcoded LSPGCTL address definitions.
- Updated m_ace_lpsram_power_down_entire macro to use DT_NODELABEL to
  fetch LPSRAM bank count and control register address
- Adjusted bit field extraction logic to align with the updated register
  information from the Devicetree.

This commit aligns with the ongoing effort to utilize Devicetree for
hardware abstraction and to facilitate easier maintenance and updates to
the codebase.

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
@tmleman tmleman force-pushed the topic/upstream/pr/intel/ace/power_down_hpsram branch from 52dfb96 to 05e45e6 Compare October 30, 2024 21:25
@tmleman tmleman removed the DNM This PR should not be merged (Do Not Merge) label Oct 30, 2024
@tmleman tmleman requested review from lyakh and kv2019i October 30, 2024 21:26
Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

only some comment ideas for a follow-up PR, really no need to respin this one!

movi \ay, 1 /* Power down command */

/* Calculate the address of the HSxPGCTL register */
movi \az, DT_REG_ADDR(DT_NODELABEL(hsbpm))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we discussed the use of movi before, do I understand it correctly, that up to this point movis are good, but not inside the loop, where memory banks are already being switched off? Maybe a follow-up PR to add a comment here about that

* if (b_disable_hpsram) {
* ace_hpsram_power_down_entire();
* }
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

also for a follow-up PR, maybe add a comment, saying that LPSRAM isn't used to run code, so we aren't running there now

@mmahadevan108
Copy link
Collaborator

We are only merging bug fixes and documentation updates to the 4.0 release. Is this something that can wait after the 4.0 release?

@dkalowsk dkalowsk added this to the v4.1.0 milestone Nov 1, 2024
@tmleman
Copy link
Collaborator Author

tmleman commented Nov 4, 2024

We are only merging bug fixes and documentation updates to the 4.0 release. Is this something that can wait after the 4.0 release?

@mmahadevan108 I think we can wait until 4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Xtensa Xtensa Architecture platform: Intel ADSP Intel Audio platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants