summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_drv.h16
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_render_cl.c4
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_validate.c39
-rw-r--r--src/gallium/drivers/vc4/vc4_simulator.c6
4 files changed, 26 insertions, 39 deletions
diff --git a/src/gallium/drivers/vc4/kernel/vc4_drv.h b/src/gallium/drivers/vc4/kernel/vc4_drv.h
index 127a366fb3c..ffc973735ae 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_drv.h
+++ b/src/gallium/drivers/vc4/kernel/vc4_drv.h
@@ -26,17 +26,6 @@
#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;
@@ -47,7 +36,7 @@ struct vc4_exec_info {
/* 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
@@ -172,8 +161,7 @@ struct vc4_validated_shader_info *
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);
diff --git a/src/gallium/drivers/vc4/kernel/vc4_render_cl.c b/src/gallium/drivers/vc4/kernel/vc4_render_cl.c
index a0681042155..b827eb7e9e1 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_render_cl.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_render_cl.c
@@ -286,7 +286,7 @@ static int vc4_rcl_surface_setup(struct vc4_exec_info *exec,
if (surf->hindex == ~0)
return 0;
- *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER);
+ *obj = vc4_use_bo(exec, surf->hindex);
if (!*obj)
return -EINVAL;
@@ -366,7 +366,7 @@ vc4_rcl_ms_surface_setup(struct vc4_exec_info *exec,
if (surf->hindex == ~0)
return 0;
- *obj = vc4_use_bo(exec, surf->hindex, VC4_MODE_RENDER);
+ *obj = vc4_use_bo(exec, surf->hindex);
if (!*obj)
return -EINVAL;
diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c
index 49bb64838ea..e81dd9935ca 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_validate.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c
@@ -95,38 +95,32 @@ size_is_lt(uint32_t width, uint32_t height, int cpp)
}
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
@@ -270,7 +264,7 @@ validate_indexed_prim_list(VALIDATE_ARGS)
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;
@@ -588,7 +582,7 @@ reloc_tex(struct vc4_exec_info *exec,
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;
@@ -787,12 +781,17 @@ validate_gl_shader_rec(struct drm_device *dev,
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;
}
diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c
index 4097dce28a7..7cfd236349d 100644
--- a/src/gallium/drivers/vc4/vc4_simulator.c
+++ b/src/gallium/drivers/vc4/vc4_simulator.c
@@ -74,7 +74,7 @@ vc4_simulator_pin_bos(struct drm_device *dev, struct vc4_exec_info *exec)
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);
@@ -87,7 +87,7 @@ vc4_simulator_pin_bos(struct drm_device *dev, struct vc4_exec_info *exec)
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.
@@ -105,7 +105,7 @@ static int
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);