Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Jul 9, 2021

Run trigger START and RELEASE in the pipeline task context

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 9, 2021

this survived "run-all-tests.sh -l 1" in a Zephyr build with only expected failures: xrun-inject, ipc-flood, kmod and suspend-resume-with-*.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Just need some more comments describing the flows and transitions and rules.

Copy link
Member

Choose a reason for hiding this comment

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

Is this patch in another PR ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I closed #4469

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood what do you think about this change - does it seem safe to you? @ranj063 expressed some concerns in #4469 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

This also looks similar to the other PR ?

@lyakh lyakh mentioned this pull request Jul 13, 2021
@lyakh lyakh changed the title [WiP] Pipeline scheduling Pipeline scheduling Jul 13, 2021
@lyakh lyakh marked this pull request as ready for review July 13, 2021 16:11
@lyakh lyakh requested a review from lgirdwood July 13, 2021 16:31
Copy link
Collaborator

@ranj063 ranj063 Jul 13, 2021

Choose a reason for hiding this comment

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

@lyakh how about moving the power_off to be the first thing in platform_complete_cmd(). That way we'd still have the same sequence as before ie power off and then send the host notification?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 but then what's the point of this patch? :-) The whole idea was to make sure we acknowledge the completion of the IPC to the host, so that it doesn't run onto an IPC timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this patch is not critical. CTX_SAVE IPC is always executed on core 0 anyway

src/idc/idc.c Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW @lyakh I assume you have tested this change with xtos too and not just zephyr? It looks correct for sure but we dont have a topology in CI with multi-core. So just wanted to make sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 We don't, really?? Oh... I thought PR CI was testing multicore? @keyonjie

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh I tested this PR with my multi-core topology and it passed with flying colors! good to go!

@lgirdwood
Copy link
Member

@lyakh looks good on all platforms except legacy ? can you check, it could be topology is using DMA driver, whereas they can support timer driven too.

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 15, 2021

@lyakh looks good on all platforms except legacy ? can you check, it could be topology is using DMA driver, whereas they can support timer driven too.

@lgirdwood I'm wondering: with this PR TRIG_START doesn't trigger components from the IPC, instead when the pipeline task is scheduled for the first time, then TRIG_START is sent to all components. But when using the DMA domain, isn't DMA scheduling started from scheduling component's TRIG_START? So, the task never gets scheduled? I can of course make this decision to postpone TRIG_START depend on timer or Zephyr LL-scheduling domain...

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 19, 2021

This PR now has 2 issues:

  1. power down in IPC completion seems to be wrong. SOF has assembly code to acknowledge the power-down IPC, which in XTOS builds is also synchronised with clock management. In Zephyr builds clock is managed by Zephyr so the SOF powers down hardware asynchronously to clock halting. Supposedly a clock interrupt can trigger at that time, trying to access RAM. But this raises a question: @lgirdwood why don't we just disable interrupts when powering down? All this should be running on the primary core.
  2. it breaks the DMA scheduling domain. To fix that I'll try to only perform synchronous triggering for timer-domain tasks, not for DMA-domain tasks

@lgirdwood
Copy link
Member

  1. @lgirdwood why don't we just disable interrupts when powering down? All this should be running on the primary core.

Doesn't work, the clock IP is still ON and asserts an IRQ. The clock must be OFF so no IRQ is asserted.

Btw, not following why power OFF is related to this PR for LL triggering ?

  1. Host should stop all streams prior to sending PM OFF IPC (otherwise FW can reply to PM off with -EBUSY)

  2. We should only reply to stream trigger IPCs when the LL scheduler has performed the trigger op. i.e. this means the IPC reply can take up to 1ms.

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 19, 2021

  1. @lgirdwood why don't we just disable interrupts when powering down? All this should be running on the primary core.

Doesn't work, the clock IP is still ON and asserts an IRQ. The clock must be OFF so no IRQ is asserted.

I understand, but IRQs will be off at the DSP level, so the DSP won't be interrupted. Or do you mean it still somehow breaks at the hardware level?

Btw, not following why power OFF is related to this PR for LL triggering ?

Not to LL triggering, but this PR also contains a patch for power off sequence. Yes, it is unrelated to the PR, I can drop it from here.

@lgirdwood
Copy link
Member

  1. @lgirdwood why don't we just disable interrupts when powering down? All this should be running on the primary core.

Doesn't work, the clock IP is still ON and asserts an IRQ. The clock must be OFF so no IRQ is asserted.

I understand, but IRQs will be off at the DSP level, so the DSP won't be interrupted. Or do you mean it still somehow breaks at the hardware level?

Yes, HW level blocker.

@keyonjie
Copy link
Contributor

This PR now has 2 issues:

  1. power down in IPC completion seems to be wrong. SOF has assembly code to acknowledge the power-down IPC, which in XTOS builds is also synchronised with clock management. In Zephyr builds clock is managed by Zephyr so the SOF powers down hardware asynchronously to clock halting. Supposedly a clock interrupt can trigger at that time, trying to access RAM. But this raises a question: @lgirdwood why don't we just disable interrupts when powering down? All this should be running on the primary core.
  2. it breaks the DMA scheduling domain. To fix that I'll try to only perform synchronous triggering for timer-domain tasks, not for DMA-domain tasks

Don't have time to review details yet, but yes, let's NOT merge this until the DMA scheduling domain issues are fixed.

Copy link
Contributor

@keyonjie keyonjie left a comment

Choose a reason for hiding this comment

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

Let's not merge it before regressions on DMA domain addressed.

lyakh added 2 commits July 27, 2021 08:15
pipeline_task_init() is always called with pipeline_task as its last
parameter. Remove the parameter and use the function explicitly.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Use bool type for boolean flags, split some too long lines, merge
some needlessly split lines.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh lyakh force-pushed the pipe-sched branch 2 times, most recently from 1a9f528 to 6e44891 Compare July 27, 2021 09:41
@lyakh
Copy link
Collaborator Author

lyakh commented Jul 27, 2021

Let's not merge it before regressions on DMA domain addressed.

@keyonjie this version should leave DMA domain pipelines unchanged.

When the firmware receives a START or RELEASE IPC message, it
immediately triggers all involved components, which starts DMA.
Then it schedules the pipeline task, but since the scheduler can be
already running at that time, the task might be scheduled when DMA
data isn't available yet or has already overflowed. To fix this
change the control flow to also trigger all components from the task
during its first run. Actual data processing then begins with the
next period. Note, that this is currently only possible with
pipelines, using timer-based scheduling. Pipelines, using DMA
interrupts for scheduling are unaffected.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh lyakh requested a review from keyonjie July 27, 2021 13:38
@lgirdwood
Copy link
Member

CI shows unrelated CML kernel PM failure.

@lgirdwood lgirdwood merged commit 9a7a5ce into thesofproject:main Jul 27, 2021
@lyakh lyakh deleted the pipe-sched branch July 27, 2021 14:10
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