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 struct host1x *host = cdma_to_host1x(cdma);
278 if (cdma->timeout.client) {
283 cdma->timeout.client = job->client;
284 cdma->timeout.syncpt = host1x_syncpt_get(host, job->syncpt_id);
285 cdma->timeout.syncpt_val = job->syncpt_end;
286 cdma->timeout.start_ktime = ktime_get();
288 schedule_delayed_work(&cdma->timeout.wq,
294 * Must be called with the cdma lock held.
296 static void stop_cdma_timer_locked(struct host1x_cdma *cdma)
298 cancel_delayed_work(&cdma->timeout.wq);
299 cdma->timeout.client = NULL;
310 * Must be called with the cdma lock held.
312 static void update_cdma_locked(struct host1x_cdma *cdma)
315 struct host1x *host1x = cdma_to_host1x(cdma);
319 if (!cdma->running)
326 list_for_each_entry_safe(job, n, &cdma->sync_queue, list) {
334 cdma_start_timer_locked(cdma, job);
340 if (cdma->timeout.client)
341 stop_cdma_timer_locked(cdma);
348 struct push_buffer *pb = &cdma->push_buffer;
352 if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE)
360 if (cdma->event == CDMA_EVENT_SYNC_QUEUE_EMPTY &&
361 list_empty(&cdma->sync_queue))
365 cdma->event = CDMA_EVENT_NONE;
366 complete(&cdma->complete);
370 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
373 struct host1x *host1x = cdma_to_host1x(cdma);
377 syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt);
392 list_for_each_entry(job, &cdma->sync_queue, list) {
395 if (!list_is_last(&job->list, &cdma->sync_queue))
418 restart_addr = cdma->last_pos;
434 host1x_hw_cdma_timeout_cpu_incr(host1x, cdma, job->first_get,
443 host1x_hw_cdma_resume(host1x, cdma, restart_addr);
447 * Create a cdma
449 int host1x_cdma_init(struct host1x_cdma *cdma)
453 mutex_init(&cdma->lock);
454 init_completion(&cdma->complete);
456 INIT_LIST_HEAD(&cdma->sync_queue);
458 cdma->event = CDMA_EVENT_NONE;
459 cdma->running = false;
460 cdma->torndown = false;
462 err = host1x_pushbuffer_init(&cdma->push_buffer);
470 * Destroy a cdma
472 int host1x_cdma_deinit(struct host1x_cdma *cdma)
474 struct push_buffer *pb = &cdma->push_buffer;
475 struct host1x *host1x = cdma_to_host1x(cdma);
477 if (cdma->running) {
483 host1x_hw_cdma_timeout_destroy(host1x, cdma);
489 * Begin a cdma submit
491 int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)
493 struct host1x *host1x = cdma_to_host1x(cdma);
495 mutex_lock(&cdma->lock);
499 if (!cdma->timeout.initialized) {
502 err = host1x_hw_cdma_timeout_init(host1x, cdma,
505 mutex_unlock(&cdma->lock);
511 if (!cdma->running)
512 host1x_hw_cdma_start(host1x, cdma);
514 cdma->slots_free = 0;
515 cdma->slots_used = 0;
516 cdma->first_get = cdma->push_buffer.pos;
526 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
528 struct host1x *host1x = cdma_to_host1x(cdma);
529 struct push_buffer *pb = &cdma->push_buffer;
530 u32 slots_free = cdma->slots_free;
533 trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
537 host1x_hw_cdma_flush(host1x, cdma);
538 slots_free = host1x_cdma_wait_locked(cdma,
542 cdma->slots_free = slots_free - 1;
543 cdma->slots_used++;
556 void host1x_cdma_push_wide(struct host1x_cdma *cdma, u32 op1, u32 op2,
559 struct host1x_channel *channel = cdma_to_channel(cdma);
560 struct host1x *host1x = cdma_to_host1x(cdma);
561 struct push_buffer *pb = &cdma->push_buffer;
563 unsigned int space = cdma->slots_free;
575 host1x_cdma_wait_pushbuffer_space(host1x, cdma, needed);
578 cdma->slots_free = space - needed;
579 cdma->slots_used += needed;
601 * End a cdma submit
606 void host1x_cdma_end(struct host1x_cdma *cdma,
609 struct host1x *host1x = cdma_to_host1x(cdma);
610 bool idle = list_empty(&cdma->sync_queue);
612 host1x_hw_cdma_flush(host1x, cdma);
614 job->first_get = cdma->first_get;
615 job->num_slots = cdma->slots_used;
617 list_add_tail(&job->list, &cdma->sync_queue);
621 cdma_start_timer_locked(cdma, job);
624 mutex_unlock(&cdma->lock);
628 * Update cdma state according to current sync point values
630 void host1x_cdma_update(struct host1x_cdma *cdma)
632 mutex_lock(&cdma->lock);
633 update_cdma_locked(cdma);
634 mutex_unlock(&cdma->lock);