@@ -1029,26 +1029,51 @@ r535_gsp_rpc_unloading_guest_driver(struct nvkm_gsp *gsp, bool suspend)
10291029 return nvkm_gsp_rpc_wr (gsp , rpc , true);
10301030}
10311031
1032+ /* dword only */
1033+ struct nv_gsp_registry_entries {
1034+ const char * name ;
1035+ u32 value ;
1036+ };
1037+
1038+ static const struct nv_gsp_registry_entries r535_registry_entries [] = {
1039+ { "RMSecBusResetEnable" , 1 },
1040+ { "RMForcePcieConfigSave" , 1 },
1041+ };
1042+ #define NV_GSP_REG_NUM_ENTRIES ARRAY_SIZE(r535_registry_entries)
1043+
10321044static int
10331045r535_gsp_rpc_set_registry (struct nvkm_gsp * gsp )
10341046{
10351047 PACKED_REGISTRY_TABLE * rpc ;
10361048 char * strings ;
1049+ int str_offset ;
1050+ int i ;
1051+ size_t rpc_size = sizeof (* rpc ) + sizeof (rpc -> entries [0 ]) * NV_GSP_REG_NUM_ENTRIES ;
1052+
1053+ /* add strings + null terminator */
1054+ for (i = 0 ; i < NV_GSP_REG_NUM_ENTRIES ; i ++ )
1055+ rpc_size += strlen (r535_registry_entries [i ].name ) + 1 ;
10371056
1038- rpc = nvkm_gsp_rpc_get (gsp , NV_VGPU_MSG_FUNCTION_SET_REGISTRY ,
1039- sizeof (* rpc ) + sizeof (rpc -> entries [0 ]) + 1 );
1057+ rpc = nvkm_gsp_rpc_get (gsp , NV_VGPU_MSG_FUNCTION_SET_REGISTRY , rpc_size );
10401058 if (IS_ERR (rpc ))
10411059 return PTR_ERR (rpc );
10421060
10431061 rpc -> size = sizeof (* rpc );
1044- rpc -> numEntries = 1 ;
1045- rpc -> entries [0 ].nameOffset = offsetof(typeof (* rpc ), entries [1 ]);
1046- rpc -> entries [0 ].type = 1 ;
1047- rpc -> entries [0 ].data = 0 ;
1048- rpc -> entries [0 ].length = 4 ;
1049-
1050- strings = (char * )& rpc -> entries [1 ];
1051- strings [0 ] = '\0' ;
1062+ rpc -> numEntries = NV_GSP_REG_NUM_ENTRIES ;
1063+
1064+ str_offset = offsetof(typeof (* rpc ), entries [NV_GSP_REG_NUM_ENTRIES ]);
1065+ strings = (char * )& rpc -> entries [NV_GSP_REG_NUM_ENTRIES ];
1066+ for (i = 0 ; i < NV_GSP_REG_NUM_ENTRIES ; i ++ ) {
1067+ int name_len = strlen (r535_registry_entries [i ].name ) + 1 ;
1068+
1069+ rpc -> entries [i ].nameOffset = str_offset ;
1070+ rpc -> entries [i ].type = 1 ;
1071+ rpc -> entries [i ].data = r535_registry_entries [i ].value ;
1072+ rpc -> entries [i ].length = 4 ;
1073+ memcpy (strings , r535_registry_entries [i ].name , name_len );
1074+ strings += name_len ;
1075+ str_offset += name_len ;
1076+ }
10521077
10531078 return nvkm_gsp_rpc_wr (gsp , rpc , false);
10541079}
0 commit comments