diff options
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 19 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 58 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 23 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 7 |
15 files changed, 118 insertions, 69 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index c4a21c6428f5..62a778012fe0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1591,6 +1591,7 @@ struct amdgpu_uvd { | |||
1591 | struct amdgpu_bo *vcpu_bo; | 1591 | struct amdgpu_bo *vcpu_bo; |
1592 | void *cpu_addr; | 1592 | void *cpu_addr; |
1593 | uint64_t gpu_addr; | 1593 | uint64_t gpu_addr; |
1594 | void *saved_bo; | ||
1594 | atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; | 1595 | atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; |
1595 | struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; | 1596 | struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; |
1596 | struct delayed_work idle_work; | 1597 | struct delayed_work idle_work; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 7a4b101e10c6..6043dc7c3a94 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -816,10 +816,13 @@ static int amdgpu_cgs_get_active_displays_info(void *cgs_device, | |||
816 | struct drm_device *ddev = adev->ddev; | 816 | struct drm_device *ddev = adev->ddev; |
817 | struct drm_crtc *crtc; | 817 | struct drm_crtc *crtc; |
818 | uint32_t line_time_us, vblank_lines; | 818 | uint32_t line_time_us, vblank_lines; |
819 | struct cgs_mode_info *mode_info; | ||
819 | 820 | ||
820 | if (info == NULL) | 821 | if (info == NULL) |
821 | return -EINVAL; | 822 | return -EINVAL; |
822 | 823 | ||
824 | mode_info = info->mode_info; | ||
825 | |||
823 | if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { | 826 | if (adev->mode_info.num_crtc && adev->mode_info.mode_config_initialized) { |
824 | list_for_each_entry(crtc, | 827 | list_for_each_entry(crtc, |
825 | &ddev->mode_config.crtc_list, head) { | 828 | &ddev->mode_config.crtc_list, head) { |
@@ -828,7 +831,7 @@ static int amdgpu_cgs_get_active_displays_info(void *cgs_device, | |||
828 | info->active_display_mask |= (1 << amdgpu_crtc->crtc_id); | 831 | info->active_display_mask |= (1 << amdgpu_crtc->crtc_id); |
829 | info->display_count++; | 832 | info->display_count++; |
830 | } | 833 | } |
831 | if (info->mode_info != NULL && | 834 | if (mode_info != NULL && |
832 | crtc->enabled && amdgpu_crtc->enabled && | 835 | crtc->enabled && amdgpu_crtc->enabled && |
833 | amdgpu_crtc->hw_mode.clock) { | 836 | amdgpu_crtc->hw_mode.clock) { |
834 | line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) / | 837 | line_time_us = (amdgpu_crtc->hw_mode.crtc_htotal * 1000) / |
@@ -836,10 +839,10 @@ static int amdgpu_cgs_get_active_displays_info(void *cgs_device, | |||
836 | vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end - | 839 | vblank_lines = amdgpu_crtc->hw_mode.crtc_vblank_end - |
837 | amdgpu_crtc->hw_mode.crtc_vdisplay + | 840 | amdgpu_crtc->hw_mode.crtc_vdisplay + |
838 | (amdgpu_crtc->v_border * 2); | 841 | (amdgpu_crtc->v_border * 2); |
839 | info->mode_info->vblank_time_us = vblank_lines * line_time_us; | 842 | mode_info->vblank_time_us = vblank_lines * line_time_us; |
840 | info->mode_info->refresh_rate = drm_mode_vrefresh(&amdgpu_crtc->hw_mode); | 843 | mode_info->refresh_rate = drm_mode_vrefresh(&amdgpu_crtc->hw_mode); |
841 | info->mode_info->ref_clock = adev->clock.spll.reference_freq; | 844 | mode_info->ref_clock = adev->clock.spll.reference_freq; |
842 | info->mode_info++; | 845 | mode_info = NULL; |
843 | } | 846 | } |
844 | } | 847 | } |
845 | } | 848 | } |
@@ -847,6 +850,16 @@ static int amdgpu_cgs_get_active_displays_info(void *cgs_device, | |||
847 | return 0; | 850 | return 0; |
848 | } | 851 | } |
849 | 852 | ||
853 | |||
854 | static int amdgpu_cgs_notify_dpm_enabled(void *cgs_device, bool enabled) | ||
855 | { | ||
856 | CGS_FUNC_ADEV; | ||
857 | |||
858 | adev->pm.dpm_enabled = enabled; | ||
859 | |||
860 | return 0; | ||
861 | } | ||
862 | |||
850 | /** \brief evaluate acpi namespace object, handle or pathname must be valid | 863 | /** \brief evaluate acpi namespace object, handle or pathname must be valid |
851 | * \param cgs_device | 864 | * \param cgs_device |
852 | * \param info input/output arguments for the control method | 865 | * \param info input/output arguments for the control method |
@@ -1097,6 +1110,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { | |||
1097 | amdgpu_cgs_set_powergating_state, | 1110 | amdgpu_cgs_set_powergating_state, |
1098 | amdgpu_cgs_set_clockgating_state, | 1111 | amdgpu_cgs_set_clockgating_state, |
1099 | amdgpu_cgs_get_active_displays_info, | 1112 | amdgpu_cgs_get_active_displays_info, |
1113 | amdgpu_cgs_notify_dpm_enabled, | ||
1100 | amdgpu_cgs_call_acpi_method, | 1114 | amdgpu_cgs_call_acpi_method, |
1101 | amdgpu_cgs_query_system_info, | 1115 | amdgpu_cgs_query_system_info, |
1102 | }; | 1116 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index f0ed974bd4e0..3fb405b3a614 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | |||
@@ -57,7 +57,7 @@ static bool amdgpu_flip_handle_fence(struct amdgpu_flip_work *work, | |||
57 | if (!fence_add_callback(fence, &work->cb, amdgpu_flip_callback)) | 57 | if (!fence_add_callback(fence, &work->cb, amdgpu_flip_callback)) |
58 | return true; | 58 | return true; |
59 | 59 | ||
60 | fence_put(*f); | 60 | fence_put(fence); |
61 | return false; | 61 | return false; |
62 | } | 62 | } |
63 | 63 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 4303b447efe8..d81f1f4883a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
@@ -121,7 +121,7 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct fence **f) | |||
121 | { | 121 | { |
122 | struct amdgpu_device *adev = ring->adev; | 122 | struct amdgpu_device *adev = ring->adev; |
123 | struct amdgpu_fence *fence; | 123 | struct amdgpu_fence *fence; |
124 | struct fence **ptr; | 124 | struct fence *old, **ptr; |
125 | uint32_t seq; | 125 | uint32_t seq; |
126 | 126 | ||
127 | fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL); | 127 | fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_KERNEL); |
@@ -141,7 +141,11 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct fence **f) | |||
141 | /* This function can't be called concurrently anyway, otherwise | 141 | /* This function can't be called concurrently anyway, otherwise |
142 | * emitting the fence would mess up the hardware ring buffer. | 142 | * emitting the fence would mess up the hardware ring buffer. |
143 | */ | 143 | */ |
144 | BUG_ON(rcu_dereference_protected(*ptr, 1)); | 144 | old = rcu_dereference_protected(*ptr, 1); |
145 | if (old && !fence_is_signaled(old)) { | ||
146 | DRM_INFO("rcu slot is busy\n"); | ||
147 | fence_wait(old, false); | ||
148 | } | ||
145 | 149 | ||
146 | rcu_assign_pointer(*ptr, fence_get(&fence->base)); | 150 | rcu_assign_pointer(*ptr, fence_get(&fence->base)); |
147 | 151 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index f594cfaa97e5..762cfdb85147 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | |||
@@ -219,6 +219,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev) | |||
219 | if (r) { | 219 | if (r) { |
220 | return r; | 220 | return r; |
221 | } | 221 | } |
222 | adev->ddev->vblank_disable_allowed = true; | ||
223 | |||
222 | /* enable msi */ | 224 | /* enable msi */ |
223 | adev->irq.msi_enabled = false; | 225 | adev->irq.msi_enabled = false; |
224 | 226 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 7805a8706af7..598eb0cd5aab 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | |||
@@ -382,6 +382,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file | |||
382 | struct drm_amdgpu_info_vram_gtt vram_gtt; | 382 | struct drm_amdgpu_info_vram_gtt vram_gtt; |
383 | 383 | ||
384 | vram_gtt.vram_size = adev->mc.real_vram_size; | 384 | vram_gtt.vram_size = adev->mc.real_vram_size; |
385 | vram_gtt.vram_size -= adev->vram_pin_size; | ||
385 | vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; | 386 | vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; |
386 | vram_gtt.vram_cpu_accessible_size -= adev->vram_pin_size; | 387 | vram_gtt.vram_cpu_accessible_size -= adev->vram_pin_size; |
387 | vram_gtt.gtt_size = adev->mc.gtt_size; | 388 | vram_gtt.gtt_size = adev->mc.gtt_size; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 151a2d42c639..5b6639faa731 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -476,6 +476,17 @@ int amdgpu_bo_evict_vram(struct amdgpu_device *adev) | |||
476 | return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM); | 476 | return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM); |
477 | } | 477 | } |
478 | 478 | ||
479 | static const char *amdgpu_vram_names[] = { | ||
480 | "UNKNOWN", | ||
481 | "GDDR1", | ||
482 | "DDR2", | ||
483 | "GDDR3", | ||
484 | "GDDR4", | ||
485 | "GDDR5", | ||
486 | "HBM", | ||
487 | "DDR3" | ||
488 | }; | ||
489 | |||
479 | int amdgpu_bo_init(struct amdgpu_device *adev) | 490 | int amdgpu_bo_init(struct amdgpu_device *adev) |
480 | { | 491 | { |
481 | /* Add an MTRR for the VRAM */ | 492 | /* Add an MTRR for the VRAM */ |
@@ -484,8 +495,8 @@ int amdgpu_bo_init(struct amdgpu_device *adev) | |||
484 | DRM_INFO("Detected VRAM RAM=%lluM, BAR=%lluM\n", | 495 | DRM_INFO("Detected VRAM RAM=%lluM, BAR=%lluM\n", |
485 | adev->mc.mc_vram_size >> 20, | 496 | adev->mc.mc_vram_size >> 20, |
486 | (unsigned long long)adev->mc.aper_size >> 20); | 497 | (unsigned long long)adev->mc.aper_size >> 20); |
487 | DRM_INFO("RAM width %dbits DDR\n", | 498 | DRM_INFO("RAM width %dbits %s\n", |
488 | adev->mc.vram_width); | 499 | adev->mc.vram_width, amdgpu_vram_names[adev->mc.vram_type]); |
489 | return amdgpu_ttm_init(adev); | 500 | return amdgpu_ttm_init(adev); |
490 | } | 501 | } |
491 | 502 | ||
@@ -608,6 +619,10 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) | |||
608 | if ((offset + size) <= adev->mc.visible_vram_size) | 619 | if ((offset + size) <= adev->mc.visible_vram_size) |
609 | return 0; | 620 | return 0; |
610 | 621 | ||
622 | /* Can't move a pinned BO to visible VRAM */ | ||
623 | if (abo->pin_count > 0) | ||
624 | return -EINVAL; | ||
625 | |||
611 | /* hurrah the memory is not visible ! */ | 626 | /* hurrah the memory is not visible ! */ |
612 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM); | 627 | amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM); |
613 | lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT; | 628 | lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c index 3cb6d6c413c7..e9c6ae6ed2f7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c | |||
@@ -143,7 +143,7 @@ static int amdgpu_pp_late_init(void *handle) | |||
143 | adev->powerplay.pp_handle); | 143 | adev->powerplay.pp_handle); |
144 | 144 | ||
145 | #ifdef CONFIG_DRM_AMD_POWERPLAY | 145 | #ifdef CONFIG_DRM_AMD_POWERPLAY |
146 | if (adev->pp_enabled) { | 146 | if (adev->pp_enabled && adev->pm.dpm_enabled) { |
147 | amdgpu_pm_sysfs_init(adev); | 147 | amdgpu_pm_sysfs_init(adev); |
148 | amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_COMPLETE_INIT, NULL, NULL); | 148 | amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_COMPLETE_INIT, NULL, NULL); |
149 | } | 149 | } |
@@ -161,12 +161,8 @@ static int amdgpu_pp_sw_init(void *handle) | |||
161 | adev->powerplay.pp_handle); | 161 | adev->powerplay.pp_handle); |
162 | 162 | ||
163 | #ifdef CONFIG_DRM_AMD_POWERPLAY | 163 | #ifdef CONFIG_DRM_AMD_POWERPLAY |
164 | if (adev->pp_enabled) { | 164 | if (adev->pp_enabled) |
165 | if (amdgpu_dpm == 0) | 165 | adev->pm.dpm_enabled = true; |
166 | adev->pm.dpm_enabled = false; | ||
167 | else | ||
168 | adev->pm.dpm_enabled = true; | ||
169 | } | ||
170 | #endif | 166 | #endif |
171 | 167 | ||
172 | return ret; | 168 | return ret; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index ab34190859a8..6f3369de232f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -384,9 +384,15 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, | |||
384 | struct ttm_mem_reg *new_mem) | 384 | struct ttm_mem_reg *new_mem) |
385 | { | 385 | { |
386 | struct amdgpu_device *adev; | 386 | struct amdgpu_device *adev; |
387 | struct amdgpu_bo *abo; | ||
387 | struct ttm_mem_reg *old_mem = &bo->mem; | 388 | struct ttm_mem_reg *old_mem = &bo->mem; |
388 | int r; | 389 | int r; |
389 | 390 | ||
391 | /* Can't move a pinned BO */ | ||
392 | abo = container_of(bo, struct amdgpu_bo, tbo); | ||
393 | if (WARN_ON_ONCE(abo->pin_count > 0)) | ||
394 | return -EINVAL; | ||
395 | |||
390 | adev = amdgpu_get_adev(bo->bdev); | 396 | adev = amdgpu_get_adev(bo->bdev); |
391 | if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) { | 397 | if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) { |
392 | amdgpu_move_null(bo, new_mem); | 398 | amdgpu_move_null(bo, new_mem); |
@@ -616,7 +622,7 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm) | |||
616 | set_page_dirty(page); | 622 | set_page_dirty(page); |
617 | 623 | ||
618 | mark_page_accessed(page); | 624 | mark_page_accessed(page); |
619 | page_cache_release(page); | 625 | put_page(page); |
620 | } | 626 | } |
621 | 627 | ||
622 | sg_free_table(ttm->sg); | 628 | sg_free_table(ttm->sg); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index c1a581044417..338da80006b6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | |||
@@ -241,32 +241,28 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) | |||
241 | 241 | ||
242 | int amdgpu_uvd_suspend(struct amdgpu_device *adev) | 242 | int amdgpu_uvd_suspend(struct amdgpu_device *adev) |
243 | { | 243 | { |
244 | struct amdgpu_ring *ring = &adev->uvd.ring; | 244 | unsigned size; |
245 | int i, r; | 245 | void *ptr; |
246 | int i; | ||
246 | 247 | ||
247 | if (adev->uvd.vcpu_bo == NULL) | 248 | if (adev->uvd.vcpu_bo == NULL) |
248 | return 0; | 249 | return 0; |
249 | 250 | ||
250 | for (i = 0; i < AMDGPU_MAX_UVD_HANDLES; ++i) { | 251 | for (i = 0; i < AMDGPU_MAX_UVD_HANDLES; ++i) |
251 | uint32_t handle = atomic_read(&adev->uvd.handles[i]); | 252 | if (atomic_read(&adev->uvd.handles[i])) |
252 | if (handle != 0) { | 253 | break; |
253 | struct fence *fence; | ||
254 | 254 | ||
255 | amdgpu_uvd_note_usage(adev); | 255 | if (i == AMDGPU_MAX_UVD_HANDLES) |
256 | return 0; | ||
256 | 257 | ||
257 | r = amdgpu_uvd_get_destroy_msg(ring, handle, false, &fence); | 258 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); |
258 | if (r) { | 259 | ptr = adev->uvd.cpu_addr; |
259 | DRM_ERROR("Error destroying UVD (%d)!\n", r); | ||
260 | continue; | ||
261 | } | ||
262 | 260 | ||
263 | fence_wait(fence, false); | 261 | adev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); |
264 | fence_put(fence); | 262 | if (!adev->uvd.saved_bo) |
263 | return -ENOMEM; | ||
265 | 264 | ||
266 | adev->uvd.filp[i] = NULL; | 265 | memcpy(adev->uvd.saved_bo, ptr, size); |
267 | atomic_set(&adev->uvd.handles[i], 0); | ||
268 | } | ||
269 | } | ||
270 | 266 | ||
271 | return 0; | 267 | return 0; |
272 | } | 268 | } |
@@ -275,23 +271,29 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) | |||
275 | { | 271 | { |
276 | unsigned size; | 272 | unsigned size; |
277 | void *ptr; | 273 | void *ptr; |
278 | const struct common_firmware_header *hdr; | ||
279 | unsigned offset; | ||
280 | 274 | ||
281 | if (adev->uvd.vcpu_bo == NULL) | 275 | if (adev->uvd.vcpu_bo == NULL) |
282 | return -EINVAL; | 276 | return -EINVAL; |
283 | 277 | ||
284 | hdr = (const struct common_firmware_header *)adev->uvd.fw->data; | ||
285 | offset = le32_to_cpu(hdr->ucode_array_offset_bytes); | ||
286 | memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset, | ||
287 | (adev->uvd.fw->size) - offset); | ||
288 | |||
289 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); | 278 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); |
290 | size -= le32_to_cpu(hdr->ucode_size_bytes); | ||
291 | ptr = adev->uvd.cpu_addr; | 279 | ptr = adev->uvd.cpu_addr; |
292 | ptr += le32_to_cpu(hdr->ucode_size_bytes); | ||
293 | 280 | ||
294 | memset(ptr, 0, size); | 281 | if (adev->uvd.saved_bo != NULL) { |
282 | memcpy(ptr, adev->uvd.saved_bo, size); | ||
283 | kfree(adev->uvd.saved_bo); | ||
284 | adev->uvd.saved_bo = NULL; | ||
285 | } else { | ||
286 | const struct common_firmware_header *hdr; | ||
287 | unsigned offset; | ||
288 | |||
289 | hdr = (const struct common_firmware_header *)adev->uvd.fw->data; | ||
290 | offset = le32_to_cpu(hdr->ucode_array_offset_bytes); | ||
291 | memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset, | ||
292 | (adev->uvd.fw->size) - offset); | ||
293 | size -= le32_to_cpu(hdr->ucode_size_bytes); | ||
294 | ptr += le32_to_cpu(hdr->ucode_size_bytes); | ||
295 | memset(ptr, 0, size); | ||
296 | } | ||
295 | 297 | ||
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index 82ce7d943884..05b0353d3880 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | |||
@@ -903,14 +903,6 @@ static int gmc_v7_0_early_init(void *handle) | |||
903 | gmc_v7_0_set_gart_funcs(adev); | 903 | gmc_v7_0_set_gart_funcs(adev); |
904 | gmc_v7_0_set_irq_funcs(adev); | 904 | gmc_v7_0_set_irq_funcs(adev); |
905 | 905 | ||
906 | if (adev->flags & AMD_IS_APU) { | ||
907 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | ||
908 | } else { | ||
909 | u32 tmp = RREG32(mmMC_SEQ_MISC0); | ||
910 | tmp &= MC_SEQ_MISC0__MT__MASK; | ||
911 | adev->mc.vram_type = gmc_v7_0_convert_vram_type(tmp); | ||
912 | } | ||
913 | |||
914 | return 0; | 906 | return 0; |
915 | } | 907 | } |
916 | 908 | ||
@@ -927,6 +919,14 @@ static int gmc_v7_0_sw_init(void *handle) | |||
927 | int dma_bits; | 919 | int dma_bits; |
928 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 920 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
929 | 921 | ||
922 | if (adev->flags & AMD_IS_APU) { | ||
923 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | ||
924 | } else { | ||
925 | u32 tmp = RREG32(mmMC_SEQ_MISC0); | ||
926 | tmp &= MC_SEQ_MISC0__MT__MASK; | ||
927 | adev->mc.vram_type = gmc_v7_0_convert_vram_type(tmp); | ||
928 | } | ||
929 | |||
930 | r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); | 930 | r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); |
931 | if (r) | 931 | if (r) |
932 | return r; | 932 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 29bd7b57dc91..02deb3229405 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
@@ -863,14 +863,6 @@ static int gmc_v8_0_early_init(void *handle) | |||
863 | gmc_v8_0_set_gart_funcs(adev); | 863 | gmc_v8_0_set_gart_funcs(adev); |
864 | gmc_v8_0_set_irq_funcs(adev); | 864 | gmc_v8_0_set_irq_funcs(adev); |
865 | 865 | ||
866 | if (adev->flags & AMD_IS_APU) { | ||
867 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | ||
868 | } else { | ||
869 | u32 tmp = RREG32(mmMC_SEQ_MISC0); | ||
870 | tmp &= MC_SEQ_MISC0__MT__MASK; | ||
871 | adev->mc.vram_type = gmc_v8_0_convert_vram_type(tmp); | ||
872 | } | ||
873 | |||
874 | return 0; | 866 | return 0; |
875 | } | 867 | } |
876 | 868 | ||
@@ -881,12 +873,27 @@ static int gmc_v8_0_late_init(void *handle) | |||
881 | return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0); | 873 | return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0); |
882 | } | 874 | } |
883 | 875 | ||
876 | #define mmMC_SEQ_MISC0_FIJI 0xA71 | ||
877 | |||
884 | static int gmc_v8_0_sw_init(void *handle) | 878 | static int gmc_v8_0_sw_init(void *handle) |
885 | { | 879 | { |
886 | int r; | 880 | int r; |
887 | int dma_bits; | 881 | int dma_bits; |
888 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 882 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
889 | 883 | ||
884 | if (adev->flags & AMD_IS_APU) { | ||
885 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | ||
886 | } else { | ||
887 | u32 tmp; | ||
888 | |||
889 | if (adev->asic_type == CHIP_FIJI) | ||
890 | tmp = RREG32(mmMC_SEQ_MISC0_FIJI); | ||
891 | else | ||
892 | tmp = RREG32(mmMC_SEQ_MISC0); | ||
893 | tmp &= MC_SEQ_MISC0__MT__MASK; | ||
894 | adev->mc.vram_type = gmc_v8_0_convert_vram_type(tmp); | ||
895 | } | ||
896 | |||
890 | r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); | 897 | r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); |
891 | if (r) | 898 | if (r) |
892 | return r; | 899 | return r; |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c index c606ccb38d8b..cb463753115b 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c | |||
@@ -224,11 +224,11 @@ static int uvd_v4_2_suspend(void *handle) | |||
224 | int r; | 224 | int r; |
225 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 225 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
226 | 226 | ||
227 | r = amdgpu_uvd_suspend(adev); | 227 | r = uvd_v4_2_hw_fini(adev); |
228 | if (r) | 228 | if (r) |
229 | return r; | 229 | return r; |
230 | 230 | ||
231 | r = uvd_v4_2_hw_fini(adev); | 231 | r = amdgpu_uvd_suspend(adev); |
232 | if (r) | 232 | if (r) |
233 | return r; | 233 | return r; |
234 | 234 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c index e3c852d9d79a..16476d80f475 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c | |||
@@ -220,11 +220,11 @@ static int uvd_v5_0_suspend(void *handle) | |||
220 | int r; | 220 | int r; |
221 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 221 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
222 | 222 | ||
223 | r = amdgpu_uvd_suspend(adev); | 223 | r = uvd_v5_0_hw_fini(adev); |
224 | if (r) | 224 | if (r) |
225 | return r; | 225 | return r; |
226 | 226 | ||
227 | r = uvd_v5_0_hw_fini(adev); | 227 | r = amdgpu_uvd_suspend(adev); |
228 | if (r) | 228 | if (r) |
229 | return r; | 229 | return r; |
230 | 230 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 3375e614ac67..d49379145ef2 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -214,15 +214,16 @@ static int uvd_v6_0_suspend(void *handle) | |||
214 | int r; | 214 | int r; |
215 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 215 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
216 | 216 | ||
217 | r = uvd_v6_0_hw_fini(adev); | ||
218 | if (r) | ||
219 | return r; | ||
220 | |||
217 | /* Skip this for APU for now */ | 221 | /* Skip this for APU for now */ |
218 | if (!(adev->flags & AMD_IS_APU)) { | 222 | if (!(adev->flags & AMD_IS_APU)) { |
219 | r = amdgpu_uvd_suspend(adev); | 223 | r = amdgpu_uvd_suspend(adev); |
220 | if (r) | 224 | if (r) |
221 | return r; | 225 | return r; |
222 | } | 226 | } |
223 | r = uvd_v6_0_hw_fini(adev); | ||
224 | if (r) | ||
225 | return r; | ||
226 | 227 | ||
227 | return r; | 228 | return r; |
228 | } | 229 | } |