Skip to content

Commit 3b966f3

Browse files
RanderWangxiulipan
authored andcommitted
ipc: remove waiti running in IRQ level higher than passive level
waiti would cause FW panic if it is called in irq level higher than passive level Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
1 parent 40f9749 commit 3b966f3

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/include/sof/wait.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@
4242
#include <sof/interrupt.h>
4343
#include <sof/trace.h>
4444
#include <sof/lock.h>
45+
#include <sof/clock.h>
46+
#include <platform/clk.h>
4547
#include <platform/interrupt.h>
4648
#include <sof/drivers/timer.h>
49+
#include <platform/platform.h>
4750

4851
#if DEBUG_LOCKS
4952
#define wait_atomic_check \
@@ -54,6 +57,8 @@
5457
#define wait_atomic_check
5558
#endif
5659

60+
#define DEFAULT_TRY_TIMES 8
61+
5762
typedef struct {
5863
uint32_t complete;
5964
struct work work;
@@ -158,4 +163,27 @@ static inline void wait_delay(uint64_t number_of_clks)
158163
idelay(PLATFORM_DEFAULT_DELAY);
159164
}
160165

166+
static inline int poll_for_completion_delay(completion_t *comp, uint64_t us)
167+
{
168+
uint64_t tick = clock_us_to_ticks(CLK_CPU, us);
169+
uint32_t tries = DEFAULT_TRY_TIMES;
170+
uint64_t delta = tick / tries;
171+
172+
if (!delta) {
173+
delta = us;
174+
tries = 1;
175+
}
176+
177+
while (!wait_is_completed(comp)) {
178+
if (!tries--) {
179+
trace_error(TRACE_CLASS_WAIT, "ewt");
180+
return -EIO;
181+
}
182+
183+
wait_delay(delta);
184+
}
185+
186+
return 0;
187+
}
188+
161189
#endif

src/ipc/ipc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,9 @@ int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table,
501501
}
502502

503503
/* wait for DMA to complete */
504-
complete.timeout = PLATFORM_HOST_DMA_TIMEOUT;
505-
ret = wait_for_completion_timeout(&complete);
504+
ret = poll_for_completion_delay(&complete, PLATFORM_DMA_TIMEOUT);
505+
if (ret < 0)
506+
trace_ipc_error("eDt");
506507

507508
/* compressed page tables now in buffer at _ipc->page_table */
508509
out:

0 commit comments

Comments
 (0)