@@ -144,6 +144,50 @@ const char *amdgpu_asic_name[] = {
144
144
"LAST" ,
145
145
};
146
146
147
+ #define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1, 0)
148
+ /*
149
+ * Default init level where all blocks are expected to be initialized. This is
150
+ * the level of initialization expected by default and also after a full reset
151
+ * of the device.
152
+ */
153
+ struct amdgpu_init_level amdgpu_init_default = {
154
+ .level = AMDGPU_INIT_LEVEL_DEFAULT ,
155
+ .hwini_ip_block_mask = AMDGPU_IP_BLK_MASK_ALL ,
156
+ };
157
+
158
+ /*
159
+ * Minimal blocks needed to be initialized before a XGMI hive can be reset. This
160
+ * is used for cases like reset on initialization where the entire hive needs to
161
+ * be reset before first use.
162
+ */
163
+ struct amdgpu_init_level amdgpu_init_minimal_xgmi = {
164
+ .level = AMDGPU_INIT_LEVEL_MINIMAL_XGMI ,
165
+ .hwini_ip_block_mask =
166
+ BIT (AMD_IP_BLOCK_TYPE_GMC ) | BIT (AMD_IP_BLOCK_TYPE_SMC ) |
167
+ BIT (AMD_IP_BLOCK_TYPE_COMMON ) | BIT (AMD_IP_BLOCK_TYPE_IH )
168
+ };
169
+
170
+ static inline bool amdgpu_ip_member_of_hwini (struct amdgpu_device * adev ,
171
+ enum amd_ip_block_type block )
172
+ {
173
+ return (adev -> init_lvl -> hwini_ip_block_mask & (1U << block )) != 0 ;
174
+ }
175
+
176
+ void amdgpu_set_init_level (struct amdgpu_device * adev ,
177
+ enum amdgpu_init_lvl_id lvl )
178
+ {
179
+ switch (lvl ) {
180
+ case AMDGPU_INIT_LEVEL_MINIMAL_XGMI :
181
+ adev -> init_lvl = & amdgpu_init_minimal_xgmi ;
182
+ break ;
183
+ case AMDGPU_INIT_LEVEL_DEFAULT :
184
+ fallthrough ;
185
+ default :
186
+ adev -> init_lvl = & amdgpu_init_default ;
187
+ break ;
188
+ }
189
+ }
190
+
147
191
static inline void amdgpu_device_stop_pending_resets (struct amdgpu_device * adev );
148
192
149
193
/**
@@ -2655,6 +2699,9 @@ static int amdgpu_device_ip_hw_init_phase1(struct amdgpu_device *adev)
2655
2699
continue ;
2656
2700
if (adev -> ip_blocks [i ].status .hw )
2657
2701
continue ;
2702
+ if (!amdgpu_ip_member_of_hwini (
2703
+ adev , adev -> ip_blocks [i ].version -> type ))
2704
+ continue ;
2658
2705
if (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_COMMON ||
2659
2706
(amdgpu_sriov_vf (adev ) && (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_PSP )) ||
2660
2707
adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_IH ) {
@@ -2680,6 +2727,9 @@ static int amdgpu_device_ip_hw_init_phase2(struct amdgpu_device *adev)
2680
2727
continue ;
2681
2728
if (adev -> ip_blocks [i ].status .hw )
2682
2729
continue ;
2730
+ if (!amdgpu_ip_member_of_hwini (
2731
+ adev , adev -> ip_blocks [i ].version -> type ))
2732
+ continue ;
2683
2733
r = adev -> ip_blocks [i ].version -> funcs -> hw_init (adev );
2684
2734
if (r ) {
2685
2735
DRM_ERROR ("hw_init of IP block <%s> failed %d\n" ,
@@ -2703,6 +2753,10 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)
2703
2753
if (adev -> ip_blocks [i ].version -> type != AMD_IP_BLOCK_TYPE_PSP )
2704
2754
continue ;
2705
2755
2756
+ if (!amdgpu_ip_member_of_hwini (adev ,
2757
+ AMD_IP_BLOCK_TYPE_PSP ))
2758
+ break ;
2759
+
2706
2760
if (!adev -> ip_blocks [i ].status .sw )
2707
2761
continue ;
2708
2762
@@ -2825,6 +2879,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
2825
2879
}
2826
2880
adev -> ip_blocks [i ].status .sw = true;
2827
2881
2882
+ if (!amdgpu_ip_member_of_hwini (
2883
+ adev , adev -> ip_blocks [i ].version -> type ))
2884
+ continue ;
2885
+
2828
2886
if (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_COMMON ) {
2829
2887
/* need to do common hw init early so everything is set up for gmc */
2830
2888
r = adev -> ip_blocks [i ].version -> funcs -> hw_init ((void * )adev );
@@ -4215,6 +4273,12 @@ int amdgpu_device_init(struct amdgpu_device *adev,
4215
4273
4216
4274
amdgpu_device_set_mcbp (adev );
4217
4275
4276
+ /*
4277
+ * By default, use default mode where all blocks are expected to be
4278
+ * initialized. At present a 'swinit' of blocks is required to be
4279
+ * completed before the need for a different level is detected.
4280
+ */
4281
+ amdgpu_set_init_level (adev , AMDGPU_INIT_LEVEL_DEFAULT );
4218
4282
/* early init functions */
4219
4283
r = amdgpu_device_ip_early_init (adev );
4220
4284
if (r )
@@ -5414,6 +5478,8 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
5414
5478
}
5415
5479
5416
5480
list_for_each_entry (tmp_adev , device_list_handle , reset_list ) {
5481
+ /* After reset, it's default init level */
5482
+ amdgpu_set_init_level (tmp_adev , AMDGPU_INIT_LEVEL_DEFAULT );
5417
5483
if (need_full_reset ) {
5418
5484
/* post card */
5419
5485
amdgpu_ras_set_fed (tmp_adev , false);
0 commit comments