Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/include/sof/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
#include <sof/interrupt.h>
#include <sof/trace.h>
#include <sof/lock.h>
#include <sof/clock.h>
#include <platform/clk.h>
#include <platform/interrupt.h>
#include <platform/platform.h>

#if DEBUG_LOCKS
#define wait_atomic_check \
Expand All @@ -53,6 +56,8 @@
#define wait_atomic_check
#endif

#define DEFAULT_TRY_TIMES 8

typedef struct {
uint32_t complete;
struct work work;
Expand Down Expand Up @@ -157,4 +162,27 @@ static inline void wait_delay(uint64_t number_of_clks)
idelay(PLATFORM_DEFAULT_DELAY);
}

static inline int poll_for_completion_delay(completion_t *comp, uint64_t us)
{
uint64_t tick = clock_us_to_ticks(CLK_CPU, us);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RanderWang @lgirdwood I think this function won't work correctly, because on cAVS platforms wait_delay function is based on XTAL (e.g. 19.2 MHZ for APL) and CLK_CPU has entirely different freq.

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.

@RanderWang can you fix, use the PLATFORM_CLK thet we use fr work/scheduling.

uint32_t tries = DEFAULT_TRY_TIMES;
uint64_t delta = tick / tries;

if (!delta) {
delta = us;
tries = 1;
}

while (!wait_is_completed(comp)) {
if (!tries--) {
trace_error(TRACE_CLASS_WAIT, "ewt");
return -EIO;
}

wait_delay(delta);
}

return 0;
}

#endif
5 changes: 3 additions & 2 deletions src/ipc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table,
}

/* wait for DMA to complete */
complete.timeout = PLATFORM_HOST_DMA_TIMEOUT;
ret = wait_for_completion_timeout(&complete);
ret = poll_for_completion_delay(&complete, PLATFORM_DMA_TIMEOUT);
if (ret < 0)
trace_ipc_error("eDt");

/* compressed page tables now in buffer at _ipc->page_table */
out:
Expand Down