@@ -4907,28 +4907,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
49074907 * @data: data
49084908 *
49094909 * This function is called when the system is about to suspend or hibernate.
4910- * It is used to evict resources from the device before the system goes to
4911- * sleep while there is still access to swap .
4910+ * It is used to set the appropriate flags so that eviction can be optimized
4911+ * in the pm prepare callback .
49124912 */
49134913static int amdgpu_device_pm_notifier (struct notifier_block * nb , unsigned long mode ,
49144914 void * data )
49154915{
49164916 struct amdgpu_device * adev = container_of (nb , struct amdgpu_device , pm_nb );
4917- int r ;
49184917
49194918 switch (mode ) {
49204919 case PM_HIBERNATION_PREPARE :
49214920 adev -> in_s4 = true;
4922- fallthrough ;
4923- case PM_SUSPEND_PREPARE :
4924- r = amdgpu_device_evict_resources (adev );
4925- /*
4926- * This is considered non-fatal at this time because
4927- * amdgpu_device_prepare() will also fatally evict resources.
4928- * See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4929- */
4930- if (r )
4931- drm_warn (adev_to_drm (adev ), "Failed to evict resources, freeze active processes if problems occur: %d\n" , r );
4921+ break ;
4922+ case PM_POST_HIBERNATION :
4923+ adev -> in_s4 = false;
49324924 break ;
49334925 }
49344926
@@ -4949,15 +4941,13 @@ int amdgpu_device_prepare(struct drm_device *dev)
49494941 struct amdgpu_device * adev = drm_to_adev (dev );
49504942 int i , r ;
49514943
4952- amdgpu_choose_low_power_state (adev );
4953-
49544944 if (dev -> switch_power_state == DRM_SWITCH_POWER_OFF )
49554945 return 0 ;
49564946
49574947 /* Evict the majority of BOs before starting suspend sequence */
49584948 r = amdgpu_device_evict_resources (adev );
49594949 if (r )
4960- goto unprepare ;
4950+ return r ;
49614951
49624952 flush_delayed_work (& adev -> gfx .gfx_off_delay_work );
49634953
@@ -4968,15 +4958,10 @@ int amdgpu_device_prepare(struct drm_device *dev)
49684958 continue ;
49694959 r = adev -> ip_blocks [i ].version -> funcs -> prepare_suspend (& adev -> ip_blocks [i ]);
49704960 if (r )
4971- goto unprepare ;
4961+ return r ;
49724962 }
49734963
49744964 return 0 ;
4975-
4976- unprepare :
4977- adev -> in_s0ix = adev -> in_s3 = adev -> in_s4 = false;
4978-
4979- return r ;
49804965}
49814966
49824967/**
0 commit comments