• Home
  • Raw
  • Download

Lines Matching refs:ring

116 	int (*push_tail)(struct k3_nav_ring *ring, void *elm);
117 int (*push_head)(struct k3_nav_ring *ring, void *elm);
118 int (*pop_tail)(struct k3_nav_ring *ring, void *elm);
119 int (*pop_head)(struct k3_nav_ring *ring, void *elm);
202 static long k3_nav_ringacc_ring_get_fifo_pos(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_get_fifo_pos() argument
205 (4 << ring->elm_size); in k3_nav_ringacc_ring_get_fifo_pos()
208 static void *k3_nav_ringacc_get_elm_addr(struct k3_nav_ring *ring, u32 idx) in k3_nav_ringacc_get_elm_addr() argument
210 return (idx * (4 << ring->elm_size) + ring->ring_mem_virt); in k3_nav_ringacc_get_elm_addr()
213 static int k3_nav_ringacc_ring_push_mem(struct k3_nav_ring *ring, void *elem);
214 static int k3_nav_ringacc_ring_pop_mem(struct k3_nav_ring *ring, void *elem);
221 static int k3_nav_ringacc_ring_push_io(struct k3_nav_ring *ring, void *elem);
222 static int k3_nav_ringacc_ring_pop_io(struct k3_nav_ring *ring, void *elem);
223 static int k3_nav_ringacc_ring_push_head_io(struct k3_nav_ring *ring,
225 static int k3_nav_ringacc_ring_pop_tail_io(struct k3_nav_ring *ring,
235 static int k3_ringacc_ring_push_head_proxy(struct k3_nav_ring *ring,
237 static int k3_ringacc_ring_push_tail_proxy(struct k3_nav_ring *ring,
239 static int k3_ringacc_ring_pop_head_proxy(struct k3_nav_ring *ring, void *elem);
240 static int k3_ringacc_ring_pop_tail_proxy(struct k3_nav_ring *ring, void *elem);
308 static void k3_ringacc_ring_reset_sci(struct k3_nav_ring *ring) in k3_ringacc_ring_reset_sci() argument
310 struct k3_nav_ringacc *ringacc = ring->parent; in k3_ringacc_ring_reset_sci()
317 ring->ring_id, in k3_ringacc_ring_reset_sci()
320 ring->size, in k3_ringacc_ring_reset_sci()
326 ret, ring->ring_id); in k3_ringacc_ring_reset_sci()
329 void k3_nav_ringacc_ring_reset(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_reset() argument
331 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_reset()
334 ring->occ = 0; in k3_nav_ringacc_ring_reset()
335 ring->free = 0; in k3_nav_ringacc_ring_reset()
336 ring->rindex = 0; in k3_nav_ringacc_ring_reset()
337 ring->windex = 0; in k3_nav_ringacc_ring_reset()
339 k3_ringacc_ring_reset_sci(ring); in k3_nav_ringacc_ring_reset()
342 static void k3_ringacc_ring_reconfig_qmode_sci(struct k3_nav_ring *ring, in k3_ringacc_ring_reconfig_qmode_sci() argument
345 struct k3_nav_ringacc *ringacc = ring->parent; in k3_ringacc_ring_reconfig_qmode_sci()
352 ring->ring_id, in k3_ringacc_ring_reconfig_qmode_sci()
361 ret, ring->ring_id); in k3_ringacc_ring_reconfig_qmode_sci()
364 void k3_nav_ringacc_ring_reset_dma(struct k3_nav_ring *ring, u32 occ) in k3_nav_ringacc_ring_reset_dma() argument
366 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_reset_dma()
369 if (!ring->parent->dma_ring_reset_quirk) { in k3_nav_ringacc_ring_reset_dma()
370 k3_nav_ringacc_ring_reset(ring); in k3_nav_ringacc_ring_reset_dma()
375 occ = ringacc_readl(&ring->rt->occ); in k3_nav_ringacc_ring_reset_dma()
381 ring->ring_id, occ); in k3_nav_ringacc_ring_reset_dma()
383 k3_ringacc_ring_reset_sci(ring); in k3_nav_ringacc_ring_reset_dma()
389 if (ring->mode != K3_NAV_RINGACC_RING_MODE_RING) in k3_nav_ringacc_ring_reset_dma()
391 ring, K3_NAV_RINGACC_RING_MODE_RING); in k3_nav_ringacc_ring_reset_dma()
410 writel(db_ring_cnt_cur, &ring->rt->db); in k3_nav_ringacc_ring_reset_dma()
415 if (ring->mode != K3_NAV_RINGACC_RING_MODE_RING) in k3_nav_ringacc_ring_reset_dma()
416 k3_ringacc_ring_reconfig_qmode_sci(ring, ring->mode); in k3_nav_ringacc_ring_reset_dma()
420 k3_nav_ringacc_ring_reset(ring); in k3_nav_ringacc_ring_reset_dma()
423 static void k3_ringacc_ring_free_sci(struct k3_nav_ring *ring) in k3_ringacc_ring_free_sci() argument
425 struct k3_nav_ringacc *ringacc = ring->parent; in k3_ringacc_ring_free_sci()
432 ring->ring_id, in k3_ringacc_ring_free_sci()
441 ret, ring->ring_id); in k3_ringacc_ring_free_sci()
444 int k3_nav_ringacc_ring_free(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_free() argument
448 if (!ring) in k3_nav_ringacc_ring_free()
451 ringacc = ring->parent; in k3_nav_ringacc_ring_free()
453 pr_debug("%s flags: 0x%08x\n", __func__, ring->flags); in k3_nav_ringacc_ring_free()
455 if (!test_bit(ring->ring_id, ringacc->rings_inuse)) in k3_nav_ringacc_ring_free()
458 if (--ring->use_count) in k3_nav_ringacc_ring_free()
461 if (!(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_free()
464 k3_ringacc_ring_free_sci(ring); in k3_nav_ringacc_ring_free()
467 ring->size * (4 << ring->elm_size), in k3_nav_ringacc_ring_free()
468 ring->ring_mem_virt, ring->ring_mem_dma); in k3_nav_ringacc_ring_free()
469 ring->flags &= ~KNAV_RING_FLAG_BUSY; in k3_nav_ringacc_ring_free()
470 ring->ops = NULL; in k3_nav_ringacc_ring_free()
471 if (ring->proxy_id != K3_RINGACC_PROXY_NOT_USED) { in k3_nav_ringacc_ring_free()
472 clear_bit(ring->proxy_id, ringacc->proxy_inuse); in k3_nav_ringacc_ring_free()
473 ring->proxy = NULL; in k3_nav_ringacc_ring_free()
474 ring->proxy_id = K3_RINGACC_PROXY_NOT_USED; in k3_nav_ringacc_ring_free()
478 clear_bit(ring->ring_id, ringacc->rings_inuse); in k3_nav_ringacc_ring_free()
486 u32 k3_nav_ringacc_get_ring_id(struct k3_nav_ring *ring) in k3_nav_ringacc_get_ring_id() argument
488 if (!ring) in k3_nav_ringacc_get_ring_id()
491 return ring->ring_id; in k3_nav_ringacc_get_ring_id()
494 static int k3_nav_ringacc_ring_cfg_sci(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_cfg_sci() argument
496 struct k3_nav_ringacc *ringacc = ring->parent; in k3_nav_ringacc_ring_cfg_sci()
503 ring_idx = ring->ring_id; in k3_nav_ringacc_ring_cfg_sci()
509 lower_32_bits(ring->ring_mem_dma), in k3_nav_ringacc_ring_cfg_sci()
510 upper_32_bits(ring->ring_mem_dma), in k3_nav_ringacc_ring_cfg_sci()
511 ring->size, in k3_nav_ringacc_ring_cfg_sci()
512 ring->mode, in k3_nav_ringacc_ring_cfg_sci()
513 ring->elm_size, in k3_nav_ringacc_ring_cfg_sci()
522 int k3_nav_ringacc_ring_cfg(struct k3_nav_ring *ring, in k3_nav_ringacc_ring_cfg() argument
525 struct k3_nav_ringacc *ringacc = ring->parent; in k3_nav_ringacc_ring_cfg()
528 if (!ring || !cfg) in k3_nav_ringacc_ring_cfg()
533 !test_bit(ring->ring_id, ringacc->rings_inuse)) in k3_nav_ringacc_ring_cfg()
536 if (ring->use_count != 1) in k3_nav_ringacc_ring_cfg()
539 ring->size = cfg->size; in k3_nav_ringacc_ring_cfg()
540 ring->elm_size = cfg->elm_size; in k3_nav_ringacc_ring_cfg()
541 ring->mode = cfg->mode; in k3_nav_ringacc_ring_cfg()
542 ring->occ = 0; in k3_nav_ringacc_ring_cfg()
543 ring->free = 0; in k3_nav_ringacc_ring_cfg()
544 ring->rindex = 0; in k3_nav_ringacc_ring_cfg()
545 ring->windex = 0; in k3_nav_ringacc_ring_cfg()
547 if (ring->proxy_id != K3_RINGACC_PROXY_NOT_USED) in k3_nav_ringacc_ring_cfg()
548 ring->proxy = ringacc->proxy_target_base + in k3_nav_ringacc_ring_cfg()
549 ring->proxy_id * K3_RINGACC_PROXY_TARGET_STEP; in k3_nav_ringacc_ring_cfg()
551 switch (ring->mode) { in k3_nav_ringacc_ring_cfg()
553 ring->ops = &k3_nav_mode_ring_ops; in k3_nav_ringacc_ring_cfg()
564 if (ring->proxy) in k3_nav_ringacc_ring_cfg()
565 ring->ops = &k3_nav_mode_proxy_ops; in k3_nav_ringacc_ring_cfg()
567 ring->ops = &k3_nav_mode_msg_ops; in k3_nav_ringacc_ring_cfg()
570 ring->ops = NULL; in k3_nav_ringacc_ring_cfg()
575 ring->ring_mem_virt = in k3_nav_ringacc_ring_cfg()
577 ring->size * (4 << ring->elm_size), in k3_nav_ringacc_ring_cfg()
578 &ring->ring_mem_dma, GFP_KERNEL); in k3_nav_ringacc_ring_cfg()
579 if (!ring->ring_mem_virt) { in k3_nav_ringacc_ring_cfg()
585 ret = k3_nav_ringacc_ring_cfg_sci(ring); in k3_nav_ringacc_ring_cfg()
590 ring->flags |= KNAV_RING_FLAG_BUSY; in k3_nav_ringacc_ring_cfg()
591 ring->flags |= (cfg->flags & K3_NAV_RINGACC_RING_SHARED) ? in k3_nav_ringacc_ring_cfg()
598 ring->size * (4 << ring->elm_size), in k3_nav_ringacc_ring_cfg()
599 ring->ring_mem_virt, in k3_nav_ringacc_ring_cfg()
600 ring->ring_mem_dma); in k3_nav_ringacc_ring_cfg()
602 ring->ops = NULL; in k3_nav_ringacc_ring_cfg()
604 ring->proxy = NULL; in k3_nav_ringacc_ring_cfg()
608 u32 k3_nav_ringacc_ring_get_size(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_get_size() argument
610 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_get_size()
613 return ring->size; in k3_nav_ringacc_ring_get_size()
616 u32 k3_nav_ringacc_ring_get_free(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_get_free() argument
618 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_get_free()
621 if (!ring->free) in k3_nav_ringacc_ring_get_free()
622 ring->free = ring->size - ringacc_readl(&ring->rt->occ); in k3_nav_ringacc_ring_get_free()
624 return ring->free; in k3_nav_ringacc_ring_get_free()
627 u32 k3_nav_ringacc_ring_get_occ(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_get_occ() argument
629 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_get_occ()
632 return ringacc_readl(&ring->rt->occ); in k3_nav_ringacc_ring_get_occ()
635 u32 k3_nav_ringacc_ring_is_full(struct k3_nav_ring *ring) in k3_nav_ringacc_ring_is_full() argument
637 return !k3_nav_ringacc_ring_get_free(ring); in k3_nav_ringacc_ring_is_full()
649 static int k3_ringacc_ring_cfg_proxy(struct k3_nav_ring *ring, in k3_ringacc_ring_cfg_proxy() argument
654 val = ring->ring_id; in k3_ringacc_ring_cfg_proxy()
656 val |= ring->elm_size << 24; in k3_ringacc_ring_cfg_proxy()
657 ringacc_writel(val, &ring->proxy->control); in k3_ringacc_ring_cfg_proxy()
662 struct k3_nav_ring *ring, void *elem, in k3_nav_ringacc_ring_access_proxy() argument
667 ptr = (void __iomem *)&ring->proxy->data; in k3_nav_ringacc_ring_access_proxy()
672 k3_ringacc_ring_cfg_proxy(ring, PROXY_ACCESS_MODE_HEAD); in k3_nav_ringacc_ring_access_proxy()
676 k3_ringacc_ring_cfg_proxy(ring, PROXY_ACCESS_MODE_TAIL); in k3_nav_ringacc_ring_access_proxy()
682 ptr += k3_nav_ringacc_ring_get_fifo_pos(ring); in k3_nav_ringacc_ring_access_proxy()
689 memcpy_fromio(elem, ptr, (4 << ring->elm_size)); in k3_nav_ringacc_ring_access_proxy()
690 ring->occ--; in k3_nav_ringacc_ring_access_proxy()
696 memcpy_toio(ptr, elem, (4 << ring->elm_size)); in k3_nav_ringacc_ring_access_proxy()
697 ring->free--; in k3_nav_ringacc_ring_access_proxy()
704 ring->free, ring->occ); in k3_nav_ringacc_ring_access_proxy()
708 static int k3_ringacc_ring_push_head_proxy(struct k3_nav_ring *ring, void *elem) in k3_ringacc_ring_push_head_proxy() argument
711 ring, elem, K3_RINGACC_ACCESS_MODE_PUSH_HEAD); in k3_ringacc_ring_push_head_proxy()
714 static int k3_ringacc_ring_push_tail_proxy(struct k3_nav_ring *ring, void *elem) in k3_ringacc_ring_push_tail_proxy() argument
717 ring, elem, K3_RINGACC_ACCESS_MODE_PUSH_TAIL); in k3_ringacc_ring_push_tail_proxy()
720 static int k3_ringacc_ring_pop_head_proxy(struct k3_nav_ring *ring, void *elem) in k3_ringacc_ring_pop_head_proxy() argument
723 ring, elem, K3_RINGACC_ACCESS_MODE_POP_HEAD); in k3_ringacc_ring_pop_head_proxy()
726 static int k3_ringacc_ring_pop_tail_proxy(struct k3_nav_ring *ring, void *elem) in k3_ringacc_ring_pop_tail_proxy() argument
729 ring, elem, K3_RINGACC_ACCESS_MODE_POP_HEAD); in k3_ringacc_ring_pop_tail_proxy()
733 struct k3_nav_ring *ring, void *elem, in k3_nav_ringacc_ring_access_io() argument
741 ptr = (void __iomem *)&ring->fifos->head_data; in k3_nav_ringacc_ring_access_io()
745 ptr = (void __iomem *)&ring->fifos->tail_data; in k3_nav_ringacc_ring_access_io()
751 ptr += k3_nav_ringacc_ring_get_fifo_pos(ring); in k3_nav_ringacc_ring_access_io()
758 memcpy_fromio(elem, ptr, (4 << ring->elm_size)); in k3_nav_ringacc_ring_access_io()
759 ring->occ--; in k3_nav_ringacc_ring_access_io()
765 memcpy_toio(ptr, elem, (4 << ring->elm_size)); in k3_nav_ringacc_ring_access_io()
766 ring->free--; in k3_nav_ringacc_ring_access_io()
773 ring->free, ring->windex, ring->occ, ring->rindex); in k3_nav_ringacc_ring_access_io()
777 static int k3_nav_ringacc_ring_push_head_io(struct k3_nav_ring *ring, in k3_nav_ringacc_ring_push_head_io() argument
781 ring, elem, K3_RINGACC_ACCESS_MODE_PUSH_HEAD); in k3_nav_ringacc_ring_push_head_io()
784 static int k3_nav_ringacc_ring_push_io(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_push_io() argument
787 ring, elem, K3_RINGACC_ACCESS_MODE_PUSH_TAIL); in k3_nav_ringacc_ring_push_io()
790 static int k3_nav_ringacc_ring_pop_io(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_pop_io() argument
793 ring, elem, K3_RINGACC_ACCESS_MODE_POP_HEAD); in k3_nav_ringacc_ring_pop_io()
796 static int k3_nav_ringacc_ring_pop_tail_io(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_pop_tail_io() argument
799 ring, elem, K3_RINGACC_ACCESS_MODE_POP_HEAD); in k3_nav_ringacc_ring_pop_tail_io()
802 static int k3_nav_ringacc_ring_push_mem(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_push_mem() argument
806 elem_ptr = k3_nav_ringacc_get_elm_addr(ring, ring->windex); in k3_nav_ringacc_ring_push_mem()
808 memcpy(elem_ptr, elem, (4 << ring->elm_size)); in k3_nav_ringacc_ring_push_mem()
810 ring->windex = (ring->windex + 1) % ring->size; in k3_nav_ringacc_ring_push_mem()
811 ring->free--; in k3_nav_ringacc_ring_push_mem()
812 ringacc_writel(1, &ring->rt->db); in k3_nav_ringacc_ring_push_mem()
815 ring->free, ring->windex); in k3_nav_ringacc_ring_push_mem()
820 static int k3_nav_ringacc_ring_pop_mem(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_pop_mem() argument
824 elem_ptr = k3_nav_ringacc_get_elm_addr(ring, ring->rindex); in k3_nav_ringacc_ring_pop_mem()
826 memcpy(elem, elem_ptr, (4 << ring->elm_size)); in k3_nav_ringacc_ring_pop_mem()
828 ring->rindex = (ring->rindex + 1) % ring->size; in k3_nav_ringacc_ring_pop_mem()
829 ring->occ--; in k3_nav_ringacc_ring_pop_mem()
830 ringacc_writel(-1, &ring->rt->db); in k3_nav_ringacc_ring_pop_mem()
833 ring->occ, ring->rindex, elem_ptr); in k3_nav_ringacc_ring_pop_mem()
837 int k3_nav_ringacc_ring_push(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_push() argument
841 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_push()
845 ring->ring_id, ring->free, ring->windex); in k3_nav_ringacc_ring_push()
847 if (k3_nav_ringacc_ring_is_full(ring)) in k3_nav_ringacc_ring_push()
850 if (ring->ops && ring->ops->push_tail) in k3_nav_ringacc_ring_push()
851 ret = ring->ops->push_tail(ring, elem); in k3_nav_ringacc_ring_push()
856 int k3_nav_ringacc_ring_push_head(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_push_head() argument
860 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_push_head()
864 ring->free, ring->windex); in k3_nav_ringacc_ring_push_head()
866 if (k3_nav_ringacc_ring_is_full(ring)) in k3_nav_ringacc_ring_push_head()
869 if (ring->ops && ring->ops->push_head) in k3_nav_ringacc_ring_push_head()
870 ret = ring->ops->push_head(ring, elem); in k3_nav_ringacc_ring_push_head()
875 int k3_nav_ringacc_ring_pop(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_pop() argument
879 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_pop()
882 if (!ring->occ) in k3_nav_ringacc_ring_pop()
883 ring->occ = k3_nav_ringacc_ring_get_occ(ring); in k3_nav_ringacc_ring_pop()
886 ring->ring_id, ring->occ, ring->rindex); in k3_nav_ringacc_ring_pop()
888 if (!ring->occ) in k3_nav_ringacc_ring_pop()
891 if (ring->ops && ring->ops->pop_head) in k3_nav_ringacc_ring_pop()
892 ret = ring->ops->pop_head(ring, elem); in k3_nav_ringacc_ring_pop()
897 int k3_nav_ringacc_ring_pop_tail(struct k3_nav_ring *ring, void *elem) in k3_nav_ringacc_ring_pop_tail() argument
901 if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) in k3_nav_ringacc_ring_pop_tail()
904 if (!ring->occ) in k3_nav_ringacc_ring_pop_tail()
905 ring->occ = k3_nav_ringacc_ring_get_occ(ring); in k3_nav_ringacc_ring_pop_tail()
908 ring->occ, ring->rindex); in k3_nav_ringacc_ring_pop_tail()
910 if (!ring->occ) in k3_nav_ringacc_ring_pop_tail()
913 if (ring->ops && ring->ops->pop_tail) in k3_nav_ringacc_ring_pop_tail()
914 ret = ring->ops->pop_tail(ring, elem); in k3_nav_ringacc_ring_pop_tail()