Commit a6c5e2ae authored by Chris Wilson's avatar Chris Wilson

drm/i915: Skip over MI_NOOP when parsing

Though less likely in practice, igt uses MI_NOOP frequently to pad out
its batch buffers. The lookup and valiation of so many MI_NOOP command
descriptions is noticeable, though the side-effect of poisoning the
last-validated-command cache is more likely to impact upon real CS.

Testcase: igt/gen9_exec_parse/bb-large
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201001102632.18789-1-chris@chris-wilson.co.uk
parent b0573472
...@@ -1452,43 +1452,42 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, ...@@ -1452,43 +1452,42 @@ 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);
do { while (*cmd != MI_BATCH_BUFFER_END) {
u32 length; u32 length = 1;
if (*cmd == MI_BATCH_BUFFER_END) if (*cmd != MI_NOOP) { /* MI_NOOP == 0 */
break; desc = find_cmd(engine, *cmd, desc, &default_desc);
if (!desc) {
desc = find_cmd(engine, *cmd, desc, &default_desc); DRM_DEBUG("CMD: Unrecognized command: 0x%08X\n", *cmd);
if (!desc) { ret = -EINVAL;
DRM_DEBUG("CMD: Unrecognized command: 0x%08X\n", *cmd); break;
ret = -EINVAL; }
break;
}
if (desc->flags & CMD_DESC_FIXED) if (desc->flags & CMD_DESC_FIXED)
length = desc->length.fixed; length = desc->length.fixed;
else else
length = (*cmd & desc->length.mask) + LENGTH_BIAS; length = (*cmd & desc->length.mask) + LENGTH_BIAS;
if ((batch_end - cmd) < length) { if ((batch_end - cmd) < length) {
DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n", DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n",
*cmd, *cmd,
length, length,
batch_end - cmd); batch_end - cmd);
ret = -EINVAL; ret = -EINVAL;
break; break;
} }
if (!check_cmd(engine, desc, cmd, length)) { if (!check_cmd(engine, desc, cmd, length)) {
ret = -EACCES; ret = -EACCES;
break; break;
} }
if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) { if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) {
ret = check_bbstart(cmd, offset, length, batch_length, ret = check_bbstart(cmd, offset, length, batch_length,
batch_addr, shadow_addr, batch_addr, shadow_addr,
jump_whitelist); jump_whitelist);
break; break;
}
} }
if (!IS_ERR_OR_NULL(jump_whitelist)) if (!IS_ERR_OR_NULL(jump_whitelist))
...@@ -1501,7 +1500,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine, ...@@ -1501,7 +1500,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