Skip to content

Commit f9e5f51

Browse files
Asad Kamalalexdeucher
authored andcommitted
drm/amdgpu: fix aperture iounmap skipped on device removal
amdgpu_pci_remove() calls drm_dev_unplug() before invoking the fini routines. After drm_dev_unplug() the drm_dev_enter() guard in amdgpu_ttm_fini() always returns false, so iounmap() for aper_base_kaddr is silently skipped. On connected_to_cpu hardware ioremap_cache() maps the aperture as WB; when iounmap() is skipped the stale WB PAT entry persists. On reload IP discovery's memremap(MEMREMAP_WC) on the same aperture range hits a WB/WC conflict, producing an ioremap error and failing re-probe. Remove the drm_dev_enter() guard and call iounmap() unconditionally. The aperture mapping is plain MMIO and does not require device-presence protection. Surprise-removal cleanup of aper_base_kaddr is already handled unconditionally by amdgpu_device_unmap_mmio(). Fixes: 62d5f9f ("drm/amdgpu: Unmap MMIO mappings when device is not unplugged") Signed-off-by: Asad Kamal <asad.kamal@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit fb3f68a) Cc: stable@vger.kernel.org
1 parent 3141e3d commit f9e5f51

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,8 +2259,6 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
22592259
*/
22602260
void amdgpu_ttm_fini(struct amdgpu_device *adev)
22612261
{
2262-
int idx;
2263-
22642262
if (!adev->mman.initialized)
22652263
return;
22662264

@@ -2283,13 +2281,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
22832281
amdgpu_ttm_unmark_vram_reserved(adev, AMDGPU_RESV_FW_VRAM_USAGE);
22842282
amdgpu_ttm_unmark_vram_reserved(adev, AMDGPU_RESV_DRV_VRAM_USAGE);
22852283

2286-
if (drm_dev_enter(adev_to_drm(adev), &idx)) {
2287-
2288-
if (adev->mman.aper_base_kaddr)
2289-
iounmap(adev->mman.aper_base_kaddr);
2284+
if (adev->mman.aper_base_kaddr) {
2285+
iounmap(adev->mman.aper_base_kaddr);
22902286
adev->mman.aper_base_kaddr = NULL;
2291-
2292-
drm_dev_exit(idx);
22932287
}
22942288

22952289
if (!adev->gmc.is_app_apu)

0 commit comments

Comments
 (0)