@@ -552,7 +552,7 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,
552552}
553553
554554/**
555- * amdgpu_mm_wreg_mmio_rlc - write register either with mmio or with RLC path if in range
555+ * amdgpu_mm_wreg_mmio_rlc - write register either with direct/indirect mmio or with RLC path if in range
556556 *
557557 * this function is invoked only the debugfs register access
558558 */
@@ -567,6 +567,8 @@ void amdgpu_mm_wreg_mmio_rlc(struct amdgpu_device *adev,
567567 adev -> gfx .rlc .funcs -> is_rlcg_access_range ) {
568568 if (adev -> gfx .rlc .funcs -> is_rlcg_access_range (adev , reg ))
569569 return adev -> gfx .rlc .funcs -> sriov_wreg (adev , reg , v , 0 , 0 );
570+ } else if ((reg * 4 ) >= adev -> rmmio_size ) {
571+ adev -> pcie_wreg (adev , reg * 4 , v );
570572 } else {
571573 writel (v , ((void __iomem * )adev -> rmmio ) + (reg * 4 ));
572574 }
@@ -1448,7 +1450,7 @@ static int amdgpu_device_init_apu_flags(struct amdgpu_device *adev)
14481450 adev -> apu_flags |= AMD_APU_IS_CYAN_SKILLFISH2 ;
14491451 break ;
14501452 default :
1451- return - EINVAL ;
1453+ break ;
14521454 }
14531455
14541456 return 0 ;
@@ -3496,9 +3498,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
34963498 mutex_init (& adev -> psp .mutex );
34973499 mutex_init (& adev -> notifier_lock );
34983500
3499- r = amdgpu_device_init_apu_flags (adev );
3500- if (r )
3501- return r ;
3501+ amdgpu_device_init_apu_flags (adev );
35023502
35033503 r = amdgpu_device_check_arguments (adev );
35043504 if (r )
@@ -3833,6 +3833,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
38333833
38343834static void amdgpu_device_unmap_mmio (struct amdgpu_device * adev )
38353835{
3836+
38363837 /* Clear all CPU mappings pointing to this device */
38373838 unmap_mapping_range (adev -> ddev .anon_inode -> i_mapping , 0 , 0 , 1 );
38383839
@@ -3913,6 +3914,8 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
39133914
39143915void amdgpu_device_fini_sw (struct amdgpu_device * adev )
39153916{
3917+ int idx ;
3918+
39163919 amdgpu_fence_driver_sw_fini (adev );
39173920 amdgpu_device_ip_fini (adev );
39183921 release_firmware (adev -> firmware .gpu_info_fw );
@@ -3937,6 +3940,14 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
39373940 if ((adev -> pdev -> class >> 8 ) == PCI_CLASS_DISPLAY_VGA )
39383941 vga_client_unregister (adev -> pdev );
39393942
3943+ if (drm_dev_enter (adev_to_drm (adev ), & idx )) {
3944+
3945+ iounmap (adev -> rmmio );
3946+ adev -> rmmio = NULL ;
3947+ amdgpu_device_doorbell_fini (adev );
3948+ drm_dev_exit (idx );
3949+ }
3950+
39403951 if (IS_ENABLED (CONFIG_PERF_EVENTS ))
39413952 amdgpu_pmu_fini (adev );
39423953 if (adev -> mman .discovery_bin )
@@ -3957,8 +3968,8 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
39573968 */
39583969static void amdgpu_device_evict_resources (struct amdgpu_device * adev )
39593970{
3960- /* No need to evict vram on APUs for suspend to ram */
3961- if (adev -> in_s3 && (adev -> flags & AMD_IS_APU ))
3971+ /* No need to evict vram on APUs for suspend to ram or s2idle */
3972+ if (( adev -> in_s3 || adev -> in_s0ix ) && (adev -> flags & AMD_IS_APU ))
39623973 return ;
39633974
39643975 if (amdgpu_ttm_evict_resources (adev , TTM_PL_VRAM ))
@@ -4005,16 +4016,11 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
40054016 if (!adev -> in_s0ix )
40064017 amdgpu_amdkfd_suspend (adev , adev -> in_runpm );
40074018
4008- /* First evict vram memory */
40094019 amdgpu_device_evict_resources (adev );
40104020
40114021 amdgpu_fence_driver_hw_fini (adev );
40124022
40134023 amdgpu_device_ip_suspend_phase2 (adev );
4014- /* This second call to evict device resources is to evict
4015- * the gart page table using the CPU.
4016- */
4017- amdgpu_device_evict_resources (adev );
40184024
40194025 return 0 ;
40204026}
@@ -4359,8 +4365,6 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,
43594365 goto error ;
43604366
43614367 amdgpu_virt_init_data_exchange (adev );
4362- /* we need recover gart prior to run SMC/CP/SDMA resume */
4363- amdgpu_gtt_mgr_recover (ttm_manager_type (& adev -> mman .bdev , TTM_PL_TT ));
43644368
43654369 r = amdgpu_device_fw_loading (adev );
43664370 if (r )
@@ -4680,10 +4684,6 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
46804684 amdgpu_inc_vram_lost (tmp_adev );
46814685 }
46824686
4683- r = amdgpu_gtt_mgr_recover (ttm_manager_type (& tmp_adev -> mman .bdev , TTM_PL_TT ));
4684- if (r )
4685- goto out ;
4686-
46874687 r = amdgpu_device_fw_loading (tmp_adev );
46884688 if (r )
46894689 return r ;
0 commit comments