sof icon indicating copy to clipboard operation
sof copied to clipboard

Time keeping breakage on SOF with Zephyr on i.MX

Open dbaluta opened this issue 3 years ago • 2 comments

Describe the bug

Commit c3c94fc5151886f ("header: rtos: use rtos specific version of wait.h") breaks i.MX platforms running SOF with Zephyr.

This happens because commit uses k_cycle_get_64 which always returns 0 on i.MX8 as the CCOUNT register is 32 bits.

e.g

-       *wallclock = sof_cycle_get_64();
+       *wallclock = k_cycle_get_64();

On, Xtos we solved this issue by introducing sof_cycle_get_64:

static inline uint64_t sof_cycle_get_64(void)
{
       if (IS_ENABLED(CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER))
               return k_cycle_get_64();
       else
               return k_ticks_to_cyc_floor64(k_uptime_ticks());
}

@lgirdwood there are two steps on solving this issue:

  1. Try to use as much as native Zephyr API for waiting functions:

e.g

replace:

+/* TODO: use equivalent Zephyr */
+static inline void idelay(int n)
+{
+       while (n--)
+               asm volatile("nop");
+}

with k_busy_wait.

  1. Add again sof_cycle_get_64 wrapper to replace k_cycle_get_64.

dbaluta avatar Oct 13 '22 12:10 dbaluta

Cc: @lgirdwood @LaurentiuM1234

dbaluta avatar Oct 13 '22 13:10 dbaluta

This should be an acceptable fix: https://github.com/thesofproject/sof/pull/6416

dbaluta avatar Oct 14 '22 07:10 dbaluta

This should be an acceptable fix: #6416

Can we close ?

lgirdwood avatar Oct 19 '22 15:10 lgirdwood

fixed with https://github.com/thesofproject/sof/pull/6416

dbaluta avatar Oct 19 '22 15:10 dbaluta