Commit 0c6609bb authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Daniel Vetter

Revert "drm/i915: Skip over MI_NOOP when parsing"

This reverts a6c5e2ae ("drm/i915: Skip over MI_NOOP when parsing").
It complicates the batch parsing code a bit and increases indentation
for no reason other than fast-skipping a command that userspace uses
only rarely.  Sure, there may be IGT tests that fill batches with NOOPs
but that's not a case we should optimize for in the kernel.  We should
optimize for code clarity instead.
Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
Reviewed-by: default avatarJon Bloomfield <jon.bloomfield@intel.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714193419.1459723-6-jason@jlekstrand.net
parent dc194184
...@@ -1470,42 +1470,43 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, ...@@ -1470,42 +1470,43 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
* space. Parsing should be faster in some cases this way. * space. Parsing should be faster in some cases this way.
*/ */
batch_end = cmd + batch_length / sizeof(*batch_end); batch_end = cmd + batch_length / sizeof(*batch_end);
while (*cmd != MI_BATCH_BUFFER_END) { do {
u32 length = 1; u32 length;
if (*cmd != MI_NOOP) { /* MI_NOOP == 0 */
desc = find_cmd(engine, *cmd, desc, &default_desc);
if (!desc) {
DRM_DEBUG("CMD: Unrecognized command: 0x%08X\n", *cmd);
ret = -EINVAL;
break;
}
if (desc->flags & CMD_DESC_FIXED) if (*cmd == MI_BATCH_BUFFER_END)
length = desc->length.fixed; break;
else
length = (*cmd & desc->length.mask) + LENGTH_BIAS;
if ((batch_end - cmd) < length) { desc = find_cmd(engine, *cmd, desc, &default_desc);
DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n", if (!desc) {
*cmd, DRM_DEBUG("CMD: Unrecognized command: 0x%08X\n", *cmd);
length, ret = -EINVAL;
batch_end - cmd); break;
ret = -EINVAL; }
break;
}
if (!check_cmd(engine, desc, cmd, length)) { if (desc->flags & CMD_DESC_FIXED)
ret = -EACCES; length = desc->length.fixed;
break; else
} length = (*cmd & desc->length.mask) + LENGTH_BIAS;
if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) { if ((batch_end - cmd) < length) {
ret = check_bbstart(cmd, offset, length, batch_length, DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n",
batch_addr, shadow_addr, *cmd,
jump_whitelist); length,
break; batch_end - cmd);
} ret = -EINVAL;
break;
}
if (!check_cmd(engine, desc, cmd, length)) {
ret = -EACCES;
break;
}
if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) {
ret = check_bbstart(cmd, offset, length, batch_length,
batch_addr, shadow_addr,
jump_whitelist);
break;
} }
if (!IS_ERR_OR_NULL(jump_whitelist)) if (!IS_ERR_OR_NULL(jump_whitelist))
...@@ -1518,7 +1519,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, ...@@ -1518,7 +1519,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
} } while (1);
if (trampoline) { if (trampoline) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment