[Mesa-dev] [PATCH 4/5] gallium/util: replace pipe_condvar_signal() with cnd_signal()
Timothy Arceri
tarceri at itsqueeze.com
Sat Mar 4 23:41:32 UTC 2017
pipe_condvar_signal() was made unnecessary with fd33a6bcd7f12.
---
src/gallium/auxiliary/os/os_thread.h | 5 +----
src/gallium/auxiliary/util/u_queue.c | 4 ++--
src/gallium/auxiliary/util/u_ringbuffer.c | 4 ++--
src/gallium/state_trackers/nine/nine_queue.c | 4 ++--
src/gallium/state_trackers/nine/nine_state.c | 4 ++--
5 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 6895f4e..a8b5d92 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -141,23 +141,20 @@ __pipe_mutex_assert_locked(pipe_mutex *mutex)
assert(ret == thrd_busy);
if (ret == thrd_success)
mtx_unlock(mutex);
#endif
}
/* pipe_condvar
*/
typedef cnd_t pipe_condvar;
-#define pipe_condvar_signal(cond) \
- cnd_signal(&(cond))
-
#define pipe_condvar_broadcast(cond) \
cnd_broadcast(&(cond))
/*
* pipe_barrier
*/
#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HURD)) && !defined(PIPE_OS_ANDROID)
@@ -257,21 +254,21 @@ pipe_semaphore_destroy(pipe_semaphore *sema)
pipe_mutex_destroy(sema->mutex);
cnd_destroy(&sema->cond);
}
/** Signal/increment semaphore counter */
static inline void
pipe_semaphore_signal(pipe_semaphore *sema)
{
pipe_mutex_lock(sema->mutex);
sema->counter++;
- pipe_condvar_signal(sema->cond);
+ cnd_signal(&sema->cond);
pipe_mutex_unlock(sema->mutex);
}
/** Wait for semaphore counter to be greater than zero */
static inline void
pipe_semaphore_wait(pipe_semaphore *sema)
{
pipe_mutex_lock(sema->mutex);
while (sema->counter <= 0) {
cnd_wait(&sema->cond, &sema->mutex);
diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index 8fc2f3b..3cef7d2 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -161,21 +161,21 @@ static PIPE_THREAD_ROUTINE(util_queue_thread_func, input)
if (queue->kill_threads) {
pipe_mutex_unlock(queue->lock);
break;
}
job = queue->jobs[queue->read_idx];
memset(&queue->jobs[queue->read_idx], 0, sizeof(struct util_queue_job));
queue->read_idx = (queue->read_idx + 1) % queue->max_jobs;
queue->num_queued--;
- pipe_condvar_signal(queue->has_space_cond);
+ cnd_signal(&queue->has_space_cond);
pipe_mutex_unlock(queue->lock);
if (job.job) {
job.execute(job.job, thread_index);
util_queue_fence_signal(job.fence);
if (job.cleanup)
job.cleanup(job.job, thread_index);
}
}
@@ -309,21 +309,21 @@ util_queue_add_job(struct util_queue *queue,
ptr = &queue->jobs[queue->write_idx];
assert(ptr->job == NULL);
ptr->job = job;
ptr->fence = fence;
ptr->execute = execute;
ptr->cleanup = cleanup;
queue->write_idx = (queue->write_idx + 1) % queue->max_jobs;
queue->num_queued++;
- pipe_condvar_signal(queue->has_queued_cond);
+ cnd_signal(&queue->has_queued_cond);
pipe_mutex_unlock(queue->lock);
}
int64_t
util_queue_get_thread_time_nano(struct util_queue *queue, unsigned thread_index)
{
/* Allow some flexibility by not raising an error. */
if (thread_index >= queue->num_threads)
return 0;
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
index adba9ea..a97236f 100644
--- a/src/gallium/auxiliary/util/u_ringbuffer.c
+++ b/src/gallium/auxiliary/util/u_ringbuffer.c
@@ -95,21 +95,21 @@ void util_ringbuffer_enqueue( struct util_ringbuffer *ring,
* typesystem a little - we're being passed a pointer to
* something, but probably not an array of packet structs:
*/
ring->buf[ring->head] = packet[i];
ring->head++;
ring->head &= ring->mask;
}
/* Signal change:
*/
- pipe_condvar_signal(ring->change);
+ cnd_signal(&ring->change);
pipe_mutex_unlock(ring->mutex);
}
enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
struct util_packet *packet,
unsigned max_dwords,
boolean wait )
{
const struct util_packet *ring_packet;
unsigned i;
@@ -147,14 +147,14 @@ enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
*/
for (i = 0; i < ring_packet->dwords; i++) {
packet[i] = ring->buf[ring->tail];
ring->tail++;
ring->tail &= ring->mask;
}
out:
/* Signal change:
*/
- pipe_condvar_signal(ring->change);
+ cnd_signal(&ring->change);
pipe_mutex_unlock(ring->mutex);
return ret;
}
diff --git a/src/gallium/state_trackers/nine/nine_queue.c b/src/gallium/state_trackers/nine/nine_queue.c
index fdfbdbb..b50b57b 100644
--- a/src/gallium/state_trackers/nine/nine_queue.c
+++ b/src/gallium/state_trackers/nine/nine_queue.c
@@ -107,21 +107,21 @@ nine_queue_get(struct nine_queue_pool* ctx)
struct nine_cmdbuf *cmdbuf = &ctx->pool[ctx->tail];
unsigned offset;
/* At this pointer there's always a cmdbuf. */
if (ctx->cur_instr == cmdbuf->num_instr) {
/* signal waiting producer */
pipe_mutex_lock(ctx->mutex_pop);
DBG("freeing cmdbuf=%p\n", cmdbuf);
cmdbuf->full = 0;
- pipe_condvar_signal(ctx->event_pop);
+ cnd_signal(&ctx->event_pop);
pipe_mutex_unlock(ctx->mutex_pop);
ctx->tail = (ctx->tail + 1) & NINE_CMD_BUFS_MASK;
return NULL;
}
/* At this pointer there's always a cmdbuf with instruction to process. */
offset = cmdbuf->offset;
cmdbuf->offset += cmdbuf->instr_size[ctx->cur_instr];
@@ -143,21 +143,21 @@ nine_queue_flush(struct nine_queue_pool* ctx)
DBG("flushing cmdbuf=%p instr=%d size=%d\n",
cmdbuf, cmdbuf->num_instr, cmdbuf->offset);
/* Nothing to flush */
if (!cmdbuf->num_instr)
return;
/* signal waiting worker */
pipe_mutex_lock(ctx->mutex_push);
cmdbuf->full = 1;
- pipe_condvar_signal(ctx->event_push);
+ cnd_signal(&ctx->event_push);
pipe_mutex_unlock(ctx->mutex_push);
ctx->head = (ctx->head + 1) & NINE_CMD_BUFS_MASK;
cmdbuf = &ctx->pool[ctx->head];
/* wait for queue empty */
pipe_mutex_lock(ctx->mutex_pop);
while (cmdbuf->full)
{
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 0a2a0b9..90c49cf 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -101,37 +101,37 @@ PIPE_THREAD_ROUTINE(nine_csmt_worker, arg)
pipe_mutex_lock(ctx->thread_running);
/* Get instruction. NULL on empty cmdbuf. */
while (!p_atomic_read(&ctx->terminate) &&
(instr = (struct csmt_instruction *)nine_queue_get(ctx->pool))) {
/* decode */
if (instr->func(ctx->device, instr)) {
pipe_mutex_lock(ctx->mutex_processed);
p_atomic_set(&ctx->processed, TRUE);
- pipe_condvar_signal(ctx->event_processed);
+ cnd_signal(&ctx->event_processed);
pipe_mutex_unlock(ctx->mutex_processed);
}
if (p_atomic_read(&ctx->toPause)) {
pipe_mutex_unlock(ctx->thread_running);
/* will wait here the thread can be resumed */
pipe_mutex_lock(ctx->thread_resume);
pipe_mutex_lock(ctx->thread_running);
pipe_mutex_unlock(ctx->thread_resume);
}
}
pipe_mutex_unlock(ctx->thread_running);
if (p_atomic_read(&ctx->terminate)) {
pipe_mutex_lock(ctx->mutex_processed);
p_atomic_set(&ctx->processed, TRUE);
- pipe_condvar_signal(ctx->event_processed);
+ cnd_signal(&ctx->event_processed);
pipe_mutex_unlock(ctx->mutex_processed);
break;
}
}
DBG("CSMT worker destroyed\n");
return 0;
}
/* Create a CSMT context.
--
2.9.3
More information about the mesa-dev
mailing list