Repository navigation
vpage: fix free tracking, release partial maps, enable vpages on small-L2 (NVL-S) #11303
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
Open
lgirdwood
wants to merge
3
commits into
thesofproject:main
Choose a base branch
from
lgirdwood:fix/vpage-region-underflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -296,18 +296,39 @@ __cold static int vpage_init(void) | |
| end = l2_end - CONFIG_LIBRARY_REGION_SIZE; | ||
| } else { | ||
| /* | ||
| * TODO: on demand mapping currently only supports | ||
| * cached mappings, so we need to limit vpages to | ||
| * physical L2 size for now until support is added to | ||
| * Zephyr mm_drv_intel_adsp_mtl_tlb.c and friends | ||
| * Small L2 (e.g. NVL-S): the virtual heap and library regions are only | ||
| * virtual address space backed on demand, so they need not fit in L2 | ||
| * together with the vpages. Use the virtual space up to the library | ||
| * region (or the end of virtual memory) and cap it below by the | ||
| * physical L2 left after the image, as vpages can never use more. | ||
| * Pages beyond physical L2 are accessed through the coherent alias | ||
| * too, which needs the Zephyr TLB driver to map the uncached alias. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last sentence is not super useful. More useful would be to replace with a link to the Zephyr PR -- the main point is Zephyr had a bug in using addresses beyond physical L2 end. |
||
| */ | ||
| LOG_WRN("no space left for vpages, start %#lx l2_end %#lx", | ||
| (unsigned long)start, (unsigned long)l2_end); | ||
| end = L2_VIRTUAL_SRAM_BASE + L2_VIRTUAL_SRAM_SIZE; | ||
| if (IS_ENABLED(CONFIG_LIBRARY_MANAGER) && CONFIG_LIBRARY_BASE_ADDRESS < end) | ||
| end = CONFIG_LIBRARY_BASE_ADDRESS; | ||
| } | ||
|
kv2019i marked this conversation as resolved.
Resolved
|
||
|
|
||
| /* the image or virtual heap may leave no room, don't let this underflow */ | ||
| if (end < start + CONFIG_MM_DRV_PAGE_SIZE) { | ||
| LOG_WRN("no space left for vpages, start %#lx end %#lx", | ||
| (unsigned long)start, (unsigned long)end); | ||
| return -ENOMEM; | ||
| } | ||
|
|
||
| remaining_ram = end - start; | ||
| __ASSERT_NO_MSG(remaining_ram >= CONFIG_MM_DRV_PAGE_SIZE); | ||
| if (end > l2_end) { | ||
| uintptr_t image_end = adsp_mm_get_unused_l2_start_aligned(); | ||
| size_t phys_left = image_end < l2_end ? l2_end - image_end : 0; | ||
|
|
||
| remaining_ram = MIN(remaining_ram, phys_left); | ||
| } | ||
|
|
||
| /* revalidate, the physical cap can leave less than a page */ | ||
| if (remaining_ram < CONFIG_MM_DRV_PAGE_SIZE) { | ||
| LOG_WRN("no physical L2 left for vpages"); | ||
| return -ENOMEM; | ||
| } | ||
|
|
||
| ret = adsp_add_virtual_memory_region(start, remaining_ram, VIRTUAL_REGION_VPAGES_ATTR); | ||
| if (ret) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not a blocker but I wonder if the vpages should go beyond l2_end in this case. IOW why limit vpages to physical L2 size in this case, if we already know Zephyr supports going beyond and we use it below for systems with smaller L2. IOW, shouldn't we size vpages based on a) physical L2 size and b) image size. vpages cannot be larger than a-b, but I don't see a need to limit otherwise.