@@ -145,7 +145,7 @@ const char *amdgpu_asic_name[] = {
145145 "LAST" ,
146146};
147147
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)
149149/*
150150 * Default init level where all blocks are expected to be initialized. This is
151151 * 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)
36703670 continue ;
36713671
36723672 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 );
36753676 return r ;
3677+ }
36763678 block -> status .hw = true;
36773679 }
36783680 }
@@ -3682,7 +3684,8 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
36823684
36833685static int amdgpu_device_ip_reinit_late_sriov (struct amdgpu_device * adev )
36843686{
3685- int i , r ;
3687+ struct amdgpu_ip_block * block ;
3688+ int i , r = 0 ;
36863689
36873690 static enum amd_ip_block_type ip_order [] = {
36883691 AMD_IP_BLOCK_TYPE_SMC ,
@@ -3697,34 +3700,28 @@ static int amdgpu_device_ip_reinit_late_sriov(struct amdgpu_device *adev)
36973700 };
36983701
36993702 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 ]);
37053704
3706- if (block -> version -> type != ip_order [i ] ||
3707- !block -> status .valid ||
3708- block -> status .hw )
3709- continue ;
3705+ if (!block )
3706+ continue ;
37103707
3708+ if (block -> status .valid && !block -> status .hw ) {
37113709 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 );
37153711 } 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 );
37233713 }
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;
37243721 }
37253722 }
37263723
3727- return 0 ;
3724+ return r ;
37283725}
37293726
37303727/**
@@ -3765,7 +3762,7 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)
37653762 *
37663763 * @adev: amdgpu_device pointer
37673764 *
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
37693766 * IPs that make up the asic is walked and the resume callbacks are run for
37703767 * all blocks except COMMON, GMC, and IH. resume puts the hardware into a
37713768 * 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)
37833780 if (adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_COMMON ||
37843781 adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_GMC ||
37853782 adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_IH ||
3783+ adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_DCE ||
37863784 adev -> ip_blocks [i ].version -> type == AMD_IP_BLOCK_TYPE_PSP )
37873785 continue ;
37883786 r = amdgpu_ip_block_resume (& adev -> ip_blocks [i ]);
@@ -3793,6 +3791,36 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)
37933791 return 0 ;
37943792}
37953793
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+
37963824/**
37973825 * amdgpu_device_ip_resume - run resume for hardware IPs
37983826 *
@@ -3822,6 +3850,13 @@ static int amdgpu_device_ip_resume(struct amdgpu_device *adev)
38223850 if (adev -> mman .buffer_funcs_ring -> sched .ready )
38233851 amdgpu_ttm_set_buffer_funcs_status (adev , true);
38243852
3853+ if (r )
3854+ return r ;
3855+
3856+ amdgpu_fence_driver_hw_init (adev );
3857+
3858+ r = amdgpu_device_ip_resume_phase3 (adev );
3859+
38253860 return r ;
38263861}
38273862
@@ -4902,7 +4937,6 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
49024937 dev_err (adev -> dev , "amdgpu_device_ip_resume failed (%d).\n" , r );
49034938 goto exit ;
49044939 }
4905- amdgpu_fence_driver_hw_init (adev );
49064940
49074941 if (!adev -> in_s0ix ) {
49084942 r = amdgpu_amdkfd_resume (adev , adev -> in_runpm );
@@ -5487,6 +5521,10 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)
54875521 if (tmp_adev -> mman .buffer_funcs_ring -> sched .ready )
54885522 amdgpu_ttm_set_buffer_funcs_status (tmp_adev , true);
54895523
5524+ r = amdgpu_device_ip_resume_phase3 (tmp_adev );
5525+ if (r )
5526+ goto out ;
5527+
54905528 if (vram_lost )
54915529 amdgpu_device_fill_reset_magic (tmp_adev );
54925530
0 commit comments