#include "vc4_simulator_validate.h"
-enum vc4_bo_mode {
- VC4_MODE_UNDECIDED,
- VC4_MODE_RENDER,
- VC4_MODE_SHADER,
-};
-
-struct vc4_bo_exec_state {
- struct drm_gem_cma_object *bo;
- enum vc4_bo_mode mode;
-};
-
struct vc4_exec_info {
/* Sequence number for this bin/render job. */
uint64_t seqno;
/* This is the array of BOs that were looked up at the start of exec.
* Command validation will use indices into this array.
*/
- struct vc4_bo_exec_state *bo;
+ struct drm_gem_cma_object **bo;
uint32_t bo_count;
/* List of other BOs used in the job that need to be released
vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec,
- uint32_t hindex,
- enum vc4_bo_mode mode);
+ uint32_t hindex);
int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec);
}
struct drm_gem_cma_object *
-vc4_use_bo(struct vc4_exec_info *exec,
- uint32_t hindex,
- enum vc4_bo_mode mode)
+vc4_use_bo(struct vc4_exec_info *exec, uint32_t hindex)
{
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 NULL;
}
- obj = exec->bo[hindex].bo;
+ 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 NULL;
- }
+ if (bo->validated_shader) {
+ DRM_ERROR("Trying to use shader BO as something other than "
+ "a shader\n");
+ return NULL;
}
return obj;
}
static struct drm_gem_cma_object *
-vc4_use_handle(struct vc4_exec_info *exec,
- uint32_t gem_handles_packet_index,
- enum vc4_bo_mode mode)
+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], mode);
+ return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index]);
}
static bool
if (max_index > shader_state->max_index)
shader_state->max_index = max_index;
- ib = vc4_use_handle(exec, 0, VC4_MODE_RENDER);
+ ib = vc4_use_handle(exec, 0);
if (!ib)
return -EINVAL;
uint32_t cube_map_stride = 0;
enum vc4_texture_data_type type;
- tex = vc4_use_bo(exec, texture_handle_index, VC4_MODE_RENDER);
+ tex = vc4_use_bo(exec, texture_handle_index);
if (!tex)
return false;
exec->shader_rec_size -= packet_size;
for (i = 0; i < shader_reloc_count; i++) {
- bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_SHADER);
+ if (src_handles[i] > exec->bo_count) {
+ DRM_ERROR("Shader handle %d too big\n", src_handles[i]);
+ return false;
+ }
+
+ bo[i] = exec->bo[src_handles[i]];
if (!bo[i])
return false;
}
for (i = shader_reloc_count; i < nr_relocs; i++) {
- bo[i] = vc4_use_bo(exec, src_handles[i], VC4_MODE_RENDER);
+ bo[i] = vc4_use_bo(exec, src_handles[i]);
if (!bo[i])
return false;
}
struct vc4_bo **bos = vc4->bo_pointers.base;
exec->bo_count = args->bo_handle_count;
- exec->bo = calloc(exec->bo_count, sizeof(struct vc4_bo_exec_state));
+ exec->bo = calloc(exec->bo_count, sizeof(void *));
for (int i = 0; i < exec->bo_count; i++) {
struct vc4_bo *bo = bos[i];
struct drm_gem_cma_object *obj = vc4_wrap_bo_with_cma(dev, bo);
vc4_bo_map(bo);
memcpy(obj->vaddr, bo->map, bo->size);
- exec->bo[i].bo = obj;
+ exec->bo[i] = obj;
/* The kernel does this validation at shader create ioctl
* time.
vc4_simulator_unpin_bos(struct vc4_exec_info *exec)
{
for (int i = 0; i < exec->bo_count; i++) {
- struct drm_gem_cma_object *obj = exec->bo[i].bo;
+ struct drm_gem_cma_object *obj = exec->bo[i];
struct vc4_bo *bo = to_vc4_bo(&obj->base)->bo;
memcpy(bo->map, obj->vaddr, bo->size);