@@ -145,7 +145,7 @@ const char *amdgpu_asic_name[] = {
145
145
"LAST" ,
146
146
};
147
147
148
- #define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM - 1 , 0)
148
+ #define AMDGPU_IP_BLK_MASK_ALL GENMASK(AMDGPU_MAX_IP_NUM, 0)
149
149
/*
150
150
* Default init level where all blocks are expected to be initialized. This is
151
151
* the level of initialization expected by default and also after a full reset
@@ -3670,9 +3670,11 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
3670
3670
continue ;
3671
3671
3672
3672
r = block -> version -> funcs -> hw_init (& adev -> ip_blocks [i ]);
3673
- DRM_INFO ("RE-INIT-early: %s %s\n" , block -> version -> funcs -> name , r ?"failed" :"succeeded" );
3674
- if (r )
3673
+ if (r ) {
3674
+ dev_err (adev -> dev , "RE-INIT-early: %s failed\n" ,
3675
+ block -> version -> funcs -> name );
3675
3676
return r ;
3677
+ }
3676
3678
block -> status .hw = true;
3677
3679
}
3678
3680
}
@@ -3682,7 +3684,8 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
3682
3684
3683
3685
static int amdgpu_device_ip_reinit_late_sriov (struct amdgpu_device * adev )
3684
3686
{
3685
- int i , r ;
3687
+ struct amdgpu_ip_block * block ;
3688
+ int i , r = 0 ;
3686
3689
3687
3690
static enum amd_ip_block_type ip_order [] = {
3688
3691
AMD_IP_BLOCK_TYPE_SMC ,
@@ -3697,34 +3700,28 @@ static int amdgpu_device_ip_reinit_late_sriov(struct amdgpu_device *adev)
3697
3700
};
3698
3701
3699
3702
for (i = 0 ; i < ARRAY_SIZE (ip_order ); i ++ ) {
3700
- int j ;
3701
- struct amdgpu_ip_block * block ;
3702
-
3703
- for (j = 0 ; j < adev -> num_ip_blocks ; j ++ ) {
3704
- block = & adev -> ip_blocks [j ];
3703
+ block = amdgpu_device_ip_get_ip_block (adev , ip_order [i ]);
3705
3704
3706
- if (block -> version -> type != ip_order [i ] ||
3707
- !block -> status .valid ||
3708
- block -> status .hw )
3709
- continue ;
3705
+ if (!block )
3706
+ continue ;
3710
3707
3708
+ if (block -> status .valid && !block -> status .hw ) {
3711
3709
if (block -> version -> type == AMD_IP_BLOCK_TYPE_SMC ) {
3712
- r = amdgpu_ip_block_resume (& adev -> ip_blocks [i ]);
3713
- if (r )
3714
- return r ;
3710
+ r = amdgpu_ip_block_resume (block );
3715
3711
} else {
3716
- r = block -> version -> funcs -> hw_init (& adev -> ip_blocks [i ]);
3717
- if (r ) {
3718
- DRM_ERROR ("hw_init of IP block <%s> failed %d\n" ,
3719
- adev -> ip_blocks [i ].version -> funcs -> name , r );
3720
- return r ;
3721
- }
3722
- block -> status .hw = true;
3712
+ r = block -> version -> funcs -> hw_init (block );
3723
3713
}
3714
+
3715
+ if (r ) {
3716
+ dev_err (adev -> dev , "RE-INIT-late: %s failed\n" ,
3717
+ block -> version -> funcs -> name );
3718
+ break ;
3719
+ }
3720
+ block -> status .hw = true;
3724
3721
}
3725
3722
}
3726
3723
3727
- return 0 ;
3724
+ return r ;
3728
3725
}
3729
3726
3730
3727
/**
@@ -3765,7 +3762,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)
3765
3762
*
3766
3763
* @adev: amdgpu_device pointer
3767
3764
*
3768
- * First resume function for hardware IPs. The list of all the hardware
3765
+ * Second resume function for hardware IPs. The list of all the hardware
3769
3766
* IPs that make up the asic is walked and the resume callbacks are run for
3770
3767
* all blocks except COMMON, GMC, and IH. resume puts the hardware into a
3771
3768
* functional state after a suspend and updates the software state as
@@ -3783,6 +3780,7 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)
3783
3780
if (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_COMMON ||
3784
3781
adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_GMC ||
3785
3782
adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_IH ||
3783
+ adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_DCE ||
3786
3784
adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_PSP )
3787
3785
continue ;
3788
3786
r = amdgpu_ip_block_resume (& adev -> ip_blocks [i ]);
@@ -3793,6 +3791,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)
3793
3791
return 0 ;
3794
3792
}
3795
3793
3794
+ /**
3795
+ * amdgpu_device_ip_resume_phase3 - run resume for hardware IPs
3796
+ *
3797
+ * @adev: amdgpu_device pointer
3798
+ *
3799
+ * Third resume function for hardware IPs. The list of all the hardware
3800
+ * IPs that make up the asic is walked and the resume callbacks are run for
3801
+ * all DCE. resume puts the hardware into a functional state after a suspend
3802
+ * and updates the software state as necessary. This function is also used
3803
+ * for restoring the GPU after a GPU reset.
3804
+ *
3805
+ * Returns 0 on success, negative error code on failure.
3806
+ */
3807
+ static int amdgpu_device_ip_resume_phase3 (struct amdgpu_device * adev )
3808
+ {
3809
+ int i , r ;
3810
+
3811
+ for (i = 0 ; i < adev -> num_ip_blocks ; i ++ ) {
3812
+ if (!adev -> ip_blocks [i ].status .valid || adev -> ip_blocks [i ].status .hw )
3813
+ continue ;
3814
+ if (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_DCE ) {
3815
+ r = amdgpu_ip_block_resume (& adev -> ip_blocks [i ]);
3816
+ if (r )
3817
+ return r ;
3818
+ }
3819
+ }
3820
+
3821
+ return 0 ;
3822
+ }
3823
+
3796
3824
/**
3797
3825
* amdgpu_device_ip_resume - run resume for hardware IPs
3798
3826
*
@@ -3822,6 +3850,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)
3822
3850
if (adev -> mman .buffer_funcs_ring -> sched .ready )
3823
3851
amdgpu_ttm_set_buffer_funcs_status (adev , true);
3824
3852
3853
+ if (r )
3854
+ return r ;
3855
+
3856
+ amdgpu_fence_driver_hw_init (adev );
3857
+
3858
+ r = amdgpu_device_ip_resume_phase3 (adev );
3859
+
3825
3860
return r ;
3826
3861
}
3827
3862
@@ -4902,7 +4937,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
4902
4937
dev_err (adev -> dev , "amdgpu_device_ip_resume failed (%d).\n" , r );
4903
4938
goto exit ;
4904
4939
}
4905
- amdgpu_fence_driver_hw_init (adev );
4906
4940
4907
4941
if (!adev -> in_s0ix ) {
4908
4942
r = amdgpu_amdkfd_resume (adev , adev -> in_runpm );
@@ -5487,6 +5521,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)
5487
5521
if (tmp_adev -> mman .buffer_funcs_ring -> sched .ready )
5488
5522
amdgpu_ttm_set_buffer_funcs_status (tmp_adev , true);
5489
5523
5524
+ r = amdgpu_device_ip_resume_phase3 (tmp_adev );
5525
+ if (r )
5526
+ goto out ;
5527
+
5490
5528
if (vram_lost )
5491
5529
amdgpu_device_fill_reset_magic (tmp_adev );
5492
5530
0 commit comments