]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Revert "drm/i915: Skip over MI_NOOP when parsing"
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 14 Jul 2021 19:34:19 +0000 (14:34 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 16 Jul 2021 19:48:02 +0000 (21:48 +0200)
This reverts a67a096e9137 ("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: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jon Bloomfield <jon.bloomfield@intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714193419.1459723-6-jason@jlekstrand.net
drivers/gpu/drm/i915/i915_cmd_parser.c

index 00ec618d0159004dd474dfccb3b7f59ca845d289..322f4d5955a4ffe2dcc81288c7d8477a1b5a3f96 100644 (file)
@@ -1470,42 +1470,43 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
         * space. Parsing should be faster in some cases this way.
         */
        batch_end = cmd + batch_length / sizeof(*batch_end);
-       while (*cmd != MI_BATCH_BUFFER_END) {
-               u32 length = 1;
-
-               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;
-                       }
+       do {
+               u32 length;
 
-                       if (desc->flags & CMD_DESC_FIXED)
-                               length = desc->length.fixed;
-                       else
-                               length = (*cmd & desc->length.mask) + LENGTH_BIAS;
+               if (*cmd == MI_BATCH_BUFFER_END)
+                       break;
 
-                       if ((batch_end - cmd) < length) {
-                               DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n",
-                                         *cmd,
-                                         length,
-                                         batch_end - cmd);
-                               ret = -EINVAL;
-                               break;
-                       }
+               desc = find_cmd(engine, *cmd, desc, &default_desc);
+               if (!desc) {
+                       DRM_DEBUG("CMD: Unrecognized command: 0x%08X\n", *cmd);
+                       ret = -EINVAL;
+                       break;
+               }
 
-                       if (!check_cmd(engine, desc, cmd, length)) {
-                               ret = -EACCES;
-                               break;
-                       }
+               if (desc->flags & CMD_DESC_FIXED)
+                       length = desc->length.fixed;
+               else
+                       length = (*cmd & desc->length.mask) + LENGTH_BIAS;
 
-                       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 ((batch_end - cmd) < length) {
+                       DRM_DEBUG("CMD: Command length exceeds batch length: 0x%08X length=%u batchlen=%td\n",
+                                 *cmd,
+                                 length,
+                                 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))
@@ -1518,7 +1519,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
                        ret = -EINVAL;
                        break;
                }
-       }
+       } while (1);
 
        if (trampoline) {
                /*