Lines Matching refs:lrc

35 lrc_to_xe(struct xe_lrc *lrc)
37 return gt_to_xe(lrc->fence_ctx.gt);
574 static inline u32 __xe_lrc_ring_offset(struct xe_lrc *lrc)
579 u32 xe_lrc_pphwsp_offset(struct xe_lrc *lrc)
581 return lrc->ring.size;
605 static inline u32 __xe_lrc_seqno_offset(struct xe_lrc *lrc)
608 return xe_lrc_pphwsp_offset(lrc) + LRC_SEQNO_PPHWSP_OFFSET;
611 static inline u32 __xe_lrc_start_seqno_offset(struct xe_lrc *lrc)
614 return xe_lrc_pphwsp_offset(lrc) + LRC_START_SEQNO_PPHWSP_OFFSET;
617 static inline u32 __xe_lrc_parallel_offset(struct xe_lrc *lrc)
620 return xe_lrc_pphwsp_offset(lrc) + LRC_PARALLEL_PPHWSP_OFFSET;
623 static inline u32 __xe_lrc_regs_offset(struct xe_lrc *lrc)
625 return xe_lrc_pphwsp_offset(lrc) + LRC_PPHWSP_SIZE;
629 static inline struct iosys_map __xe_lrc_##elem##_map(struct xe_lrc *lrc) \
631 struct iosys_map map = lrc->bo->vmap; \
633 xe_assert(lrc_to_xe(lrc), !iosys_map_is_null(&map)); \
634 iosys_map_incr(&map, __xe_lrc_##elem##_offset(lrc)); \
637 static inline u32 __xe_lrc_##elem##_ggtt_addr(struct xe_lrc *lrc) \
639 return xe_bo_ggtt_addr(lrc->bo) + __xe_lrc_##elem##_offset(lrc); \
651 u32 xe_lrc_ggtt_addr(struct xe_lrc *lrc)
653 return __xe_lrc_pphwsp_ggtt_addr(lrc);
656 u32 xe_lrc_read_ctx_reg(struct xe_lrc *lrc, int reg_nr)
658 struct xe_device *xe = lrc_to_xe(lrc);
661 map = __xe_lrc_regs_map(lrc);
666 void xe_lrc_write_ctx_reg(struct xe_lrc *lrc, int reg_nr, u32 val)
668 struct xe_device *xe = lrc_to_xe(lrc);
671 map = __xe_lrc_regs_map(lrc);
696 static void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)
698 u64 desc = xe_vm_pdp4_descriptor(vm, lrc->tile);
700 xe_lrc_write_ctx_reg(lrc, CTX_PDP0_UDW, upper_32_bits(desc));
701 xe_lrc_write_ctx_reg(lrc, CTX_PDP0_LDW, lower_32_bits(desc));
707 int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
718 lrc->flags = 0;
724 lrc->bo = xe_bo_create_pin_map(xe, tile, vm,
729 if (IS_ERR(lrc->bo))
730 return PTR_ERR(lrc->bo);
732 lrc->tile = gt_to_tile(hwe->gt);
733 lrc->ring.size = ring_size;
734 lrc->ring.tail = 0;
736 xe_hw_fence_ctx_init(&lrc->fence_ctx, hwe->gt,
751 map = __xe_lrc_pphwsp_map(lrc);
764 xe_lrc_set_ppgtt(lrc, vm);
767 xe_drm_client_add_bo(vm->xef->client, lrc->bo);
770 xe_lrc_write_ctx_reg(lrc, CTX_RING_START, __xe_lrc_ring_ggtt_addr(lrc));
771 xe_lrc_write_ctx_reg(lrc, CTX_RING_HEAD, 0);
772 xe_lrc_write_ctx_reg(lrc, CTX_RING_TAIL, lrc->ring.tail);
773 xe_lrc_write_ctx_reg(lrc, CTX_RING_CTL,
774 RING_CTL_SIZE(lrc->ring.size) | RING_VALID);
776 xe_lrc_write_ctx_reg(lrc, PVC_CTX_ASID, vm->usm.asid);
778 lrc->desc = LRC_VALID;
779 lrc->desc |= LRC_LEGACY_64B_CONTEXT << LRC_ADDRESSING_MODE_SHIFT;
786 lrc->desc |= LRC_PRIVILEGE;
789 lrc->desc |= (u64)hwe->instance << ENGINE_INSTANCE_SHIFT;
790 lrc->desc |= (u64)hwe->class << ENGINE_CLASS_SHIFT;
794 xe_lrc_write_ring(lrc, &arb_enable, sizeof(arb_enable));
796 map = __xe_lrc_seqno_map(lrc);
797 xe_map_write32(lrc_to_xe(lrc), &map, lrc->fence_ctx.next_seqno - 1);
799 map = __xe_lrc_start_seqno_map(lrc);
800 xe_map_write32(lrc_to_xe(lrc), &map, lrc->fence_ctx.next_seqno - 1);
805 xe_lrc_finish(lrc);
809 void xe_lrc_finish(struct xe_lrc *lrc)
811 xe_hw_fence_ctx_finish(&lrc->fence_ctx);
812 xe_bo_lock(lrc->bo, false);
813 xe_bo_unpin(lrc->bo);
814 xe_bo_unlock(lrc->bo);
815 xe_bo_put(lrc->bo);
818 void xe_lrc_set_ring_head(struct xe_lrc *lrc, u32 head)
820 xe_lrc_write_ctx_reg(lrc, CTX_RING_HEAD, head);
823 u32 xe_lrc_ring_head(struct xe_lrc *lrc)
825 return xe_lrc_read_ctx_reg(lrc, CTX_RING_HEAD) & HEAD_ADDR;
828 u32 xe_lrc_ring_space(struct xe_lrc *lrc)
830 const u32 head = xe_lrc_ring_head(lrc);
831 const u32 tail = lrc->ring.tail;
832 const u32 size = lrc->ring.size;
837 static void __xe_lrc_write_ring(struct xe_lrc *lrc, struct iosys_map ring,
840 struct xe_device *xe = lrc_to_xe(lrc);
842 iosys_map_incr(&ring, lrc->ring.tail);
844 lrc->ring.tail = (lrc->ring.tail + size) & (lrc->ring.size - 1);
847 void xe_lrc_write_ring(struct xe_lrc *lrc, const void *data, size_t size)
849 struct xe_device *xe = lrc_to_xe(lrc);
857 ring = __xe_lrc_ring_map(lrc);
859 xe_assert(xe, lrc->ring.tail < lrc->ring.size);
860 rhs = lrc->ring.size - lrc->ring.tail;
862 __xe_lrc_write_ring(lrc, ring, data, rhs);
863 __xe_lrc_write_ring(lrc, ring, data + rhs, size - rhs);
865 __xe_lrc_write_ring(lrc, ring, data, size);
871 __xe_lrc_write_ring(lrc, ring, &noop, sizeof(noop));
875 u64 xe_lrc_descriptor(struct xe_lrc *lrc)
877 return lrc->desc | xe_lrc_ggtt_addr(lrc);
880 u32 xe_lrc_seqno_ggtt_addr(struct xe_lrc *lrc)
882 return __xe_lrc_seqno_ggtt_addr(lrc);
885 struct dma_fence *xe_lrc_create_seqno_fence(struct xe_lrc *lrc)
887 return &xe_hw_fence_create(&lrc->fence_ctx,
888 __xe_lrc_seqno_map(lrc))->dma;
891 s32 xe_lrc_seqno(struct xe_lrc *lrc)
893 struct iosys_map map = __xe_lrc_seqno_map(lrc);
895 return xe_map_read32(lrc_to_xe(lrc), &map);
898 s32 xe_lrc_start_seqno(struct xe_lrc *lrc)
900 struct iosys_map map = __xe_lrc_start_seqno_map(lrc);
902 return xe_map_read32(lrc_to_xe(lrc), &map);
905 u32 xe_lrc_start_seqno_ggtt_addr(struct xe_lrc *lrc)
907 return __xe_lrc_start_seqno_ggtt_addr(lrc);
910 u32 xe_lrc_parallel_ggtt_addr(struct xe_lrc *lrc)
912 return __xe_lrc_parallel_ggtt_addr(lrc);
915 struct iosys_map xe_lrc_parallel_map(struct xe_lrc *lrc)
917 return __xe_lrc_parallel_map(lrc);