Skip to content

Conversation

@keyonjie
Copy link
Contributor

@keyonjie keyonjie commented Sep 6, 2021

unregister/free schedulers, IDCs, for DSP core tearing down gracefully.

@gkbldcig
Copy link
Collaborator

gkbldcig commented Sep 8, 2021

Can one of the admins verify this patch?

@keyonjie keyonjie force-pushed the multi_core branch 2 times, most recently from 1f49a53 to 73fc2b1 Compare October 18, 2021 09:03
@keyonjie keyonjie force-pushed the multi_core branch 2 times, most recently from 7c7669a to 99c153e Compare October 19, 2021 09:59
@keyonjie keyonjie force-pushed the multi_core branch 2 times, most recently from 4105535 to 5cea70f Compare October 19, 2021 12:08
Copy link
Member

Choose a reason for hiding this comment

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

This change looks like a rename and only part of it is needed ?

Copy link
Member

Choose a reason for hiding this comment

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

How do we do this per core ? What's the flow ?

Copy link
Member

Choose a reason for hiding this comment

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

What about EDF scheduler ?

Copy link
Member

Choose a reason for hiding this comment

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

This should probably be renamed to reflect the use cases i.e. we have

  1. power down the core (with memories off i.e. S4)
  2. power down the core (with memories on i.e. S3)
    The flows will also be very similar for both 1 & 2 and diverge at some point, so this could be
idc_core_power_down();

which in turn would call a generic

core_power_down(int pm_flags);

@keyonjie keyonjie changed the title [DO NOT REVIEW][For Test Only] Multi-core test only Secondary core tearing down series Oct 19, 2021
@keyonjie keyonjie marked this pull request as ready for review October 19, 2021 14:08
Copy link
Collaborator

Choose a reason for hiding this comment

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

@keyonjie we already call schedule_free() in cpu_power_down_core(). Is this really ncessary on tpo of that?

Copy link
Contributor Author

@keyonjie keyonjie Oct 20, 2021

Choose a reason for hiding this comment

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

Hi @ranj063 , yes, we already call schedule_free(), the problem is that neither the generic schedule_data struct nor the scheduler specific struct (e.g. edf_schedule_data and ll_schedule_data) is freed. Here the PR is for fixing the memory freeing. This will make sense in case of only the secondary cores are in loops of power off <--> on, e.g. dynamic pipelines run on a secondary core.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@keyonjie do you have an issue to show the behaviour? I have run secondary core power on/off (all 4 cores) loops for 10000 cycles without any issues. I added a debugfs entry in the kernel and wrote a script to test it. Have yyou done something similar and noticed issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@keyonjie do you have an issue to show the behaviour? I have run secondary core power on/off (all 4 cores) loops for 10000 cycles without any issues. I added a debugfs entry in the kernel and wrote a script to test it. Have yyou done something similar and noticed issues?

Thanks, @ranj063 I didn't run this kind of test, can you share your patch to test it? Your comment below about the "free_heap(SOF_MEM_ZONE_SYS)" explains why we are not seeing system memory leak.

I would still suggest this change as it is a graceful and symmetric way to tearing down each modules, it can make sure each allocated buffer is freed and writeback/invalidated, no matter it is located in system or some other zone in future, we should not rely on the powerful free_heap() and dcache_writeback_invalidate_all().

Copy link
Collaborator

Choose a reason for hiding this comment

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

same here. idc_free() is also called from cpu_power_down_core()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same. the original idc_free() is lack of freeing of struct idc and its payload, they are allocated in generic src/idc/idc.c so add the freeing to there also, and the platform specific platform_idc_free() only do the register clearing and interrupt unregistering stuff.

@ranj063
Copy link
Collaborator

ranj063 commented Oct 19, 2021

@keyonjie I think the main problem is with the shutting down of the primary core. The secondary core power down sequence is actually quite rock solid.

@ranj063
Copy link
Collaborator

ranj063 commented Oct 20, 2021

@keyonjie I'm still unsure about the need for this change. If this series is related to your changes in #4747 , you need to mention it. AFAICT, looking at free_heap(SOF_MEM_ZONE_SYS); in cpu_power_down_core(), frees the entire sys zone for the secondary cores. But if your change is needed because you are getting rid of the mem zones, then this change needs to be folded into the other PR where you do that and in a way that you don't break bisect. For ex: freeing the sys zone today will lead to a pnic. So you need to remove the panic first, free the zone and the add the changes in to remove the zone. It is very hard to review these patches otherwise

@keyonjie keyonjie force-pushed the multi_core branch 2 times, most recently from d484277 to 5745c64 Compare October 21, 2021 08:47
To power down a secondary core safely, we need to unregister and free the
schedulers that run on the corresponding core cleanly, which will help
to create clean one on the next powering up to the core.

Move the scheduler data allocation to SYSTEM_RUNTIME zone, and free it
at core powering down.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add scheuler free support to align to multi-core cAVS platform
implementation.

We don't need explicit freeing in tb_pipeline_free() anymore.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
To power down a secondary core gracefully, we need to free the IDC
related memory used on the corresponding core cleanly, which will help
to create clean one on the next powering up to the core.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
To power down a secondary core gracefully, we need to free the notifier
related memory used on the corresponding core cleanly, which will help
to create clean one on the next powering up to the core.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
@abonislawski
Copy link
Member

I can agree too that this is not needed and probably wrong.

Currently we are not freeing such things because they are not designed to free:

System Zone. Fixed size heap where alloc always succeeds and is never
freed. Used by any init code that will never give up the memory.

Thats why you have changed them to SYS_RUNTIME, but are they? We will not alloc idc again in runtime.

So we will abuse mem zone design only to get something like free(1) free(2) and anyway free(all)

@keyonjie
Copy link
Contributor Author

@abonislawski @ranj063 thanks for review, looks this doesn't fix any secondary core power down/on issues although no side effect observed either. Let me put it away at the moment.

@keyonjie keyonjie marked this pull request as draft October 22, 2021 09:12
@keyonjie keyonjie changed the title Secondary core tearing down series [Do Not Review] Secondary core tearing down series Oct 22, 2021
@keyonjie
Copy link
Contributor Author

closing this as it doesn't look needed.

@keyonjie keyonjie closed this Nov 22, 2021
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.

5 participants