aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/vc4/kernel
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2015-02-23 06:48:34 +0000
committerEric Anholt <[email protected]>2015-02-24 13:49:12 +0000
commit49d3c6a8e63ead43fafb7d52e2c770a1320eb2ee (patch)
tree1a9455ef787340a7b82883863f8b68b79871b718 /src/gallium/drivers/vc4/kernel
parent1d1e820a6dce5e6fc8f67bd0f00e402645774e1b (diff)
vc4: Update to current kernel sources.
New BO create and mmap ioctls are added. The submit ABI gains a flags argument, and the pointers are fixed at 64-bit. Shaders are now fixed at the start of their BOs.
Diffstat (limited to 'src/gallium/drivers/vc4/kernel')
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_drv.h12
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_gem.c16
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_validate.c28
-rw-r--r--src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c16
4 files changed, 39 insertions, 33 deletions
diff --git a/src/gallium/drivers/vc4/kernel/vc4_drv.h b/src/gallium/drivers/vc4/kernel/vc4_drv.h
index 81ffa03a6fa..12a3ceff725 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_drv.h
+++ b/src/gallium/drivers/vc4/kernel/vc4_drv.h
@@ -39,7 +39,10 @@ struct vc4_bo_exec_state {
enum vc4_bo_mode mode;
};
-struct exec_info {
+struct vc4_exec_info {
+ /* Sequence number for this bin/render job. */
+ uint64_t seqno;
+
/* Kernel-space copy of the ioctl arguments */
struct drm_vc4_submit_cl *args;
@@ -159,13 +162,12 @@ vc4_validate_cl(struct drm_device *dev,
void *unvalidated,
uint32_t len,
bool is_bin,
- struct exec_info *exec);
+ struct vc4_exec_info *exec);
int
-vc4_validate_shader_recs(struct drm_device *dev, struct exec_info *exec);
+vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec);
struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_cma_object *shader_obj,
- uint32_t start_offset);
+vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
#endif /* VC4_DRV_H */
diff --git a/src/gallium/drivers/vc4/kernel/vc4_gem.c b/src/gallium/drivers/vc4/kernel/vc4_gem.c
index 1ea17aa4e8c..c9a75733d6d 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_gem.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_gem.c
@@ -26,7 +26,7 @@
#include "vc4_drv.h"
int
-vc4_cl_validate(struct drm_device *dev, struct exec_info *exec)
+vc4_cl_validate(struct drm_device *dev, struct vc4_exec_info *exec)
{
struct drm_vc4_submit_cl *args = exec->args;
void *temp = NULL;
@@ -72,26 +72,32 @@ vc4_cl_validate(struct drm_device *dev, struct exec_info *exec)
exec->shader_state = temp + exec_size;
exec->shader_state_size = args->shader_rec_count;
- ret = copy_from_user(bin, args->bin_cl, args->bin_cl_size);
+ ret = copy_from_user(bin,
+ (void __user *)(uintptr_t)args->bin_cl,
+ args->bin_cl_size);
if (ret) {
DRM_ERROR("Failed to copy in bin cl\n");
goto fail;
}
- ret = copy_from_user(render, args->render_cl, args->render_cl_size);
+ ret = copy_from_user(render,
+ (void __user *)(uintptr_t)args->render_cl,
+ args->render_cl_size);
if (ret) {
DRM_ERROR("Failed to copy in render cl\n");
goto fail;
}
- ret = copy_from_user(exec->shader_rec_u, args->shader_rec,
+ ret = copy_from_user(exec->shader_rec_u,
+ (void __user *)(uintptr_t)args->shader_rec,
args->shader_rec_size);
if (ret) {
DRM_ERROR("Failed to copy in shader recs\n");
goto fail;
}
- ret = copy_from_user(exec->uniforms_u, args->uniforms,
+ ret = copy_from_user(exec->uniforms_u,
+ (void __user *)(uintptr_t)args->uniforms,
args->uniforms_size);
if (ret) {
DRM_ERROR("Failed to copy in uniforms cl\n");
diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate.c b/src/gallium/drivers/vc4/kernel/vc4_validate.c
index ba6e46f2041..0691a8d769c 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_validate.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_validate.c
@@ -43,7 +43,7 @@
#include "vc4_packet.h"
#define VALIDATE_ARGS \
- struct exec_info *exec, \
+ struct vc4_exec_info *exec, \
void *validated, \
void *untrusted
@@ -95,7 +95,7 @@ size_is_lt(uint32_t width, uint32_t height, int cpp)
}
static bool
-vc4_use_bo(struct exec_info *exec,
+vc4_use_bo(struct vc4_exec_info *exec,
uint32_t hindex,
enum vc4_bo_mode mode,
struct drm_gem_cma_object **obj)
@@ -123,7 +123,7 @@ vc4_use_bo(struct exec_info *exec,
}
static bool
-vc4_use_handle(struct exec_info *exec,
+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)
@@ -148,7 +148,7 @@ gl_shader_rec_size(uint32_t pointer_bits)
}
static bool
-check_tex_size(struct exec_info *exec, struct drm_gem_cma_object *fbo,
+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)
{
@@ -657,7 +657,8 @@ static const struct cmd_info {
bool render;
uint16_t len;
const char *name;
- int (*func)(struct exec_info *exec, void *validated, void *untrusted);
+ 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 },
@@ -720,7 +721,7 @@ vc4_validate_cl(struct drm_device *dev,
void *unvalidated,
uint32_t len,
bool is_bin,
- struct exec_info *exec)
+ struct vc4_exec_info *exec)
{
uint32_t dst_offset = 0;
uint32_t src_offset = 0;
@@ -815,7 +816,7 @@ vc4_validate_cl(struct drm_device *dev,
}
static bool
-reloc_tex(struct exec_info *exec,
+reloc_tex(struct vc4_exec_info *exec,
void *uniform_data_u,
struct vc4_texture_sample_info *sample,
uint32_t texture_handle_index)
@@ -976,7 +977,7 @@ reloc_tex(struct exec_info *exec,
static int
validate_shader_rec(struct drm_device *dev,
- struct exec_info *exec,
+ struct vc4_exec_info *exec,
struct vc4_shader_state *state)
{
uint32_t *src_handles;
@@ -1073,9 +1074,14 @@ validate_shader_rec(struct drm_device *dev,
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],
- src_offset);
+ validated_shader = vc4_validate_shader(bo[i]);
if (!validated_shader)
goto fail;
@@ -1158,7 +1164,7 @@ fail:
int
vc4_validate_shader_recs(struct drm_device *dev,
- struct exec_info *exec)
+ struct vc4_exec_info *exec)
{
uint32_t i;
int ret = 0;
diff --git a/src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c b/src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c
index 48bc683da5c..e5a75c5f8c2 100644
--- a/src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c
+++ b/src/gallium/drivers/vc4/kernel/vc4_validate_shaders.c
@@ -368,8 +368,7 @@ check_instruction_reads(uint64_t inst,
}
struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_cma_object *shader_obj,
- uint32_t start_offset)
+vc4_validate_shader(struct drm_gem_cma_object *shader_obj)
{
bool found_shader_end = false;
int shader_end_ip = 0;
@@ -386,14 +385,8 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj,
for (i = 0; i < ARRAY_SIZE(validation_state.live_clamp_offsets); i++)
validation_state.live_clamp_offsets[i] = ~0;
- if (start_offset + sizeof(uint64_t) > shader_obj->base.size) {
- DRM_ERROR("shader starting at %d outside of BO sized %d\n",
- start_offset,
- shader_obj->base.size);
- return NULL;
- }
- shader = shader_obj->vaddr + start_offset;
- max_ip = (shader_obj->base.size - start_offset) / sizeof(uint64_t);
+ shader = shader_obj->vaddr;
+ max_ip = shader_obj->base.size / sizeof(uint64_t);
validated_shader = kcalloc(sizeof(*validated_shader), 1, GFP_KERNEL);
if (!validated_shader)
@@ -450,9 +443,8 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj,
}
if (ip == max_ip) {
- DRM_ERROR("shader starting at %d failed to terminate before "
+ DRM_ERROR("shader failed to terminate before "
"shader BO end at %d\n",
- start_offset,
shader_obj->base.size);
goto fail;
}