Skip to content

Conversation

@lgirdwood
Copy link
Member

Add Kconfig for heap sizes instead of hard coding and remove all mentions of zone.

Allow the developer to set the maximum heap size so that power savings
can be made when full memory is not required for device use cases.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Copy link

Copilot AI left a comment

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 replaces hard-coded heap size macros with configurable Kconfig options and updates memory allocation APIs and documentation to use flag-based terminology instead of zones.

  • Introduce SOF_ZEPHYR_HEAP_SIZE and SOF_ZEPHYR_VIRTUAL_HEAP_SIZE Kconfig options and replace HEAPMEM_SIZE defines.
  • Update allocator and platform memory headers to switch from zone-based to SOF_MEM_FLAG_* usage.
  • Refine function signatures, comments, and log messages across modules (alloc, DMA trace, probe, component, Google RTC mock, buffers).

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
zephyr/lib/alloc.c Switched HEAPMEM_SIZE to CONFIG_SOF_ZEPHYR_VIRTUAL_HEAP_SIZE, updated error message and comments.
zephyr/include/rtos/alloc.h Removed zone/capabilities parameters from allocator docs; updated parameter descriptions.
zephyr/Kconfig Added SOF_USERSPACE, SOF_ZEPHYR_HEAP_SIZE, and SOF_ZEPHYR_VIRTUAL_HEAP_SIZE.
src/trace/dma-trace.c Changed dma_sg_alloc calls to use SOF_MEM_FLAG_USER.
src/probe/probe.c Similar update for dma_sg_alloc to use flags instead of zones.
src/platform/*/memory.h Replaced #define HEAPMEM_SIZE with CONFIG_SOF_ZEPHYR_HEAP_SIZE.
src/include/sof/lib/dai-legacy.h Updated comments to reference SOF_MEM_FLAG_COHERENT.
src/include/sof/audio/component.h Removed outdated zone-based allocation guidance.
src/audio/google/google_rtc_audio_processing_mock.c Changed SetFormats to return int, added error handling and updated call site.
src/audio/buffers/comp_buffer.c Refined buf_err messages to clarify flags usage.
posix/include/rtos/alloc.h Mirrored allocator documentation updates for POSIX build.
Comments suppressed due to low confidence (4)

zephyr/lib/alloc.c:388

  • [nitpick] The term 'addresses' may be misleading here; consider using 'memory' to clarify that only cached memory is allowed.
			tr_err(&zephyr_tr, "L3_HEAP available for cached addresses only!");

src/audio/buffers/comp_buffer.c:333

  • [nitpick] The phrase 'bytes of flags' is awkward; consider changing to 'bytes with flags' for readability.
		buf_err(buffer, "resize can't alloc %u bytes of flags 0x%x",

src/audio/buffers/comp_buffer.c:391

  • [nitpick] Similar to the earlier log, 'bytes of flags' is confusing; use 'with flags' instead.
		buf_err(buffer, "resize can't alloc %zu bytes of flags 0x%x", new_size,

src/include/sof/audio/component.h:323

  • [nitpick] The original guidance on using the runtime heap was removed; consider updating this comment to specify the new flag-based allocator (e.g., use rmalloc with appropriate SOF_MEM_FLAG_*).
	 *

zephyr/Kconfig Outdated
help
SOF userspace modules support will enable modules to run in DP
processing mode as userspace code and data. This feature is WIP
and is not yest ready for production, for developers only.
Copy link

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

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

Correct the typo 'yest' to 'yet' in the help text.

Suggested change
and is not yest ready for production, for developers only.
and is not yet ready for production, for developers only.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

* @param zone Zone to allocate memory from, see enum mem_zone.
* @param flags Flags, see SOF_MEM_FLAG_...
* @param caps Capabilities, see SOF_MEM_CAPS_...
* @param flags Flags, see SOF_MEM_FLAG_....
Copy link

Copilot AI Jul 12, 2025

Choose a reason for hiding this comment

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

The ellipsis '....' should use three dots '...' for consistency with other parameter docs.

Copilot uses AI. Check for mistakes.
lrgirdwo added 6 commits July 13, 2025 12:56
Allow the developer to set the maximum virtual heap size so that power
savings can be made when full memory is not required for device use cases.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a Kconfig to be used for SOF userspace support. This will be a staging
feature at the moment until its stable upstream.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Fix the log messages to show flags instead of type.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Currently the caller checks for allocation failure in the callee.
Make the correct function check for allocation failure.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Zone was mentioned in many comments and one log message. Fix this to
remove zone references.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Trace and probes were using ZONE macro instead of flags. Fix.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
Copy link
Member Author

@softwarecki fyi - this one has your review comments from memory API update PR in the list of patches.

@lgirdwood lgirdwood merged commit c743cbc into thesofproject:main Jul 14, 2025
37 of 44 checks passed
@lgirdwood lgirdwood deleted the lrg/topic/heap2 branch July 14, 2025 21:45
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.

4 participants