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),
251 if (cdma->event != CDMA_EVENT_NONE) {
252 mutex_unlock(&cdma->lock);
254 mutex_lock(&cdma->lock);
258 cdma->event = CDMA_EVENT_PUSH_BUFFER_SPACE;
260 mutex_unlock(&cdma->lock);
261 wait_for_completion(&cdma->complete);
262 mutex_lock(&cdma->lock);
269 * Must be called with the cdma lock held.
271 static void cdma_start_timer_locked(struct host1x_cdma *cdma,
274 if (cdma->timeout.client) {
279 cdma->timeout.client = job->client;
280 cdma->timeout.syncpt = job->syncpt;
281 cdma->timeout.syncpt_val = job->syncpt_end;
282 cdma->timeout.start_ktime = ktime_get();
284 schedule_delayed_work(&cdma->timeout.wq,
290 * Must be called with the cdma lock held.
292 static void stop_cdma_timer_locked(struct host1x_cdma *cdma)
294 cancel_delayed_work(&cdma->timeout.wq);
295 cdma->timeout.client = NULL;
306 * Must be called with the cdma lock held.
308 static void update_cdma_locked(struct host1x_cdma *cdma)
317 list_for_each_entry_safe(job, n, &cdma->sync_queue, list) {
325 cdma_start_timer_locked(cdma, job);
331 if (cdma->timeout.client)
332 stop_cdma_timer_locked(cdma);
339 struct push_buffer *pb = &cdma->push_buffer;
343 if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE)
351 if (cdma->event == CDMA_EVENT_SYNC_QUEUE_EMPTY &&
352 list_empty(&cdma->sync_queue))
356 cdma->event = CDMA_EVENT_NONE;
357 complete(&cdma->complete);
361 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
364 struct host1x *host1x = cdma_to_host1x(cdma);
368 syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt);
383 list_for_each_entry(job, &cdma->sync_queue, list) {
386 if (!list_is_last(&job->list, &cdma->sync_queue))
409 restart_addr = cdma->last_pos;
428 host1x_hw_cdma_timeout_cpu_incr(host1x, cdma, job->first_get,
442 list_for_each_entry_continue(job, &cdma->sync_queue, list) {
451 u32 *mapped = cdma->push_buffer.mapped;
483 update_cdma_locked(cdma);
488 host1x_hw_cdma_resume(host1x, cdma, restart_addr);
493 struct host1x_cdma *cdma = container_of(work, struct host1x_cdma, update_work);
495 mutex_lock(&cdma->lock);
496 update_cdma_locked(cdma);
497 mutex_unlock(&cdma->lock);
501 * Create a cdma
503 int host1x_cdma_init(struct host1x_cdma *cdma)
507 mutex_init(&cdma->lock);
508 init_completion(&cdma->complete);
509 INIT_WORK(&cdma->update_work, cdma_update_work);
511 INIT_LIST_HEAD(&cdma->sync_queue);
513 cdma->event = CDMA_EVENT_NONE;
514 cdma->running = false;
515 cdma->torndown = false;
517 err = host1x_pushbuffer_init(&cdma->push_buffer);
525 * Destroy a cdma
527 int host1x_cdma_deinit(struct host1x_cdma *cdma)
529 struct push_buffer *pb = &cdma->push_buffer;
530 struct host1x *host1x = cdma_to_host1x(cdma);
532 if (cdma->running) {
538 host1x_hw_cdma_timeout_destroy(host1x, cdma);
544 * Begin a cdma submit
546 int host1x_cdma_begin(struct host1x_cdma *cdma, struct host1x_job *job)
548 struct host1x *host1x = cdma_to_host1x(cdma);
550 mutex_lock(&cdma->lock);
554 * This needs to be done within the cdma lock to avoid a race
558 mutex_unlock(&cdma->lock);
564 if (!cdma->timeout.initialized) {
567 err = host1x_hw_cdma_timeout_init(host1x, cdma);
569 mutex_unlock(&cdma->lock);
575 if (!cdma->running)
576 host1x_hw_cdma_start(host1x, cdma);
578 cdma->slots_free = 0;
579 cdma->slots_used = 0;
580 cdma->first_get = cdma->push_buffer.pos;
590 void host1x_cdma_push(struct host1x_cdma *cdma, u32 op1, u32 op2)
592 struct push_buffer *pb = &cdma->push_buffer;
593 u32 slots_free = cdma->slots_free;
596 trace_host1x_cdma_push(dev_name(cdma_to_channel(cdma)->dev),
600 slots_free = host1x_cdma_wait_locked(cdma,
603 cdma->slots_free = slots_free - 1;
604 cdma->slots_used++;
617 void host1x_cdma_push_wide(struct host1x_cdma *cdma, u32 op1, u32 op2,
620 struct host1x_channel *channel = cdma_to_channel(cdma);
621 struct host1x *host1x = cdma_to_host1x(cdma);
622 struct push_buffer *pb = &cdma->push_buffer;
635 host1x_cdma_wait_pushbuffer_space(host1x, cdma, needed);
638 cdma->slots_free = space - needed;
639 cdma->slots_used += needed;
655 * End a cdma submit
660 void host1x_cdma_end(struct host1x_cdma *cdma,
663 struct host1x *host1x = cdma_to_host1x(cdma);
664 bool idle = list_empty(&cdma->sync_queue);
666 host1x_hw_cdma_flush(host1x, cdma);
668 job->first_get = cdma->first_get;
669 job->num_slots = cdma->slots_used;
671 list_add_tail(&job->list, &cdma->sync_queue);
675 cdma_start_timer_locked(cdma, job);
678 mutex_unlock(&cdma->lock);
682 * Update cdma state according to current sync point values
684 void host1x_cdma_update(struct host1x_cdma *cdma)
686 schedule_work(&cdma->update_work);