Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xe/oa: Drop the unused logic to parse context image

Now that all register configurations are using MI_LOAD_REGISTER_IMM,
drop the logic to parse context image for offset.

v2: Remove unused lrc headers (Ashutosh)

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241220171919.571528-3-umesh.nerlige.ramappa@intel.com

authored by

Umesh Nerlige Ramappa and committed by
Ashutosh Dixit
fba0f039 55039832

-91
-88
drivers/gpu/drm/xe/xe_oa.c
··· 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" ··· 27 28 #include "xe_gt_mcr.h" 28 29 #include "xe_gt_printk.h" 29 30 #include "xe_guc_pc.h" 30 - #include "xe_lrc.h" 31 31 #include "xe_macros.h" 32 32 #include "xe_mmio.h" 33 33 #include "xe_oa.h" ··· 1671 1673 .mmap = xe_oa_mmap, 1672 1674 }; 1673 1675 1674 - static bool engine_supports_mi_query(struct xe_hw_engine *hwe) 1675 - { 1676 - return hwe->class == XE_ENGINE_CLASS_RENDER || 1677 - hwe->class == XE_ENGINE_CLASS_COMPUTE; 1678 - } 1679 - 1680 - static bool xe_oa_find_reg_in_lri(u32 *state, u32 reg, u32 *offset, u32 end) 1681 - { 1682 - u32 idx = *offset; 1683 - u32 len = min(MI_LRI_LEN(state[idx]) + idx, end); 1684 - bool found = false; 1685 - 1686 - idx++; 1687 - for (; idx < len; idx += 2) { 1688 - if (state[idx] == reg) { 1689 - found = true; 1690 - break; 1691 - } 1692 - } 1693 - 1694 - *offset = idx; 1695 - return found; 1696 - } 1697 - 1698 - #define IS_MI_LRI_CMD(x) (REG_FIELD_GET(MI_OPCODE, (x)) == \ 1699 - REG_FIELD_GET(MI_OPCODE, MI_LOAD_REGISTER_IMM)) 1700 - 1701 - static u32 xe_oa_context_image_offset(struct xe_oa_stream *stream, u32 reg) 1702 - { 1703 - struct xe_lrc *lrc = stream->exec_q->lrc[0]; 1704 - u32 len = (xe_gt_lrc_size(stream->gt, stream->hwe->class) + 1705 - lrc->ring.size) / sizeof(u32); 1706 - u32 offset = xe_lrc_regs_offset(lrc) / sizeof(u32); 1707 - u32 *state = (u32 *)lrc->bo->vmap.vaddr; 1708 - 1709 - if (drm_WARN_ON(&stream->oa->xe->drm, !state)) 1710 - return U32_MAX; 1711 - 1712 - for (; offset < len; ) { 1713 - if (IS_MI_LRI_CMD(state[offset])) { 1714 - /* 1715 - * We expect reg-value pairs in MI_LRI command, so 1716 - * MI_LRI_LEN() should be even 1717 - */ 1718 - drm_WARN_ON(&stream->oa->xe->drm, 1719 - MI_LRI_LEN(state[offset]) & 0x1); 1720 - 1721 - if (xe_oa_find_reg_in_lri(state, reg, &offset, len)) 1722 - break; 1723 - } else { 1724 - offset++; 1725 - } 1726 - } 1727 - 1728 - return offset < len ? offset : U32_MAX; 1729 - } 1730 - 1731 - static int xe_oa_set_ctx_ctrl_offset(struct xe_oa_stream *stream) 1732 - { 1733 - struct xe_reg reg = OACTXCONTROL(stream->hwe->mmio_base); 1734 - u32 offset = stream->oa->ctx_oactxctrl_offset[stream->hwe->class]; 1735 - 1736 - /* Do this only once. Failure is stored as offset of U32_MAX */ 1737 - if (offset) 1738 - goto exit; 1739 - 1740 - offset = xe_oa_context_image_offset(stream, reg.addr); 1741 - stream->oa->ctx_oactxctrl_offset[stream->hwe->class] = offset; 1742 - 1743 - drm_dbg(&stream->oa->xe->drm, "%s oa ctx control at 0x%08x dword offset\n", 1744 - stream->hwe->name, offset); 1745 - exit: 1746 - return offset && offset != U32_MAX ? 0 : -ENODEV; 1747 - } 1748 - 1749 1676 static int xe_oa_stream_init(struct xe_oa_stream *stream, 1750 1677 struct xe_oa_open_param *param) 1751 1678 { ··· 1707 1784 param->oa_buffer_size % stream->oa_buffer.format->size; 1708 1785 else 1709 1786 stream->oa_buffer.circ_size = param->oa_buffer_size; 1710 - 1711 - if (stream->exec_q && engine_supports_mi_query(stream->hwe)) { 1712 - /* If we don't find the context offset, just return error */ 1713 - ret = xe_oa_set_ctx_ctrl_offset(stream); 1714 - if (ret) { 1715 - drm_err(&stream->oa->xe->drm, 1716 - "xe_oa_set_ctx_ctrl_offset failed for %s\n", 1717 - stream->hwe->name); 1718 - goto exit; 1719 - } 1720 - } 1721 1787 1722 1788 stream->oa_config = xe_oa_get_oa_config(stream->oa, param->metric_set); 1723 1789 if (!stream->oa_config) {
-3
drivers/gpu/drm/xe/xe_oa_types.h
··· 138 138 /** @metrics_idr: List of dynamic configurations (struct xe_oa_config) */ 139 139 struct idr metrics_idr; 140 140 141 - /** @ctx_oactxctrl_offset: offset of OACTXCONTROL register in context image */ 142 - u32 ctx_oactxctrl_offset[XE_ENGINE_CLASS_MAX]; 143 - 144 141 /** @oa_formats: tracks all OA formats across platforms */ 145 142 const struct xe_oa_format *oa_formats; 146 143