Skip to content

zephyr: wrapper: no need to split heap into shared and unshared for imx - #4477

Closed
iuliana-prodan wants to merge 1 commit into
thesofproject:mainfrom
iuliana-prodan:fix_imx_and_upsquared
Closed

zephyr: wrapper: no need to split heap into shared and unshared for imx#4477
iuliana-prodan wants to merge 1 commit into
thesofproject:mainfrom
iuliana-prodan:fix_imx_and_upsquared

Conversation

@iuliana-prodan

@iuliana-prodan iuliana-prodan commented Jul 12, 2021

Copy link
Copy Markdown
Contributor

There is no need to split heap into shared and unshared since,
for imx, we only have 1 DSP core.
In this case, the kernel will never be built in a mode
where all shared data is placed in multiprocessor-coherent
(generally "uncached") memory.
Therefore, for imx, use sof_heap to allocate memory.

Fixes: 34bb9b7("zephyr: wrapper: build SOF with Zephyr for imx")
Signed-off-by: Iuliana Prodan iuliana.prodan@nxp.com

@paulstelian97

Copy link
Copy Markdown
Collaborator

Is there a second PR pushed with the Zephyr base branch? Otherwise looks good to me.

@iuliana-prodan

Copy link
Copy Markdown
Contributor Author

Is there a second PR pushed with the Zephyr base branch?

I don't understand exactly the question, but this PR fixes a commit from #4217, which was merged last week.

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The correct commit SHA1 is 34bb9b7

Shouldn't rfree() logic be consistent with this?

Even better: shouldn't the sof_heap_shared declaration be under the same #ifdef? This could have avoided some issues.

Speaking of #ifdef IMX, shouldn't it be something more generic like #ifndef SMP?

There is no need to split heap into shared and unshared since,
for imx, we only have 1 DSP core.
In this case, the kernel will never be built in a mode
where all shared data is placed in multiprocessor-coherent
(generally "uncached") memory.
Therefore, for imx, use sof_heap to allocate memory.

Fixes: 34bb9b7("zephyr: wrapper: build SOF with Zephyr for imx")
Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
@iuliana-prodan
iuliana-prodan force-pushed the fix_imx_and_upsquared branch from 34888f8 to cc5dbc5 Compare July 12, 2021 16:30
@iuliana-prodan

iuliana-prodan commented Jul 12, 2021

Copy link
Copy Markdown
Contributor Author

The correct commit SHA1 is 34bb9b7

Done.

Shouldn't rfree() logic be consistent with this?

Even better: shouldn't the sof_heap_shared declaration be under the same #ifdef? This could have avoided some issues.

Done.

Speaking of #ifdef IMX, shouldn't it be something more generic like #ifndef SMP?

I've kept the CONFIG_IMX since we also have some memory map and linker file differences - e.g. heapmem variable needs to be in a specific section otherwise the sdram0 region overflows - see comment here.
SMP will be too generic.

@iuliana-prodan
iuliana-prodan requested a review from marc-hb July 12, 2021 16:35
@marc-hb

marc-hb commented Jul 12, 2021

Copy link
Copy Markdown
Collaborator

I've kept the CONFIG_IMX

I wasn't suggesting to remove the CONFIG_IMX entirely, sorry for any confusion. I was only referring to rmalloc() and rfree(). In fact I just tried to remove sof_heap_shared entirely on my APL Up Squared where I use a single core and it seems fine.

There is no need to split heap into shared and unshared since, for imx, we only have 1 DSP core.

IMX is not the only thing with 1 core.

@marc-hb
marc-hb requested a review from ranj063 July 12, 2021 19:50
Comment thread zephyr/wrapper.c
/* select heap based on address range */
if (is_uncached(ptr)) {
#ifdef CONFIG_IMX
heap_free(&sof_heap, ptr);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would you ever get uncached pointers from malloc on IMX? From your description it sounds like you don't need those. Let's do this: let's get one of these PRs in - either this one or #4479 (I don't mind either, but I'd prefer mine because it's smaller, it only fixes a bug without adding more confusion). After that I'd make a new PR to extract all heap management into a separate file zephyr/alloc.c and then we'd duplicate it into zephyr/alloc_cavs.c and zephyr/alloc_imx.c or whatever. And remove all the #ifdefs from both. Then you can do what you need in your copy.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would you ever get uncached pointers from malloc on IMX?

We don't have the memory map aliasing that permits cached vs uncached pointers. I was having internal discussions more than a year ago about this, currently cache_to_uncache and uncache_to_cache macros are no-ops but I was wondering if there was a way to remove them (because they cannot be meaningfully implemented) for platforms like IMX.

@marc-hb

marc-hb commented Jul 13, 2021

Copy link
Copy Markdown
Collaborator

(I don't mind either, but I'd prefer mine because it's smaller, it only fixes a bug without adding more confusion)

The whole test suite has been broken for almost a week so I agree we should merge ASAP the smallest possible change that gets up back to where we were. If @lyakh's #4479 works then it looks like a good candidate. Then this will give all the time needed for discussing the best refactor, clean up, etc. without pressure.

@iuliana-prodan

Copy link
Copy Markdown
Contributor Author

@lyakh @marc-hb I agree. Let's merge #4479 - that was my initial fix also :)
The SMP vs non-SMP should be done for sof_heap and sof_heap_shared.
So far, for imx we only have non-SMP so there is not need for shared heap.

@dbaluta dbaluta closed this Jul 13, 2021
@dbaluta

dbaluta commented Jul 13, 2021

Copy link
Copy Markdown
Collaborator

Closed this because a similar PR #4479 was merged.

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.

6 participants