Commit 66120c3
committed
ipc: userspace: fix IPC serialization with multiple cores
Fix a race in IPC serialization with multi-core. One sequence
observed:
- MOD_SET_DX IPC to power up core 1
- IPC reply to host
- CREATE_PIPELINE IPC (routed via core 0 to core 1)
- core 1 IPC thread starts, signals ipc_user->sem semaphore
- core 0 does NOT wait for thread as ipc_user->init_needed is set late
- ipc_user->sem signal for thread start is handled as
indication that IPC is handled (this is wrong)
- IPC reply to host (before CREATE_PIPELINE is handled)
- INIT_INSTANCE IPC (routed via core 0 to core 1)
- core 0 sees init_needed, but it is already signaled so execution
continues
-> DSP panic as IPC mailbox is modified while still in use
Using a semaphore is not ideal to synchronize with the secondary core
IPC threads. Proper execution requires the host to send the correct IPC
sequence (e.g. first to send MOD_SET_DX for core x, and then follow-up
with IPC messages for same core x). Additionally the start-up is
different for first power-up of a secondary core (context is initialized
in memory), and subsequent power-ups (IPC thread is never terminated and
restarted, it just resumes when core is powered up again).
To handle all cases, replace the sem based synchronization with a simple
per-core bitmask to indicate whether IPC thread has been created.
Before forwarding IPC messages from ipc_user_forward_cmd(), use the bitmask
to check core status, and sleep if necessary.
This leaves ipc_user->sem dedicated to signal completion of IPC handling
in a user thread, and this will no longer get mixed with IPC thread boot
signaling.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>1 parent 158518d commit 66120c3
2 files changed
Lines changed: 20 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
406 | 408 | | |
407 | 409 | | |
408 | 410 | | |
| |||
437 | 439 | | |
438 | 440 | | |
439 | 441 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
496 | 500 | | |
497 | 501 | | |
498 | 502 | | |
499 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
500 | 509 | | |
501 | 510 | | |
502 | 511 | | |
| |||
598 | 607 | | |
599 | 608 | | |
600 | 609 | | |
601 | | - | |
602 | | - | |
603 | | - | |
604 | 610 | | |
605 | 611 | | |
606 | 612 | | |
| |||
628 | 634 | | |
629 | 635 | | |
630 | 636 | | |
| 637 | + | |
| 638 | + | |
631 | 639 | | |
632 | 640 | | |
633 | 641 | | |
| |||
0 commit comments