drm/vc4: Fix termination of the initial scan for branch targets.
Subsystems (3)
PATCH 1/2 drm/vc4: Fix termination of the initial scan for branch targets.
The loop is scanning until the original max_ip (size of the BO), but we want to not examine any code after the PROG_END's delay slots. There was a block trying to do that, except that we had some early continue statements if the signal wasn't a PROG_END or a BRANCH.
The failure mode would be that a valid shader is rejected because some undefined memory after the PROG_END slots is parsed as a branch and the rest of its setup is illegal. I haven't seen this in the wild, but valgrind was complaining when about this up in the userland simulator mode.
--- drivers/gpu/drm/vc4/vc4_validate_shaders.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/gpu/drm/vc4/vc4_validate_shaders.c +8 -11
@@ -608,9 +608,7 @@ static bool vc4_validate_branches(struct vc4_shader_validation_state *validation_state) {uint32_t max_branch_target =0 ; -bool found_shader_end = false;int ip; -int shader_end_ip =0 ;int last_branch =-2 ;for (ip =0 ; ip < validation_state->max_ip; ip++) {
@@ -621,8 +619,13 @@ vc4_validate_branches(struct vc4_shader_validation_state *validation_state)uint32_t branch_target_ip;if (sig ==QPU_SIG_PROG_END ) { - shader_end_ip = ip; - found_shader_end = true; +/* There are two delay slots after program end is +* signaled that are still executed, then we're +* finished. validation_state->max_ip is the +* instruction after the last valid instruction in the +* program. +*/ + validation_state->max_ip = ip +3 ;continue ; }
@@ -676,15 +679,9 @@ vc4_validate_branches(struct vc4_shader_validation_state *validation_state) }set_bit (after_delay_ip, validation_state->branch_targets); max_branch_target =max (max_branch_target, after_delay_ip); - -/* There are two delay slots after program end is signaled -* that are still executed, then we're finished. -*/ -if (found_shader_end && ip == shader_end_ip +2 ) -break ; } -if (max_branch_target > shader_end_ip) { +if (max_branch_target > validation_state->max_ip -3 ) {DRM_ERROR ("Branch landed after QPU_SIG_PROG_END" );return false; }
Signature · 1 line
2.10.1
PATCH 2/2 drm/vc4: Add support for rendering with ETC1 textures.
The validation for it ends up being quite simple, but I hadn't got around to it before merging the driver. For backwards compatibility, we also need to add a flag so that the userspace GL driver can easily tell if the kernel will allow ETC1 textures (on an old kernel, it will continue to convert to RGBA8)
--- drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_validate.c | 7 +++++++ include/uapi/drm/vc4_drm.h | 1 + 3 files changed, 9 insertions(+)
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
@@ -78,6 +78,7 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,pm_runtime_put (&vc4->v3d->pdev->dev);break ;case DRM_VC4_PARAM_SUPPORTS_BRANCHES : +case DRM_VC4_PARAM_SUPPORTS_ETC1 : args->value = true;break ;default :
drivers/gpu/drm/vc4/vc4_validate.c +7 -0
@@ -644,6 +644,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 :
include/uapi/drm/vc4_drm.h +1 -0
@@ -286,6 +286,7 @@ struct drm_vc4_get_hang_state {#define DRM_VC4_PARAM_V3D_IDENT1 1#define DRM_VC4_PARAM_V3D_IDENT2 2#define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3 +#define DRM_VC4_PARAM_SUPPORTS_ETC1 4struct drm_vc4_get_param {__u32 param;
Signature · 6 lines
2.10.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel