|
16 | 16 | #include "instructions/xe_mi_commands.h" |
17 | 17 | #include "regs/xe_engine_regs.h" |
18 | 18 | #include "regs/xe_gt_regs.h" |
19 | | -#include "regs/xe_lrc_layout.h" |
20 | 19 | #include "regs/xe_oa_regs.h" |
21 | 20 | #include "xe_assert.h" |
22 | 21 | #include "xe_bb.h" |
|
28 | 27 | #include "xe_gt_mcr.h" |
29 | 28 | #include "xe_gt_printk.h" |
30 | 29 | #include "xe_guc_pc.h" |
31 | | -#include "xe_lrc.h" |
32 | 30 | #include "xe_macros.h" |
33 | 31 | #include "xe_mmio.h" |
34 | 32 | #include "xe_oa.h" |
@@ -1673,81 +1671,6 @@ static const struct file_operations xe_oa_fops = { |
1673 | 1671 | .mmap = xe_oa_mmap, |
1674 | 1672 | }; |
1675 | 1673 |
|
1676 | | -static bool engine_supports_mi_query(struct xe_hw_engine *hwe) |
1677 | | -{ |
1678 | | - return hwe->class == XE_ENGINE_CLASS_RENDER || |
1679 | | - hwe->class == XE_ENGINE_CLASS_COMPUTE; |
1680 | | -} |
1681 | | - |
1682 | | -static bool xe_oa_find_reg_in_lri(u32 *state, u32 reg, u32 *offset, u32 end) |
1683 | | -{ |
1684 | | - u32 idx = *offset; |
1685 | | - u32 len = min(MI_LRI_LEN(state[idx]) + idx, end); |
1686 | | - bool found = false; |
1687 | | - |
1688 | | - idx++; |
1689 | | - for (; idx < len; idx += 2) { |
1690 | | - if (state[idx] == reg) { |
1691 | | - found = true; |
1692 | | - break; |
1693 | | - } |
1694 | | - } |
1695 | | - |
1696 | | - *offset = idx; |
1697 | | - return found; |
1698 | | -} |
1699 | | - |
1700 | | -#define IS_MI_LRI_CMD(x) (REG_FIELD_GET(MI_OPCODE, (x)) == \ |
1701 | | - REG_FIELD_GET(MI_OPCODE, MI_LOAD_REGISTER_IMM)) |
1702 | | - |
1703 | | -static u32 xe_oa_context_image_offset(struct xe_oa_stream *stream, u32 reg) |
1704 | | -{ |
1705 | | - struct xe_lrc *lrc = stream->exec_q->lrc[0]; |
1706 | | - u32 len = (xe_gt_lrc_size(stream->gt, stream->hwe->class) + |
1707 | | - lrc->ring.size) / sizeof(u32); |
1708 | | - u32 offset = xe_lrc_regs_offset(lrc) / sizeof(u32); |
1709 | | - u32 *state = (u32 *)lrc->bo->vmap.vaddr; |
1710 | | - |
1711 | | - if (drm_WARN_ON(&stream->oa->xe->drm, !state)) |
1712 | | - return U32_MAX; |
1713 | | - |
1714 | | - for (; offset < len; ) { |
1715 | | - if (IS_MI_LRI_CMD(state[offset])) { |
1716 | | - /* |
1717 | | - * We expect reg-value pairs in MI_LRI command, so |
1718 | | - * MI_LRI_LEN() should be even |
1719 | | - */ |
1720 | | - drm_WARN_ON(&stream->oa->xe->drm, |
1721 | | - MI_LRI_LEN(state[offset]) & 0x1); |
1722 | | - |
1723 | | - if (xe_oa_find_reg_in_lri(state, reg, &offset, len)) |
1724 | | - break; |
1725 | | - } else { |
1726 | | - offset++; |
1727 | | - } |
1728 | | - } |
1729 | | - |
1730 | | - return offset < len ? offset : U32_MAX; |
1731 | | -} |
1732 | | - |
1733 | | -static int xe_oa_set_ctx_ctrl_offset(struct xe_oa_stream *stream) |
1734 | | -{ |
1735 | | - struct xe_reg reg = OACTXCONTROL(stream->hwe->mmio_base); |
1736 | | - u32 offset = stream->oa->ctx_oactxctrl_offset[stream->hwe->class]; |
1737 | | - |
1738 | | - /* Do this only once. Failure is stored as offset of U32_MAX */ |
1739 | | - if (offset) |
1740 | | - goto exit; |
1741 | | - |
1742 | | - offset = xe_oa_context_image_offset(stream, reg.addr); |
1743 | | - stream->oa->ctx_oactxctrl_offset[stream->hwe->class] = offset; |
1744 | | - |
1745 | | - drm_dbg(&stream->oa->xe->drm, "%s oa ctx control at 0x%08x dword offset\n", |
1746 | | - stream->hwe->name, offset); |
1747 | | -exit: |
1748 | | - return offset && offset != U32_MAX ? 0 : -ENODEV; |
1749 | | -} |
1750 | | - |
1751 | 1674 | static int xe_oa_stream_init(struct xe_oa_stream *stream, |
1752 | 1675 | struct xe_oa_open_param *param) |
1753 | 1676 | { |
@@ -1785,17 +1708,6 @@ static int xe_oa_stream_init(struct xe_oa_stream *stream, |
1785 | 1708 | else |
1786 | 1709 | stream->oa_buffer.circ_size = param->oa_buffer_size; |
1787 | 1710 |
|
1788 | | - if (stream->exec_q && engine_supports_mi_query(stream->hwe)) { |
1789 | | - /* If we don't find the context offset, just return error */ |
1790 | | - ret = xe_oa_set_ctx_ctrl_offset(stream); |
1791 | | - if (ret) { |
1792 | | - drm_err(&stream->oa->xe->drm, |
1793 | | - "xe_oa_set_ctx_ctrl_offset failed for %s\n", |
1794 | | - stream->hwe->name); |
1795 | | - goto exit; |
1796 | | - } |
1797 | | - } |
1798 | | - |
1799 | 1711 | stream->oa_config = xe_oa_get_oa_config(stream->oa, param->metric_set); |
1800 | 1712 | if (!stream->oa_config) { |
1801 | 1713 | drm_dbg(&stream->oa->xe->drm, "Invalid OA config id=%i\n", param->metric_set); |
|
0 commit comments