Skip to content

Commit 387befd

Browse files
committed
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 5df6c68 commit 387befd

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,7 +42,10 @@
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>
48+
#include <platform/platform.h>
4649

4750
#if DEBUG_LOCKS
4851
#define wait_atomic_check \
@@ -53,6 +56,8 @@
5356
#define wait_atomic_check
5457
#endif
5558

59+
#define DEFAULT_TRY_TIMES 8
60+
5661
typedef struct {
5762
uint32_t complete;
5863
struct work work;
@@ -157,4 +162,27 @@ static inline void wait_delay(uint64_t number_of_clks)
157162
idelay(PLATFORM_DEFAULT_DELAY);
158163
}
159164

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