Skip to content

IPC and keyword detection fixes - #4869

Merged
lgirdwood merged 5 commits into
thesofproject:mainfrom
lyakh:20211008-misc_3
Oct 18, 2021
Merged

lgirdwood merged 5 commits into
thesofproject:mainfrom
lyakh:20211008-misc_3

Conversation

@lyakh

@lyakh lyakh commented Oct 13, 2021

Copy link
Copy Markdown
Collaborator

No description provided.

@kv2019i kv2019i 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.

Hmm, sensible problems to fix, but I'm left with many questions about the how the fixes work. Please see questions inline.

Comment thread src/drivers/intel/cavs/ipc.c Outdated

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.

I get the commit message description of the problem, but I've having hard time how moving the cpu-is-me check form one place to another actually fixes the problem as describe in commit message. Can you somehow clarify how this is supposed to work?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I can. Look at the .delayed_response flag below. As I describe in the commit message, ipc_complete_cmd() can be entered 3 times: first on the primary core, then on the secondary core from the IDC / IPC, then on the secondary core from the pipeline task. Before this patch the first call on the primary core would set .delayed_response to false, so that the second call to this function would already find .delayed_response set to false and send a response. Then the third call would again find it as false and send it again. After this patch the primary core won't set false, only the secondary core will.

@ranj063 ranj063 Oct 13, 2021 •

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.

@lyakh it is true the function is entered 3 times but the delayed_response flag is actually set only on the core that the IPC gets executed on right? So what the primary core does is sort of immaterial right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ipc is a global object. So, can something like this happen?

core 0                           core 1
IPC IRQ
IPC EDF task
ipc_cmd()
IDC to core 1
                                 IDC IRQ
timer IRQ
pipeline tasks
                                 ipc_cmd()
                                 ipc->delayed_response = 1
resume IPC
ipc->delayed_response = 0

?

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.

IDC is non-blocking isnt it? And timer IRQ can preempt the IPC task?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ranj063 It depends on the mode parameter. E.g. for STREAM_TRIGGER it's non-blocking:

static int ipc_stream_trigger(uint32_t header)
{
	...
	if (!cpu_is_me(pcm_dev->core))
		return ipc_process_on_core(pcm_dev->core, false);

false means non-blocking

Comment thread src/ipc/ipc3/handler.c Resolved
Comment thread src/ipc/ipc3/handler.c Outdated

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.

Commit not matching code. Commit says ignore, code says "-EINVAL".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

true, let me fix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and -EINVAL is not a a success code either ;-)

ipc: ipc3: return error on PCM_PARAMS request for active pipelines
If a PCM_PARAMS IPC arrives on an active pipeline, log and return an error immediately.

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.

but why should it be an error? can we not ignore the IPC and return succes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should also be a bit more verbose with the trace context, i.e. "ipc: pipe X is active but client requested PCM params change"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood could you please reply to @ranj063 's question, I'm not sure I asked for an explanation from you when you requested me to do this :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sending PCM params during a running pipeline means the driver and FW are out of sync. Now that's an obvious eror, but IIUC an IPC4 use case, so we should return 0 and have a big comment about this in teh code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood you want it back to returning zero?..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes please, with a comment too :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lyakh ping - only this change is needed I think (and the commit message to align with return value).

@lyakh

lyakh commented Oct 13, 2021

Copy link
Copy Markdown
Collaborator Author

CI failures:
QuickBuild keyword tests fail because they use the sample width of 0, which was previously ignored, but now it triggers an error. Should the tests be fixed?
Device test: two timeouts on CML_RVP_SDW, seems unrelated.

@lyakh

lyakh commented Oct 14, 2021

Copy link
Copy Markdown
Collaborator Author

@wszypelt can the sample width be fixed in KD tests?

Comment thread src/ipc/ipc3/handler.c Resolved
Comment thread src/ipc/ipc3/handler.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should also be a bit more verbose with the trace context, i.e. "ipc: pipe X is active but client requested PCM params change"

@lgirdwood

Copy link
Copy Markdown
Member

@kkarask @wszypelt any comments on QB using sample width of 0 (see above comments). May need an update on your side ?

@wszypelt

Copy link
Copy Markdown

@lyakh @lgirdwood we'll take a look at it together with Filip

@lyakh
lyakh requested a review from mrajwa as a code owner October 15, 2021 12:26
@lyakh
lyakh requested a review from kv2019i October 15, 2021 12:39

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@lyakh pls ping @kv2019i when update is pushed. Should get merged on Monday

lyakh added 5 commits October 15, 2021 16:35
It is possible, that ipc_complete_cmd() is entered 3 times while
processing a single IPC message in multicore configurations: once by
the primary core, then by the IDC IPC processing context, and finally
by the pipeline thread, actually executing the IPC. To make sure that
the response is only sent once by the core, that actually processes
the IPC, we must not clear the .delayed_response flag on the primary
core in such cases, it should only be done by the IDC IPC context
before the pipeline task actually sends the response.

Fixes: 82857a7 ("ipc: fix a IPC completion race")
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
IPCs from the host aren't very frequent during normal operation, and
having all their codes in firmware trace output is extremely useful
for debugging. Add a trace print for arriving IPCs.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
test_keyword_get_threshold() can return errors, make sure to check
its return value before using it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
With IPC3 it is an error to send a PCM_PARAMS IPC on an active
pipeline, but it is a valid use-case with IPC4, ignore such IPCs.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
cpu_is_primary() can be easier to parse than !cpu_is_secondary(), make
the swap.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>

@kv2019i kv2019i 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.

Looks fine. I did leave a comment/question to the last patch, but not a blocker.


/* flush for secondary core */
if (cpu_is_secondary(task->core))
if (!cpu_is_primary(task->core))

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.

Why this change @lyakh ? Isn't cpu_is_secondary() the easier to parse in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@kv2019i sorry, I might not have the best taste for "simple" vs. "complex" :-) This is the only use of cpu_is_secondary() and I decided that !cpu_is_primary() is easy enough to understand to justify the removal of cpu_is_secondary() in one place...

@lgirdwood

Copy link
Copy Markdown
Member

CI showing known suspend timeouts.

@lgirdwood
lgirdwood merged commit 8549c9c into thesofproject:main Oct 18, 2021
@lyakh
lyakh deleted the 20211008-misc_3 branch October 18, 2021 14:09
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