freedreno: Add layout_resource_for_modifier screen vfunc
[mesa.git] / src / gallium / drivers / vc4 / kernel / vc4_validate.c
index 2b57ca0b4b0c5c397533d5e817c33a8bb5a918c9..bd193b993b321e460760e5da6a66ddd20d89e1a8 100644 (file)
@@ -47,7 +47,6 @@
        void *validated,                                \
        void *untrusted
 
-
 /** Return the width in pixels of a 64-byte microtile. */
 static uint32_t
 utile_width(int cpp)
@@ -94,42 +93,42 @@ size_is_lt(uint32_t width, uint32_t height, int cpp)
                height <= 4 * utile_height(cpp));
 }
 
-static bool
-vc4_use_bo(struct vc4_exec_info *exec,
-          uint32_t hindex,
-          enum vc4_bo_mode mode,
-          struct drm_gem_cma_object **obj)
+struct drm_gem_cma_object *
+vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex)
 {
-       *obj = NULL;
+       struct drm_gem_cma_object *obj;
+       struct drm_vc4_bo *bo;
 
        if (hindex >= exec->bo_count) {
                DRM_ERROR("BO index %d greater than BO count %d\n",
                          hindex, exec->bo_count);
-               return false;
+               return NULL;
        }
+       obj = exec->bo[hindex];
+       bo = to_vc4_bo(&obj->base);
 
-       if (exec->bo[hindex].mode != mode) {
-               if (exec->bo[hindex].mode == VC4_MODE_UNDECIDED) {
-                       exec->bo[hindex].mode = mode;
-               } else {
-                       DRM_ERROR("BO index %d reused with mode %d vs %d\n",
-                                 hindex, exec->bo[hindex].mode, mode);
-                       return false;
-               }
+       if (bo->validated_shader) {
+               DRM_ERROR("Trying to use shader BO as something other than "
+                         "a shader\n");
+               return NULL;
        }
 
-       *obj = exec->bo[hindex].bo;
-       return true;
+       return obj;
+}
+
+static struct drm_gem_cma_object *
+vc4_use_handle(struct vc4_exec_info *exec, uint32_t gem_handles_packet_index)
+{
+       return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index]);
 }
 
 static bool
-vc4_use_handle(struct vc4_exec_info *exec,
-              uint32_t gem_handles_packet_index,
-              enum vc4_bo_mode mode,
-              struct drm_gem_cma_object **obj)
+validate_bin_pos(struct vc4_exec_info *exec, void *untrusted, uint32_t pos)
 {
-       return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index],
-                         mode, obj);
+       /* Note that the untrusted pointer passed to these functions is
+        * incremented past the packet byte.
+        */
+       return (untrusted - 1 == exec->bin_u + pos);
 }
 
 static uint32_t
@@ -147,10 +146,10 @@ gl_shader_rec_size(uint32_t pointer_bits)
                return 36 + attribute_count * 8;
 }
 
-static bool
-check_tex_size(struct vc4_exec_info *exec, struct drm_gem_cma_object *fbo,
-              uint32_t offset, uint8_t tiling_format,
-              uint32_t width, uint32_t height, uint8_t cpp)
+bool
+vc4_check_tex_size(struct vc4_exec_info *exec, struct drm_gem_cma_object *fbo,
+                  uint32_t offset, uint8_t tiling_format,
+                  uint32_t width, uint32_t height, uint8_t cpp)
 {
        uint32_t aligned_width, aligned_height, stride, size;
        uint32_t utile_w = utile_width(cpp);
@@ -191,7 +190,7 @@ check_tex_size(struct vc4_exec_info *exec, struct drm_gem_cma_object *fbo,
 
        if (size + offset < size ||
            size + offset > fbo->base.size) {
-               DRM_ERROR("Overflow in %dx%d (%dx%d) fbo size (%d + %d > %d)\n",
+               DRM_ERROR("Overflow in %dx%d (%dx%d) fbo size (%d + %d > %zd)\n",
                          width, height,
                          aligned_width, aligned_height,
                          size, offset, fbo->base.size);
@@ -202,13 +201,13 @@ check_tex_size(struct vc4_exec_info *exec, struct drm_gem_cma_object *fbo,
 }
 
 static int
-validate_flush_all(VALIDATE_ARGS)
+validate_flush(VALIDATE_ARGS)
 {
-       if (exec->found_increment_semaphore_packet) {
-               DRM_ERROR("VC4_PACKET_FLUSH_ALL after "
-                         "VC4_PACKET_INCREMENT_SEMAPHORE\n");
+       if (!validate_bin_pos(exec, untrusted, exec->args->bin_cl_size - 1)) {
+               DRM_ERROR("Bin CL must end with VC4_PACKET_FLUSH\n");
                return -EINVAL;
        }
+       exec->found_flush = true;
 
        return 0;
 }
@@ -233,128 +232,12 @@ validate_start_tile_binning(VALIDATE_ARGS)
 static int
 validate_increment_semaphore(VALIDATE_ARGS)
 {
-       if (exec->found_increment_semaphore_packet) {
-               DRM_ERROR("Duplicate VC4_PACKET_INCREMENT_SEMAPHORE\n");
-               return -EINVAL;
-       }
-       exec->found_increment_semaphore_packet = true;
-
-       /* Once we've found the semaphore increment, there should be one FLUSH
-        * then the end of the command list.  The FLUSH actually triggers the
-        * increment, so we only need to make sure there
-        */
-
-       return 0;
-}
-
-static int
-validate_wait_on_semaphore(VALIDATE_ARGS)
-{
-       if (exec->found_wait_on_semaphore_packet) {
-               DRM_ERROR("Duplicate VC4_PACKET_WAIT_ON_SEMAPHORE\n");
-               return -EINVAL;
-       }
-       exec->found_wait_on_semaphore_packet = true;
-
-       if (!exec->found_increment_semaphore_packet) {
-               DRM_ERROR("VC4_PACKET_WAIT_ON_SEMAPHORE without "
+       if (!validate_bin_pos(exec, untrusted, exec->args->bin_cl_size - 2)) {
+               DRM_ERROR("Bin CL must end with "
                          "VC4_PACKET_INCREMENT_SEMAPHORE\n");
                return -EINVAL;
        }
-
-       return 0;
-}
-
-static int
-validate_branch_to_sublist(VALIDATE_ARGS)
-{
-       uint32_t offset;
-
-       if (!exec->tile_alloc_bo) {
-               DRM_ERROR("VC4_PACKET_BRANCH_TO_SUB_LIST seen before "
-                         "binner setup\n");
-               return -EINVAL;
-       }
-
-       if (!exec->found_wait_on_semaphore_packet) {
-               DRM_ERROR("Jumping to tile alloc before binning finished.\n");
-               return -EINVAL;
-       }
-
-       offset = *(uint32_t *)(untrusted + 0);
-       if (offset & exec->tile_alloc_init_block_mask ||
-           offset > exec->tile_alloc_init_block_last) {
-               DRM_ERROR("VC4_PACKET_BRANCH_TO_SUB_LIST must jump to initial "
-                         "tile allocation space.\n");
-               return -EINVAL;
-       }
-
-       *(uint32_t *)(validated + 0) = exec->tile_alloc_bo->paddr + offset;
-
-       return 0;
-}
-
-/**
- * validate_loadstore_tile_buffer_general() - Validation for
- * VC4_PACKET_LOAD_TILE_BUFFER_GENERAL and
- * VC4_PACKET_STORE_TILE_BUFFER_GENERAL.
- *
- * The two packets are nearly the same, except for the TLB-clearing management
- * bits not being present for loads.  Additionally, while stores are executed
- * immediately (using the current tile coordinates), loads are queued to be
- * executed when the tile coordinates packet occurs.
- *
- * Note that coordinates packets are validated to be within the declared
- * bin_x/y, which themselves are verified to match the rendering-configuration
- * FB width and height (which the hardware uses to clip loads and stores).
- */
-static int
-validate_loadstore_tile_buffer_general(VALIDATE_ARGS)
-{
-       uint32_t packet_b0 = *(uint8_t *)(untrusted + 0);
-       uint32_t packet_b1 = *(uint8_t *)(untrusted + 1);
-       struct drm_gem_cma_object *fbo;
-       uint32_t buffer_type = packet_b0 & 0xf;
-       uint32_t untrusted_address, offset, cpp;
-
-       switch (buffer_type) {
-       case VC4_LOADSTORE_TILE_BUFFER_NONE:
-               return 0;
-       case VC4_LOADSTORE_TILE_BUFFER_COLOR:
-               if ((packet_b1 & VC4_LOADSTORE_TILE_BUFFER_MASK) ==
-                   VC4_LOADSTORE_TILE_BUFFER_RGBA8888) {
-                       cpp = 4;
-               } else {
-                       cpp = 2;
-               }
-               break;
-
-       case VC4_LOADSTORE_TILE_BUFFER_Z:
-       case VC4_LOADSTORE_TILE_BUFFER_ZS:
-               cpp = 4;
-               break;
-
-       default:
-               DRM_ERROR("Load/store type %d unsupported\n", buffer_type);
-               return -EINVAL;
-       }
-
-       if (!vc4_use_handle(exec, 0, VC4_MODE_RENDER, &fbo))
-               return -EINVAL;
-
-       untrusted_address = *(uint32_t *)(untrusted + 2);
-       offset = untrusted_address & ~0xf;
-
-       if (!check_tex_size(exec, fbo, offset,
-                           ((packet_b0 &
-                             VC4_LOADSTORE_TILE_BUFFER_FORMAT_MASK) >>
-                            VC4_LOADSTORE_TILE_BUFFER_FORMAT_SHIFT),
-                           exec->fb_width, exec->fb_height, cpp)) {
-               return -EINVAL;
-       }
-
-       *(uint32_t *)(validated + 2) = (offset + fbo->paddr +
-                                       (untrusted_address & 0xf));
+       exec->found_increment_semaphore_packet = true;
 
        return 0;
 }
@@ -369,11 +252,6 @@ validate_indexed_prim_list(VALIDATE_ARGS)
        uint32_t index_size = (*(uint8_t *)(untrusted + 0) >> 4) ? 2 : 1;
        struct vc4_shader_state *shader_state;
 
-       if (exec->found_increment_semaphore_packet) {
-               DRM_ERROR("Drawing after VC4_PACKET_INCREMENT_SEMAPHORE\n");
-               return -EINVAL;
-       }
-
        /* Check overflow condition */
        if (exec->shader_state_count == 0) {
                DRM_ERROR("shader state must precede primitives\n");
@@ -384,12 +262,13 @@ validate_indexed_prim_list(VALIDATE_ARGS)
        if (max_index > shader_state->max_index)
                shader_state->max_index = max_index;
 
-       if (!vc4_use_handle(exec, 0, VC4_MODE_RENDER, &ib))
+       ib = vc4_use_handle(exec, 0);
+       if (!ib)
                return -EINVAL;
 
        if (offset > ib->base.size ||
            (ib->base.size - offset) / index_size < length) {
-               DRM_ERROR("IB access overflow (%d + %d*%d > %d)\n",
+               DRM_ERROR("IB access overflow (%d + %d*%d > %zd)\n",
                          offset, length, index_size, ib->base.size);
                return -EINVAL;
        }
@@ -407,11 +286,6 @@ validate_gl_array_primitive(VALIDATE_ARGS)
        uint32_t max_index;
        struct vc4_shader_state *shader_state;
 
-       if (exec->found_increment_semaphore_packet) {
-               DRM_ERROR("Drawing after VC4_PACKET_INCREMENT_SEMAPHORE\n");
-               return -EINVAL;
-       }
-
        /* Check overflow condition */
        if (exec->shader_state_count == 0) {
                DRM_ERROR("shader state must precede primitives\n");
@@ -441,7 +315,6 @@ validate_gl_shader_state(VALIDATE_ARGS)
                return -EINVAL;
        }
 
-       exec->shader_state[i].packet = VC4_PACKET_GL_SHADER_STATE;
        exec->shader_state[i].addr = *(uint32_t *)untrusted;
        exec->shader_state[i].max_index = 0;
 
@@ -459,43 +332,13 @@ validate_gl_shader_state(VALIDATE_ARGS)
        return 0;
 }
 
-static int
-validate_nv_shader_state(VALIDATE_ARGS)
-{
-       uint32_t i = exec->shader_state_count++;
-
-       if (i >= exec->shader_state_size) {
-               DRM_ERROR("More requests for shader states than declared\n");
-               return -EINVAL;
-       }
-
-       exec->shader_state[i].packet = VC4_PACKET_NV_SHADER_STATE;
-       exec->shader_state[i].addr = *(uint32_t *)untrusted;
-
-       if (exec->shader_state[i].addr & 15) {
-               DRM_ERROR("NV shader state address 0x%08x misaligned\n",
-                         exec->shader_state[i].addr);
-               return -EINVAL;
-       }
-
-       *(uint32_t *)validated = (exec->shader_state[i].addr +
-                                 exec->shader_rec_p);
-
-       return 0;
-}
-
 static int
 validate_tile_binning_config(VALIDATE_ARGS)
 {
-       struct drm_gem_cma_object *tile_allocation;
-       struct drm_gem_cma_object *tile_state_data_array;
+       struct drm_device *dev = exec->exec_bo->base.dev;
        uint8_t flags;
-       uint32_t tile_allocation_size;
-       uint32_t tile_alloc_init_block_size;
-
-       if (!vc4_use_handle(exec, 0, VC4_MODE_TILE_ALLOC, &tile_allocation) ||
-           !vc4_use_handle(exec, 1, VC4_MODE_TSDA, &tile_state_data_array))
-               return -EINVAL;
+       uint32_t tile_state_size, tile_alloc_size;
+       uint32_t tile_count;
 
        if (exec->found_tile_binning_mode_config_packet) {
                DRM_ERROR("Duplicate VC4_PACKET_TILE_BINNING_MODE_CONFIG\n");
@@ -505,6 +348,7 @@ validate_tile_binning_config(VALIDATE_ARGS)
 
        exec->bin_tiles_x = *(uint8_t *)(untrusted + 12);
        exec->bin_tiles_y = *(uint8_t *)(untrusted + 13);
+       tile_count = exec->bin_tiles_x * exec->bin_tiles_y;
        flags = *(uint8_t *)(untrusted + 14);
 
        if (exec->bin_tiles_x == 0 ||
@@ -514,114 +358,58 @@ validate_tile_binning_config(VALIDATE_ARGS)
                return -EINVAL;
        }
 
-       /* Our validation relies on the user not getting to set up their own
-        * tile state/tile allocation BO contents.
-        */
-       if (!(flags & VC4_BIN_CONFIG_AUTO_INIT_TSDA)) {
-               DRM_ERROR("binning config missing "
-                         "VC4_BIN_CONFIG_AUTO_INIT_TSDA\n");
-               return -EINVAL;
-       }
-
        if (flags & (VC4_BIN_CONFIG_DB_NON_MS |
-                    VC4_BIN_CONFIG_TILE_BUFFER_64BIT |
-                    VC4_BIN_CONFIG_MS_MODE_4X)) {
-               DRM_ERROR("unsupported bining config flags 0x%02x\n", flags);
-               return -EINVAL;
-       }
-
-       if (*(uint32_t *)(untrusted + 0) != 0) {
-               DRM_ERROR("tile allocation offset != 0 unsupported\n");
-               return -EINVAL;
-       }
-       tile_allocation_size = *(uint32_t *)(untrusted + 4);
-       if (tile_allocation_size > tile_allocation->base.size) {
-               DRM_ERROR("tile allocation size %d > BO size %d\n",
-                         tile_allocation_size, tile_allocation->base.size);
-               return -EINVAL;
-       }
-       *(uint32_t *)validated = tile_allocation->paddr;
-       exec->tile_alloc_bo = tile_allocation;
-
-       tile_alloc_init_block_size = 1 << (5 + ((flags >> 5) & 3));
-       if (exec->bin_tiles_x * exec->bin_tiles_y *
-           tile_alloc_init_block_size > tile_allocation_size) {
-               DRM_ERROR("tile init exceeds tile alloc size (%d vs %d)\n",
-                         exec->bin_tiles_x * exec->bin_tiles_y *
-                         tile_alloc_init_block_size,
-                         tile_allocation_size);
-               return -EINVAL;
-       }
-       exec->tile_alloc_init_block_mask = tile_alloc_init_block_size - 1;
-       exec->tile_alloc_init_block_last = tile_alloc_init_block_size *
-               (exec->bin_tiles_x * exec->bin_tiles_y - 1);
-
-       if (*(uint32_t *)(untrusted + 8) != 0) {
-               DRM_ERROR("TSDA offset != 0 unsupported\n");
-               return -EINVAL;
-       }
-       if (exec->bin_tiles_x * exec->bin_tiles_y * 48 >
-           tile_state_data_array->base.size) {
-               DRM_ERROR("TSDA of %db too small for %dx%d bin config\n",
-                         tile_state_data_array->base.size,
-                         exec->bin_tiles_x, exec->bin_tiles_y);
-       }
-       *(uint32_t *)(validated + 8) = tile_state_data_array->paddr;
-
-       return 0;
-}
-
-static int
-validate_tile_rendering_mode_config(VALIDATE_ARGS)
-{
-       struct drm_gem_cma_object *fbo;
-       uint32_t flags, offset, cpp;
-
-       if (exec->found_tile_rendering_mode_config_packet) {
-               DRM_ERROR("Duplicate VC4_PACKET_TILE_RENDERING_MODE_CONFIG\n");
+                    VC4_BIN_CONFIG_TILE_BUFFER_64BIT)) {
+               DRM_ERROR("unsupported binning config flags 0x%02x\n", flags);
                return -EINVAL;
        }
-       exec->found_tile_rendering_mode_config_packet = true;
-
-       if (!vc4_use_handle(exec, 0, VC4_MODE_RENDER, &fbo))
-               return -EINVAL;
-
-       exec->fb_width = *(uint16_t *)(untrusted + 4);
-       exec->fb_height = *(uint16_t *)(untrusted + 6);
-
-       flags = *(uint16_t *)(untrusted + 8);
-       if ((flags & VC4_RENDER_CONFIG_FORMAT_MASK) ==
-           VC4_RENDER_CONFIG_FORMAT_RGBA8888) {
-               cpp = 4;
-       } else {
-               cpp = 2;
-       }
-
-       offset = *(uint32_t *)untrusted;
-       if (!check_tex_size(exec, fbo, offset,
-                           ((flags &
-                             VC4_RENDER_CONFIG_MEMORY_FORMAT_MASK) >>
-                            VC4_RENDER_CONFIG_MEMORY_FORMAT_SHIFT),
-                           exec->fb_width, exec->fb_height, cpp)) {
-               return -EINVAL;
-       }
-
-       *(uint32_t *)validated = fbo->paddr + offset;
-
-       return 0;
-}
 
-static int
-validate_tile_coordinates(VALIDATE_ARGS)
-{
-       uint8_t tile_x = *(uint8_t *)(untrusted + 0);
-       uint8_t tile_y = *(uint8_t *)(untrusted + 1);
+       /* The tile state data array is 48 bytes per tile, and we put it at
+        * the start of a BO containing both it and the tile alloc.
+        */
+       tile_state_size = 48 * tile_count;
+
+       /* Since the tile alloc array will follow us, align. */
+       exec->tile_alloc_offset = roundup(tile_state_size, 4096);
+
+       *(uint8_t *)(validated + 14) =
+               ((flags & ~(VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_MASK |
+                           VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_MASK)) |
+                VC4_BIN_CONFIG_AUTO_INIT_TSDA |
+                VC4_SET_FIELD(VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE_32,
+                              VC4_BIN_CONFIG_ALLOC_INIT_BLOCK_SIZE) |
+                VC4_SET_FIELD(VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE_128,
+                              VC4_BIN_CONFIG_ALLOC_BLOCK_SIZE));
+
+       /* Initial block size. */
+       tile_alloc_size = 32 * tile_count;
+
+       /*
+        * The initial allocation gets rounded to the next 256 bytes before
+        * the hardware starts fulfilling further allocations.
+        */
+       tile_alloc_size = roundup(tile_alloc_size, 256);
 
-       if (tile_x * 64 >= exec->fb_width || tile_y * 64 >= exec->fb_height) {
-               DRM_ERROR("Tile coordinates %d,%d > render config %dx%d\n",
-                         tile_x, tile_y, exec->fb_width, exec->fb_height);
-               return -EINVAL;
-       }
+       /* Add space for the extra allocations.  This is what gets used first,
+        * before overflow memory.  It must have at least 4096 bytes, but we
+        * want to avoid overflow memory usage if possible.
+        */
+       tile_alloc_size += 1024 * 1024;
+
+       exec->tile_bo = drm_gem_cma_create(dev, exec->tile_alloc_offset +
+                                          tile_alloc_size);
+       if (!exec->tile_bo)
+               return -ENOMEM;
+       list_addtail(&to_vc4_bo(&exec->tile_bo->base)->unref_head,
+                    &exec->unref_list);
+
+       /* tile alloc address. */
+       *(uint32_t *)(validated + 0) = (exec->tile_bo->paddr +
+                                       exec->tile_alloc_offset);
+       /* tile alloc size. */
+       *(uint32_t *)(validated + 4) = tile_alloc_size;
+       /* tile state address. */
+       *(uint32_t *)(validated + 8) = exec->tile_bo->paddr;
 
        return 0;
 }
@@ -633,78 +421,60 @@ validate_gem_handles(VALIDATE_ARGS)
        return 0;
 }
 
+#define VC4_DEFINE_PACKET(packet, func) \
+       [packet] = { packet ## _SIZE, #packet, func }
+
 static const struct cmd_info {
-       bool bin;
-       bool render;
        uint16_t len;
        const char *name;
        int (*func)(struct vc4_exec_info *exec, void *validated,
                    void *untrusted);
 } cmd_info[] = {
-       [VC4_PACKET_HALT] = { 1, 1, 1, "halt", NULL },
-       [VC4_PACKET_NOP] = { 1, 1, 1, "nop", NULL },
-       [VC4_PACKET_FLUSH] = { 1, 1, 1, "flush", NULL },
-       [VC4_PACKET_FLUSH_ALL] = { 1, 0, 1, "flush all state", validate_flush_all },
-       [VC4_PACKET_START_TILE_BINNING] = { 1, 0, 1, "start tile binning", validate_start_tile_binning },
-       [VC4_PACKET_INCREMENT_SEMAPHORE] = { 1, 0, 1, "increment semaphore", validate_increment_semaphore },
-       [VC4_PACKET_WAIT_ON_SEMAPHORE] = { 0, 1, 1, "wait on semaphore", validate_wait_on_semaphore },
-       /* BRANCH_TO_SUB_LIST is actually supported in the binner as well, but
-        * we only use it from the render CL in order to jump into the tile
-        * allocation BO.
-        */
-       [VC4_PACKET_BRANCH_TO_SUB_LIST] = { 0, 1, 5, "branch to sublist", validate_branch_to_sublist },
-       [VC4_PACKET_STORE_MS_TILE_BUFFER] = { 0, 1, 1, "store MS resolved tile color buffer", NULL },
-       [VC4_PACKET_STORE_MS_TILE_BUFFER_AND_EOF] = { 0, 1, 1, "store MS resolved tile color buffer and EOF", NULL },
-
-       [VC4_PACKET_STORE_TILE_BUFFER_GENERAL] = { 0, 1, 7, "Store Tile Buffer General", validate_loadstore_tile_buffer_general },
-       [VC4_PACKET_LOAD_TILE_BUFFER_GENERAL] = { 0, 1, 7, "Load Tile Buffer General", validate_loadstore_tile_buffer_general },
-
-       [VC4_PACKET_GL_INDEXED_PRIMITIVE] = { 1, 1, 14, "Indexed Primitive List", validate_indexed_prim_list },
-
-       [VC4_PACKET_GL_ARRAY_PRIMITIVE] = { 1, 1, 10, "Vertex Array Primitives", validate_gl_array_primitive },
-
-       /* This is only used by clipped primitives (packets 48 and 49), which
-        * we don't support parsing yet.
-        */
-       [VC4_PACKET_PRIMITIVE_LIST_FORMAT] = { 1, 1, 2, "primitive list format", NULL },
-
-       [VC4_PACKET_GL_SHADER_STATE] = { 1, 1, 5, "GL Shader State", validate_gl_shader_state },
-       [VC4_PACKET_NV_SHADER_STATE] = { 1, 1, 5, "NV Shader State", validate_nv_shader_state },
-
-       [VC4_PACKET_CONFIGURATION_BITS] = { 1, 1, 4, "configuration bits", NULL },
-       [VC4_PACKET_FLAT_SHADE_FLAGS] = { 1, 1, 5, "flat shade flags", NULL },
-       [VC4_PACKET_POINT_SIZE] = { 1, 1, 5, "point size", NULL },
-       [VC4_PACKET_LINE_WIDTH] = { 1, 1, 5, "line width", NULL },
-       [VC4_PACKET_RHT_X_BOUNDARY] = { 1, 1, 3, "RHT X boundary", NULL },
-       [VC4_PACKET_DEPTH_OFFSET] = { 1, 1, 5, "Depth Offset", NULL },
-       [VC4_PACKET_CLIP_WINDOW] = { 1, 1, 9, "Clip Window", NULL },
-       [VC4_PACKET_VIEWPORT_OFFSET] = { 1, 1, 5, "Viewport Offset", NULL },
-       [VC4_PACKET_CLIPPER_XY_SCALING] = { 1, 1, 9, "Clipper XY Scaling", NULL },
+       VC4_DEFINE_PACKET(VC4_PACKET_HALT, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_NOP, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_FLUSH, validate_flush),
+       VC4_DEFINE_PACKET(VC4_PACKET_FLUSH_ALL, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_START_TILE_BINNING,
+                         validate_start_tile_binning),
+       VC4_DEFINE_PACKET(VC4_PACKET_INCREMENT_SEMAPHORE,
+                         validate_increment_semaphore),
+
+       VC4_DEFINE_PACKET(VC4_PACKET_GL_INDEXED_PRIMITIVE,
+                         validate_indexed_prim_list),
+       VC4_DEFINE_PACKET(VC4_PACKET_GL_ARRAY_PRIMITIVE,
+                         validate_gl_array_primitive),
+
+       VC4_DEFINE_PACKET(VC4_PACKET_PRIMITIVE_LIST_FORMAT, NULL),
+
+       VC4_DEFINE_PACKET(VC4_PACKET_GL_SHADER_STATE, validate_gl_shader_state),
+
+       VC4_DEFINE_PACKET(VC4_PACKET_CONFIGURATION_BITS, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_FLAT_SHADE_FLAGS, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_POINT_SIZE, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_LINE_WIDTH, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_RHT_X_BOUNDARY, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_DEPTH_OFFSET, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_CLIP_WINDOW, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_VIEWPORT_OFFSET, NULL),
+       VC4_DEFINE_PACKET(VC4_PACKET_CLIPPER_XY_SCALING, NULL),
        /* Note: The docs say this was also 105, but it was 106 in the
         * initial userland code drop.
         */
-       [VC4_PACKET_CLIPPER_Z_SCALING] = { 1, 1, 9, "Clipper Z Scale and Offset", NULL },
+       VC4_DEFINE_PACKET(VC4_PACKET_CLIPPER_Z_SCALING, NULL),
 
-       [VC4_PACKET_TILE_BINNING_MODE_CONFIG] = { 1, 0, 16, "tile binning configuration", validate_tile_binning_config },
+       VC4_DEFINE_PACKET(VC4_PACKET_TILE_BINNING_MODE_CONFIG,
+                         validate_tile_binning_config),
 
-       [VC4_PACKET_TILE_RENDERING_MODE_CONFIG] = { 0, 1, 11, "tile rendering mode configuration", validate_tile_rendering_mode_config},
-
-       [VC4_PACKET_CLEAR_COLORS] = { 0, 1, 14, "Clear Colors", NULL },
-
-       [VC4_PACKET_TILE_COORDINATES] = { 0, 1, 3, "Tile Coordinates", validate_tile_coordinates },
-
-       [VC4_PACKET_GEM_HANDLES] = { 1, 1, 9, "GEM handles", validate_gem_handles },
+       VC4_DEFINE_PACKET(VC4_PACKET_GEM_HANDLES, validate_gem_handles),
 };
 
 int
-vc4_validate_cl(struct drm_device *dev,
-               void *validated,
-               void *unvalidated,
-               uint32_t len,
-               bool is_bin,
-               bool has_bin,
-               struct vc4_exec_info *exec)
+vc4_validate_bin_cl(struct drm_device *dev,
+                   void *validated,
+                   void *unvalidated,
+                   struct vc4_exec_info *exec)
 {
+       uint32_t len = exec->args->bin_cl_size;
        uint32_t dst_offset = 0;
        uint32_t src_offset = 0;
 
@@ -714,7 +484,7 @@ vc4_validate_cl(struct drm_device *dev,
                u8 cmd = *(uint8_t *)src_pkt;
                const struct cmd_info *info;
 
-               if (cmd > ARRAY_SIZE(cmd_info)) {
+               if (cmd >= ARRAY_SIZE(cmd_info)) {
                        DRM_ERROR("0x%08x: packet %d out of bounds\n",
                                  src_offset, cmd);
                        return -EINVAL;
@@ -727,19 +497,6 @@ vc4_validate_cl(struct drm_device *dev,
                        return -EINVAL;
                }
 
-#if 0
-               DRM_INFO("0x%08x: packet %d (%s) size %d processing...\n",
-                        src_offset, cmd, info->name, info->len);
-#endif
-
-               if ((is_bin && !info->bin) ||
-                   (!is_bin && !info->render)) {
-                       DRM_ERROR("0x%08x: packet %d (%s) invalid for %s\n",
-                                 src_offset, cmd, info->name,
-                                 is_bin ? "binner" : "render");
-                       return -EINVAL;
-               }
-
                if (src_offset + info->len > len) {
                        DRM_ERROR("0x%08x: packet %d (%s) length 0x%08x "
                                  "exceeds bounds (0x%08x)\n",
@@ -754,8 +511,7 @@ vc4_validate_cl(struct drm_device *dev,
                if (info->func && info->func(exec,
                                             dst_pkt + 1,
                                             src_pkt + 1)) {
-                       DRM_ERROR("0x%08x: packet %d (%s) failed to "
-                                 "validate\n",
+                       DRM_ERROR("0x%08x: packet %d (%s) failed to validate\n",
                                  src_offset, cmd, info->name);
                        return -EINVAL;
                }
@@ -770,30 +526,24 @@ vc4_validate_cl(struct drm_device *dev,
                        break;
        }
 
-       if (is_bin) {
-               exec->ct0ea = exec->ct0ca + dst_offset;
+       exec->ct0ea = exec->ct0ca + dst_offset;
 
-               if (has_bin && !exec->found_start_tile_binning_packet) {
-                       DRM_ERROR("Bin CL missing VC4_PACKET_START_TILE_BINNING\n");
-                       return -EINVAL;
-               }
-       } else {
-               if (!exec->found_tile_rendering_mode_config_packet) {
-                       DRM_ERROR("Render CL missing VC4_PACKET_TILE_RENDERING_MODE_CONFIG\n");
-                       return -EINVAL;
-               }
+       if (!exec->found_start_tile_binning_packet) {
+               DRM_ERROR("Bin CL missing VC4_PACKET_START_TILE_BINNING\n");
+               return -EINVAL;
+       }
 
-               /* Make sure that they actually consumed the semaphore
-                * increment from the bin CL.  Otherwise a later submit would
-                * have render execute immediately.
-                */
-               if (exec->found_wait_on_semaphore_packet != has_bin) {
-                       DRM_ERROR("Render CL %s VC4_PACKET_WAIT_ON_SEMAPHORE\n",
-                                 exec->found_wait_on_semaphore_packet ?
-                                 "has" : "missing");
-                       return -EINVAL;
-               }
-               exec->ct1ea = exec->ct1ca + dst_offset;
+       /* The bin CL must be ended with INCREMENT_SEMAPHORE and FLUSH.  The
+        * semaphore is used to trigger the render CL to start up, and the
+        * FLUSH is what caps the bin lists with
+        * VC4_PACKET_RETURN_FROM_SUB_LIST (so they jump back to the main
+        * render CL when they get called to) and actually triggers the queued
+        * semaphore increment.
+        */
+       if (!exec->found_increment_semaphore_packet || !exec->found_flush) {
+               DRM_ERROR("Bin CL missing VC4_PACKET_INCREMENT_SEMAPHORE + "
+                         "VC4_PACKET_FLUSH\n");
+               return -EINVAL;
        }
 
        return 0;
@@ -814,27 +564,30 @@ reloc_tex(struct vc4_exec_info *exec,
        uint32_t p3 = (sample->p_offset[3] != ~0 ?
                       *(uint32_t *)(uniform_data_u + sample->p_offset[3]) : 0);
        uint32_t *validated_p0 = exec->uniforms_v + sample->p_offset[0];
-       uint32_t offset = p0 & ~0xfff;
-       uint32_t miplevels = (p0 & 15);
-       uint32_t width = (p1 >> 8) & 2047;
-       uint32_t height = (p1 >> 20) & 2047;
+       uint32_t offset = p0 & VC4_TEX_P0_OFFSET_MASK;
+       uint32_t miplevels = VC4_GET_FIELD(p0, VC4_TEX_P0_MIPLVLS);
+       uint32_t width = VC4_GET_FIELD(p1, VC4_TEX_P1_WIDTH);
+       uint32_t height = VC4_GET_FIELD(p1, VC4_TEX_P1_HEIGHT);
        uint32_t cpp, tiling_format, utile_w, utile_h;
        uint32_t i;
        uint32_t cube_map_stride = 0;
        enum vc4_texture_data_type type;
 
-       if (!vc4_use_bo(exec, texture_handle_index, VC4_MODE_RENDER, &tex))
+       tex = vc4_use_bo(exec, texture_handle_index);
+       if (!tex)
                return false;
 
        if (sample->is_direct) {
                uint32_t remaining_size = tex->base.size - p0;
+
                if (p0 > tex->base.size - 4) {
                        DRM_ERROR("UBO offset greater than UBO size\n");
-                       return false;
+                       goto fail;
                }
                if (p1 > remaining_size - 4) {
-                       DRM_ERROR("UBO clamp would allow reads outside of UBO\n");
-                       return false;
+                       DRM_ERROR("UBO clamp would allow reads "
+                                 "outside of UBO\n");
+                       goto fail;
                }
                *validated_p0 = tex->paddr + p0;
                return true;
@@ -845,24 +598,27 @@ reloc_tex(struct vc4_exec_info *exec,
        if (height == 0)
                height = 2048;
 
-       if (p0 & (1 << 9)) {
-               if ((p2 & (3 << 30)) == (1 << 30))
-                       cube_map_stride = p2 & 0x3ffff000;
-               if ((p3 & (3 << 30)) == (1 << 30)) {
+       if (p0 & VC4_TEX_P0_CMMODE_MASK) {
+               if (VC4_GET_FIELD(p2, VC4_TEX_P2_PTYPE) ==
+                   VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE)
+                       cube_map_stride = p2 & VC4_TEX_P2_CMST_MASK;
+               if (VC4_GET_FIELD(p3, VC4_TEX_P2_PTYPE) ==
+                   VC4_TEX_P2_PTYPE_CUBE_MAP_STRIDE) {
                        if (cube_map_stride) {
                                DRM_ERROR("Cube map stride set twice\n");
-                               return false;
+                               goto fail;
                        }
 
-                       cube_map_stride = p3 & 0x3ffff000;
+                       cube_map_stride = p3 & VC4_TEX_P2_CMST_MASK;
                }
                if (!cube_map_stride) {
                        DRM_ERROR("Cube map stride not set\n");
-                       return false;
+                       goto fail;
                }
        }
 
-       type = ((p0 >> 4) & 15) | ((p1 >> 31) << 4);
+       type = (VC4_GET_FIELD(p0, VC4_TEX_P0_TYPE) |
+               (VC4_GET_FIELD(p1, VC4_TEX_P1_TYPE4) << 4));
 
        switch (type) {
        case VC4_TEXTURE_TYPE_RGBA8888:
@@ -884,6 +640,13 @@ reloc_tex(struct vc4_exec_info *exec,
                cpp = 1;
                break;
        case VC4_TEXTURE_TYPE_ETC1:
+               /* ETC1 is arranged as 64-bit blocks, where each block is 4x4
+                * pixels.
+                */
+               cpp = 8;
+               width = (width + 3) >> 2;
+               height = (height + 3) >> 2;
+               break;
        case VC4_TEXTURE_TYPE_BW1:
        case VC4_TEXTURE_TYPE_A4:
        case VC4_TEXTURE_TYPE_A1:
@@ -891,7 +654,7 @@ reloc_tex(struct vc4_exec_info *exec,
        case VC4_TEXTURE_TYPE_YUV422R:
        default:
                DRM_ERROR("Texture format %d unsupported\n", type);
-               return false;
+               goto fail;
        }
        utile_w = utile_width(cpp);
        utile_h = utile_height(cpp);
@@ -905,9 +668,9 @@ reloc_tex(struct vc4_exec_info *exec,
                        tiling_format = VC4_TILING_FORMAT_T;
        }
 
-       if (!check_tex_size(exec, tex, offset + cube_map_stride * 5,
-                           tiling_format, width, height, cpp)) {
-               return false;
+       if (!vc4_check_tex_size(exec, tex, offset + cube_map_stride * 5,
+                               tiling_format, width, height, cpp)) {
+               goto fail;
        }
 
        /* The mipmap levels are stored before the base of the texture.  Make
@@ -948,7 +711,7 @@ reloc_tex(struct vc4_exec_info *exec,
                                  i, level_width, level_height,
                                  aligned_width, aligned_height,
                                  level_size, offset);
-                       return false;
+                       goto fail;
                }
 
                offset -= level_size;
@@ -957,54 +720,37 @@ reloc_tex(struct vc4_exec_info *exec,
        *validated_p0 = tex->paddr + p0;
 
        return true;
+ fail:
+       DRM_INFO("Texture p0 at %d: 0x%08x\n", sample->p_offset[0], p0);
+       DRM_INFO("Texture p1 at %d: 0x%08x\n", sample->p_offset[1], p1);
+       DRM_INFO("Texture p2 at %d: 0x%08x\n", sample->p_offset[2], p2);
+       DRM_INFO("Texture p3 at %d: 0x%08x\n", sample->p_offset[3], p3);
+       return false;
 }
 
 static int
-validate_shader_rec(struct drm_device *dev,
-                   struct vc4_exec_info *exec,
-                   struct vc4_shader_state *state)
+validate_gl_shader_rec(struct drm_device *dev,
+                      struct vc4_exec_info *exec,
+                      struct vc4_shader_state *state)
 {
        uint32_t *src_handles;
        void *pkt_u, *pkt_v;
-       enum shader_rec_reloc_type {
-               RELOC_CODE,
-               RELOC_VBO,
-       };
-       struct shader_rec_reloc {
-               enum shader_rec_reloc_type type;
-               uint32_t offset;
-       };
-       static const struct shader_rec_reloc gl_relocs[] = {
-               { RELOC_CODE, 4 },  /* fs */
-               { RELOC_CODE, 16 }, /* vs */
-               { RELOC_CODE, 28 }, /* cs */
+       static const uint32_t shader_reloc_offsets[] = {
+               4, /* fs */
+               16, /* vs */
+               28, /* cs */
        };
-       static const struct shader_rec_reloc nv_relocs[] = {
-               { RELOC_CODE, 4 }, /* fs */
-               { RELOC_VBO, 12 }
-       };
-       const struct shader_rec_reloc *relocs;
-       struct drm_gem_cma_object *bo[ARRAY_SIZE(gl_relocs) + 8];
-       uint32_t nr_attributes = 0, nr_fixed_relocs, nr_relocs, packet_size;
+       uint32_t shader_reloc_count = ARRAY_SIZE(shader_reloc_offsets);
+       struct drm_gem_cma_object *bo[shader_reloc_count + 8];
+       uint32_t nr_attributes, nr_relocs, packet_size;
        int i;
-       struct vc4_validated_shader_info *validated_shader = NULL;
-
-       if (state->packet == VC4_PACKET_NV_SHADER_STATE) {
-               relocs = nv_relocs;
-               nr_fixed_relocs = ARRAY_SIZE(nv_relocs);
 
-               packet_size = 16;
-       } else {
-               relocs = gl_relocs;
-               nr_fixed_relocs = ARRAY_SIZE(gl_relocs);
-
-               nr_attributes = state->addr & 0x7;
-               if (nr_attributes == 0)
-                       nr_attributes = 8;
-               packet_size = gl_shader_rec_size(state->addr);
-       }
-       nr_relocs = nr_fixed_relocs + nr_attributes;
+       nr_attributes = state->addr & 0x7;
+       if (nr_attributes == 0)
+               nr_attributes = 8;
+       packet_size = gl_shader_rec_size(state->addr);
 
+       nr_relocs = ARRAY_SIZE(shader_reloc_offsets) + nr_attributes;
        if (nr_relocs * 4 > exec->shader_rec_size) {
                DRM_ERROR("overflowed shader recs reading %d handles "
                          "from %d bytes left\n",
@@ -1034,80 +780,99 @@ validate_shader_rec(struct drm_device *dev,
        exec->shader_rec_v += roundup(packet_size, 16);
        exec->shader_rec_size -= packet_size;
 
-       for (i = 0; i < nr_relocs; i++) {
-               enum vc4_bo_mode mode;
+       for (i = 0; i < shader_reloc_count; i++) {
+               if (src_handles[i] > exec->bo_count) {
+                       DRM_ERROR("Shader handle %d too big\n", src_handles[i]);
+                       return -EINVAL;
+               }
 
-               if (i < nr_fixed_relocs && relocs[i].type == RELOC_CODE)
-                       mode = VC4_MODE_SHADER;
-               else
-                       mode = VC4_MODE_RENDER;
+               bo[i] = exec->bo[src_handles[i]];
+               if (!bo[i])
+                       return -EINVAL;
+       }
+       for (i = shader_reloc_count; i < nr_relocs; i++) {
+               bo[i] = vc4_use_bo(exec, src_handles[i]);
+               if (!bo[i])
+                       return -EINVAL;
+       }
 
-               if (!vc4_use_bo(exec, src_handles[i], mode, &bo[i])) {
-                       return false;
-               }
+       if (((*(uint16_t *)pkt_u & VC4_SHADER_FLAG_FS_SINGLE_THREAD) == 0) !=
+           to_vc4_bo(&bo[0]->base)->validated_shader->is_threaded) {
+               DRM_ERROR("Thread mode of CL and FS do not match\n");
+               return -EINVAL;
+       }
+
+       if (to_vc4_bo(&bo[1]->base)->validated_shader->is_threaded ||
+           to_vc4_bo(&bo[2]->base)->validated_shader->is_threaded) {
+               DRM_ERROR("cs and vs cannot be threaded\n");
+               return -EINVAL;
        }
 
-       for (i = 0; i < nr_fixed_relocs; i++) {
-               uint32_t o = relocs[i].offset;
+       for (i = 0; i < shader_reloc_count; i++) {
+               struct vc4_validated_shader_info *validated_shader;
+               uint32_t o = shader_reloc_offsets[i];
                uint32_t src_offset = *(uint32_t *)(pkt_u + o);
                uint32_t *texture_handles_u;
                void *uniform_data_u;
-               uint32_t tex;
+               uint32_t tex, uni;
 
                *(uint32_t *)(pkt_v + o) = bo[i]->paddr + src_offset;
 
-               switch (relocs[i].type) {
-               case RELOC_CODE:
-                       if (src_offset != 0) {
-                               DRM_ERROR("Shaders must be at offset 0 of "
-                                         "the BO.\n");
-                               goto fail;
-                       }
-
-                       kfree(validated_shader);
-                       validated_shader = vc4_validate_shader(bo[i]);
-                       if (!validated_shader)
-                               goto fail;
+               if (src_offset != 0) {
+                       DRM_ERROR("Shaders must be at offset 0 of "
+                                 "the BO.\n");
+                       return -EINVAL;
+               }
 
-                       if (validated_shader->uniforms_src_size >
-                           exec->uniforms_size) {
-                               DRM_ERROR("Uniforms src buffer overflow\n");
-                               goto fail;
-                       }
+               validated_shader = to_vc4_bo(&bo[i]->base)->validated_shader;
+               if (!validated_shader)
+                       return -EINVAL;
 
-                       texture_handles_u = exec->uniforms_u;
-                       uniform_data_u = (texture_handles_u +
-                                         validated_shader->num_texture_samples);
-
-                       memcpy(exec->uniforms_v, uniform_data_u,
-                              validated_shader->uniforms_size);
-
-                       for (tex = 0;
-                            tex < validated_shader->num_texture_samples;
-                            tex++) {
-                               if (!reloc_tex(exec,
-                                              uniform_data_u,
-                                              &validated_shader->texture_samples[tex],
-                                              texture_handles_u[tex])) {
-                                       goto fail;
-                               }
-                       }
+               if (validated_shader->uniforms_src_size >
+                   exec->uniforms_size) {
+                       DRM_ERROR("Uniforms src buffer overflow\n");
+                       return -EINVAL;
+               }
 
-                       *(uint32_t *)(pkt_v + o + 4) = exec->uniforms_p;
+               texture_handles_u = exec->uniforms_u;
+               uniform_data_u = (texture_handles_u +
+                                 validated_shader->num_texture_samples);
 
-                       exec->uniforms_u += validated_shader->uniforms_src_size;
-                       exec->uniforms_v += validated_shader->uniforms_size;
-                       exec->uniforms_p += validated_shader->uniforms_size;
+               memcpy(exec->uniforms_v, uniform_data_u,
+                      validated_shader->uniforms_size);
 
-                       break;
+               for (tex = 0;
+                    tex < validated_shader->num_texture_samples;
+                    tex++) {
+                       if (!reloc_tex(exec,
+                                      uniform_data_u,
+                                      &validated_shader->texture_samples[tex],
+                                      texture_handles_u[tex])) {
+                               return -EINVAL;
+                       }
+               }
 
-               case RELOC_VBO:
-                       break;
+               /* Fill in the uniform slots that need this shader's
+                * start-of-uniforms address (used for resetting the uniform
+                * stream in the presence of control flow).
+                */
+               for (uni = 0;
+                    uni < validated_shader->num_uniform_addr_offsets;
+                    uni++) {
+                       uint32_t o = validated_shader->uniform_addr_offsets[uni];
+                       ((uint32_t *)exec->uniforms_v)[o] = exec->uniforms_p;
                }
+
+               *(uint32_t *)(pkt_v + o + 4) = exec->uniforms_p;
+
+               exec->uniforms_u += validated_shader->uniforms_src_size;
+               exec->uniforms_v += validated_shader->uniforms_size;
+               exec->uniforms_p += validated_shader->uniforms_size;
        }
 
        for (i = 0; i < nr_attributes; i++) {
-               struct drm_gem_cma_object *vbo = bo[nr_fixed_relocs + i];
+               struct drm_gem_cma_object *vbo =
+                       bo[ARRAY_SIZE(shader_reloc_offsets) + i];
                uint32_t o = 36 + i * 8;
                uint32_t offset = *(uint32_t *)(pkt_u + o + 0);
                uint32_t attr_size = *(uint8_t *)(pkt_u + o + 4) + 1;
@@ -1119,7 +884,7 @@ validate_shader_rec(struct drm_device *dev,
 
                if (vbo->base.size < offset ||
                    vbo->base.size - offset < attr_size) {
-                       DRM_ERROR("BO offset overflow (%d + %d > %d)\n",
+                       DRM_ERROR("BO offset overflow (%d + %d > %zd)\n",
                                  offset, attr_size, vbo->base.size);
                        return -EINVAL;
                }
@@ -1128,7 +893,8 @@ validate_shader_rec(struct drm_device *dev,
                        max_index = ((vbo->base.size - offset - attr_size) /
                                     stride);
                        if (state->max_index > max_index) {
-                               DRM_ERROR("primitives use index %d out of supplied %d\n",
+                               DRM_ERROR("primitives use index %d out of "
+                                         "supplied %d\n",
                                          state->max_index, max_index);
                                return -EINVAL;
                        }
@@ -1137,13 +903,7 @@ validate_shader_rec(struct drm_device *dev,
                *(uint32_t *)(pkt_v + o) = vbo->paddr + offset;
        }
 
-       kfree(validated_shader);
-
        return 0;
-
-fail:
-       kfree(validated_shader);
-       return -EINVAL;
 }
 
 int
@@ -1154,7 +914,7 @@ vc4_validate_shader_recs(struct drm_device *dev,
        int ret = 0;
 
        for (i = 0; i < exec->shader_state_count; i++) {
-               ret = validate_shader_rec(dev, exec, &exec->shader_state[i]);
+               ret = validate_gl_shader_rec(dev, exec, &exec->shader_state[i]);
                if (ret)
                        return ret;
        }