diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index 6dcde37..0ecd3c8 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c @@ -8516,6 +8516,7 @@ int cik_resume(struct radeon_device *rdev) radeon_pm_resume(rdev); rdev->accel_working = true; + radeon_gart_table_gtt_unpin(rdev); r = cik_startup(rdev); if (r) { DRM_ERROR("cik startup failed on resume\n"); @@ -8552,6 +8553,7 @@ int cik_suspend(struct radeon_device *rdev) cik_irq_suspend(rdev); radeon_wb_disable(rdev); cik_pcie_gart_disable(rdev); + radeon_gart_table_gtt_pin(rdev); return 0; } diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index 85995b4..710c1e0 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c @@ -5318,6 +5318,7 @@ int evergreen_resume(struct radeon_device *rdev) radeon_pm_resume(rdev); rdev->accel_working = true; + radeon_gart_table_gtt_unpin(rdev); r = evergreen_startup(rdev); if (r) { DRM_ERROR("evergreen startup failed on resume\n"); @@ -5340,6 +5341,7 @@ int evergreen_suspend(struct radeon_device *rdev) evergreen_irq_suspend(rdev); radeon_wb_disable(rdev); evergreen_pcie_gart_disable(rdev); + radeon_gart_table_gtt_pin(rdev); return 0; } diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 54529b8..f9dd0cf 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -653,6 +653,8 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev); void radeon_gart_table_ram_free(struct radeon_device *rdev); int radeon_gart_table_vram_alloc(struct radeon_device *rdev); void radeon_gart_table_vram_free(struct radeon_device *rdev); +int radeon_gart_table_gtt_pin(struct radeon_device *rdev); +void radeon_gart_table_gtt_unpin(struct radeon_device *rdev); int radeon_gart_table_vram_pin(struct radeon_device *rdev); void radeon_gart_table_vram_unpin(struct radeon_device *rdev); int radeon_gart_init(struct radeon_device *rdev); diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 84146d5..b086b70 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -136,6 +136,41 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev) return 0; } +int radeon_gart_table_gtt_pin(struct radeon_device *rdev) +{ + int r; + + r = radeon_bo_reserve(rdev->gart.robj, false); + if (unlikely(r != 0)) + return r; + r = radeon_bo_pin(rdev->gart.robj, RADEON_GEM_DOMAIN_GTT, NULL); + if (r) { + radeon_bo_unreserve(rdev->gart.robj); + return r; + } + r = radeon_bo_kmap(rdev->gart.robj, &rdev->gart.ptr); + if (r) + radeon_bo_unpin(rdev->gart.robj); + radeon_bo_unreserve(rdev->gart.robj); + return r; +} + +void radeon_gart_table_gtt_unpin(struct radeon_device *rdev) +{ + int r; + + if (rdev->gart.ptr == NULL) { + return; + } + r = radeon_bo_reserve(rdev->gart.robj, false); + if (likely(r == 0)) { + radeon_bo_kunmap(rdev->gart.robj); + radeon_bo_unpin(rdev->gart.robj); + radeon_bo_unreserve(rdev->gart.robj); + rdev->gart.ptr = NULL; + } +} + /** * radeon_gart_table_vram_pin - pin gart page table in vram * @@ -245,7 +280,8 @@ void radeon_gart_unbind(struct radeon_device *rdev, unsigned offset, if (rdev->gart.ptr) { radeon_gart_set_page(rdev, t, page_base, RADEON_GART_PAGE_DUMMY); - } + } else + WARN_ONCE(1, "rdev->gart.ptr NULL for unbind"); page_base += RADEON_GPU_PAGE_SIZE; } } @@ -293,7 +329,8 @@ int radeon_gart_bind(struct radeon_device *rdev, unsigned offset, radeon_gart_set_page(rdev, t, page_base, flags); page_base += RADEON_GPU_PAGE_SIZE; } - } + } else + WARN_ONCE(1, "rdev->gart.ptr NULL for bind"); } mb(); radeon_gart_tlb_flush(rdev);