@@ -1164,8 +1164,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv,
11641164 }
11651165 vmw_bo_placement_set (vmw_bo , VMW_BO_DOMAIN_MOB , VMW_BO_DOMAIN_MOB );
11661166 ret = vmw_validation_add_bo (sw_context -> ctx , vmw_bo );
1167- ttm_bo_put (& vmw_bo -> tbo );
1168- drm_gem_object_put (& vmw_bo -> tbo .base );
1167+ vmw_user_bo_unref (vmw_bo );
11691168 if (unlikely (ret != 0 ))
11701169 return ret ;
11711170
@@ -1221,8 +1220,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv,
12211220 vmw_bo_placement_set (vmw_bo , VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM ,
12221221 VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM );
12231222 ret = vmw_validation_add_bo (sw_context -> ctx , vmw_bo );
1224- ttm_bo_put (& vmw_bo -> tbo );
1225- drm_gem_object_put (& vmw_bo -> tbo .base );
1223+ vmw_user_bo_unref (vmw_bo );
12261224 if (unlikely (ret != 0 ))
12271225 return ret ;
12281226
@@ -1992,7 +1990,7 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv,
19921990
19931991 cmd = container_of (header , typeof (* cmd ), header );
19941992
1995- if (cmd -> body .type >= SVGA3D_SHADERTYPE_PREDX_MAX ) {
1993+ if (! vmw_shadertype_is_valid ( VMW_SM_LEGACY , cmd -> body .type ) ) {
19961994 VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
19971995 (unsigned int ) cmd -> body .type );
19981996 return - EINVAL ;
@@ -2115,8 +2113,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
21152113 SVGA3dCmdHeader * header )
21162114{
21172115 VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetSingleConstantBuffer );
2118- SVGA3dShaderType max_shader_num = has_sm5_context (dev_priv ) ?
2119- SVGA3D_NUM_SHADERTYPE : SVGA3D_NUM_SHADERTYPE_DX10 ;
21202116
21212117 struct vmw_resource * res = NULL ;
21222118 struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
@@ -2133,6 +2129,14 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
21332129 if (unlikely (ret != 0 ))
21342130 return ret ;
21352131
2132+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type ) ||
2133+ cmd -> body .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2134+ VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2135+ (unsigned int ) cmd -> body .type ,
2136+ (unsigned int ) cmd -> body .slot );
2137+ return - EINVAL ;
2138+ }
2139+
21362140 binding .bi .ctx = ctx_node -> ctx ;
21372141 binding .bi .res = res ;
21382142 binding .bi .bt = vmw_ctx_binding_cb ;
@@ -2141,14 +2145,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
21412145 binding .size = cmd -> body .sizeInBytes ;
21422146 binding .slot = cmd -> body .slot ;
21432147
2144- if (binding .shader_slot >= max_shader_num ||
2145- binding .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2146- VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2147- (unsigned int ) cmd -> body .type ,
2148- (unsigned int ) binding .slot );
2149- return - EINVAL ;
2150- }
2151-
21522148 vmw_binding_add (ctx_node -> staged , & binding .bi , binding .shader_slot ,
21532149 binding .slot );
21542150
@@ -2207,15 +2203,13 @@ static int vmw_cmd_dx_set_shader_res(struct vmw_private *dev_priv,
22072203{
22082204 VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShaderResources ) =
22092205 container_of (header , typeof (* cmd ), header );
2210- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2211- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
22122206
22132207 u32 num_sr_view = (cmd -> header .size - sizeof (cmd -> body )) /
22142208 sizeof (SVGA3dShaderResourceViewId );
22152209
22162210 if ((u64 ) cmd -> body .startView + (u64 ) num_sr_view >
22172211 (u64 ) SVGA3D_DX_MAX_SRVIEWS ||
2218- cmd -> body .type >= max_allowed ) {
2212+ ! vmw_shadertype_is_valid ( dev_priv -> sm_type , cmd -> body .type ) ) {
22192213 VMW_DEBUG_USER ("Invalid shader binding.\n" );
22202214 return - EINVAL ;
22212215 }
@@ -2239,8 +2233,6 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
22392233 SVGA3dCmdHeader * header )
22402234{
22412235 VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShader );
2242- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2243- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
22442236 struct vmw_resource * res = NULL ;
22452237 struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
22462238 struct vmw_ctx_bindinfo_shader binding ;
@@ -2251,8 +2243,7 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
22512243
22522244 cmd = container_of (header , typeof (* cmd ), header );
22532245
2254- if (cmd -> body .type >= max_allowed ||
2255- cmd -> body .type < SVGA3D_SHADERTYPE_MIN ) {
2246+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type )) {
22562247 VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
22572248 (unsigned int ) cmd -> body .type );
22582249 return - EINVAL ;
0 commit comments