Lines Matching refs:cdma
19 #include "cdma.h"
50 struct host1x_cdma *cdma = pb_to_cdma(pb);
51 struct host1x *host1x = cdma_to_host1x(cdma);
72 struct host1x_cdma *cdma = pb_to_cdma(pb);
73 struct host1x *host1x = cdma_to_host1x(cdma);
183 * Must be called with the cdma lock held.
185 unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma,
189 struct push_buffer *pb = &cdma->push_buffer;
194 space = list_empty(&cdma->sync_queue) ? 1 : 0;
209 trace_host1x_wait_cdma(dev_name(cdma_to_channel(cdma)->dev),
213 if (cdma->event != CDMA_EVENT_NONE) {
214 mutex_unlock(&cdma->lock);
216 mutex_lock(&cdma->lock);
220 cdma->event = event;
222 mutex_unlock(&cdma->lock);
223 wait_for_completion(&cdma->complete);
224 mutex_lock(&cdma->lock);
233 * Must be called with the cdma lock held.
236 struct host1x_cdma *cdma,
240 struct push_buffer *pb = &cdma->push_buffer;
247 trace_host1x_wait_cdma(dev_name(cdma_to_channel(cdma)->dev),
250 host1x_hw_cdma_flush(host1x, cdma);
253 if (cdma->event != CDMA_EVENT_NONE) {
254 mutex_unlock(&cdma->lock);
256 mutex_lock(&cdma->lock);
260 cdma->event = CDMA_EVENT_PUSH_BUFFER_SPACE;
262 mutex_unlock(&cdma->lock);
263 wait_for_completion(&cdma->complete);
264 mutex_lock(&cdma->lock);
271 * Must be called with the cdma lock held.
273 static void cdma_start_timer_locked(struct host1x_cdma *cdma,
276 if (cdma->timeout.client) {
281 cdma->timeout.client = job->client;
282 cdma->timeout.syncpt = job->syncpt;
283 cdma->timeout.syncpt_val = job->syncpt_end;
284 cdma->timeout.start_ktime = ktime_get();
286 schedule_delayed_work(&cdma->timeout.wq,
292 * Must be called with the cdma lock held.
294 static void stop_cdma_timer_locked(struct host1x_cdma *cdma)
296 cancel_delayed_work(&cdma->timeout.wq);
297 cdma->timeout.client = NULL;
308 * Must be called with the cdma lock held.
310 static void update_cdma_locked(struct host1x_cdma *cdma)
319 list_for_each_entry_safe(job, n, &cdma->sync_queue, list) {
327 cdma_start_timer_locked(cdma, job);
333 if (cdma->timeout.client)
334 stop_cdma_timer_locked(cdma);
341 struct push_buffer *pb = &cdma->push_buffer;
345 if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE)
353 if (cdma->event == CDMA_EVENT_SYNC_QUEUE_EMPTY &&
354 list_empty(&cdma->sync_queue))
358 cdma->event = CDMA_EVENT_NONE;
359 complete(&cdma->complete);
363 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
366 struct host1x *host1x = cdma_to_host1x(cdma);
370 syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt);
385 list_for_each_entry(job, &cdma->sync_queue, list) {
388 if (!list_is_last(&job->list, &cdma->sync_queue))
411 restart_addr = cdma->last_pos;
430 host1x_hw_cdma_timeout_cpu_incr(host1x, cdma, job->first_get,
444 list_for_each_entry_continue(job, &cdma->sync_queue, list) {
453 u32 *mapped = cdma->push_buffer.mapped;
485 update_cdma_locked(cdma);
490 host1x_hw_cdma_resume(host1x, cdma, restart_addr);
495 struct host1x_cdma *cdma = container_of(work, struct host1x_cdma, update_work);
497 mutex_lock(&cdma->lock);
498 update_cdma_locked(cdma);
499 mutex_unlock(&cdma->lock);
503 * Create a cdma
505 int host1x_cdma_init(struct host1x_cdma *cdma)
509 mutex_init(&cdma->lock);
510 init_completion(&cdma->complete);
511 INIT_WORK(&cdma->update_work, cdma_update_work);
513 INIT_LIST_HEAD(&cdma->sync_queue);
515 cdma->event = CDMA_EVENT_NONE;
516 cdma->running = false;
517 cdma->torndown = false;
519 err = host1x_pushbuffer_init(&cdma->push_buffer);
527 * Destroy a cdma
529 int host1x_cdma_deinit(struct host1x_cdma *cdma)
531 struct push_buffer *pb = &cdma->push_buffer;
532 struct host1x *host1x = cdma_to_host1x(cdma);
534 if (cdma->running) {
540 host1x_hw_cdma_timeout_destroy(host1x, cdma);
546 * Begin a cdma submit
548 int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)
550 struct host1x *host1x = cdma_to_host1x(cdma);
552 mutex_lock(&cdma->lock);
556 * This needs to be done within the cdma lock to avoid a race
560 mutex_unlock(&cdma->lock);
566 if (!cdma->timeout.initialized) {
569 err = host1x_hw_cdma_timeout_init(host1x, cdma);
571 mutex_unlock(&cdma->lock);
577 if (!cdma->running)
578 host1x_hw_cdma_start(host1x, cdma);
580 cdma->slots_free = 0;
581 cdma->slots_used = 0;
582 cdma->first_get = cdma->push_buffer.pos;
592 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
594 struct host1x *host1x = cdma_to_host1x(cdma);
595 struct push_buffer *pb = &cdma->push_buffer;
596 u32 slots_free = cdma->slots_free;
599 trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
603 host1x_hw_cdma_flush(host1x, cdma);
604 slots_free = host1x_cdma_wait_locked(cdma,
608 cdma->slots_free = slots_free - 1;
609 cdma->slots_used++;
622 void host1x_cdma_push_wide(struct host1x_cdma *cdma, u32 op1, u32 op2,
625 struct host1x_channel *channel = cdma_to_channel(cdma);
626 struct host1x *host1x = cdma_to_host1x(cdma);
627 struct push_buffer *pb = &cdma->push_buffer;
628 unsigned int space = cdma->slots_free;
641 host1x_cdma_wait_pushbuffer_space(host1x, cdma, needed);
644 cdma->slots_free = space - needed;
645 cdma->slots_used += needed;
661 * End a cdma submit
666 void host1x_cdma_end(struct host1x_cdma *cdma,
669 struct host1x *host1x = cdma_to_host1x(cdma);
670 bool idle = list_empty(&cdma->sync_queue);
672 host1x_hw_cdma_flush(host1x, cdma);
674 job->first_get = cdma->first_get;
675 job->num_slots = cdma->slots_used;
677 list_add_tail(&job->list, &cdma->sync_queue);
681 cdma_start_timer_locked(cdma, job);
684 mutex_unlock(&cdma->lock);
688 * Update cdma state according to current sync point values
690 void host1x_cdma_update(struct host1x_cdma *cdma)
692 schedule_work(&cdma->update_work);