[Sound-open-firmware] [PATCH] Use 64-bit time instead of 32-bit time for work queue utility.
yan.wang at linux.intel.com
yan.wang at linux.intel.com
Tue Oct 10 12:40:13 CEST 2017
From: Yan Wang <yan.wang at linux.intel.com>
Current timer has been upgraded to 64-bit but work queue utility
still uses 32-bit.
So timer->hitime can't be added rightly because the 64-bit time
is truncated by work queue utility.
"rmbox" will still receive 32-bit timestamp value only and can't
be upgraded to 64-bit timestamp.
Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
---
src/audio/dma-trace.c | 2 +-
src/audio/volume.c | 2 +-
src/include/reef/reef.h | 1 +
src/include/reef/wait.h | 4 ++--
src/include/reef/work.h | 4 ++--
src/lib/schedule.c | 2 +-
src/lib/work.c | 30 +++++++++++++++---------------
7 files changed, 23 insertions(+), 22 deletions(-)
diff --git a/src/audio/dma-trace.c b/src/audio/dma-trace.c
index 8fc220e..d725fcf 100644
--- a/src/audio/dma-trace.c
+++ b/src/audio/dma-trace.c
@@ -97,7 +97,7 @@ static void trace_send(struct dma_trace_data *d)
trace_buffer("dts");
}
-static uint32_t trace_work(void *data, uint32_t delay)
+static uint64_t trace_work(void *data, uint64_t delay)
{
struct dma_trace_data *d = (struct dma_trace_data *)data;
diff --git a/src/audio/volume.c b/src/audio/volume.c
index 68c8453..04d1b34 100644
--- a/src/audio/volume.c
+++ b/src/audio/volume.c
@@ -277,7 +277,7 @@ static void vol_update(struct comp_data *cd, uint32_t chan)
}
/* this ramps volume changes over time */
-static uint32_t vol_work(void *data, uint32_t delay)
+static uint64_t vol_work(void *data, uint64_t delay)
{
struct comp_dev *dev = (struct comp_dev *)data;
struct comp_data *cd = comp_get_drvdata(dev);
diff --git a/src/include/reef/reef.h b/src/include/reef/reef.h
index 0cf8261..3450208 100644
--- a/src/include/reef/reef.h
+++ b/src/include/reef/reef.h
@@ -39,6 +39,7 @@ struct ipc;
/* TODO: define for unsigned and short, byte */
#define MAX_INT 0xffffffff
+#define MAX_INT64 0xffffffffffffffff
/* use same syntax as Linux for simplicity */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
diff --git a/src/include/reef/wait.h b/src/include/reef/wait.h
index c830a75..08fc0b0 100644
--- a/src/include/reef/wait.h
+++ b/src/include/reef/wait.h
@@ -45,7 +45,7 @@
typedef struct {
uint32_t complete;
struct work work;
- uint32_t timeout;
+ uint64_t timeout;
} completion_t;
void arch_wait_for_interrupt(int level);
@@ -57,7 +57,7 @@ static inline void wait_for_interrupt(int level)
tracev_event(TRACE_CLASS_WAIT, "WFX");
}
-static uint32_t _wait_cb(void *data, uint32_t delay)
+static uint64_t _wait_cb(void *data, uint64_t delay)
{
volatile completion_t *wc = (volatile completion_t*)data;
diff --git a/src/include/reef/work.h b/src/include/reef/work.h
index 516f98f..0cdb085 100644
--- a/src/include/reef/work.h
+++ b/src/include/reef/work.h
@@ -45,10 +45,10 @@ struct work_queue;
#define WORK_SYNC (1 << 0) /* work is scheduled synchronously */
struct work {
- uint32_t (*cb)(void*, uint32_t udelay); /* returns reschedule timeout in msecs */
+ uint64_t (*cb)(void*, uint64_t udelay); /* returns reschedule timeout in msecs */
void *cb_data;
struct list_item list;
- uint32_t timeout;
+ uint64_t timeout;
uint32_t pending;
uint32_t flags;
};
diff --git a/src/lib/schedule.c b/src/lib/schedule.c
index 427ca2e..993f94a 100644
--- a/src/lib/schedule.c
+++ b/src/lib/schedule.c
@@ -146,7 +146,7 @@ static inline struct task *edf_get_next(uint64_t current,
}
/* work set in the future when next task can be scheduled */
-static uint32_t sch_work(void *data, uint32_t delay)
+static uint64_t sch_work(void *data, uint64_t delay)
{
tracev_pipe("wrk");
schedule();
diff --git a/src/lib/work.c b/src/lib/work.c
index a267b80..cd21b20 100644
--- a/src/lib/work.c
+++ b/src/lib/work.c
@@ -98,8 +98,8 @@ static int is_work_pending(struct work_queue *queue)
{
struct list_item *wlist;
struct work *work;
- uint32_t win_end;
- uint32_t win_start;
+ uint64_t win_end;
+ uint64_t win_start;
int pending_count = 0;
/* get the current valid window of work */
@@ -131,7 +131,7 @@ static int is_work_pending(struct work_queue *queue)
/* if work has timed out then mark it as pending to run */
if (work->timeout <= win_end ||
- (work->timeout >= win_start && work->timeout < MAX_INT)) {
+ (work->timeout >= win_start && work->timeout < MAX_INT64)) {
work->pending = 1;
pending_count++;
} else {
@@ -144,7 +144,7 @@ static int is_work_pending(struct work_queue *queue)
}
static inline void work_next_timeout(struct work_queue *queue,
- struct work *work, uint32_t reschedule_usecs)
+ struct work *work, uint64_t reschedule_usecs)
{
/* reschedule work */
if (work->flags & WORK_SYNC) {
@@ -162,8 +162,8 @@ static void run_work(struct work_queue *queue, uint32_t *flags)
struct list_item *wlist;
struct list_item *tlist;
struct work *work;
- uint32_t reschedule_usecs;
- uint32_t udelay;
+ uint64_t reschedule_usecs;
+ uint64_t udelay;
/* check each work item in queue for pending */
list_for_item_safe(wlist, tlist, &queue->work) {
@@ -192,9 +192,9 @@ static void run_work(struct work_queue *queue, uint32_t *flags)
}
}
-static inline uint32_t calc_delta_ticks(uint32_t current, uint32_t work)
+static inline uint64_t calc_delta_ticks(uint64_t current, uint64_t work)
{
- uint32_t max = MAX_INT;
+ uint64_t max = MAX_INT64;
/* does work run in next cycle ? */
if (work < current) {
@@ -210,10 +210,10 @@ static void queue_get_next_timeout(struct work_queue *queue)
{
struct list_item *wlist;
struct work *work;
- uint32_t delta = MAX_INT;
- uint32_t current;
- uint32_t d;
- uint32_t ticks;
+ uint64_t delta = MAX_INT64;
+ uint64_t current;
+ uint64_t d;
+ uint64_t ticks;
/* only recalc if work list not empty */
if (list_is_empty(&queue->work)) {
@@ -246,9 +246,9 @@ static void queue_recalc_timers(struct work_queue *queue,
{
struct list_item *wlist;
struct work *work;
- uint32_t delta_ticks;
- uint32_t delta_usecs;
- uint32_t current;
+ uint64_t delta_ticks;
+ uint64_t delta_usecs;
+ uint64_t current;
/* get current time */
current = work_get_timer(queue);
--
2.7.4
More information about the Sound-open-firmware
mailing list