diff options
author | Dave Airlie <airlied@redhat.com> | 2017-12-20 20:17:45 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2017-12-20 20:17:45 -0500 |
commit | df2869abd92b740af141ee2eb081bfc69bd80877 (patch) | |
tree | 61088b24d70246d16fd3d3e04d022255076decc5 /drivers | |
parent | 991eecc1c0743be7b942367af36637796e578e08 (diff) | |
parent | 4f4b94ee616500f326650f5b25439f1f7d606ea7 (diff) |
Merge branch 'drm-next-4.16' of git://people.freedesktop.org/~agd5f/linux into drm-next
* 'drm-next-4.16' of git://people.freedesktop.org/~agd5f/linux: (171 commits)
drm/amdgpu: fix test for shadow page tables
drm/amd/display: Expose dpp1_set_cursor_attributes
drm/amd/display: Update FMT and OPPBUF functions
drm/amd/display: check for null before calling is_blanked
drm/amd/display: dal 3.1.27
drm/amd/display: Fix unused variable warnings.
drm/amd/display: Only blank DCN when we have set_blank implementation
drm/amd/display: Put dcn_mi_registers with other structs
drm/amd/display: hubp refactor
drm/amd/display: integrating optc pseudocode
drm/amd/display: Call validate_fbc should_enable_fbc
drm/amd/display: Clean up DCN cursor code
drm/amd/display: fix 180 full screen pipe split
drm/amd/display: reprogram surface config on scaling change
drm/amd/display: Remove dwbc from pipe_ctx
drm/amd/display: Use the maximum link setting which EDP reported.
drm/amd/display: Add hdr_supported flag
drm/amd/display: fix global sync param retrieval when not pipe splitting
drm/amd/display: Update HUBP
drm/amd/display: fix rotated surface scaling
...
Diffstat (limited to 'drivers')
189 files changed, 6434 insertions, 6064 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index d853989848d6..0bc374459440 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig | |||
@@ -154,6 +154,10 @@ config DRM_VM | |||
154 | bool | 154 | bool |
155 | depends on DRM && MMU | 155 | depends on DRM && MMU |
156 | 156 | ||
157 | config DRM_SCHED | ||
158 | tristate | ||
159 | depends on DRM | ||
160 | |||
157 | source "drivers/gpu/drm/i2c/Kconfig" | 161 | source "drivers/gpu/drm/i2c/Kconfig" |
158 | 162 | ||
159 | source "drivers/gpu/drm/arm/Kconfig" | 163 | source "drivers/gpu/drm/arm/Kconfig" |
@@ -183,6 +187,7 @@ config DRM_AMDGPU | |||
183 | depends on DRM && PCI && MMU | 187 | depends on DRM && PCI && MMU |
184 | select FW_LOADER | 188 | select FW_LOADER |
185 | select DRM_KMS_HELPER | 189 | select DRM_KMS_HELPER |
190 | select DRM_SCHED | ||
186 | select DRM_TTM | 191 | select DRM_TTM |
187 | select POWER_SUPPLY | 192 | select POWER_SUPPLY |
188 | select HWMON | 193 | select HWMON |
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index e5bf68b9c171..dd5ae67f8e2b 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -102,3 +102,4 @@ obj-$(CONFIG_DRM_MXSFB) += mxsfb/ | |||
102 | obj-$(CONFIG_DRM_TINYDRM) += tinydrm/ | 102 | obj-$(CONFIG_DRM_TINYDRM) += tinydrm/ |
103 | obj-$(CONFIG_DRM_PL111) += pl111/ | 103 | obj-$(CONFIG_DRM_PL111) += pl111/ |
104 | obj-$(CONFIG_DRM_TVE200) += tve200/ | 104 | obj-$(CONFIG_DRM_TVE200) += tve200/ |
105 | obj-$(CONFIG_DRM_SCHED) += scheduler/ | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 90202cf4cd1e..d8da12c114b1 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile | |||
@@ -52,7 +52,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ | |||
52 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ | 52 | amdgpu_prime.o amdgpu_vm.o amdgpu_ib.o amdgpu_pll.o \ |
53 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ | 53 | amdgpu_ucode.o amdgpu_bo_list.o amdgpu_ctx.o amdgpu_sync.o \ |
54 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ | 54 | amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ |
55 | amdgpu_queue_mgr.o amdgpu_vf_error.o amdgpu_sched.o | 55 | amdgpu_queue_mgr.o amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o |
56 | 56 | ||
57 | # add asic specific block | 57 | # add asic specific block |
58 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | 58 | amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ |
@@ -62,7 +62,7 @@ amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \ | |||
62 | amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o dce_v6_0.o si_dpm.o si_smc.o | 62 | amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o dce_v6_0.o si_dpm.o si_smc.o |
63 | 63 | ||
64 | amdgpu-y += \ | 64 | amdgpu-y += \ |
65 | vi.o mxgpu_vi.o nbio_v6_1.o soc15.o mxgpu_ai.o nbio_v7_0.o | 65 | vi.o mxgpu_vi.o nbio_v6_1.o soc15.o mxgpu_ai.o nbio_v7_0.o vega10_reg_init.o |
66 | 66 | ||
67 | # add GMC block | 67 | # add GMC block |
68 | amdgpu-y += \ | 68 | amdgpu-y += \ |
@@ -135,10 +135,7 @@ amdgpu-y += \ | |||
135 | amdgpu-y += amdgpu_cgs.o | 135 | amdgpu-y += amdgpu_cgs.o |
136 | 136 | ||
137 | # GPU scheduler | 137 | # GPU scheduler |
138 | amdgpu-y += \ | 138 | amdgpu-y += amdgpu_job.o |
139 | ../scheduler/gpu_scheduler.o \ | ||
140 | ../scheduler/sched_fence.o \ | ||
141 | amdgpu_job.o | ||
142 | 139 | ||
143 | # ACP componet | 140 | # ACP componet |
144 | ifneq ($(CONFIG_DRM_AMD_ACP),) | 141 | ifneq ($(CONFIG_DRM_AMD_ACP),) |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 5e2958a79928..bbe06e04dcb6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <drm/drmP.h> | 45 | #include <drm/drmP.h> |
46 | #include <drm/drm_gem.h> | 46 | #include <drm/drm_gem.h> |
47 | #include <drm/amdgpu_drm.h> | 47 | #include <drm/amdgpu_drm.h> |
48 | #include <drm/gpu_scheduler.h> | ||
48 | 49 | ||
49 | #include <kgd_kfd_interface.h> | 50 | #include <kgd_kfd_interface.h> |
50 | #include "dm_pp_interface.h" | 51 | #include "dm_pp_interface.h" |
@@ -68,10 +69,9 @@ | |||
68 | #include "amdgpu_vcn.h" | 69 | #include "amdgpu_vcn.h" |
69 | #include "amdgpu_mn.h" | 70 | #include "amdgpu_mn.h" |
70 | #include "amdgpu_dm.h" | 71 | #include "amdgpu_dm.h" |
71 | #include "gpu_scheduler.h" | ||
72 | #include "amdgpu_virt.h" | 72 | #include "amdgpu_virt.h" |
73 | #include "amdgpu_gart.h" | 73 | #include "amdgpu_gart.h" |
74 | 74 | #include "amdgpu_debugfs.h" | |
75 | 75 | ||
76 | /* | 76 | /* |
77 | * Modules parameters. | 77 | * Modules parameters. |
@@ -126,6 +126,7 @@ extern int amdgpu_param_buf_per_se; | |||
126 | extern int amdgpu_job_hang_limit; | 126 | extern int amdgpu_job_hang_limit; |
127 | extern int amdgpu_lbpw; | 127 | extern int amdgpu_lbpw; |
128 | extern int amdgpu_compute_multipipe; | 128 | extern int amdgpu_compute_multipipe; |
129 | extern int amdgpu_gpu_recovery; | ||
129 | 130 | ||
130 | #ifdef CONFIG_DRM_AMDGPU_SI | 131 | #ifdef CONFIG_DRM_AMDGPU_SI |
131 | extern int amdgpu_si_support; | 132 | extern int amdgpu_si_support; |
@@ -223,17 +224,18 @@ enum amdgpu_kiq_irq { | |||
223 | AMDGPU_CP_KIQ_IRQ_LAST | 224 | AMDGPU_CP_KIQ_IRQ_LAST |
224 | }; | 225 | }; |
225 | 226 | ||
226 | int amdgpu_set_clockgating_state(struct amdgpu_device *adev, | 227 | int amdgpu_device_ip_set_clockgating_state(struct amdgpu_device *adev, |
227 | enum amd_ip_block_type block_type, | 228 | enum amd_ip_block_type block_type, |
228 | enum amd_clockgating_state state); | 229 | enum amd_clockgating_state state); |
229 | int amdgpu_set_powergating_state(struct amdgpu_device *adev, | 230 | int amdgpu_device_ip_set_powergating_state(struct amdgpu_device *adev, |
230 | enum amd_ip_block_type block_type, | 231 | enum amd_ip_block_type block_type, |
231 | enum amd_powergating_state state); | 232 | enum amd_powergating_state state); |
232 | void amdgpu_get_clockgating_state(struct amdgpu_device *adev, u32 *flags); | 233 | void amdgpu_device_ip_get_clockgating_state(struct amdgpu_device *adev, |
233 | int amdgpu_wait_for_idle(struct amdgpu_device *adev, | 234 | u32 *flags); |
234 | enum amd_ip_block_type block_type); | 235 | int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev, |
235 | bool amdgpu_is_idle(struct amdgpu_device *adev, | 236 | enum amd_ip_block_type block_type); |
236 | enum amd_ip_block_type block_type); | 237 | bool amdgpu_device_ip_is_idle(struct amdgpu_device *adev, |
238 | enum amd_ip_block_type block_type); | ||
237 | 239 | ||
238 | #define AMDGPU_MAX_IP_NUM 16 | 240 | #define AMDGPU_MAX_IP_NUM 16 |
239 | 241 | ||
@@ -258,15 +260,16 @@ struct amdgpu_ip_block { | |||
258 | const struct amdgpu_ip_block_version *version; | 260 | const struct amdgpu_ip_block_version *version; |
259 | }; | 261 | }; |
260 | 262 | ||
261 | int amdgpu_ip_block_version_cmp(struct amdgpu_device *adev, | 263 | int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev, |
262 | enum amd_ip_block_type type, | 264 | enum amd_ip_block_type type, |
263 | u32 major, u32 minor); | 265 | u32 major, u32 minor); |
264 | 266 | ||
265 | struct amdgpu_ip_block * amdgpu_get_ip_block(struct amdgpu_device *adev, | 267 | struct amdgpu_ip_block * |
266 | enum amd_ip_block_type type); | 268 | amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev, |
269 | enum amd_ip_block_type type); | ||
267 | 270 | ||
268 | int amdgpu_ip_block_add(struct amdgpu_device *adev, | 271 | int amdgpu_device_ip_block_add(struct amdgpu_device *adev, |
269 | const struct amdgpu_ip_block_version *ip_block_version); | 272 | const struct amdgpu_ip_block_version *ip_block_version); |
270 | 273 | ||
271 | /* provided by hw blocks that can move/clear data. e.g., gfx or sdma */ | 274 | /* provided by hw blocks that can move/clear data. e.g., gfx or sdma */ |
272 | struct amdgpu_buffer_funcs { | 275 | struct amdgpu_buffer_funcs { |
@@ -346,7 +349,8 @@ struct amdgpu_gart_funcs { | |||
346 | uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev, | 349 | uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev, |
347 | uint32_t flags); | 350 | uint32_t flags); |
348 | /* get the pde for a given mc addr */ | 351 | /* get the pde for a given mc addr */ |
349 | u64 (*get_vm_pde)(struct amdgpu_device *adev, u64 addr); | 352 | void (*get_vm_pde)(struct amdgpu_device *adev, int level, |
353 | u64 *dst, u64 *flags); | ||
350 | uint32_t (*get_invalidate_req)(unsigned int vm_id); | 354 | uint32_t (*get_invalidate_req)(unsigned int vm_id); |
351 | }; | 355 | }; |
352 | 356 | ||
@@ -373,9 +377,6 @@ struct amdgpu_dummy_page { | |||
373 | struct page *page; | 377 | struct page *page; |
374 | dma_addr_t addr; | 378 | dma_addr_t addr; |
375 | }; | 379 | }; |
376 | int amdgpu_dummy_page_init(struct amdgpu_device *adev); | ||
377 | void amdgpu_dummy_page_fini(struct amdgpu_device *adev); | ||
378 | |||
379 | 380 | ||
380 | /* | 381 | /* |
381 | * Clocks | 382 | * Clocks |
@@ -423,7 +424,6 @@ struct reservation_object *amdgpu_gem_prime_res_obj(struct drm_gem_object *); | |||
423 | void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj); | 424 | void *amdgpu_gem_prime_vmap(struct drm_gem_object *obj); |
424 | void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); | 425 | void amdgpu_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr); |
425 | int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); | 426 | int amdgpu_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); |
426 | int amdgpu_gem_debugfs_init(struct amdgpu_device *adev); | ||
427 | 427 | ||
428 | /* sub-allocation manager, it has to be protected by another lock. | 428 | /* sub-allocation manager, it has to be protected by another lock. |
429 | * By conception this is an helper for other part of the driver | 429 | * By conception this is an helper for other part of the driver |
@@ -540,6 +540,7 @@ struct amdgpu_mc { | |||
540 | u64 private_aperture_end; | 540 | u64 private_aperture_end; |
541 | /* protects concurrent invalidation */ | 541 | /* protects concurrent invalidation */ |
542 | spinlock_t invalidate_lock; | 542 | spinlock_t invalidate_lock; |
543 | bool translate_further; | ||
543 | }; | 544 | }; |
544 | 545 | ||
545 | /* | 546 | /* |
@@ -650,12 +651,6 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT | |||
650 | AMDGPU_DOORBELL64_INVALID = 0xFFFF | 651 | AMDGPU_DOORBELL64_INVALID = 0xFFFF |
651 | } AMDGPU_DOORBELL64_ASSIGNMENT; | 652 | } AMDGPU_DOORBELL64_ASSIGNMENT; |
652 | 653 | ||
653 | |||
654 | void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, | ||
655 | phys_addr_t *aperture_base, | ||
656 | size_t *aperture_size, | ||
657 | size_t *start_offset); | ||
658 | |||
659 | /* | 654 | /* |
660 | * IRQS. | 655 | * IRQS. |
661 | */ | 656 | */ |
@@ -689,7 +684,7 @@ struct amdgpu_ib { | |||
689 | uint32_t flags; | 684 | uint32_t flags; |
690 | }; | 685 | }; |
691 | 686 | ||
692 | extern const struct amd_sched_backend_ops amdgpu_sched_ops; | 687 | extern const struct drm_sched_backend_ops amdgpu_sched_ops; |
693 | 688 | ||
694 | int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, | 689 | int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, |
695 | struct amdgpu_job **job, struct amdgpu_vm *vm); | 690 | struct amdgpu_job **job, struct amdgpu_vm *vm); |
@@ -699,7 +694,7 @@ int amdgpu_job_alloc_with_ib(struct amdgpu_device *adev, unsigned size, | |||
699 | void amdgpu_job_free_resources(struct amdgpu_job *job); | 694 | void amdgpu_job_free_resources(struct amdgpu_job *job); |
700 | void amdgpu_job_free(struct amdgpu_job *job); | 695 | void amdgpu_job_free(struct amdgpu_job *job); |
701 | int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, | 696 | int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, |
702 | struct amd_sched_entity *entity, void *owner, | 697 | struct drm_sched_entity *entity, void *owner, |
703 | struct dma_fence **f); | 698 | struct dma_fence **f); |
704 | 699 | ||
705 | /* | 700 | /* |
@@ -732,7 +727,7 @@ int amdgpu_queue_mgr_map(struct amdgpu_device *adev, | |||
732 | struct amdgpu_ctx_ring { | 727 | struct amdgpu_ctx_ring { |
733 | uint64_t sequence; | 728 | uint64_t sequence; |
734 | struct dma_fence **fences; | 729 | struct dma_fence **fences; |
735 | struct amd_sched_entity entity; | 730 | struct drm_sched_entity entity; |
736 | }; | 731 | }; |
737 | 732 | ||
738 | struct amdgpu_ctx { | 733 | struct amdgpu_ctx { |
@@ -746,8 +741,8 @@ struct amdgpu_ctx { | |||
746 | struct dma_fence **fences; | 741 | struct dma_fence **fences; |
747 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; | 742 | struct amdgpu_ctx_ring rings[AMDGPU_MAX_RINGS]; |
748 | bool preamble_presented; | 743 | bool preamble_presented; |
749 | enum amd_sched_priority init_priority; | 744 | enum drm_sched_priority init_priority; |
750 | enum amd_sched_priority override_priority; | 745 | enum drm_sched_priority override_priority; |
751 | struct mutex lock; | 746 | struct mutex lock; |
752 | atomic_t guilty; | 747 | atomic_t guilty; |
753 | }; | 748 | }; |
@@ -767,7 +762,7 @@ int amdgpu_ctx_add_fence(struct amdgpu_ctx *ctx, struct amdgpu_ring *ring, | |||
767 | struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | 762 | struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, |
768 | struct amdgpu_ring *ring, uint64_t seq); | 763 | struct amdgpu_ring *ring, uint64_t seq); |
769 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | 764 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, |
770 | enum amd_sched_priority priority); | 765 | enum drm_sched_priority priority); |
771 | 766 | ||
772 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | 767 | int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, |
773 | struct drm_file *filp); | 768 | struct drm_file *filp); |
@@ -1116,7 +1111,7 @@ struct amdgpu_cs_parser { | |||
1116 | #define AMDGPU_HAVE_CTX_SWITCH (1 << 2) /* bit set means context switch occured */ | 1111 | #define AMDGPU_HAVE_CTX_SWITCH (1 << 2) /* bit set means context switch occured */ |
1117 | 1112 | ||
1118 | struct amdgpu_job { | 1113 | struct amdgpu_job { |
1119 | struct amd_sched_job base; | 1114 | struct drm_sched_job base; |
1120 | struct amdgpu_device *adev; | 1115 | struct amdgpu_device *adev; |
1121 | struct amdgpu_vm *vm; | 1116 | struct amdgpu_vm *vm; |
1122 | struct amdgpu_ring *ring; | 1117 | struct amdgpu_ring *ring; |
@@ -1170,10 +1165,10 @@ struct amdgpu_wb { | |||
1170 | unsigned long used[DIV_ROUND_UP(AMDGPU_MAX_WB, BITS_PER_LONG)]; | 1165 | unsigned long used[DIV_ROUND_UP(AMDGPU_MAX_WB, BITS_PER_LONG)]; |
1171 | }; | 1166 | }; |
1172 | 1167 | ||
1173 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); | 1168 | int amdgpu_device_wb_get(struct amdgpu_device *adev, u32 *wb); |
1174 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); | 1169 | void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb); |
1175 | 1170 | ||
1176 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); | 1171 | void amdgpu_device_get_pcie_info(struct amdgpu_device *adev); |
1177 | 1172 | ||
1178 | /* | 1173 | /* |
1179 | * SDMA | 1174 | * SDMA |
@@ -1238,24 +1233,6 @@ void amdgpu_benchmark(struct amdgpu_device *adev, int test_number); | |||
1238 | */ | 1233 | */ |
1239 | void amdgpu_test_moves(struct amdgpu_device *adev); | 1234 | void amdgpu_test_moves(struct amdgpu_device *adev); |
1240 | 1235 | ||
1241 | /* | ||
1242 | * Debugfs | ||
1243 | */ | ||
1244 | struct amdgpu_debugfs { | ||
1245 | const struct drm_info_list *files; | ||
1246 | unsigned num_files; | ||
1247 | }; | ||
1248 | |||
1249 | int amdgpu_debugfs_add_files(struct amdgpu_device *adev, | ||
1250 | const struct drm_info_list *files, | ||
1251 | unsigned nfiles); | ||
1252 | int amdgpu_debugfs_fence_init(struct amdgpu_device *adev); | ||
1253 | |||
1254 | #if defined(CONFIG_DEBUG_FS) | ||
1255 | int amdgpu_debugfs_init(struct drm_minor *minor); | ||
1256 | #endif | ||
1257 | |||
1258 | int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev); | ||
1259 | 1236 | ||
1260 | /* | 1237 | /* |
1261 | * amdgpu smumgr functions | 1238 | * amdgpu smumgr functions |
@@ -1410,9 +1387,6 @@ struct amdgpu_fw_vram_usage { | |||
1410 | void *va; | 1387 | void *va; |
1411 | }; | 1388 | }; |
1412 | 1389 | ||
1413 | int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev); | ||
1414 | void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev); | ||
1415 | |||
1416 | /* | 1390 | /* |
1417 | * CGS | 1391 | * CGS |
1418 | */ | 1392 | */ |
@@ -1428,6 +1402,80 @@ typedef void (*amdgpu_wreg_t)(struct amdgpu_device*, uint32_t, uint32_t); | |||
1428 | typedef uint32_t (*amdgpu_block_rreg_t)(struct amdgpu_device*, uint32_t, uint32_t); | 1402 | typedef uint32_t (*amdgpu_block_rreg_t)(struct amdgpu_device*, uint32_t, uint32_t); |
1429 | typedef void (*amdgpu_block_wreg_t)(struct amdgpu_device*, uint32_t, uint32_t, uint32_t); | 1403 | typedef void (*amdgpu_block_wreg_t)(struct amdgpu_device*, uint32_t, uint32_t, uint32_t); |
1430 | 1404 | ||
1405 | |||
1406 | /* | ||
1407 | * amdgpu nbio functions | ||
1408 | * | ||
1409 | */ | ||
1410 | struct nbio_hdp_flush_reg { | ||
1411 | u32 ref_and_mask_cp0; | ||
1412 | u32 ref_and_mask_cp1; | ||
1413 | u32 ref_and_mask_cp2; | ||
1414 | u32 ref_and_mask_cp3; | ||
1415 | u32 ref_and_mask_cp4; | ||
1416 | u32 ref_and_mask_cp5; | ||
1417 | u32 ref_and_mask_cp6; | ||
1418 | u32 ref_and_mask_cp7; | ||
1419 | u32 ref_and_mask_cp8; | ||
1420 | u32 ref_and_mask_cp9; | ||
1421 | u32 ref_and_mask_sdma0; | ||
1422 | u32 ref_and_mask_sdma1; | ||
1423 | }; | ||
1424 | |||
1425 | struct amdgpu_nbio_funcs { | ||
1426 | const struct nbio_hdp_flush_reg *hdp_flush_reg; | ||
1427 | u32 (*get_hdp_flush_req_offset)(struct amdgpu_device *adev); | ||
1428 | u32 (*get_hdp_flush_done_offset)(struct amdgpu_device *adev); | ||
1429 | u32 (*get_pcie_index_offset)(struct amdgpu_device *adev); | ||
1430 | u32 (*get_pcie_data_offset)(struct amdgpu_device *adev); | ||
1431 | u32 (*get_rev_id)(struct amdgpu_device *adev); | ||
1432 | void (*mc_access_enable)(struct amdgpu_device *adev, bool enable); | ||
1433 | void (*hdp_flush)(struct amdgpu_device *adev); | ||
1434 | u32 (*get_memsize)(struct amdgpu_device *adev); | ||
1435 | void (*sdma_doorbell_range)(struct amdgpu_device *adev, int instance, | ||
1436 | bool use_doorbell, int doorbell_index); | ||
1437 | void (*enable_doorbell_aperture)(struct amdgpu_device *adev, | ||
1438 | bool enable); | ||
1439 | void (*enable_doorbell_selfring_aperture)(struct amdgpu_device *adev, | ||
1440 | bool enable); | ||
1441 | void (*ih_doorbell_range)(struct amdgpu_device *adev, | ||
1442 | bool use_doorbell, int doorbell_index); | ||
1443 | void (*update_medium_grain_clock_gating)(struct amdgpu_device *adev, | ||
1444 | bool enable); | ||
1445 | void (*update_medium_grain_light_sleep)(struct amdgpu_device *adev, | ||
1446 | bool enable); | ||
1447 | void (*get_clockgating_state)(struct amdgpu_device *adev, | ||
1448 | u32 *flags); | ||
1449 | void (*ih_control)(struct amdgpu_device *adev); | ||
1450 | void (*init_registers)(struct amdgpu_device *adev); | ||
1451 | void (*detect_hw_virt)(struct amdgpu_device *adev); | ||
1452 | }; | ||
1453 | |||
1454 | |||
1455 | /* Define the HW IP blocks will be used in driver , add more if necessary */ | ||
1456 | enum amd_hw_ip_block_type { | ||
1457 | GC_HWIP = 1, | ||
1458 | HDP_HWIP, | ||
1459 | SDMA0_HWIP, | ||
1460 | SDMA1_HWIP, | ||
1461 | MMHUB_HWIP, | ||
1462 | ATHUB_HWIP, | ||
1463 | NBIO_HWIP, | ||
1464 | MP0_HWIP, | ||
1465 | UVD_HWIP, | ||
1466 | VCN_HWIP = UVD_HWIP, | ||
1467 | VCE_HWIP, | ||
1468 | DF_HWIP, | ||
1469 | DCE_HWIP, | ||
1470 | OSSSYS_HWIP, | ||
1471 | SMUIO_HWIP, | ||
1472 | PWR_HWIP, | ||
1473 | NBIF_HWIP, | ||
1474 | MAX_HWIP | ||
1475 | }; | ||
1476 | |||
1477 | #define HWIP_MAX_INSTANCE 6 | ||
1478 | |||
1431 | struct amd_powerplay { | 1479 | struct amd_powerplay { |
1432 | struct cgs_device *cgs_device; | 1480 | struct cgs_device *cgs_device; |
1433 | void *pp_handle; | 1481 | void *pp_handle; |
@@ -1620,6 +1668,11 @@ struct amdgpu_device { | |||
1620 | /* amdkfd interface */ | 1668 | /* amdkfd interface */ |
1621 | struct kfd_dev *kfd; | 1669 | struct kfd_dev *kfd; |
1622 | 1670 | ||
1671 | /* soc15 register offset based on ip, instance and segment */ | ||
1672 | uint32_t *reg_offset[MAX_HWIP][HWIP_MAX_INSTANCE]; | ||
1673 | |||
1674 | const struct amdgpu_nbio_funcs *nbio_funcs; | ||
1675 | |||
1623 | /* delayed work_func for deferring clockgating during resume */ | 1676 | /* delayed work_func for deferring clockgating during resume */ |
1624 | struct delayed_work late_init_work; | 1677 | struct delayed_work late_init_work; |
1625 | 1678 | ||
@@ -1785,7 +1838,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
1785 | #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev)) | 1838 | #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev)) |
1786 | #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid)) | 1839 | #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid)) |
1787 | #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) | 1840 | #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags)) |
1788 | #define amdgpu_gart_get_vm_pde(adev, addr) (adev)->gart.gart_funcs->get_vm_pde((adev), (addr)) | 1841 | #define amdgpu_gart_get_vm_pde(adev, level, dst, flags) (adev)->gart.gart_funcs->get_vm_pde((adev), (level), (dst), (flags)) |
1789 | #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count))) | 1842 | #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count))) |
1790 | #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr))) | 1843 | #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr))) |
1791 | #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags))) | 1844 | #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags))) |
@@ -1835,23 +1888,25 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
1835 | #define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i)) | 1888 | #define amdgpu_psp_check_fw_loading_status(adev, i) (adev)->firmware.funcs->check_fw_loading_status((adev), (i)) |
1836 | 1889 | ||
1837 | /* Common functions */ | 1890 | /* Common functions */ |
1838 | int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job* job); | 1891 | int amdgpu_device_gpu_recover(struct amdgpu_device *adev, |
1839 | bool amdgpu_need_backup(struct amdgpu_device *adev); | 1892 | struct amdgpu_job* job, bool force); |
1840 | void amdgpu_pci_config_reset(struct amdgpu_device *adev); | 1893 | void amdgpu_device_pci_config_reset(struct amdgpu_device *adev); |
1841 | bool amdgpu_need_post(struct amdgpu_device *adev); | 1894 | bool amdgpu_device_need_post(struct amdgpu_device *adev); |
1842 | void amdgpu_update_display_priority(struct amdgpu_device *adev); | 1895 | void amdgpu_update_display_priority(struct amdgpu_device *adev); |
1843 | 1896 | ||
1844 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, | 1897 | void amdgpu_cs_report_moved_bytes(struct amdgpu_device *adev, u64 num_bytes, |
1845 | u64 num_vis_bytes); | 1898 | u64 num_vis_bytes); |
1846 | void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain); | 1899 | void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain); |
1847 | bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo); | 1900 | bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo); |
1848 | void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base); | 1901 | void amdgpu_device_vram_location(struct amdgpu_device *adev, |
1849 | void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc); | 1902 | struct amdgpu_mc *mc, u64 base); |
1903 | void amdgpu_device_gart_location(struct amdgpu_device *adev, | ||
1904 | struct amdgpu_mc *mc); | ||
1850 | int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev); | 1905 | int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev); |
1851 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); | 1906 | void amdgpu_ttm_set_active_vram_size(struct amdgpu_device *adev, u64 size); |
1852 | int amdgpu_ttm_init(struct amdgpu_device *adev); | 1907 | int amdgpu_ttm_init(struct amdgpu_device *adev); |
1853 | void amdgpu_ttm_fini(struct amdgpu_device *adev); | 1908 | void amdgpu_ttm_fini(struct amdgpu_device *adev); |
1854 | void amdgpu_program_register_sequence(struct amdgpu_device *adev, | 1909 | void amdgpu_device_program_register_sequence(struct amdgpu_device *adev, |
1855 | const u32 *registers, | 1910 | const u32 *registers, |
1856 | const u32 array_size); | 1911 | const u32 array_size); |
1857 | 1912 | ||
@@ -1885,7 +1940,7 @@ void amdgpu_driver_lastclose_kms(struct drm_device *dev); | |||
1885 | int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv); | 1940 | int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv); |
1886 | void amdgpu_driver_postclose_kms(struct drm_device *dev, | 1941 | void amdgpu_driver_postclose_kms(struct drm_device *dev, |
1887 | struct drm_file *file_priv); | 1942 | struct drm_file *file_priv); |
1888 | int amdgpu_suspend(struct amdgpu_device *adev); | 1943 | int amdgpu_device_ip_suspend(struct amdgpu_device *adev); |
1889 | int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon); | 1944 | int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon); |
1890 | int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon); | 1945 | int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon); |
1891 | u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe); | 1946 | u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c index c04f44a90392..a29362f9ef41 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | |||
@@ -277,7 +277,7 @@ static int acp_hw_init(void *handle) | |||
277 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 277 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
278 | 278 | ||
279 | const struct amdgpu_ip_block *ip_block = | 279 | const struct amdgpu_ip_block *ip_block = |
280 | amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ACP); | 280 | amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_ACP); |
281 | 281 | ||
282 | if (!ip_block) | 282 | if (!ip_block) |
283 | return -EINVAL; | 283 | return -EINVAL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c index c70cda04dbfb..896b16db58aa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | |||
@@ -93,6 +93,39 @@ void amdgpu_amdkfd_device_probe(struct amdgpu_device *adev) | |||
93 | adev->pdev, kfd2kgd); | 93 | adev->pdev, kfd2kgd); |
94 | } | 94 | } |
95 | 95 | ||
96 | /** | ||
97 | * amdgpu_doorbell_get_kfd_info - Report doorbell configuration required to | ||
98 | * setup amdkfd | ||
99 | * | ||
100 | * @adev: amdgpu_device pointer | ||
101 | * @aperture_base: output returning doorbell aperture base physical address | ||
102 | * @aperture_size: output returning doorbell aperture size in bytes | ||
103 | * @start_offset: output returning # of doorbell bytes reserved for amdgpu. | ||
104 | * | ||
105 | * amdgpu and amdkfd share the doorbell aperture. amdgpu sets it up, | ||
106 | * takes doorbells required for its own rings and reports the setup to amdkfd. | ||
107 | * amdgpu reserved doorbells are at the start of the doorbell aperture. | ||
108 | */ | ||
109 | static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, | ||
110 | phys_addr_t *aperture_base, | ||
111 | size_t *aperture_size, | ||
112 | size_t *start_offset) | ||
113 | { | ||
114 | /* | ||
115 | * The first num_doorbells are used by amdgpu. | ||
116 | * amdkfd takes whatever's left in the aperture. | ||
117 | */ | ||
118 | if (adev->doorbell.size > adev->doorbell.num_doorbells * sizeof(u32)) { | ||
119 | *aperture_base = adev->doorbell.base; | ||
120 | *aperture_size = adev->doorbell.size; | ||
121 | *start_offset = adev->doorbell.num_doorbells * sizeof(u32); | ||
122 | } else { | ||
123 | *aperture_base = 0; | ||
124 | *aperture_size = 0; | ||
125 | *start_offset = 0; | ||
126 | } | ||
127 | } | ||
128 | |||
96 | void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) | 129 | void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) |
97 | { | 130 | { |
98 | int i; | 131 | int i; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c index 39f4d0df1ada..bf872f694f50 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <drm/amdgpu_drm.h> | 27 | #include <drm/amdgpu_drm.h> |
28 | #include "amdgpu.h" | 28 | #include "amdgpu.h" |
29 | #include "amdgpu_atombios.h" | 29 | #include "amdgpu_atombios.h" |
30 | #include "amdgpu_atomfirmware.h" | ||
30 | #include "amdgpu_i2c.h" | 31 | #include "amdgpu_i2c.h" |
31 | 32 | ||
32 | #include "atom.h" | 33 | #include "atom.h" |
@@ -1699,7 +1700,7 @@ void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock) | |||
1699 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); | 1700 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); |
1700 | } | 1701 | } |
1701 | 1702 | ||
1702 | void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) | 1703 | static void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) |
1703 | { | 1704 | { |
1704 | uint32_t bios_2_scratch, bios_6_scratch; | 1705 | uint32_t bios_2_scratch, bios_6_scratch; |
1705 | 1706 | ||
@@ -1721,28 +1722,6 @@ void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev) | |||
1721 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); | 1722 | WREG32(adev->bios_scratch_reg_offset + 6, bios_6_scratch); |
1722 | } | 1723 | } |
1723 | 1724 | ||
1724 | void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev) | ||
1725 | { | ||
1726 | int i; | ||
1727 | |||
1728 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
1729 | adev->bios_scratch[i] = RREG32(adev->bios_scratch_reg_offset + i); | ||
1730 | } | ||
1731 | |||
1732 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev) | ||
1733 | { | ||
1734 | int i; | ||
1735 | |||
1736 | /* | ||
1737 | * VBIOS will check ASIC_INIT_COMPLETE bit to decide if | ||
1738 | * execute ASIC_Init posting via driver | ||
1739 | */ | ||
1740 | adev->bios_scratch[7] &= ~ATOM_S7_ASIC_INIT_COMPLETE_MASK; | ||
1741 | |||
1742 | for (i = 0; i < AMDGPU_BIOS_NUM_SCRATCH; i++) | ||
1743 | WREG32(adev->bios_scratch_reg_offset + i, adev->bios_scratch[i]); | ||
1744 | } | ||
1745 | |||
1746 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, | 1725 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, |
1747 | bool hung) | 1726 | bool hung) |
1748 | { | 1727 | { |
@@ -1798,7 +1777,7 @@ void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le) | |||
1798 | #endif | 1777 | #endif |
1799 | } | 1778 | } |
1800 | 1779 | ||
1801 | int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev) | 1780 | static int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev) |
1802 | { | 1781 | { |
1803 | struct atom_context *ctx = adev->mode_info.atom_context; | 1782 | struct atom_context *ctx = adev->mode_info.atom_context; |
1804 | int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); | 1783 | int index = GetIndexIntoMasterTable(DATA, VRAM_UsageByFirmware); |
@@ -1841,3 +1820,234 @@ int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev) | |||
1841 | ctx->scratch_size_bytes = usage_bytes; | 1820 | ctx->scratch_size_bytes = usage_bytes; |
1842 | return 0; | 1821 | return 0; |
1843 | } | 1822 | } |
1823 | |||
1824 | /* ATOM accessor methods */ | ||
1825 | /* | ||
1826 | * ATOM is an interpreted byte code stored in tables in the vbios. The | ||
1827 | * driver registers callbacks to access registers and the interpreter | ||
1828 | * in the driver parses the tables and executes then to program specific | ||
1829 | * actions (set display modes, asic init, etc.). See amdgpu_atombios.c, | ||
1830 | * atombios.h, and atom.c | ||
1831 | */ | ||
1832 | |||
1833 | /** | ||
1834 | * cail_pll_read - read PLL register | ||
1835 | * | ||
1836 | * @info: atom card_info pointer | ||
1837 | * @reg: PLL register offset | ||
1838 | * | ||
1839 | * Provides a PLL register accessor for the atom interpreter (r4xx+). | ||
1840 | * Returns the value of the PLL register. | ||
1841 | */ | ||
1842 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) | ||
1843 | { | ||
1844 | return 0; | ||
1845 | } | ||
1846 | |||
1847 | /** | ||
1848 | * cail_pll_write - write PLL register | ||
1849 | * | ||
1850 | * @info: atom card_info pointer | ||
1851 | * @reg: PLL register offset | ||
1852 | * @val: value to write to the pll register | ||
1853 | * | ||
1854 | * Provides a PLL register accessor for the atom interpreter (r4xx+). | ||
1855 | */ | ||
1856 | static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
1857 | { | ||
1858 | |||
1859 | } | ||
1860 | |||
1861 | /** | ||
1862 | * cail_mc_read - read MC (Memory Controller) register | ||
1863 | * | ||
1864 | * @info: atom card_info pointer | ||
1865 | * @reg: MC register offset | ||
1866 | * | ||
1867 | * Provides an MC register accessor for the atom interpreter (r4xx+). | ||
1868 | * Returns the value of the MC register. | ||
1869 | */ | ||
1870 | static uint32_t cail_mc_read(struct card_info *info, uint32_t reg) | ||
1871 | { | ||
1872 | return 0; | ||
1873 | } | ||
1874 | |||
1875 | /** | ||
1876 | * cail_mc_write - write MC (Memory Controller) register | ||
1877 | * | ||
1878 | * @info: atom card_info pointer | ||
1879 | * @reg: MC register offset | ||
1880 | * @val: value to write to the pll register | ||
1881 | * | ||
1882 | * Provides a MC register accessor for the atom interpreter (r4xx+). | ||
1883 | */ | ||
1884 | static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
1885 | { | ||
1886 | |||
1887 | } | ||
1888 | |||
1889 | /** | ||
1890 | * cail_reg_write - write MMIO register | ||
1891 | * | ||
1892 | * @info: atom card_info pointer | ||
1893 | * @reg: MMIO register offset | ||
1894 | * @val: value to write to the pll register | ||
1895 | * | ||
1896 | * Provides a MMIO register accessor for the atom interpreter (r4xx+). | ||
1897 | */ | ||
1898 | static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
1899 | { | ||
1900 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1901 | |||
1902 | WREG32(reg, val); | ||
1903 | } | ||
1904 | |||
1905 | /** | ||
1906 | * cail_reg_read - read MMIO register | ||
1907 | * | ||
1908 | * @info: atom card_info pointer | ||
1909 | * @reg: MMIO register offset | ||
1910 | * | ||
1911 | * Provides an MMIO register accessor for the atom interpreter (r4xx+). | ||
1912 | * Returns the value of the MMIO register. | ||
1913 | */ | ||
1914 | static uint32_t cail_reg_read(struct card_info *info, uint32_t reg) | ||
1915 | { | ||
1916 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1917 | uint32_t r; | ||
1918 | |||
1919 | r = RREG32(reg); | ||
1920 | return r; | ||
1921 | } | ||
1922 | |||
1923 | /** | ||
1924 | * cail_ioreg_write - write IO register | ||
1925 | * | ||
1926 | * @info: atom card_info pointer | ||
1927 | * @reg: IO register offset | ||
1928 | * @val: value to write to the pll register | ||
1929 | * | ||
1930 | * Provides a IO register accessor for the atom interpreter (r4xx+). | ||
1931 | */ | ||
1932 | static void cail_ioreg_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
1933 | { | ||
1934 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1935 | |||
1936 | WREG32_IO(reg, val); | ||
1937 | } | ||
1938 | |||
1939 | /** | ||
1940 | * cail_ioreg_read - read IO register | ||
1941 | * | ||
1942 | * @info: atom card_info pointer | ||
1943 | * @reg: IO register offset | ||
1944 | * | ||
1945 | * Provides an IO register accessor for the atom interpreter (r4xx+). | ||
1946 | * Returns the value of the IO register. | ||
1947 | */ | ||
1948 | static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg) | ||
1949 | { | ||
1950 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1951 | uint32_t r; | ||
1952 | |||
1953 | r = RREG32_IO(reg); | ||
1954 | return r; | ||
1955 | } | ||
1956 | |||
1957 | static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev, | ||
1958 | struct device_attribute *attr, | ||
1959 | char *buf) | ||
1960 | { | ||
1961 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
1962 | struct amdgpu_device *adev = ddev->dev_private; | ||
1963 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
1964 | |||
1965 | return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); | ||
1966 | } | ||
1967 | |||
1968 | static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, | ||
1969 | NULL); | ||
1970 | |||
1971 | /** | ||
1972 | * amdgpu_atombios_fini - free the driver info and callbacks for atombios | ||
1973 | * | ||
1974 | * @adev: amdgpu_device pointer | ||
1975 | * | ||
1976 | * Frees the driver info and register access callbacks for the ATOM | ||
1977 | * interpreter (r4xx+). | ||
1978 | * Called at driver shutdown. | ||
1979 | */ | ||
1980 | void amdgpu_atombios_fini(struct amdgpu_device *adev) | ||
1981 | { | ||
1982 | if (adev->mode_info.atom_context) { | ||
1983 | kfree(adev->mode_info.atom_context->scratch); | ||
1984 | kfree(adev->mode_info.atom_context->iio); | ||
1985 | } | ||
1986 | kfree(adev->mode_info.atom_context); | ||
1987 | adev->mode_info.atom_context = NULL; | ||
1988 | kfree(adev->mode_info.atom_card_info); | ||
1989 | adev->mode_info.atom_card_info = NULL; | ||
1990 | device_remove_file(adev->dev, &dev_attr_vbios_version); | ||
1991 | } | ||
1992 | |||
1993 | /** | ||
1994 | * amdgpu_atombios_init - init the driver info and callbacks for atombios | ||
1995 | * | ||
1996 | * @adev: amdgpu_device pointer | ||
1997 | * | ||
1998 | * Initializes the driver info and register access callbacks for the | ||
1999 | * ATOM interpreter (r4xx+). | ||
2000 | * Returns 0 on sucess, -ENOMEM on failure. | ||
2001 | * Called at driver startup. | ||
2002 | */ | ||
2003 | int amdgpu_atombios_init(struct amdgpu_device *adev) | ||
2004 | { | ||
2005 | struct card_info *atom_card_info = | ||
2006 | kzalloc(sizeof(struct card_info), GFP_KERNEL); | ||
2007 | int ret; | ||
2008 | |||
2009 | if (!atom_card_info) | ||
2010 | return -ENOMEM; | ||
2011 | |||
2012 | adev->mode_info.atom_card_info = atom_card_info; | ||
2013 | atom_card_info->dev = adev->ddev; | ||
2014 | atom_card_info->reg_read = cail_reg_read; | ||
2015 | atom_card_info->reg_write = cail_reg_write; | ||
2016 | /* needed for iio ops */ | ||
2017 | if (adev->rio_mem) { | ||
2018 | atom_card_info->ioreg_read = cail_ioreg_read; | ||
2019 | atom_card_info->ioreg_write = cail_ioreg_write; | ||
2020 | } else { | ||
2021 | DRM_DEBUG("PCI I/O BAR is not found. Using MMIO to access ATOM BIOS\n"); | ||
2022 | atom_card_info->ioreg_read = cail_reg_read; | ||
2023 | atom_card_info->ioreg_write = cail_reg_write; | ||
2024 | } | ||
2025 | atom_card_info->mc_read = cail_mc_read; | ||
2026 | atom_card_info->mc_write = cail_mc_write; | ||
2027 | atom_card_info->pll_read = cail_pll_read; | ||
2028 | atom_card_info->pll_write = cail_pll_write; | ||
2029 | |||
2030 | adev->mode_info.atom_context = amdgpu_atom_parse(atom_card_info, adev->bios); | ||
2031 | if (!adev->mode_info.atom_context) { | ||
2032 | amdgpu_atombios_fini(adev); | ||
2033 | return -ENOMEM; | ||
2034 | } | ||
2035 | |||
2036 | mutex_init(&adev->mode_info.atom_context->mutex); | ||
2037 | if (adev->is_atom_fw) { | ||
2038 | amdgpu_atomfirmware_scratch_regs_init(adev); | ||
2039 | amdgpu_atomfirmware_allocate_fb_scratch(adev); | ||
2040 | } else { | ||
2041 | amdgpu_atombios_scratch_regs_init(adev); | ||
2042 | amdgpu_atombios_allocate_fb_scratch(adev); | ||
2043 | } | ||
2044 | |||
2045 | ret = device_create_file(adev->dev, &dev_attr_vbios_version); | ||
2046 | if (ret) { | ||
2047 | DRM_ERROR("Failed to create device file for VBIOS version\n"); | ||
2048 | return ret; | ||
2049 | } | ||
2050 | |||
2051 | return 0; | ||
2052 | } | ||
2053 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h index b0d5d1d7fdba..fd8f18074f7a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h | |||
@@ -195,9 +195,6 @@ int amdgpu_atombios_init_mc_reg_table(struct amdgpu_device *adev, | |||
195 | bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev); | 195 | bool amdgpu_atombios_has_gpu_virtualization_table(struct amdgpu_device *adev); |
196 | 196 | ||
197 | void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock); | 197 | void amdgpu_atombios_scratch_regs_lock(struct amdgpu_device *adev, bool lock); |
198 | void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev); | ||
199 | void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev); | ||
200 | void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); | ||
201 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, | 198 | void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, |
202 | bool hung); | 199 | bool hung); |
203 | bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev); | 200 | bool amdgpu_atombios_scratch_need_asic_init(struct amdgpu_device *adev); |
@@ -219,6 +216,7 @@ int amdgpu_atombios_get_svi2_info(struct amdgpu_device *adev, | |||
219 | u8 voltage_type, | 216 | u8 voltage_type, |
220 | u8 *svd_gpio_id, u8 *svc_gpio_id); | 217 | u8 *svd_gpio_id, u8 *svc_gpio_id); |
221 | 218 | ||
222 | int amdgpu_atombios_allocate_fb_scratch(struct amdgpu_device *adev); | 219 | void amdgpu_atombios_fini(struct amdgpu_device *adev); |
220 | int amdgpu_atombios_init(struct amdgpu_device *adev); | ||
223 | 221 | ||
224 | #endif | 222 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c index 057e1ecd83ce..a5df80d50d44 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | |||
@@ -93,7 +93,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) | |||
93 | resource_size_t size = 256 * 1024; /* ??? */ | 93 | resource_size_t size = 256 * 1024; /* ??? */ |
94 | 94 | ||
95 | if (!(adev->flags & AMD_IS_APU)) | 95 | if (!(adev->flags & AMD_IS_APU)) |
96 | if (amdgpu_need_post(adev)) | 96 | if (amdgpu_device_need_post(adev)) |
97 | return false; | 97 | return false; |
98 | 98 | ||
99 | adev->bios = NULL; | 99 | adev->bios = NULL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 85d2149b9dbe..13607e28c1c9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | |||
@@ -801,6 +801,9 @@ static int amdgpu_cgs_get_firmware_info(struct cgs_device *cgs_device, | |||
801 | else | 801 | else |
802 | strcpy(fw_name, "amdgpu/vega10_smc.bin"); | 802 | strcpy(fw_name, "amdgpu/vega10_smc.bin"); |
803 | break; | 803 | break; |
804 | case CHIP_RAVEN: | ||
805 | adev->pm.fw_version = info->version; | ||
806 | return 0; | ||
804 | default: | 807 | default: |
805 | DRM_ERROR("SMC firmware not supported\n"); | 808 | DRM_ERROR("SMC firmware not supported\n"); |
806 | return -EINVAL; | 809 | return -EINVAL; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 4cea9ab237ac..5e539fc5b05f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -343,7 +343,12 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, | |||
343 | struct amdgpu_bo *bo) | 343 | struct amdgpu_bo *bo) |
344 | { | 344 | { |
345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | 345 | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); |
346 | struct ttm_operation_ctx ctx = { true, false }; | 346 | struct ttm_operation_ctx ctx = { |
347 | .interruptible = true, | ||
348 | .no_wait_gpu = false, | ||
349 | .allow_reserved_eviction = false, | ||
350 | .resv = bo->tbo.resv | ||
351 | }; | ||
347 | uint32_t domain; | 352 | uint32_t domain; |
348 | int r; | 353 | int r; |
349 | 354 | ||
@@ -1150,7 +1155,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1150 | union drm_amdgpu_cs *cs) | 1155 | union drm_amdgpu_cs *cs) |
1151 | { | 1156 | { |
1152 | struct amdgpu_ring *ring = p->job->ring; | 1157 | struct amdgpu_ring *ring = p->job->ring; |
1153 | struct amd_sched_entity *entity = &p->ctx->rings[ring->idx].entity; | 1158 | struct drm_sched_entity *entity = &p->ctx->rings[ring->idx].entity; |
1154 | struct amdgpu_job *job; | 1159 | struct amdgpu_job *job; |
1155 | unsigned i; | 1160 | unsigned i; |
1156 | uint64_t seq; | 1161 | uint64_t seq; |
@@ -1173,7 +1178,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1173 | job = p->job; | 1178 | job = p->job; |
1174 | p->job = NULL; | 1179 | p->job = NULL; |
1175 | 1180 | ||
1176 | r = amd_sched_job_init(&job->base, &ring->sched, entity, p->filp); | 1181 | r = drm_sched_job_init(&job->base, &ring->sched, entity, p->filp); |
1177 | if (r) { | 1182 | if (r) { |
1178 | amdgpu_job_free(job); | 1183 | amdgpu_job_free(job); |
1179 | amdgpu_mn_unlock(p->mn); | 1184 | amdgpu_mn_unlock(p->mn); |
@@ -1202,7 +1207,7 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, | |||
1202 | amdgpu_ring_priority_get(job->ring, job->base.s_priority); | 1207 | amdgpu_ring_priority_get(job->ring, job->base.s_priority); |
1203 | 1208 | ||
1204 | trace_amdgpu_cs_ioctl(job); | 1209 | trace_amdgpu_cs_ioctl(job); |
1205 | amd_sched_entity_push_job(&job->base, entity); | 1210 | drm_sched_entity_push_job(&job->base, entity); |
1206 | 1211 | ||
1207 | ttm_eu_fence_buffer_objects(&p->ticket, &p->validated, p->fence); | 1212 | ttm_eu_fence_buffer_objects(&p->ticket, &p->validated, p->fence); |
1208 | amdgpu_mn_unlock(p->mn); | 1213 | amdgpu_mn_unlock(p->mn); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index d71dc164b469..09d35051fdd6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | |||
@@ -28,10 +28,10 @@ | |||
28 | #include "amdgpu_sched.h" | 28 | #include "amdgpu_sched.h" |
29 | 29 | ||
30 | static int amdgpu_ctx_priority_permit(struct drm_file *filp, | 30 | static int amdgpu_ctx_priority_permit(struct drm_file *filp, |
31 | enum amd_sched_priority priority) | 31 | enum drm_sched_priority priority) |
32 | { | 32 | { |
33 | /* NORMAL and below are accessible by everyone */ | 33 | /* NORMAL and below are accessible by everyone */ |
34 | if (priority <= AMD_SCHED_PRIORITY_NORMAL) | 34 | if (priority <= DRM_SCHED_PRIORITY_NORMAL) |
35 | return 0; | 35 | return 0; |
36 | 36 | ||
37 | if (capable(CAP_SYS_NICE)) | 37 | if (capable(CAP_SYS_NICE)) |
@@ -44,14 +44,14 @@ static int amdgpu_ctx_priority_permit(struct drm_file *filp, | |||
44 | } | 44 | } |
45 | 45 | ||
46 | static int amdgpu_ctx_init(struct amdgpu_device *adev, | 46 | static int amdgpu_ctx_init(struct amdgpu_device *adev, |
47 | enum amd_sched_priority priority, | 47 | enum drm_sched_priority priority, |
48 | struct drm_file *filp, | 48 | struct drm_file *filp, |
49 | struct amdgpu_ctx *ctx) | 49 | struct amdgpu_ctx *ctx) |
50 | { | 50 | { |
51 | unsigned i, j; | 51 | unsigned i, j; |
52 | int r; | 52 | int r; |
53 | 53 | ||
54 | if (priority < 0 || priority >= AMD_SCHED_PRIORITY_MAX) | 54 | if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX) |
55 | return -EINVAL; | 55 | return -EINVAL; |
56 | 56 | ||
57 | r = amdgpu_ctx_priority_permit(filp, priority); | 57 | r = amdgpu_ctx_priority_permit(filp, priority); |
@@ -78,19 +78,19 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, | |||
78 | ctx->reset_counter_query = ctx->reset_counter; | 78 | ctx->reset_counter_query = ctx->reset_counter; |
79 | ctx->vram_lost_counter = atomic_read(&adev->vram_lost_counter); | 79 | ctx->vram_lost_counter = atomic_read(&adev->vram_lost_counter); |
80 | ctx->init_priority = priority; | 80 | ctx->init_priority = priority; |
81 | ctx->override_priority = AMD_SCHED_PRIORITY_UNSET; | 81 | ctx->override_priority = DRM_SCHED_PRIORITY_UNSET; |
82 | 82 | ||
83 | /* create context entity for each ring */ | 83 | /* create context entity for each ring */ |
84 | for (i = 0; i < adev->num_rings; i++) { | 84 | for (i = 0; i < adev->num_rings; i++) { |
85 | struct amdgpu_ring *ring = adev->rings[i]; | 85 | struct amdgpu_ring *ring = adev->rings[i]; |
86 | struct amd_sched_rq *rq; | 86 | struct drm_sched_rq *rq; |
87 | 87 | ||
88 | rq = &ring->sched.sched_rq[priority]; | 88 | rq = &ring->sched.sched_rq[priority]; |
89 | 89 | ||
90 | if (ring == &adev->gfx.kiq.ring) | 90 | if (ring == &adev->gfx.kiq.ring) |
91 | continue; | 91 | continue; |
92 | 92 | ||
93 | r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity, | 93 | r = drm_sched_entity_init(&ring->sched, &ctx->rings[i].entity, |
94 | rq, amdgpu_sched_jobs, &ctx->guilty); | 94 | rq, amdgpu_sched_jobs, &ctx->guilty); |
95 | if (r) | 95 | if (r) |
96 | goto failed; | 96 | goto failed; |
@@ -104,7 +104,7 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, | |||
104 | 104 | ||
105 | failed: | 105 | failed: |
106 | for (j = 0; j < i; j++) | 106 | for (j = 0; j < i; j++) |
107 | amd_sched_entity_fini(&adev->rings[j]->sched, | 107 | drm_sched_entity_fini(&adev->rings[j]->sched, |
108 | &ctx->rings[j].entity); | 108 | &ctx->rings[j].entity); |
109 | kfree(ctx->fences); | 109 | kfree(ctx->fences); |
110 | ctx->fences = NULL; | 110 | ctx->fences = NULL; |
@@ -126,7 +126,7 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) | |||
126 | ctx->fences = NULL; | 126 | ctx->fences = NULL; |
127 | 127 | ||
128 | for (i = 0; i < adev->num_rings; i++) | 128 | for (i = 0; i < adev->num_rings; i++) |
129 | amd_sched_entity_fini(&adev->rings[i]->sched, | 129 | drm_sched_entity_fini(&adev->rings[i]->sched, |
130 | &ctx->rings[i].entity); | 130 | &ctx->rings[i].entity); |
131 | 131 | ||
132 | amdgpu_queue_mgr_fini(adev, &ctx->queue_mgr); | 132 | amdgpu_queue_mgr_fini(adev, &ctx->queue_mgr); |
@@ -137,7 +137,7 @@ static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx) | |||
137 | static int amdgpu_ctx_alloc(struct amdgpu_device *adev, | 137 | static int amdgpu_ctx_alloc(struct amdgpu_device *adev, |
138 | struct amdgpu_fpriv *fpriv, | 138 | struct amdgpu_fpriv *fpriv, |
139 | struct drm_file *filp, | 139 | struct drm_file *filp, |
140 | enum amd_sched_priority priority, | 140 | enum drm_sched_priority priority, |
141 | uint32_t *id) | 141 | uint32_t *id) |
142 | { | 142 | { |
143 | struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; | 143 | struct amdgpu_ctx_mgr *mgr = &fpriv->ctx_mgr; |
@@ -266,7 +266,7 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | |||
266 | { | 266 | { |
267 | int r; | 267 | int r; |
268 | uint32_t id; | 268 | uint32_t id; |
269 | enum amd_sched_priority priority; | 269 | enum drm_sched_priority priority; |
270 | 270 | ||
271 | union drm_amdgpu_ctx *args = data; | 271 | union drm_amdgpu_ctx *args = data; |
272 | struct amdgpu_device *adev = dev->dev_private; | 272 | struct amdgpu_device *adev = dev->dev_private; |
@@ -278,8 +278,8 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, | |||
278 | 278 | ||
279 | /* For backwards compatibility reasons, we need to accept | 279 | /* For backwards compatibility reasons, we need to accept |
280 | * ioctls with garbage in the priority field */ | 280 | * ioctls with garbage in the priority field */ |
281 | if (priority == AMD_SCHED_PRIORITY_INVALID) | 281 | if (priority == DRM_SCHED_PRIORITY_INVALID) |
282 | priority = AMD_SCHED_PRIORITY_NORMAL; | 282 | priority = DRM_SCHED_PRIORITY_NORMAL; |
283 | 283 | ||
284 | switch (args->in.op) { | 284 | switch (args->in.op) { |
285 | case AMDGPU_CTX_OP_ALLOC_CTX: | 285 | case AMDGPU_CTX_OP_ALLOC_CTX: |
@@ -385,18 +385,18 @@ struct dma_fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, | |||
385 | } | 385 | } |
386 | 386 | ||
387 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | 387 | void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, |
388 | enum amd_sched_priority priority) | 388 | enum drm_sched_priority priority) |
389 | { | 389 | { |
390 | int i; | 390 | int i; |
391 | struct amdgpu_device *adev = ctx->adev; | 391 | struct amdgpu_device *adev = ctx->adev; |
392 | struct amd_sched_rq *rq; | 392 | struct drm_sched_rq *rq; |
393 | struct amd_sched_entity *entity; | 393 | struct drm_sched_entity *entity; |
394 | struct amdgpu_ring *ring; | 394 | struct amdgpu_ring *ring; |
395 | enum amd_sched_priority ctx_prio; | 395 | enum drm_sched_priority ctx_prio; |
396 | 396 | ||
397 | ctx->override_priority = priority; | 397 | ctx->override_priority = priority; |
398 | 398 | ||
399 | ctx_prio = (ctx->override_priority == AMD_SCHED_PRIORITY_UNSET) ? | 399 | ctx_prio = (ctx->override_priority == DRM_SCHED_PRIORITY_UNSET) ? |
400 | ctx->init_priority : ctx->override_priority; | 400 | ctx->init_priority : ctx->override_priority; |
401 | 401 | ||
402 | for (i = 0; i < adev->num_rings; i++) { | 402 | for (i = 0; i < adev->num_rings; i++) { |
@@ -407,7 +407,7 @@ void amdgpu_ctx_priority_override(struct amdgpu_ctx *ctx, | |||
407 | if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ) | 407 | if (ring->funcs->type == AMDGPU_RING_TYPE_KIQ) |
408 | continue; | 408 | continue; |
409 | 409 | ||
410 | amd_sched_entity_set_rq(entity, rq); | 410 | drm_sched_entity_set_rq(entity, rq); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c new file mode 100644 index 000000000000..ee76b468774a --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | |||
@@ -0,0 +1,792 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Advanced Micro Devices, Inc. | ||
3 | * Copyright 2008 Red Hat Inc. | ||
4 | * Copyright 2009 Jerome Glisse. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included in | ||
14 | * all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
22 | * OTHER DEALINGS IN THE SOFTWARE. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #include <linux/kthread.h> | ||
27 | #include <drm/drmP.h> | ||
28 | #include <linux/debugfs.h> | ||
29 | #include "amdgpu.h" | ||
30 | |||
31 | /* | ||
32 | * Debugfs | ||
33 | */ | ||
34 | int amdgpu_debugfs_add_files(struct amdgpu_device *adev, | ||
35 | const struct drm_info_list *files, | ||
36 | unsigned nfiles) | ||
37 | { | ||
38 | unsigned i; | ||
39 | |||
40 | for (i = 0; i < adev->debugfs_count; i++) { | ||
41 | if (adev->debugfs[i].files == files) { | ||
42 | /* Already registered */ | ||
43 | return 0; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | i = adev->debugfs_count + 1; | ||
48 | if (i > AMDGPU_DEBUGFS_MAX_COMPONENTS) { | ||
49 | DRM_ERROR("Reached maximum number of debugfs components.\n"); | ||
50 | DRM_ERROR("Report so we increase " | ||
51 | "AMDGPU_DEBUGFS_MAX_COMPONENTS.\n"); | ||
52 | return -EINVAL; | ||
53 | } | ||
54 | adev->debugfs[adev->debugfs_count].files = files; | ||
55 | adev->debugfs[adev->debugfs_count].num_files = nfiles; | ||
56 | adev->debugfs_count = i; | ||
57 | #if defined(CONFIG_DEBUG_FS) | ||
58 | drm_debugfs_create_files(files, nfiles, | ||
59 | adev->ddev->primary->debugfs_root, | ||
60 | adev->ddev->primary); | ||
61 | #endif | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | #if defined(CONFIG_DEBUG_FS) | ||
66 | |||
67 | static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf, | ||
68 | size_t size, loff_t *pos) | ||
69 | { | ||
70 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
71 | ssize_t result = 0; | ||
72 | int r; | ||
73 | bool pm_pg_lock, use_bank; | ||
74 | unsigned instance_bank, sh_bank, se_bank; | ||
75 | |||
76 | if (size & 0x3 || *pos & 0x3) | ||
77 | return -EINVAL; | ||
78 | |||
79 | /* are we reading registers for which a PG lock is necessary? */ | ||
80 | pm_pg_lock = (*pos >> 23) & 1; | ||
81 | |||
82 | if (*pos & (1ULL << 62)) { | ||
83 | se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24; | ||
84 | sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34; | ||
85 | instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44; | ||
86 | |||
87 | if (se_bank == 0x3FF) | ||
88 | se_bank = 0xFFFFFFFF; | ||
89 | if (sh_bank == 0x3FF) | ||
90 | sh_bank = 0xFFFFFFFF; | ||
91 | if (instance_bank == 0x3FF) | ||
92 | instance_bank = 0xFFFFFFFF; | ||
93 | use_bank = 1; | ||
94 | } else { | ||
95 | use_bank = 0; | ||
96 | } | ||
97 | |||
98 | *pos &= (1UL << 22) - 1; | ||
99 | |||
100 | if (use_bank) { | ||
101 | if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) || | ||
102 | (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) | ||
103 | return -EINVAL; | ||
104 | mutex_lock(&adev->grbm_idx_mutex); | ||
105 | amdgpu_gfx_select_se_sh(adev, se_bank, | ||
106 | sh_bank, instance_bank); | ||
107 | } | ||
108 | |||
109 | if (pm_pg_lock) | ||
110 | mutex_lock(&adev->pm.mutex); | ||
111 | |||
112 | while (size) { | ||
113 | uint32_t value; | ||
114 | |||
115 | if (*pos > adev->rmmio_size) | ||
116 | goto end; | ||
117 | |||
118 | value = RREG32(*pos >> 2); | ||
119 | r = put_user(value, (uint32_t *)buf); | ||
120 | if (r) { | ||
121 | result = r; | ||
122 | goto end; | ||
123 | } | ||
124 | |||
125 | result += 4; | ||
126 | buf += 4; | ||
127 | *pos += 4; | ||
128 | size -= 4; | ||
129 | } | ||
130 | |||
131 | end: | ||
132 | if (use_bank) { | ||
133 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
134 | mutex_unlock(&adev->grbm_idx_mutex); | ||
135 | } | ||
136 | |||
137 | if (pm_pg_lock) | ||
138 | mutex_unlock(&adev->pm.mutex); | ||
139 | |||
140 | return result; | ||
141 | } | ||
142 | |||
143 | static ssize_t amdgpu_debugfs_regs_write(struct file *f, const char __user *buf, | ||
144 | size_t size, loff_t *pos) | ||
145 | { | ||
146 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
147 | ssize_t result = 0; | ||
148 | int r; | ||
149 | bool pm_pg_lock, use_bank; | ||
150 | unsigned instance_bank, sh_bank, se_bank; | ||
151 | |||
152 | if (size & 0x3 || *pos & 0x3) | ||
153 | return -EINVAL; | ||
154 | |||
155 | /* are we reading registers for which a PG lock is necessary? */ | ||
156 | pm_pg_lock = (*pos >> 23) & 1; | ||
157 | |||
158 | if (*pos & (1ULL << 62)) { | ||
159 | se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24; | ||
160 | sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34; | ||
161 | instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44; | ||
162 | |||
163 | if (se_bank == 0x3FF) | ||
164 | se_bank = 0xFFFFFFFF; | ||
165 | if (sh_bank == 0x3FF) | ||
166 | sh_bank = 0xFFFFFFFF; | ||
167 | if (instance_bank == 0x3FF) | ||
168 | instance_bank = 0xFFFFFFFF; | ||
169 | use_bank = 1; | ||
170 | } else { | ||
171 | use_bank = 0; | ||
172 | } | ||
173 | |||
174 | *pos &= (1UL << 22) - 1; | ||
175 | |||
176 | if (use_bank) { | ||
177 | if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) || | ||
178 | (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) | ||
179 | return -EINVAL; | ||
180 | mutex_lock(&adev->grbm_idx_mutex); | ||
181 | amdgpu_gfx_select_se_sh(adev, se_bank, | ||
182 | sh_bank, instance_bank); | ||
183 | } | ||
184 | |||
185 | if (pm_pg_lock) | ||
186 | mutex_lock(&adev->pm.mutex); | ||
187 | |||
188 | while (size) { | ||
189 | uint32_t value; | ||
190 | |||
191 | if (*pos > adev->rmmio_size) | ||
192 | return result; | ||
193 | |||
194 | r = get_user(value, (uint32_t *)buf); | ||
195 | if (r) | ||
196 | return r; | ||
197 | |||
198 | WREG32(*pos >> 2, value); | ||
199 | |||
200 | result += 4; | ||
201 | buf += 4; | ||
202 | *pos += 4; | ||
203 | size -= 4; | ||
204 | } | ||
205 | |||
206 | if (use_bank) { | ||
207 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
208 | mutex_unlock(&adev->grbm_idx_mutex); | ||
209 | } | ||
210 | |||
211 | if (pm_pg_lock) | ||
212 | mutex_unlock(&adev->pm.mutex); | ||
213 | |||
214 | return result; | ||
215 | } | ||
216 | |||
217 | static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf, | ||
218 | size_t size, loff_t *pos) | ||
219 | { | ||
220 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
221 | ssize_t result = 0; | ||
222 | int r; | ||
223 | |||
224 | if (size & 0x3 || *pos & 0x3) | ||
225 | return -EINVAL; | ||
226 | |||
227 | while (size) { | ||
228 | uint32_t value; | ||
229 | |||
230 | value = RREG32_PCIE(*pos >> 2); | ||
231 | r = put_user(value, (uint32_t *)buf); | ||
232 | if (r) | ||
233 | return r; | ||
234 | |||
235 | result += 4; | ||
236 | buf += 4; | ||
237 | *pos += 4; | ||
238 | size -= 4; | ||
239 | } | ||
240 | |||
241 | return result; | ||
242 | } | ||
243 | |||
244 | static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user *buf, | ||
245 | size_t size, loff_t *pos) | ||
246 | { | ||
247 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
248 | ssize_t result = 0; | ||
249 | int r; | ||
250 | |||
251 | if (size & 0x3 || *pos & 0x3) | ||
252 | return -EINVAL; | ||
253 | |||
254 | while (size) { | ||
255 | uint32_t value; | ||
256 | |||
257 | r = get_user(value, (uint32_t *)buf); | ||
258 | if (r) | ||
259 | return r; | ||
260 | |||
261 | WREG32_PCIE(*pos >> 2, value); | ||
262 | |||
263 | result += 4; | ||
264 | buf += 4; | ||
265 | *pos += 4; | ||
266 | size -= 4; | ||
267 | } | ||
268 | |||
269 | return result; | ||
270 | } | ||
271 | |||
272 | static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf, | ||
273 | size_t size, loff_t *pos) | ||
274 | { | ||
275 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
276 | ssize_t result = 0; | ||
277 | int r; | ||
278 | |||
279 | if (size & 0x3 || *pos & 0x3) | ||
280 | return -EINVAL; | ||
281 | |||
282 | while (size) { | ||
283 | uint32_t value; | ||
284 | |||
285 | value = RREG32_DIDT(*pos >> 2); | ||
286 | r = put_user(value, (uint32_t *)buf); | ||
287 | if (r) | ||
288 | return r; | ||
289 | |||
290 | result += 4; | ||
291 | buf += 4; | ||
292 | *pos += 4; | ||
293 | size -= 4; | ||
294 | } | ||
295 | |||
296 | return result; | ||
297 | } | ||
298 | |||
299 | static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user *buf, | ||
300 | size_t size, loff_t *pos) | ||
301 | { | ||
302 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
303 | ssize_t result = 0; | ||
304 | int r; | ||
305 | |||
306 | if (size & 0x3 || *pos & 0x3) | ||
307 | return -EINVAL; | ||
308 | |||
309 | while (size) { | ||
310 | uint32_t value; | ||
311 | |||
312 | r = get_user(value, (uint32_t *)buf); | ||
313 | if (r) | ||
314 | return r; | ||
315 | |||
316 | WREG32_DIDT(*pos >> 2, value); | ||
317 | |||
318 | result += 4; | ||
319 | buf += 4; | ||
320 | *pos += 4; | ||
321 | size -= 4; | ||
322 | } | ||
323 | |||
324 | return result; | ||
325 | } | ||
326 | |||
327 | static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf, | ||
328 | size_t size, loff_t *pos) | ||
329 | { | ||
330 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
331 | ssize_t result = 0; | ||
332 | int r; | ||
333 | |||
334 | if (size & 0x3 || *pos & 0x3) | ||
335 | return -EINVAL; | ||
336 | |||
337 | while (size) { | ||
338 | uint32_t value; | ||
339 | |||
340 | value = RREG32_SMC(*pos); | ||
341 | r = put_user(value, (uint32_t *)buf); | ||
342 | if (r) | ||
343 | return r; | ||
344 | |||
345 | result += 4; | ||
346 | buf += 4; | ||
347 | *pos += 4; | ||
348 | size -= 4; | ||
349 | } | ||
350 | |||
351 | return result; | ||
352 | } | ||
353 | |||
354 | static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *buf, | ||
355 | size_t size, loff_t *pos) | ||
356 | { | ||
357 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
358 | ssize_t result = 0; | ||
359 | int r; | ||
360 | |||
361 | if (size & 0x3 || *pos & 0x3) | ||
362 | return -EINVAL; | ||
363 | |||
364 | while (size) { | ||
365 | uint32_t value; | ||
366 | |||
367 | r = get_user(value, (uint32_t *)buf); | ||
368 | if (r) | ||
369 | return r; | ||
370 | |||
371 | WREG32_SMC(*pos, value); | ||
372 | |||
373 | result += 4; | ||
374 | buf += 4; | ||
375 | *pos += 4; | ||
376 | size -= 4; | ||
377 | } | ||
378 | |||
379 | return result; | ||
380 | } | ||
381 | |||
382 | static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf, | ||
383 | size_t size, loff_t *pos) | ||
384 | { | ||
385 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
386 | ssize_t result = 0; | ||
387 | int r; | ||
388 | uint32_t *config, no_regs = 0; | ||
389 | |||
390 | if (size & 0x3 || *pos & 0x3) | ||
391 | return -EINVAL; | ||
392 | |||
393 | config = kmalloc_array(256, sizeof(*config), GFP_KERNEL); | ||
394 | if (!config) | ||
395 | return -ENOMEM; | ||
396 | |||
397 | /* version, increment each time something is added */ | ||
398 | config[no_regs++] = 3; | ||
399 | config[no_regs++] = adev->gfx.config.max_shader_engines; | ||
400 | config[no_regs++] = adev->gfx.config.max_tile_pipes; | ||
401 | config[no_regs++] = adev->gfx.config.max_cu_per_sh; | ||
402 | config[no_regs++] = adev->gfx.config.max_sh_per_se; | ||
403 | config[no_regs++] = adev->gfx.config.max_backends_per_se; | ||
404 | config[no_regs++] = adev->gfx.config.max_texture_channel_caches; | ||
405 | config[no_regs++] = adev->gfx.config.max_gprs; | ||
406 | config[no_regs++] = adev->gfx.config.max_gs_threads; | ||
407 | config[no_regs++] = adev->gfx.config.max_hw_contexts; | ||
408 | config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_frontend; | ||
409 | config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_backend; | ||
410 | config[no_regs++] = adev->gfx.config.sc_hiz_tile_fifo_size; | ||
411 | config[no_regs++] = adev->gfx.config.sc_earlyz_tile_fifo_size; | ||
412 | config[no_regs++] = adev->gfx.config.num_tile_pipes; | ||
413 | config[no_regs++] = adev->gfx.config.backend_enable_mask; | ||
414 | config[no_regs++] = adev->gfx.config.mem_max_burst_length_bytes; | ||
415 | config[no_regs++] = adev->gfx.config.mem_row_size_in_kb; | ||
416 | config[no_regs++] = adev->gfx.config.shader_engine_tile_size; | ||
417 | config[no_regs++] = adev->gfx.config.num_gpus; | ||
418 | config[no_regs++] = adev->gfx.config.multi_gpu_tile_size; | ||
419 | config[no_regs++] = adev->gfx.config.mc_arb_ramcfg; | ||
420 | config[no_regs++] = adev->gfx.config.gb_addr_config; | ||
421 | config[no_regs++] = adev->gfx.config.num_rbs; | ||
422 | |||
423 | /* rev==1 */ | ||
424 | config[no_regs++] = adev->rev_id; | ||
425 | config[no_regs++] = adev->pg_flags; | ||
426 | config[no_regs++] = adev->cg_flags; | ||
427 | |||
428 | /* rev==2 */ | ||
429 | config[no_regs++] = adev->family; | ||
430 | config[no_regs++] = adev->external_rev_id; | ||
431 | |||
432 | /* rev==3 */ | ||
433 | config[no_regs++] = adev->pdev->device; | ||
434 | config[no_regs++] = adev->pdev->revision; | ||
435 | config[no_regs++] = adev->pdev->subsystem_device; | ||
436 | config[no_regs++] = adev->pdev->subsystem_vendor; | ||
437 | |||
438 | while (size && (*pos < no_regs * 4)) { | ||
439 | uint32_t value; | ||
440 | |||
441 | value = config[*pos >> 2]; | ||
442 | r = put_user(value, (uint32_t *)buf); | ||
443 | if (r) { | ||
444 | kfree(config); | ||
445 | return r; | ||
446 | } | ||
447 | |||
448 | result += 4; | ||
449 | buf += 4; | ||
450 | *pos += 4; | ||
451 | size -= 4; | ||
452 | } | ||
453 | |||
454 | kfree(config); | ||
455 | return result; | ||
456 | } | ||
457 | |||
458 | static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf, | ||
459 | size_t size, loff_t *pos) | ||
460 | { | ||
461 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
462 | int idx, x, outsize, r, valuesize; | ||
463 | uint32_t values[16]; | ||
464 | |||
465 | if (size & 3 || *pos & 0x3) | ||
466 | return -EINVAL; | ||
467 | |||
468 | if (amdgpu_dpm == 0) | ||
469 | return -EINVAL; | ||
470 | |||
471 | /* convert offset to sensor number */ | ||
472 | idx = *pos >> 2; | ||
473 | |||
474 | valuesize = sizeof(values); | ||
475 | if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->read_sensor) | ||
476 | r = amdgpu_dpm_read_sensor(adev, idx, &values[0], &valuesize); | ||
477 | else | ||
478 | return -EINVAL; | ||
479 | |||
480 | if (size > valuesize) | ||
481 | return -EINVAL; | ||
482 | |||
483 | outsize = 0; | ||
484 | x = 0; | ||
485 | if (!r) { | ||
486 | while (size) { | ||
487 | r = put_user(values[x++], (int32_t *)buf); | ||
488 | buf += 4; | ||
489 | size -= 4; | ||
490 | outsize += 4; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | return !r ? outsize : r; | ||
495 | } | ||
496 | |||
497 | static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf, | ||
498 | size_t size, loff_t *pos) | ||
499 | { | ||
500 | struct amdgpu_device *adev = f->f_inode->i_private; | ||
501 | int r, x; | ||
502 | ssize_t result=0; | ||
503 | uint32_t offset, se, sh, cu, wave, simd, data[32]; | ||
504 | |||
505 | if (size & 3 || *pos & 3) | ||
506 | return -EINVAL; | ||
507 | |||
508 | /* decode offset */ | ||
509 | offset = (*pos & GENMASK_ULL(6, 0)); | ||
510 | se = (*pos & GENMASK_ULL(14, 7)) >> 7; | ||
511 | sh = (*pos & GENMASK_ULL(22, 15)) >> 15; | ||
512 | cu = (*pos & GENMASK_ULL(30, 23)) >> 23; | ||
513 | wave = (*pos & GENMASK_ULL(36, 31)) >> 31; | ||
514 | simd = (*pos & GENMASK_ULL(44, 37)) >> 37; | ||
515 | |||
516 | /* switch to the specific se/sh/cu */ | ||
517 | mutex_lock(&adev->grbm_idx_mutex); | ||
518 | amdgpu_gfx_select_se_sh(adev, se, sh, cu); | ||
519 | |||
520 | x = 0; | ||
521 | if (adev->gfx.funcs->read_wave_data) | ||
522 | adev->gfx.funcs->read_wave_data(adev, simd, wave, data, &x); | ||
523 | |||
524 | amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | ||
525 | mutex_unlock(&adev->grbm_idx_mutex); | ||
526 | |||
527 | if (!x) | ||
528 | return -EINVAL; | ||
529 | |||
530 | while (size && (offset < x * 4)) { | ||
531 | uint32_t value; | ||
532 | |||
533 | value = data[offset >> 2]; | ||
534 | r = put_user(value, (uint32_t *)buf); | ||
535 | if (r) | ||
536 | return r; | ||
537 | |||
538 | result += 4; | ||
539 | buf += 4; | ||
540 | offset += 4; | ||
541 | size -= 4; | ||
542 | } | ||
543 | |||
544 | return result; | ||
545 | } | ||
546 | |||
547 | static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, | ||
548 | size_t size, loff_t *pos) | ||
549 | { | ||
550 | struct amdgpu_device *adev = f->f_inode->i_private; | ||
551 | int r; | ||
552 | ssize_t result = 0; | ||
553 | uint32_t offset, se, sh, cu, wave, simd, thread, bank, *data; | ||
554 | |||
555 | if (size & 3 || *pos & 3) | ||
556 | return -EINVAL; | ||
557 | |||
558 | /* decode offset */ | ||
559 | offset = *pos & GENMASK_ULL(11, 0); | ||
560 | se = (*pos & GENMASK_ULL(19, 12)) >> 12; | ||
561 | sh = (*pos & GENMASK_ULL(27, 20)) >> 20; | ||
562 | cu = (*pos & GENMASK_ULL(35, 28)) >> 28; | ||
563 | wave = (*pos & GENMASK_ULL(43, 36)) >> 36; | ||
564 | simd = (*pos & GENMASK_ULL(51, 44)) >> 44; | ||
565 | thread = (*pos & GENMASK_ULL(59, 52)) >> 52; | ||
566 | bank = (*pos & GENMASK_ULL(61, 60)) >> 60; | ||
567 | |||
568 | data = kmalloc_array(1024, sizeof(*data), GFP_KERNEL); | ||
569 | if (!data) | ||
570 | return -ENOMEM; | ||
571 | |||
572 | /* switch to the specific se/sh/cu */ | ||
573 | mutex_lock(&adev->grbm_idx_mutex); | ||
574 | amdgpu_gfx_select_se_sh(adev, se, sh, cu); | ||
575 | |||
576 | if (bank == 0) { | ||
577 | if (adev->gfx.funcs->read_wave_vgprs) | ||
578 | adev->gfx.funcs->read_wave_vgprs(adev, simd, wave, thread, offset, size>>2, data); | ||
579 | } else { | ||
580 | if (adev->gfx.funcs->read_wave_sgprs) | ||
581 | adev->gfx.funcs->read_wave_sgprs(adev, simd, wave, offset, size>>2, data); | ||
582 | } | ||
583 | |||
584 | amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | ||
585 | mutex_unlock(&adev->grbm_idx_mutex); | ||
586 | |||
587 | while (size) { | ||
588 | uint32_t value; | ||
589 | |||
590 | value = data[offset++]; | ||
591 | r = put_user(value, (uint32_t *)buf); | ||
592 | if (r) { | ||
593 | result = r; | ||
594 | goto err; | ||
595 | } | ||
596 | |||
597 | result += 4; | ||
598 | buf += 4; | ||
599 | size -= 4; | ||
600 | } | ||
601 | |||
602 | err: | ||
603 | kfree(data); | ||
604 | return result; | ||
605 | } | ||
606 | |||
607 | static const struct file_operations amdgpu_debugfs_regs_fops = { | ||
608 | .owner = THIS_MODULE, | ||
609 | .read = amdgpu_debugfs_regs_read, | ||
610 | .write = amdgpu_debugfs_regs_write, | ||
611 | .llseek = default_llseek | ||
612 | }; | ||
613 | static const struct file_operations amdgpu_debugfs_regs_didt_fops = { | ||
614 | .owner = THIS_MODULE, | ||
615 | .read = amdgpu_debugfs_regs_didt_read, | ||
616 | .write = amdgpu_debugfs_regs_didt_write, | ||
617 | .llseek = default_llseek | ||
618 | }; | ||
619 | static const struct file_operations amdgpu_debugfs_regs_pcie_fops = { | ||
620 | .owner = THIS_MODULE, | ||
621 | .read = amdgpu_debugfs_regs_pcie_read, | ||
622 | .write = amdgpu_debugfs_regs_pcie_write, | ||
623 | .llseek = default_llseek | ||
624 | }; | ||
625 | static const struct file_operations amdgpu_debugfs_regs_smc_fops = { | ||
626 | .owner = THIS_MODULE, | ||
627 | .read = amdgpu_debugfs_regs_smc_read, | ||
628 | .write = amdgpu_debugfs_regs_smc_write, | ||
629 | .llseek = default_llseek | ||
630 | }; | ||
631 | |||
632 | static const struct file_operations amdgpu_debugfs_gca_config_fops = { | ||
633 | .owner = THIS_MODULE, | ||
634 | .read = amdgpu_debugfs_gca_config_read, | ||
635 | .llseek = default_llseek | ||
636 | }; | ||
637 | |||
638 | static const struct file_operations amdgpu_debugfs_sensors_fops = { | ||
639 | .owner = THIS_MODULE, | ||
640 | .read = amdgpu_debugfs_sensor_read, | ||
641 | .llseek = default_llseek | ||
642 | }; | ||
643 | |||
644 | static const struct file_operations amdgpu_debugfs_wave_fops = { | ||
645 | .owner = THIS_MODULE, | ||
646 | .read = amdgpu_debugfs_wave_read, | ||
647 | .llseek = default_llseek | ||
648 | }; | ||
649 | static const struct file_operations amdgpu_debugfs_gpr_fops = { | ||
650 | .owner = THIS_MODULE, | ||
651 | .read = amdgpu_debugfs_gpr_read, | ||
652 | .llseek = default_llseek | ||
653 | }; | ||
654 | |||
655 | static const struct file_operations *debugfs_regs[] = { | ||
656 | &amdgpu_debugfs_regs_fops, | ||
657 | &amdgpu_debugfs_regs_didt_fops, | ||
658 | &amdgpu_debugfs_regs_pcie_fops, | ||
659 | &amdgpu_debugfs_regs_smc_fops, | ||
660 | &amdgpu_debugfs_gca_config_fops, | ||
661 | &amdgpu_debugfs_sensors_fops, | ||
662 | &amdgpu_debugfs_wave_fops, | ||
663 | &amdgpu_debugfs_gpr_fops, | ||
664 | }; | ||
665 | |||
666 | static const char *debugfs_regs_names[] = { | ||
667 | "amdgpu_regs", | ||
668 | "amdgpu_regs_didt", | ||
669 | "amdgpu_regs_pcie", | ||
670 | "amdgpu_regs_smc", | ||
671 | "amdgpu_gca_config", | ||
672 | "amdgpu_sensors", | ||
673 | "amdgpu_wave", | ||
674 | "amdgpu_gpr", | ||
675 | }; | ||
676 | |||
677 | int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) | ||
678 | { | ||
679 | struct drm_minor *minor = adev->ddev->primary; | ||
680 | struct dentry *ent, *root = minor->debugfs_root; | ||
681 | unsigned i, j; | ||
682 | |||
683 | for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) { | ||
684 | ent = debugfs_create_file(debugfs_regs_names[i], | ||
685 | S_IFREG | S_IRUGO, root, | ||
686 | adev, debugfs_regs[i]); | ||
687 | if (IS_ERR(ent)) { | ||
688 | for (j = 0; j < i; j++) { | ||
689 | debugfs_remove(adev->debugfs_regs[i]); | ||
690 | adev->debugfs_regs[i] = NULL; | ||
691 | } | ||
692 | return PTR_ERR(ent); | ||
693 | } | ||
694 | |||
695 | if (!i) | ||
696 | i_size_write(ent->d_inode, adev->rmmio_size); | ||
697 | adev->debugfs_regs[i] = ent; | ||
698 | } | ||
699 | |||
700 | return 0; | ||
701 | } | ||
702 | |||
703 | void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) | ||
704 | { | ||
705 | unsigned i; | ||
706 | |||
707 | for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) { | ||
708 | if (adev->debugfs_regs[i]) { | ||
709 | debugfs_remove(adev->debugfs_regs[i]); | ||
710 | adev->debugfs_regs[i] = NULL; | ||
711 | } | ||
712 | } | ||
713 | } | ||
714 | |||
715 | static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data) | ||
716 | { | ||
717 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
718 | struct drm_device *dev = node->minor->dev; | ||
719 | struct amdgpu_device *adev = dev->dev_private; | ||
720 | int r = 0, i; | ||
721 | |||
722 | /* hold on the scheduler */ | ||
723 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | ||
724 | struct amdgpu_ring *ring = adev->rings[i]; | ||
725 | |||
726 | if (!ring || !ring->sched.thread) | ||
727 | continue; | ||
728 | kthread_park(ring->sched.thread); | ||
729 | } | ||
730 | |||
731 | seq_printf(m, "run ib test:\n"); | ||
732 | r = amdgpu_ib_ring_tests(adev); | ||
733 | if (r) | ||
734 | seq_printf(m, "ib ring tests failed (%d).\n", r); | ||
735 | else | ||
736 | seq_printf(m, "ib ring tests passed.\n"); | ||
737 | |||
738 | /* go on the scheduler */ | ||
739 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | ||
740 | struct amdgpu_ring *ring = adev->rings[i]; | ||
741 | |||
742 | if (!ring || !ring->sched.thread) | ||
743 | continue; | ||
744 | kthread_unpark(ring->sched.thread); | ||
745 | } | ||
746 | |||
747 | return 0; | ||
748 | } | ||
749 | |||
750 | static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data) | ||
751 | { | ||
752 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
753 | struct drm_device *dev = node->minor->dev; | ||
754 | struct amdgpu_device *adev = dev->dev_private; | ||
755 | |||
756 | seq_write(m, adev->bios, adev->bios_size); | ||
757 | return 0; | ||
758 | } | ||
759 | |||
760 | static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data) | ||
761 | { | ||
762 | struct drm_info_node *node = (struct drm_info_node *)m->private; | ||
763 | struct drm_device *dev = node->minor->dev; | ||
764 | struct amdgpu_device *adev = dev->dev_private; | ||
765 | |||
766 | seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev)); | ||
767 | return 0; | ||
768 | } | ||
769 | |||
770 | static const struct drm_info_list amdgpu_debugfs_list[] = { | ||
771 | {"amdgpu_vbios", amdgpu_debugfs_get_vbios_dump}, | ||
772 | {"amdgpu_test_ib", &amdgpu_debugfs_test_ib}, | ||
773 | {"amdgpu_evict_vram", &amdgpu_debugfs_evict_vram} | ||
774 | }; | ||
775 | |||
776 | int amdgpu_debugfs_init(struct amdgpu_device *adev) | ||
777 | { | ||
778 | return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_list, | ||
779 | ARRAY_SIZE(amdgpu_debugfs_list)); | ||
780 | } | ||
781 | |||
782 | #else | ||
783 | int amdgpu_debugfs_init(struct amdgpu_device *adev) | ||
784 | { | ||
785 | return 0; | ||
786 | } | ||
787 | int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) | ||
788 | { | ||
789 | return 0; | ||
790 | } | ||
791 | void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) { } | ||
792 | #endif | ||
diff --git a/drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h index 147822545252..8260d8073c26 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/grph_object_id.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.h | |||
@@ -1,5 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2012-15 Advanced Micro Devices, Inc. | 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
3 | * Copyright 2008 Red Hat Inc. | ||
4 | * Copyright 2009 Jerome Glisse. | ||
3 | * | 5 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a | 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), | 7 | * copy of this software and associated documentation files (the "Software"), |
@@ -19,57 +21,22 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 22 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 23 | * |
22 | * Authors: AMD | ||
23 | * | ||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "dm_services.h" | 26 | /* |
27 | #include "include/grph_object_id.h" | 27 | * Debugfs |
28 | 28 | */ | |
29 | static bool dal_graphics_object_id_is_valid(struct graphics_object_id id) | 29 | struct amdgpu_debugfs { |
30 | { | 30 | const struct drm_info_list *files; |
31 | bool rc = true; | 31 | unsigned num_files; |
32 | 32 | }; | |
33 | switch (id.type) { | 33 | |
34 | case OBJECT_TYPE_UNKNOWN: | 34 | int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); |
35 | rc = false; | 35 | void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); |
36 | break; | 36 | int amdgpu_debugfs_init(struct amdgpu_device *adev); |
37 | case OBJECT_TYPE_GPU: | 37 | int amdgpu_debugfs_add_files(struct amdgpu_device *adev, |
38 | case OBJECT_TYPE_ENGINE: | 38 | const struct drm_info_list *files, |
39 | /* do NOT check for id.id == 0 */ | 39 | unsigned nfiles); |
40 | if (id.enum_id == ENUM_ID_UNKNOWN) | 40 | int amdgpu_debugfs_fence_init(struct amdgpu_device *adev); |
41 | rc = false; | 41 | int amdgpu_debugfs_firmware_init(struct amdgpu_device *adev); |
42 | break; | 42 | int amdgpu_debugfs_gem_init(struct amdgpu_device *adev); |
43 | default: | ||
44 | if (id.id == 0 || id.enum_id == ENUM_ID_UNKNOWN) | ||
45 | rc = false; | ||
46 | break; | ||
47 | } | ||
48 | |||
49 | return rc; | ||
50 | } | ||
51 | |||
52 | bool dal_graphics_object_id_is_equal( | ||
53 | struct graphics_object_id id1, | ||
54 | struct graphics_object_id id2) | ||
55 | { | ||
56 | if (false == dal_graphics_object_id_is_valid(id1)) { | ||
57 | dm_output_to_console( | ||
58 | "%s: Warning: comparing invalid object 'id1'!\n", __func__); | ||
59 | return false; | ||
60 | } | ||
61 | |||
62 | if (false == dal_graphics_object_id_is_valid(id2)) { | ||
63 | dm_output_to_console( | ||
64 | "%s: Warning: comparing invalid object 'id2'!\n", __func__); | ||
65 | return false; | ||
66 | } | ||
67 | |||
68 | if (id1.id == id2.id && id1.enum_id == id2.enum_id | ||
69 | && id1.type == id2.type) | ||
70 | return true; | ||
71 | |||
72 | return false; | ||
73 | } | ||
74 | |||
75 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 70c9e5756b02..357cd8bf2e55 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/kthread.h> | 28 | #include <linux/kthread.h> |
29 | #include <linux/console.h> | 29 | #include <linux/console.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/debugfs.h> | ||
32 | #include <drm/drmP.h> | 31 | #include <drm/drmP.h> |
33 | #include <drm/drm_crtc_helper.h> | 32 | #include <drm/drm_crtc_helper.h> |
34 | #include <drm/drm_atomic_helper.h> | 33 | #include <drm/drm_atomic_helper.h> |
@@ -64,11 +63,6 @@ MODULE_FIRMWARE("amdgpu/raven_gpu_info.bin"); | |||
64 | 63 | ||
65 | #define AMDGPU_RESUME_MS 2000 | 64 | #define AMDGPU_RESUME_MS 2000 |
66 | 65 | ||
67 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev); | ||
68 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev); | ||
69 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev); | ||
70 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev); | ||
71 | |||
72 | static const char *amdgpu_asic_name[] = { | 66 | static const char *amdgpu_asic_name[] = { |
73 | "TAHITI", | 67 | "TAHITI", |
74 | "PITCAIRN", | 68 | "PITCAIRN", |
@@ -333,7 +327,7 @@ static void amdgpu_block_invalid_wreg(struct amdgpu_device *adev, | |||
333 | BUG(); | 327 | BUG(); |
334 | } | 328 | } |
335 | 329 | ||
336 | static int amdgpu_vram_scratch_init(struct amdgpu_device *adev) | 330 | static int amdgpu_device_vram_scratch_init(struct amdgpu_device *adev) |
337 | { | 331 | { |
338 | return amdgpu_bo_create_kernel(adev, AMDGPU_GPU_PAGE_SIZE, | 332 | return amdgpu_bo_create_kernel(adev, AMDGPU_GPU_PAGE_SIZE, |
339 | PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, | 333 | PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, |
@@ -342,13 +336,13 @@ static int amdgpu_vram_scratch_init(struct amdgpu_device *adev) | |||
342 | (void **)&adev->vram_scratch.ptr); | 336 | (void **)&adev->vram_scratch.ptr); |
343 | } | 337 | } |
344 | 338 | ||
345 | static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev) | 339 | static void amdgpu_device_vram_scratch_fini(struct amdgpu_device *adev) |
346 | { | 340 | { |
347 | amdgpu_bo_free_kernel(&adev->vram_scratch.robj, NULL, NULL); | 341 | amdgpu_bo_free_kernel(&adev->vram_scratch.robj, NULL, NULL); |
348 | } | 342 | } |
349 | 343 | ||
350 | /** | 344 | /** |
351 | * amdgpu_program_register_sequence - program an array of registers. | 345 | * amdgpu_device_program_register_sequence - program an array of registers. |
352 | * | 346 | * |
353 | * @adev: amdgpu_device pointer | 347 | * @adev: amdgpu_device pointer |
354 | * @registers: pointer to the register array | 348 | * @registers: pointer to the register array |
@@ -357,9 +351,9 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev) | |||
357 | * Programs an array or registers with and and or masks. | 351 | * Programs an array or registers with and and or masks. |
358 | * This is a helper for setting golden registers. | 352 | * This is a helper for setting golden registers. |
359 | */ | 353 | */ |
360 | void amdgpu_program_register_sequence(struct amdgpu_device *adev, | 354 | void amdgpu_device_program_register_sequence(struct amdgpu_device *adev, |
361 | const u32 *registers, | 355 | const u32 *registers, |
362 | const u32 array_size) | 356 | const u32 array_size) |
363 | { | 357 | { |
364 | u32 tmp, reg, and_mask, or_mask; | 358 | u32 tmp, reg, and_mask, or_mask; |
365 | int i; | 359 | int i; |
@@ -383,7 +377,7 @@ void amdgpu_program_register_sequence(struct amdgpu_device *adev, | |||
383 | } | 377 | } |
384 | } | 378 | } |
385 | 379 | ||
386 | void amdgpu_pci_config_reset(struct amdgpu_device *adev) | 380 | void amdgpu_device_pci_config_reset(struct amdgpu_device *adev) |
387 | { | 381 | { |
388 | pci_write_config_dword(adev->pdev, 0x7c, AMDGPU_ASIC_RESET_DATA); | 382 | pci_write_config_dword(adev->pdev, 0x7c, AMDGPU_ASIC_RESET_DATA); |
389 | } | 383 | } |
@@ -392,14 +386,14 @@ void amdgpu_pci_config_reset(struct amdgpu_device *adev) | |||
392 | * GPU doorbell aperture helpers function. | 386 | * GPU doorbell aperture helpers function. |
393 | */ | 387 | */ |
394 | /** | 388 | /** |
395 | * amdgpu_doorbell_init - Init doorbell driver information. | 389 | * amdgpu_device_doorbell_init - Init doorbell driver information. |
396 | * | 390 | * |
397 | * @adev: amdgpu_device pointer | 391 | * @adev: amdgpu_device pointer |
398 | * | 392 | * |
399 | * Init doorbell driver information (CIK) | 393 | * Init doorbell driver information (CIK) |
400 | * Returns 0 on success, error on failure. | 394 | * Returns 0 on success, error on failure. |
401 | */ | 395 | */ |
402 | static int amdgpu_doorbell_init(struct amdgpu_device *adev) | 396 | static int amdgpu_device_doorbell_init(struct amdgpu_device *adev) |
403 | { | 397 | { |
404 | /* No doorbell on SI hardware generation */ | 398 | /* No doorbell on SI hardware generation */ |
405 | if (adev->asic_type < CHIP_BONAIRE) { | 399 | if (adev->asic_type < CHIP_BONAIRE) { |
@@ -432,66 +426,35 @@ static int amdgpu_doorbell_init(struct amdgpu_device *adev) | |||
432 | } | 426 | } |
433 | 427 | ||
434 | /** | 428 | /** |
435 | * amdgpu_doorbell_fini - Tear down doorbell driver information. | 429 | * amdgpu_device_doorbell_fini - Tear down doorbell driver information. |
436 | * | 430 | * |
437 | * @adev: amdgpu_device pointer | 431 | * @adev: amdgpu_device pointer |
438 | * | 432 | * |
439 | * Tear down doorbell driver information (CIK) | 433 | * Tear down doorbell driver information (CIK) |
440 | */ | 434 | */ |
441 | static void amdgpu_doorbell_fini(struct amdgpu_device *adev) | 435 | static void amdgpu_device_doorbell_fini(struct amdgpu_device *adev) |
442 | { | 436 | { |
443 | iounmap(adev->doorbell.ptr); | 437 | iounmap(adev->doorbell.ptr); |
444 | adev->doorbell.ptr = NULL; | 438 | adev->doorbell.ptr = NULL; |
445 | } | 439 | } |
446 | 440 | ||
447 | /** | 441 | |
448 | * amdgpu_doorbell_get_kfd_info - Report doorbell configuration required to | ||
449 | * setup amdkfd | ||
450 | * | ||
451 | * @adev: amdgpu_device pointer | ||
452 | * @aperture_base: output returning doorbell aperture base physical address | ||
453 | * @aperture_size: output returning doorbell aperture size in bytes | ||
454 | * @start_offset: output returning # of doorbell bytes reserved for amdgpu. | ||
455 | * | ||
456 | * amdgpu and amdkfd share the doorbell aperture. amdgpu sets it up, | ||
457 | * takes doorbells required for its own rings and reports the setup to amdkfd. | ||
458 | * amdgpu reserved doorbells are at the start of the doorbell aperture. | ||
459 | */ | ||
460 | void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, | ||
461 | phys_addr_t *aperture_base, | ||
462 | size_t *aperture_size, | ||
463 | size_t *start_offset) | ||
464 | { | ||
465 | /* | ||
466 | * The first num_doorbells are used by amdgpu. | ||
467 | * amdkfd takes whatever's left in the aperture. | ||
468 | */ | ||
469 | if (adev->doorbell.size > adev->doorbell.num_doorbells * sizeof(u32)) { | ||
470 | *aperture_base = adev->doorbell.base; | ||
471 | *aperture_size = adev->doorbell.size; | ||
472 | *start_offset = adev->doorbell.num_doorbells * sizeof(u32); | ||
473 | } else { | ||
474 | *aperture_base = 0; | ||
475 | *aperture_size = 0; | ||
476 | *start_offset = 0; | ||
477 | } | ||
478 | } | ||
479 | 442 | ||
480 | /* | 443 | /* |
481 | * amdgpu_wb_*() | 444 | * amdgpu_device_wb_*() |
482 | * Writeback is the method by which the GPU updates special pages in memory | 445 | * Writeback is the method by which the GPU updates special pages in memory |
483 | * with the status of certain GPU events (fences, ring pointers,etc.). | 446 | * with the status of certain GPU events (fences, ring pointers,etc.). |
484 | */ | 447 | */ |
485 | 448 | ||
486 | /** | 449 | /** |
487 | * amdgpu_wb_fini - Disable Writeback and free memory | 450 | * amdgpu_device_wb_fini - Disable Writeback and free memory |
488 | * | 451 | * |
489 | * @adev: amdgpu_device pointer | 452 | * @adev: amdgpu_device pointer |
490 | * | 453 | * |
491 | * Disables Writeback and frees the Writeback memory (all asics). | 454 | * Disables Writeback and frees the Writeback memory (all asics). |
492 | * Used at driver shutdown. | 455 | * Used at driver shutdown. |
493 | */ | 456 | */ |
494 | static void amdgpu_wb_fini(struct amdgpu_device *adev) | 457 | static void amdgpu_device_wb_fini(struct amdgpu_device *adev) |
495 | { | 458 | { |
496 | if (adev->wb.wb_obj) { | 459 | if (adev->wb.wb_obj) { |
497 | amdgpu_bo_free_kernel(&adev->wb.wb_obj, | 460 | amdgpu_bo_free_kernel(&adev->wb.wb_obj, |
@@ -502,7 +465,7 @@ static void amdgpu_wb_fini(struct amdgpu_device *adev) | |||
502 | } | 465 | } |
503 | 466 | ||
504 | /** | 467 | /** |
505 | * amdgpu_wb_init- Init Writeback driver info and allocate memory | 468 | * amdgpu_device_wb_init- Init Writeback driver info and allocate memory |
506 | * | 469 | * |
507 | * @adev: amdgpu_device pointer | 470 | * @adev: amdgpu_device pointer |
508 | * | 471 | * |
@@ -510,7 +473,7 @@ static void amdgpu_wb_fini(struct amdgpu_device *adev) | |||
510 | * Used at driver startup. | 473 | * Used at driver startup. |
511 | * Returns 0 on success or an -error on failure. | 474 | * Returns 0 on success or an -error on failure. |
512 | */ | 475 | */ |
513 | static int amdgpu_wb_init(struct amdgpu_device *adev) | 476 | static int amdgpu_device_wb_init(struct amdgpu_device *adev) |
514 | { | 477 | { |
515 | int r; | 478 | int r; |
516 | 479 | ||
@@ -536,7 +499,7 @@ static int amdgpu_wb_init(struct amdgpu_device *adev) | |||
536 | } | 499 | } |
537 | 500 | ||
538 | /** | 501 | /** |
539 | * amdgpu_wb_get - Allocate a wb entry | 502 | * amdgpu_device_wb_get - Allocate a wb entry |
540 | * | 503 | * |
541 | * @adev: amdgpu_device pointer | 504 | * @adev: amdgpu_device pointer |
542 | * @wb: wb index | 505 | * @wb: wb index |
@@ -544,7 +507,7 @@ static int amdgpu_wb_init(struct amdgpu_device *adev) | |||
544 | * Allocate a wb slot for use by the driver (all asics). | 507 | * Allocate a wb slot for use by the driver (all asics). |
545 | * Returns 0 on success or -EINVAL on failure. | 508 | * Returns 0 on success or -EINVAL on failure. |
546 | */ | 509 | */ |
547 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb) | 510 | int amdgpu_device_wb_get(struct amdgpu_device *adev, u32 *wb) |
548 | { | 511 | { |
549 | unsigned long offset = find_first_zero_bit(adev->wb.used, adev->wb.num_wb); | 512 | unsigned long offset = find_first_zero_bit(adev->wb.used, adev->wb.num_wb); |
550 | 513 | ||
@@ -558,21 +521,21 @@ int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb) | |||
558 | } | 521 | } |
559 | 522 | ||
560 | /** | 523 | /** |
561 | * amdgpu_wb_free - Free a wb entry | 524 | * amdgpu_device_wb_free - Free a wb entry |
562 | * | 525 | * |
563 | * @adev: amdgpu_device pointer | 526 | * @adev: amdgpu_device pointer |
564 | * @wb: wb index | 527 | * @wb: wb index |
565 | * | 528 | * |
566 | * Free a wb slot allocated for use by the driver (all asics) | 529 | * Free a wb slot allocated for use by the driver (all asics) |
567 | */ | 530 | */ |
568 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb) | 531 | void amdgpu_device_wb_free(struct amdgpu_device *adev, u32 wb) |
569 | { | 532 | { |
570 | if (wb < adev->wb.num_wb) | 533 | if (wb < adev->wb.num_wb) |
571 | __clear_bit(wb >> 3, adev->wb.used); | 534 | __clear_bit(wb >> 3, adev->wb.used); |
572 | } | 535 | } |
573 | 536 | ||
574 | /** | 537 | /** |
575 | * amdgpu_vram_location - try to find VRAM location | 538 | * amdgpu_device_vram_location - try to find VRAM location |
576 | * @adev: amdgpu device structure holding all necessary informations | 539 | * @adev: amdgpu device structure holding all necessary informations |
577 | * @mc: memory controller structure holding memory informations | 540 | * @mc: memory controller structure holding memory informations |
578 | * @base: base address at which to put VRAM | 541 | * @base: base address at which to put VRAM |
@@ -580,7 +543,8 @@ void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb) | |||
580 | * Function will try to place VRAM at base address provided | 543 | * Function will try to place VRAM at base address provided |
581 | * as parameter. | 544 | * as parameter. |
582 | */ | 545 | */ |
583 | void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 base) | 546 | void amdgpu_device_vram_location(struct amdgpu_device *adev, |
547 | struct amdgpu_mc *mc, u64 base) | ||
584 | { | 548 | { |
585 | uint64_t limit = (uint64_t)amdgpu_vram_limit << 20; | 549 | uint64_t limit = (uint64_t)amdgpu_vram_limit << 20; |
586 | 550 | ||
@@ -594,7 +558,7 @@ void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 | |||
594 | } | 558 | } |
595 | 559 | ||
596 | /** | 560 | /** |
597 | * amdgpu_gart_location - try to find GTT location | 561 | * amdgpu_device_gart_location - try to find GTT location |
598 | * @adev: amdgpu device structure holding all necessary informations | 562 | * @adev: amdgpu device structure holding all necessary informations |
599 | * @mc: memory controller structure holding memory informations | 563 | * @mc: memory controller structure holding memory informations |
600 | * | 564 | * |
@@ -605,7 +569,8 @@ void amdgpu_vram_location(struct amdgpu_device *adev, struct amdgpu_mc *mc, u64 | |||
605 | * | 569 | * |
606 | * FIXME: when reducing GTT size align new size on power of 2. | 570 | * FIXME: when reducing GTT size align new size on power of 2. |
607 | */ | 571 | */ |
608 | void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc) | 572 | void amdgpu_device_gart_location(struct amdgpu_device *adev, |
573 | struct amdgpu_mc *mc) | ||
609 | { | 574 | { |
610 | u64 size_af, size_bf; | 575 | u64 size_af, size_bf; |
611 | 576 | ||
@@ -632,101 +597,6 @@ void amdgpu_gart_location(struct amdgpu_device *adev, struct amdgpu_mc *mc) | |||
632 | mc->gart_size >> 20, mc->gart_start, mc->gart_end); | 597 | mc->gart_size >> 20, mc->gart_start, mc->gart_end); |
633 | } | 598 | } |
634 | 599 | ||
635 | /* | ||
636 | * Firmware Reservation functions | ||
637 | */ | ||
638 | /** | ||
639 | * amdgpu_fw_reserve_vram_fini - free fw reserved vram | ||
640 | * | ||
641 | * @adev: amdgpu_device pointer | ||
642 | * | ||
643 | * free fw reserved vram if it has been reserved. | ||
644 | */ | ||
645 | void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev) | ||
646 | { | ||
647 | amdgpu_bo_free_kernel(&adev->fw_vram_usage.reserved_bo, | ||
648 | NULL, &adev->fw_vram_usage.va); | ||
649 | } | ||
650 | |||
651 | /** | ||
652 | * amdgpu_fw_reserve_vram_init - create bo vram reservation from fw | ||
653 | * | ||
654 | * @adev: amdgpu_device pointer | ||
655 | * | ||
656 | * create bo vram reservation from fw. | ||
657 | */ | ||
658 | int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev) | ||
659 | { | ||
660 | struct ttm_operation_ctx ctx = { false, false }; | ||
661 | int r = 0; | ||
662 | int i; | ||
663 | u64 vram_size = adev->mc.visible_vram_size; | ||
664 | u64 offset = adev->fw_vram_usage.start_offset; | ||
665 | u64 size = adev->fw_vram_usage.size; | ||
666 | struct amdgpu_bo *bo; | ||
667 | |||
668 | adev->fw_vram_usage.va = NULL; | ||
669 | adev->fw_vram_usage.reserved_bo = NULL; | ||
670 | |||
671 | if (adev->fw_vram_usage.size > 0 && | ||
672 | adev->fw_vram_usage.size <= vram_size) { | ||
673 | |||
674 | r = amdgpu_bo_create(adev, adev->fw_vram_usage.size, | ||
675 | PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, | ||
676 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
677 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, NULL, NULL, 0, | ||
678 | &adev->fw_vram_usage.reserved_bo); | ||
679 | if (r) | ||
680 | goto error_create; | ||
681 | |||
682 | r = amdgpu_bo_reserve(adev->fw_vram_usage.reserved_bo, false); | ||
683 | if (r) | ||
684 | goto error_reserve; | ||
685 | |||
686 | /* remove the original mem node and create a new one at the | ||
687 | * request position | ||
688 | */ | ||
689 | bo = adev->fw_vram_usage.reserved_bo; | ||
690 | offset = ALIGN(offset, PAGE_SIZE); | ||
691 | for (i = 0; i < bo->placement.num_placement; ++i) { | ||
692 | bo->placements[i].fpfn = offset >> PAGE_SHIFT; | ||
693 | bo->placements[i].lpfn = (offset + size) >> PAGE_SHIFT; | ||
694 | } | ||
695 | |||
696 | ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem); | ||
697 | r = ttm_bo_mem_space(&bo->tbo, &bo->placement, | ||
698 | &bo->tbo.mem, &ctx); | ||
699 | if (r) | ||
700 | goto error_pin; | ||
701 | |||
702 | r = amdgpu_bo_pin_restricted(adev->fw_vram_usage.reserved_bo, | ||
703 | AMDGPU_GEM_DOMAIN_VRAM, | ||
704 | adev->fw_vram_usage.start_offset, | ||
705 | (adev->fw_vram_usage.start_offset + | ||
706 | adev->fw_vram_usage.size), NULL); | ||
707 | if (r) | ||
708 | goto error_pin; | ||
709 | r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo, | ||
710 | &adev->fw_vram_usage.va); | ||
711 | if (r) | ||
712 | goto error_kmap; | ||
713 | |||
714 | amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); | ||
715 | } | ||
716 | return r; | ||
717 | |||
718 | error_kmap: | ||
719 | amdgpu_bo_unpin(adev->fw_vram_usage.reserved_bo); | ||
720 | error_pin: | ||
721 | amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); | ||
722 | error_reserve: | ||
723 | amdgpu_bo_unref(&adev->fw_vram_usage.reserved_bo); | ||
724 | error_create: | ||
725 | adev->fw_vram_usage.va = NULL; | ||
726 | adev->fw_vram_usage.reserved_bo = NULL; | ||
727 | return r; | ||
728 | } | ||
729 | |||
730 | /** | 600 | /** |
731 | * amdgpu_device_resize_fb_bar - try to resize FB BAR | 601 | * amdgpu_device_resize_fb_bar - try to resize FB BAR |
732 | * | 602 | * |
@@ -771,7 +641,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) | |||
771 | cmd & ~PCI_COMMAND_MEMORY); | 641 | cmd & ~PCI_COMMAND_MEMORY); |
772 | 642 | ||
773 | /* Free the VRAM and doorbell BAR, we most likely need to move both. */ | 643 | /* Free the VRAM and doorbell BAR, we most likely need to move both. */ |
774 | amdgpu_doorbell_fini(adev); | 644 | amdgpu_device_doorbell_fini(adev); |
775 | if (adev->asic_type >= CHIP_BONAIRE) | 645 | if (adev->asic_type >= CHIP_BONAIRE) |
776 | pci_release_resource(adev->pdev, 2); | 646 | pci_release_resource(adev->pdev, 2); |
777 | 647 | ||
@@ -788,7 +658,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) | |||
788 | /* When the doorbell or fb BAR isn't available we have no chance of | 658 | /* When the doorbell or fb BAR isn't available we have no chance of |
789 | * using the device. | 659 | * using the device. |
790 | */ | 660 | */ |
791 | r = amdgpu_doorbell_init(adev); | 661 | r = amdgpu_device_doorbell_init(adev); |
792 | if (r || (pci_resource_flags(adev->pdev, 0) & IORESOURCE_UNSET)) | 662 | if (r || (pci_resource_flags(adev->pdev, 0) & IORESOURCE_UNSET)) |
793 | return -ENODEV; | 663 | return -ENODEV; |
794 | 664 | ||
@@ -801,7 +671,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) | |||
801 | * GPU helpers function. | 671 | * GPU helpers function. |
802 | */ | 672 | */ |
803 | /** | 673 | /** |
804 | * amdgpu_need_post - check if the hw need post or not | 674 | * amdgpu_device_need_post - check if the hw need post or not |
805 | * | 675 | * |
806 | * @adev: amdgpu_device pointer | 676 | * @adev: amdgpu_device pointer |
807 | * | 677 | * |
@@ -809,7 +679,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) | |||
809 | * or post is needed if hw reset is performed. | 679 | * or post is needed if hw reset is performed. |
810 | * Returns true if need or false if not. | 680 | * Returns true if need or false if not. |
811 | */ | 681 | */ |
812 | bool amdgpu_need_post(struct amdgpu_device *adev) | 682 | bool amdgpu_device_need_post(struct amdgpu_device *adev) |
813 | { | 683 | { |
814 | uint32_t reg; | 684 | uint32_t reg; |
815 | 685 | ||
@@ -854,285 +724,9 @@ bool amdgpu_need_post(struct amdgpu_device *adev) | |||
854 | return true; | 724 | return true; |
855 | } | 725 | } |
856 | 726 | ||
857 | /** | ||
858 | * amdgpu_dummy_page_init - init dummy page used by the driver | ||
859 | * | ||
860 | * @adev: amdgpu_device pointer | ||
861 | * | ||
862 | * Allocate the dummy page used by the driver (all asics). | ||
863 | * This dummy page is used by the driver as a filler for gart entries | ||
864 | * when pages are taken out of the GART | ||
865 | * Returns 0 on sucess, -ENOMEM on failure. | ||
866 | */ | ||
867 | int amdgpu_dummy_page_init(struct amdgpu_device *adev) | ||
868 | { | ||
869 | if (adev->dummy_page.page) | ||
870 | return 0; | ||
871 | adev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO); | ||
872 | if (adev->dummy_page.page == NULL) | ||
873 | return -ENOMEM; | ||
874 | adev->dummy_page.addr = pci_map_page(adev->pdev, adev->dummy_page.page, | ||
875 | 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | ||
876 | if (pci_dma_mapping_error(adev->pdev, adev->dummy_page.addr)) { | ||
877 | dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n"); | ||
878 | __free_page(adev->dummy_page.page); | ||
879 | adev->dummy_page.page = NULL; | ||
880 | return -ENOMEM; | ||
881 | } | ||
882 | return 0; | ||
883 | } | ||
884 | |||
885 | /** | ||
886 | * amdgpu_dummy_page_fini - free dummy page used by the driver | ||
887 | * | ||
888 | * @adev: amdgpu_device pointer | ||
889 | * | ||
890 | * Frees the dummy page used by the driver (all asics). | ||
891 | */ | ||
892 | void amdgpu_dummy_page_fini(struct amdgpu_device *adev) | ||
893 | { | ||
894 | if (adev->dummy_page.page == NULL) | ||
895 | return; | ||
896 | pci_unmap_page(adev->pdev, adev->dummy_page.addr, | ||
897 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | ||
898 | __free_page(adev->dummy_page.page); | ||
899 | adev->dummy_page.page = NULL; | ||
900 | } | ||
901 | |||
902 | |||
903 | /* ATOM accessor methods */ | ||
904 | /* | ||
905 | * ATOM is an interpreted byte code stored in tables in the vbios. The | ||
906 | * driver registers callbacks to access registers and the interpreter | ||
907 | * in the driver parses the tables and executes then to program specific | ||
908 | * actions (set display modes, asic init, etc.). See amdgpu_atombios.c, | ||
909 | * atombios.h, and atom.c | ||
910 | */ | ||
911 | |||
912 | /** | ||
913 | * cail_pll_read - read PLL register | ||
914 | * | ||
915 | * @info: atom card_info pointer | ||
916 | * @reg: PLL register offset | ||
917 | * | ||
918 | * Provides a PLL register accessor for the atom interpreter (r4xx+). | ||
919 | * Returns the value of the PLL register. | ||
920 | */ | ||
921 | static uint32_t cail_pll_read(struct card_info *info, uint32_t reg) | ||
922 | { | ||
923 | return 0; | ||
924 | } | ||
925 | |||
926 | /** | ||
927 | * cail_pll_write - write PLL register | ||
928 | * | ||
929 | * @info: atom card_info pointer | ||
930 | * @reg: PLL register offset | ||
931 | * @val: value to write to the pll register | ||
932 | * | ||
933 | * Provides a PLL register accessor for the atom interpreter (r4xx+). | ||
934 | */ | ||
935 | static void cail_pll_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
936 | { | ||
937 | |||
938 | } | ||
939 | |||
940 | /** | ||
941 | * cail_mc_read - read MC (Memory Controller) register | ||
942 | * | ||
943 | * @info: atom card_info pointer | ||
944 | * @reg: MC register offset | ||
945 | * | ||
946 | * Provides an MC register accessor for the atom interpreter (r4xx+). | ||
947 | * Returns the value of the MC register. | ||
948 | */ | ||
949 | static uint32_t cail_mc_read(struct card_info *info, uint32_t reg) | ||
950 | { | ||
951 | return 0; | ||
952 | } | ||
953 | |||
954 | /** | ||
955 | * cail_mc_write - write MC (Memory Controller) register | ||
956 | * | ||
957 | * @info: atom card_info pointer | ||
958 | * @reg: MC register offset | ||
959 | * @val: value to write to the pll register | ||
960 | * | ||
961 | * Provides a MC register accessor for the atom interpreter (r4xx+). | ||
962 | */ | ||
963 | static void cail_mc_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
964 | { | ||
965 | |||
966 | } | ||
967 | |||
968 | /** | ||
969 | * cail_reg_write - write MMIO register | ||
970 | * | ||
971 | * @info: atom card_info pointer | ||
972 | * @reg: MMIO register offset | ||
973 | * @val: value to write to the pll register | ||
974 | * | ||
975 | * Provides a MMIO register accessor for the atom interpreter (r4xx+). | ||
976 | */ | ||
977 | static void cail_reg_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
978 | { | ||
979 | struct amdgpu_device *adev = info->dev->dev_private; | ||
980 | |||
981 | WREG32(reg, val); | ||
982 | } | ||
983 | |||
984 | /** | ||
985 | * cail_reg_read - read MMIO register | ||
986 | * | ||
987 | * @info: atom card_info pointer | ||
988 | * @reg: MMIO register offset | ||
989 | * | ||
990 | * Provides an MMIO register accessor for the atom interpreter (r4xx+). | ||
991 | * Returns the value of the MMIO register. | ||
992 | */ | ||
993 | static uint32_t cail_reg_read(struct card_info *info, uint32_t reg) | ||
994 | { | ||
995 | struct amdgpu_device *adev = info->dev->dev_private; | ||
996 | uint32_t r; | ||
997 | |||
998 | r = RREG32(reg); | ||
999 | return r; | ||
1000 | } | ||
1001 | |||
1002 | /** | ||
1003 | * cail_ioreg_write - write IO register | ||
1004 | * | ||
1005 | * @info: atom card_info pointer | ||
1006 | * @reg: IO register offset | ||
1007 | * @val: value to write to the pll register | ||
1008 | * | ||
1009 | * Provides a IO register accessor for the atom interpreter (r4xx+). | ||
1010 | */ | ||
1011 | static void cail_ioreg_write(struct card_info *info, uint32_t reg, uint32_t val) | ||
1012 | { | ||
1013 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1014 | |||
1015 | WREG32_IO(reg, val); | ||
1016 | } | ||
1017 | |||
1018 | /** | ||
1019 | * cail_ioreg_read - read IO register | ||
1020 | * | ||
1021 | * @info: atom card_info pointer | ||
1022 | * @reg: IO register offset | ||
1023 | * | ||
1024 | * Provides an IO register accessor for the atom interpreter (r4xx+). | ||
1025 | * Returns the value of the IO register. | ||
1026 | */ | ||
1027 | static uint32_t cail_ioreg_read(struct card_info *info, uint32_t reg) | ||
1028 | { | ||
1029 | struct amdgpu_device *adev = info->dev->dev_private; | ||
1030 | uint32_t r; | ||
1031 | |||
1032 | r = RREG32_IO(reg); | ||
1033 | return r; | ||
1034 | } | ||
1035 | |||
1036 | static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev, | ||
1037 | struct device_attribute *attr, | ||
1038 | char *buf) | ||
1039 | { | ||
1040 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
1041 | struct amdgpu_device *adev = ddev->dev_private; | ||
1042 | struct atom_context *ctx = adev->mode_info.atom_context; | ||
1043 | |||
1044 | return snprintf(buf, PAGE_SIZE, "%s\n", ctx->vbios_version); | ||
1045 | } | ||
1046 | |||
1047 | static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version, | ||
1048 | NULL); | ||
1049 | |||
1050 | /** | ||
1051 | * amdgpu_atombios_fini - free the driver info and callbacks for atombios | ||
1052 | * | ||
1053 | * @adev: amdgpu_device pointer | ||
1054 | * | ||
1055 | * Frees the driver info and register access callbacks for the ATOM | ||
1056 | * interpreter (r4xx+). | ||
1057 | * Called at driver shutdown. | ||
1058 | */ | ||
1059 | static void amdgpu_atombios_fini(struct amdgpu_device *adev) | ||
1060 | { | ||
1061 | if (adev->mode_info.atom_context) { | ||
1062 | kfree(adev->mode_info.atom_context->scratch); | ||
1063 | kfree(adev->mode_info.atom_context->iio); | ||
1064 | } | ||
1065 | kfree(adev->mode_info.atom_context); | ||
1066 | adev->mode_info.atom_context = NULL; | ||
1067 | kfree(adev->mode_info.atom_card_info); | ||
1068 | adev->mode_info.atom_card_info = NULL; | ||
1069 | device_remove_file(adev->dev, &dev_attr_vbios_version); | ||
1070 | } | ||
1071 | |||
1072 | /** | ||
1073 | * amdgpu_atombios_init - init the driver info and callbacks for atombios | ||
1074 | * | ||
1075 | * @adev: amdgpu_device pointer | ||
1076 | * | ||
1077 | * Initializes the driver info and register access callbacks for the | ||
1078 | * ATOM interpreter (r4xx+). | ||
1079 | * Returns 0 on sucess, -ENOMEM on failure. | ||
1080 | * Called at driver startup. | ||
1081 | */ | ||
1082 | static int amdgpu_atombios_init(struct amdgpu_device *adev) | ||
1083 | { | ||
1084 | struct card_info *atom_card_info = | ||
1085 | kzalloc(sizeof(struct card_info), GFP_KERNEL); | ||
1086 | int ret; | ||
1087 | |||
1088 | if (!atom_card_info) | ||
1089 | return -ENOMEM; | ||
1090 | |||
1091 | adev->mode_info.atom_card_info = atom_card_info; | ||
1092 | atom_card_info->dev = adev->ddev; | ||
1093 | atom_card_info->reg_read = cail_reg_read; | ||
1094 | atom_card_info->reg_write = cail_reg_write; | ||
1095 | /* needed for iio ops */ | ||
1096 | if (adev->rio_mem) { | ||
1097 | atom_card_info->ioreg_read = cail_ioreg_read; | ||
1098 | atom_card_info->ioreg_write = cail_ioreg_write; | ||
1099 | } else { | ||
1100 | DRM_DEBUG("PCI I/O BAR is not found. Using MMIO to access ATOM BIOS\n"); | ||
1101 | atom_card_info->ioreg_read = cail_reg_read; | ||
1102 | atom_card_info->ioreg_write = cail_reg_write; | ||
1103 | } | ||
1104 | atom_card_info->mc_read = cail_mc_read; | ||
1105 | atom_card_info->mc_write = cail_mc_write; | ||
1106 | atom_card_info->pll_read = cail_pll_read; | ||
1107 | atom_card_info->pll_write = cail_pll_write; | ||
1108 | |||
1109 | adev->mode_info.atom_context = amdgpu_atom_parse(atom_card_info, adev->bios); | ||
1110 | if (!adev->mode_info.atom_context) { | ||
1111 | amdgpu_atombios_fini(adev); | ||
1112 | return -ENOMEM; | ||
1113 | } | ||
1114 | |||
1115 | mutex_init(&adev->mode_info.atom_context->mutex); | ||
1116 | if (adev->is_atom_fw) { | ||
1117 | amdgpu_atomfirmware_scratch_regs_init(adev); | ||
1118 | amdgpu_atomfirmware_allocate_fb_scratch(adev); | ||
1119 | } else { | ||
1120 | amdgpu_atombios_scratch_regs_init(adev); | ||
1121 | amdgpu_atombios_allocate_fb_scratch(adev); | ||
1122 | } | ||
1123 | |||
1124 | ret = device_create_file(adev->dev, &dev_attr_vbios_version); | ||
1125 | if (ret) { | ||
1126 | DRM_ERROR("Failed to create device file for VBIOS version\n"); | ||
1127 | return ret; | ||
1128 | } | ||
1129 | |||
1130 | return 0; | ||
1131 | } | ||
1132 | |||
1133 | /* if we get transitioned to only one device, take VGA back */ | 727 | /* if we get transitioned to only one device, take VGA back */ |
1134 | /** | 728 | /** |
1135 | * amdgpu_vga_set_decode - enable/disable vga decode | 729 | * amdgpu_device_vga_set_decode - enable/disable vga decode |
1136 | * | 730 | * |
1137 | * @cookie: amdgpu_device pointer | 731 | * @cookie: amdgpu_device pointer |
1138 | * @state: enable/disable vga decode | 732 | * @state: enable/disable vga decode |
@@ -1140,7 +734,7 @@ static int amdgpu_atombios_init(struct amdgpu_device *adev) | |||
1140 | * Enable/disable vga decode (all asics). | 734 | * Enable/disable vga decode (all asics). |
1141 | * Returns VGA resource flags. | 735 | * Returns VGA resource flags. |
1142 | */ | 736 | */ |
1143 | static unsigned int amdgpu_vga_set_decode(void *cookie, bool state) | 737 | static unsigned int amdgpu_device_vga_set_decode(void *cookie, bool state) |
1144 | { | 738 | { |
1145 | struct amdgpu_device *adev = cookie; | 739 | struct amdgpu_device *adev = cookie; |
1146 | amdgpu_asic_set_vga_state(adev, state); | 740 | amdgpu_asic_set_vga_state(adev, state); |
@@ -1151,7 +745,7 @@ static unsigned int amdgpu_vga_set_decode(void *cookie, bool state) | |||
1151 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; | 745 | return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM; |
1152 | } | 746 | } |
1153 | 747 | ||
1154 | static void amdgpu_check_block_size(struct amdgpu_device *adev) | 748 | static void amdgpu_device_check_block_size(struct amdgpu_device *adev) |
1155 | { | 749 | { |
1156 | /* defines number of bits in page table versus page directory, | 750 | /* defines number of bits in page table versus page directory, |
1157 | * a page is 4KB so we have 12 bits offset, minimum 9 bits in the | 751 | * a page is 4KB so we have 12 bits offset, minimum 9 bits in the |
@@ -1166,7 +760,7 @@ static void amdgpu_check_block_size(struct amdgpu_device *adev) | |||
1166 | } | 760 | } |
1167 | } | 761 | } |
1168 | 762 | ||
1169 | static void amdgpu_check_vm_size(struct amdgpu_device *adev) | 763 | static void amdgpu_device_check_vm_size(struct amdgpu_device *adev) |
1170 | { | 764 | { |
1171 | /* no need to check the default value */ | 765 | /* no need to check the default value */ |
1172 | if (amdgpu_vm_size == -1) | 766 | if (amdgpu_vm_size == -1) |
@@ -1180,14 +774,14 @@ static void amdgpu_check_vm_size(struct amdgpu_device *adev) | |||
1180 | } | 774 | } |
1181 | 775 | ||
1182 | /** | 776 | /** |
1183 | * amdgpu_check_arguments - validate module params | 777 | * amdgpu_device_check_arguments - validate module params |
1184 | * | 778 | * |
1185 | * @adev: amdgpu_device pointer | 779 | * @adev: amdgpu_device pointer |
1186 | * | 780 | * |
1187 | * Validates certain module parameters and updates | 781 | * Validates certain module parameters and updates |
1188 | * the associated values used by the driver (all asics). | 782 | * the associated values used by the driver (all asics). |
1189 | */ | 783 | */ |
1190 | static void amdgpu_check_arguments(struct amdgpu_device *adev) | 784 | static void amdgpu_device_check_arguments(struct amdgpu_device *adev) |
1191 | { | 785 | { |
1192 | if (amdgpu_sched_jobs < 4) { | 786 | if (amdgpu_sched_jobs < 4) { |
1193 | dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", | 787 | dev_warn(adev->dev, "sched jobs (%d) must be at least 4\n", |
@@ -1220,9 +814,9 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev) | |||
1220 | amdgpu_vm_fragment_size = -1; | 814 | amdgpu_vm_fragment_size = -1; |
1221 | } | 815 | } |
1222 | 816 | ||
1223 | amdgpu_check_vm_size(adev); | 817 | amdgpu_device_check_vm_size(adev); |
1224 | 818 | ||
1225 | amdgpu_check_block_size(adev); | 819 | amdgpu_device_check_block_size(adev); |
1226 | 820 | ||
1227 | if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 || | 821 | if (amdgpu_vram_page_split != -1 && (amdgpu_vram_page_split < 16 || |
1228 | !is_power_of_2(amdgpu_vram_page_split))) { | 822 | !is_power_of_2(amdgpu_vram_page_split))) { |
@@ -1230,6 +824,11 @@ static void amdgpu_check_arguments(struct amdgpu_device *adev) | |||
1230 | amdgpu_vram_page_split); | 824 | amdgpu_vram_page_split); |
1231 | amdgpu_vram_page_split = 1024; | 825 | amdgpu_vram_page_split = 1024; |
1232 | } | 826 | } |
827 | |||
828 | if (amdgpu_lockup_timeout == 0) { | ||
829 | dev_warn(adev->dev, "lockup_timeout msut be > 0, adjusting to 10000\n"); | ||
830 | amdgpu_lockup_timeout = 10000; | ||
831 | } | ||
1233 | } | 832 | } |
1234 | 833 | ||
1235 | /** | 834 | /** |
@@ -1293,9 +892,9 @@ static const struct vga_switcheroo_client_ops amdgpu_switcheroo_ops = { | |||
1293 | .can_switch = amdgpu_switcheroo_can_switch, | 892 | .can_switch = amdgpu_switcheroo_can_switch, |
1294 | }; | 893 | }; |
1295 | 894 | ||
1296 | int amdgpu_set_clockgating_state(struct amdgpu_device *adev, | 895 | int amdgpu_device_ip_set_clockgating_state(struct amdgpu_device *adev, |
1297 | enum amd_ip_block_type block_type, | 896 | enum amd_ip_block_type block_type, |
1298 | enum amd_clockgating_state state) | 897 | enum amd_clockgating_state state) |
1299 | { | 898 | { |
1300 | int i, r = 0; | 899 | int i, r = 0; |
1301 | 900 | ||
@@ -1315,9 +914,9 @@ int amdgpu_set_clockgating_state(struct amdgpu_device *adev, | |||
1315 | return r; | 914 | return r; |
1316 | } | 915 | } |
1317 | 916 | ||
1318 | int amdgpu_set_powergating_state(struct amdgpu_device *adev, | 917 | int amdgpu_device_ip_set_powergating_state(struct amdgpu_device *adev, |
1319 | enum amd_ip_block_type block_type, | 918 | enum amd_ip_block_type block_type, |
1320 | enum amd_powergating_state state) | 919 | enum amd_powergating_state state) |
1321 | { | 920 | { |
1322 | int i, r = 0; | 921 | int i, r = 0; |
1323 | 922 | ||
@@ -1337,7 +936,8 @@ int amdgpu_set_powergating_state(struct amdgpu_device *adev, | |||
1337 | return r; | 936 | return r; |
1338 | } | 937 | } |
1339 | 938 | ||
1340 | void amdgpu_get_clockgating_state(struct amdgpu_device *adev, u32 *flags) | 939 | void amdgpu_device_ip_get_clockgating_state(struct amdgpu_device *adev, |
940 | u32 *flags) | ||
1341 | { | 941 | { |
1342 | int i; | 942 | int i; |
1343 | 943 | ||
@@ -1349,8 +949,8 @@ void amdgpu_get_clockgating_state(struct amdgpu_device *adev, u32 *flags) | |||
1349 | } | 949 | } |
1350 | } | 950 | } |
1351 | 951 | ||
1352 | int amdgpu_wait_for_idle(struct amdgpu_device *adev, | 952 | int amdgpu_device_ip_wait_for_idle(struct amdgpu_device *adev, |
1353 | enum amd_ip_block_type block_type) | 953 | enum amd_ip_block_type block_type) |
1354 | { | 954 | { |
1355 | int i, r; | 955 | int i, r; |
1356 | 956 | ||
@@ -1368,8 +968,8 @@ int amdgpu_wait_for_idle(struct amdgpu_device *adev, | |||
1368 | 968 | ||
1369 | } | 969 | } |
1370 | 970 | ||
1371 | bool amdgpu_is_idle(struct amdgpu_device *adev, | 971 | bool amdgpu_device_ip_is_idle(struct amdgpu_device *adev, |
1372 | enum amd_ip_block_type block_type) | 972 | enum amd_ip_block_type block_type) |
1373 | { | 973 | { |
1374 | int i; | 974 | int i; |
1375 | 975 | ||
@@ -1383,8 +983,9 @@ bool amdgpu_is_idle(struct amdgpu_device *adev, | |||
1383 | 983 | ||
1384 | } | 984 | } |
1385 | 985 | ||
1386 | struct amdgpu_ip_block * amdgpu_get_ip_block(struct amdgpu_device *adev, | 986 | struct amdgpu_ip_block * |
1387 | enum amd_ip_block_type type) | 987 | amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev, |
988 | enum amd_ip_block_type type) | ||
1388 | { | 989 | { |
1389 | int i; | 990 | int i; |
1390 | 991 | ||
@@ -1396,7 +997,7 @@ struct amdgpu_ip_block * amdgpu_get_ip_block(struct amdgpu_device *adev, | |||
1396 | } | 997 | } |
1397 | 998 | ||
1398 | /** | 999 | /** |
1399 | * amdgpu_ip_block_version_cmp | 1000 | * amdgpu_device_ip_block_version_cmp |
1400 | * | 1001 | * |
1401 | * @adev: amdgpu_device pointer | 1002 | * @adev: amdgpu_device pointer |
1402 | * @type: enum amd_ip_block_type | 1003 | * @type: enum amd_ip_block_type |
@@ -1406,11 +1007,11 @@ struct amdgpu_ip_block * amdgpu_get_ip_block(struct amdgpu_device *adev, | |||
1406 | * return 0 if equal or greater | 1007 | * return 0 if equal or greater |
1407 | * return 1 if smaller or the ip_block doesn't exist | 1008 | * return 1 if smaller or the ip_block doesn't exist |
1408 | */ | 1009 | */ |
1409 | int amdgpu_ip_block_version_cmp(struct amdgpu_device *adev, | 1010 | int amdgpu_device_ip_block_version_cmp(struct amdgpu_device *adev, |
1410 | enum amd_ip_block_type type, | 1011 | enum amd_ip_block_type type, |
1411 | u32 major, u32 minor) | 1012 | u32 major, u32 minor) |
1412 | { | 1013 | { |
1413 | struct amdgpu_ip_block *ip_block = amdgpu_get_ip_block(adev, type); | 1014 | struct amdgpu_ip_block *ip_block = amdgpu_device_ip_get_ip_block(adev, type); |
1414 | 1015 | ||
1415 | if (ip_block && ((ip_block->version->major > major) || | 1016 | if (ip_block && ((ip_block->version->major > major) || |
1416 | ((ip_block->version->major == major) && | 1017 | ((ip_block->version->major == major) && |
@@ -1421,7 +1022,7 @@ int amdgpu_ip_block_version_cmp(struct amdgpu_device *adev, | |||
1421 | } | 1022 | } |
1422 | 1023 | ||
1423 | /** | 1024 | /** |
1424 | * amdgpu_ip_block_add | 1025 | * amdgpu_device_ip_block_add |
1425 | * | 1026 | * |
1426 | * @adev: amdgpu_device pointer | 1027 | * @adev: amdgpu_device pointer |
1427 | * @ip_block_version: pointer to the IP to add | 1028 | * @ip_block_version: pointer to the IP to add |
@@ -1429,8 +1030,8 @@ int amdgpu_ip_block_version_cmp(struct amdgpu_device *adev, | |||
1429 | * Adds the IP block driver information to the collection of IPs | 1030 | * Adds the IP block driver information to the collection of IPs |
1430 | * on the asic. | 1031 | * on the asic. |
1431 | */ | 1032 | */ |
1432 | int amdgpu_ip_block_add(struct amdgpu_device *adev, | 1033 | int amdgpu_device_ip_block_add(struct amdgpu_device *adev, |
1433 | const struct amdgpu_ip_block_version *ip_block_version) | 1034 | const struct amdgpu_ip_block_version *ip_block_version) |
1434 | { | 1035 | { |
1435 | if (!ip_block_version) | 1036 | if (!ip_block_version) |
1436 | return -EINVAL; | 1037 | return -EINVAL; |
@@ -1586,7 +1187,7 @@ out: | |||
1586 | return err; | 1187 | return err; |
1587 | } | 1188 | } |
1588 | 1189 | ||
1589 | static int amdgpu_early_init(struct amdgpu_device *adev) | 1190 | static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) |
1590 | { | 1191 | { |
1591 | int i, r; | 1192 | int i, r; |
1592 | 1193 | ||
@@ -1695,7 +1296,7 @@ static int amdgpu_early_init(struct amdgpu_device *adev) | |||
1695 | return 0; | 1296 | return 0; |
1696 | } | 1297 | } |
1697 | 1298 | ||
1698 | static int amdgpu_init(struct amdgpu_device *adev) | 1299 | static int amdgpu_device_ip_init(struct amdgpu_device *adev) |
1699 | { | 1300 | { |
1700 | int i, r; | 1301 | int i, r; |
1701 | 1302 | ||
@@ -1711,7 +1312,7 @@ static int amdgpu_init(struct amdgpu_device *adev) | |||
1711 | adev->ip_blocks[i].status.sw = true; | 1312 | adev->ip_blocks[i].status.sw = true; |
1712 | /* need to do gmc hw init early so we can allocate gpu mem */ | 1313 | /* need to do gmc hw init early so we can allocate gpu mem */ |
1713 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { | 1314 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { |
1714 | r = amdgpu_vram_scratch_init(adev); | 1315 | r = amdgpu_device_vram_scratch_init(adev); |
1715 | if (r) { | 1316 | if (r) { |
1716 | DRM_ERROR("amdgpu_vram_scratch_init failed %d\n", r); | 1317 | DRM_ERROR("amdgpu_vram_scratch_init failed %d\n", r); |
1717 | return r; | 1318 | return r; |
@@ -1721,9 +1322,9 @@ static int amdgpu_init(struct amdgpu_device *adev) | |||
1721 | DRM_ERROR("hw_init %d failed %d\n", i, r); | 1322 | DRM_ERROR("hw_init %d failed %d\n", i, r); |
1722 | return r; | 1323 | return r; |
1723 | } | 1324 | } |
1724 | r = amdgpu_wb_init(adev); | 1325 | r = amdgpu_device_wb_init(adev); |
1725 | if (r) { | 1326 | if (r) { |
1726 | DRM_ERROR("amdgpu_wb_init failed %d\n", r); | 1327 | DRM_ERROR("amdgpu_device_wb_init failed %d\n", r); |
1727 | return r; | 1328 | return r; |
1728 | } | 1329 | } |
1729 | adev->ip_blocks[i].status.hw = true; | 1330 | adev->ip_blocks[i].status.hw = true; |
@@ -1762,18 +1363,18 @@ static int amdgpu_init(struct amdgpu_device *adev) | |||
1762 | return 0; | 1363 | return 0; |
1763 | } | 1364 | } |
1764 | 1365 | ||
1765 | static void amdgpu_fill_reset_magic(struct amdgpu_device *adev) | 1366 | static void amdgpu_device_fill_reset_magic(struct amdgpu_device *adev) |
1766 | { | 1367 | { |
1767 | memcpy(adev->reset_magic, adev->gart.ptr, AMDGPU_RESET_MAGIC_NUM); | 1368 | memcpy(adev->reset_magic, adev->gart.ptr, AMDGPU_RESET_MAGIC_NUM); |
1768 | } | 1369 | } |
1769 | 1370 | ||
1770 | static bool amdgpu_check_vram_lost(struct amdgpu_device *adev) | 1371 | static bool amdgpu_device_check_vram_lost(struct amdgpu_device *adev) |
1771 | { | 1372 | { |
1772 | return !!memcmp(adev->gart.ptr, adev->reset_magic, | 1373 | return !!memcmp(adev->gart.ptr, adev->reset_magic, |
1773 | AMDGPU_RESET_MAGIC_NUM); | 1374 | AMDGPU_RESET_MAGIC_NUM); |
1774 | } | 1375 | } |
1775 | 1376 | ||
1776 | static int amdgpu_late_set_cg_state(struct amdgpu_device *adev) | 1377 | static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev) |
1777 | { | 1378 | { |
1778 | int i = 0, r; | 1379 | int i = 0, r; |
1779 | 1380 | ||
@@ -1796,7 +1397,7 @@ static int amdgpu_late_set_cg_state(struct amdgpu_device *adev) | |||
1796 | return 0; | 1397 | return 0; |
1797 | } | 1398 | } |
1798 | 1399 | ||
1799 | static int amdgpu_late_init(struct amdgpu_device *adev) | 1400 | static int amdgpu_device_ip_late_init(struct amdgpu_device *adev) |
1800 | { | 1401 | { |
1801 | int i = 0, r; | 1402 | int i = 0, r; |
1802 | 1403 | ||
@@ -1817,12 +1418,12 @@ static int amdgpu_late_init(struct amdgpu_device *adev) | |||
1817 | mod_delayed_work(system_wq, &adev->late_init_work, | 1418 | mod_delayed_work(system_wq, &adev->late_init_work, |
1818 | msecs_to_jiffies(AMDGPU_RESUME_MS)); | 1419 | msecs_to_jiffies(AMDGPU_RESUME_MS)); |
1819 | 1420 | ||
1820 | amdgpu_fill_reset_magic(adev); | 1421 | amdgpu_device_fill_reset_magic(adev); |
1821 | 1422 | ||
1822 | return 0; | 1423 | return 0; |
1823 | } | 1424 | } |
1824 | 1425 | ||
1825 | static int amdgpu_fini(struct amdgpu_device *adev) | 1426 | static int amdgpu_device_ip_fini(struct amdgpu_device *adev) |
1826 | { | 1427 | { |
1827 | int i, r; | 1428 | int i, r; |
1828 | 1429 | ||
@@ -1856,8 +1457,8 @@ static int amdgpu_fini(struct amdgpu_device *adev) | |||
1856 | continue; | 1457 | continue; |
1857 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { | 1458 | if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) { |
1858 | amdgpu_free_static_csa(adev); | 1459 | amdgpu_free_static_csa(adev); |
1859 | amdgpu_wb_fini(adev); | 1460 | amdgpu_device_wb_fini(adev); |
1860 | amdgpu_vram_scratch_fini(adev); | 1461 | amdgpu_device_vram_scratch_fini(adev); |
1861 | } | 1462 | } |
1862 | 1463 | ||
1863 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && | 1464 | if (adev->ip_blocks[i].version->type != AMD_IP_BLOCK_TYPE_UVD && |
@@ -1910,14 +1511,14 @@ static int amdgpu_fini(struct amdgpu_device *adev) | |||
1910 | return 0; | 1511 | return 0; |
1911 | } | 1512 | } |
1912 | 1513 | ||
1913 | static void amdgpu_late_init_func_handler(struct work_struct *work) | 1514 | static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work) |
1914 | { | 1515 | { |
1915 | struct amdgpu_device *adev = | 1516 | struct amdgpu_device *adev = |
1916 | container_of(work, struct amdgpu_device, late_init_work.work); | 1517 | container_of(work, struct amdgpu_device, late_init_work.work); |
1917 | amdgpu_late_set_cg_state(adev); | 1518 | amdgpu_device_ip_late_set_cg_state(adev); |
1918 | } | 1519 | } |
1919 | 1520 | ||
1920 | int amdgpu_suspend(struct amdgpu_device *adev) | 1521 | int amdgpu_device_ip_suspend(struct amdgpu_device *adev) |
1921 | { | 1522 | { |
1922 | int i, r; | 1523 | int i, r; |
1923 | 1524 | ||
@@ -1925,10 +1526,10 @@ int amdgpu_suspend(struct amdgpu_device *adev) | |||
1925 | amdgpu_virt_request_full_gpu(adev, false); | 1526 | amdgpu_virt_request_full_gpu(adev, false); |
1926 | 1527 | ||
1927 | /* ungate SMC block first */ | 1528 | /* ungate SMC block first */ |
1928 | r = amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC, | 1529 | r = amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_SMC, |
1929 | AMD_CG_STATE_UNGATE); | 1530 | AMD_CG_STATE_UNGATE); |
1930 | if (r) { | 1531 | if (r) { |
1931 | DRM_ERROR("set_clockgating_state(ungate) SMC failed %d\n",r); | 1532 | DRM_ERROR("set_clockgating_state(ungate) SMC failed %d\n", r); |
1932 | } | 1533 | } |
1933 | 1534 | ||
1934 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { | 1535 | for (i = adev->num_ip_blocks - 1; i >= 0; i--) { |
@@ -1958,7 +1559,7 @@ int amdgpu_suspend(struct amdgpu_device *adev) | |||
1958 | return 0; | 1559 | return 0; |
1959 | } | 1560 | } |
1960 | 1561 | ||
1961 | static int amdgpu_sriov_reinit_early(struct amdgpu_device *adev) | 1562 | static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev) |
1962 | { | 1563 | { |
1963 | int i, r; | 1564 | int i, r; |
1964 | 1565 | ||
@@ -1987,7 +1588,7 @@ static int amdgpu_sriov_reinit_early(struct amdgpu_device *adev) | |||
1987 | return 0; | 1588 | return 0; |
1988 | } | 1589 | } |
1989 | 1590 | ||
1990 | static int amdgpu_sriov_reinit_late(struct amdgpu_device *adev) | 1591 | static int amdgpu_device_ip_reinit_late_sriov(struct amdgpu_device *adev) |
1991 | { | 1592 | { |
1992 | int i, r; | 1593 | int i, r; |
1993 | 1594 | ||
@@ -2020,7 +1621,7 @@ static int amdgpu_sriov_reinit_late(struct amdgpu_device *adev) | |||
2020 | return 0; | 1621 | return 0; |
2021 | } | 1622 | } |
2022 | 1623 | ||
2023 | static int amdgpu_resume_phase1(struct amdgpu_device *adev) | 1624 | static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev) |
2024 | { | 1625 | { |
2025 | int i, r; | 1626 | int i, r; |
2026 | 1627 | ||
@@ -2043,7 +1644,7 @@ static int amdgpu_resume_phase1(struct amdgpu_device *adev) | |||
2043 | return 0; | 1644 | return 0; |
2044 | } | 1645 | } |
2045 | 1646 | ||
2046 | static int amdgpu_resume_phase2(struct amdgpu_device *adev) | 1647 | static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev) |
2047 | { | 1648 | { |
2048 | int i, r; | 1649 | int i, r; |
2049 | 1650 | ||
@@ -2065,14 +1666,14 @@ static int amdgpu_resume_phase2(struct amdgpu_device *adev) | |||
2065 | return 0; | 1666 | return 0; |
2066 | } | 1667 | } |
2067 | 1668 | ||
2068 | static int amdgpu_resume(struct amdgpu_device *adev) | 1669 | static int amdgpu_device_ip_resume(struct amdgpu_device *adev) |
2069 | { | 1670 | { |
2070 | int r; | 1671 | int r; |
2071 | 1672 | ||
2072 | r = amdgpu_resume_phase1(adev); | 1673 | r = amdgpu_device_ip_resume_phase1(adev); |
2073 | if (r) | 1674 | if (r) |
2074 | return r; | 1675 | return r; |
2075 | r = amdgpu_resume_phase2(adev); | 1676 | r = amdgpu_device_ip_resume_phase2(adev); |
2076 | 1677 | ||
2077 | return r; | 1678 | return r; |
2078 | } | 1679 | } |
@@ -2211,7 +1812,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2211 | hash_init(adev->mn_hash); | 1812 | hash_init(adev->mn_hash); |
2212 | mutex_init(&adev->lock_reset); | 1813 | mutex_init(&adev->lock_reset); |
2213 | 1814 | ||
2214 | amdgpu_check_arguments(adev); | 1815 | amdgpu_device_check_arguments(adev); |
2215 | 1816 | ||
2216 | spin_lock_init(&adev->mmio_idx_lock); | 1817 | spin_lock_init(&adev->mmio_idx_lock); |
2217 | spin_lock_init(&adev->smc_idx_lock); | 1818 | spin_lock_init(&adev->smc_idx_lock); |
@@ -2229,7 +1830,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2229 | INIT_LIST_HEAD(&adev->ring_lru_list); | 1830 | INIT_LIST_HEAD(&adev->ring_lru_list); |
2230 | spin_lock_init(&adev->ring_lru_list_lock); | 1831 | spin_lock_init(&adev->ring_lru_list_lock); |
2231 | 1832 | ||
2232 | INIT_DELAYED_WORK(&adev->late_init_work, amdgpu_late_init_func_handler); | 1833 | INIT_DELAYED_WORK(&adev->late_init_work, |
1834 | amdgpu_device_ip_late_init_func_handler); | ||
2233 | 1835 | ||
2234 | /* Registers mapping */ | 1836 | /* Registers mapping */ |
2235 | /* TODO: block userspace mapping of io register */ | 1837 | /* TODO: block userspace mapping of io register */ |
@@ -2249,7 +1851,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2249 | DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size); | 1851 | DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size); |
2250 | 1852 | ||
2251 | /* doorbell bar mapping */ | 1853 | /* doorbell bar mapping */ |
2252 | amdgpu_doorbell_init(adev); | 1854 | amdgpu_device_doorbell_init(adev); |
2253 | 1855 | ||
2254 | /* io port mapping */ | 1856 | /* io port mapping */ |
2255 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 1857 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
@@ -2263,14 +1865,14 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2263 | DRM_INFO("PCI I/O BAR is not found.\n"); | 1865 | DRM_INFO("PCI I/O BAR is not found.\n"); |
2264 | 1866 | ||
2265 | /* early init functions */ | 1867 | /* early init functions */ |
2266 | r = amdgpu_early_init(adev); | 1868 | r = amdgpu_device_ip_early_init(adev); |
2267 | if (r) | 1869 | if (r) |
2268 | return r; | 1870 | return r; |
2269 | 1871 | ||
2270 | /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */ | 1872 | /* if we have > 1 VGA cards, then disable the amdgpu VGA resources */ |
2271 | /* this will fail for cards that aren't VGA class devices, just | 1873 | /* this will fail for cards that aren't VGA class devices, just |
2272 | * ignore it */ | 1874 | * ignore it */ |
2273 | vga_client_register(adev->pdev, adev, NULL, amdgpu_vga_set_decode); | 1875 | vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode); |
2274 | 1876 | ||
2275 | if (amdgpu_runtime_pm == 1) | 1877 | if (amdgpu_runtime_pm == 1) |
2276 | runtime = true; | 1878 | runtime = true; |
@@ -2299,7 +1901,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2299 | amdgpu_device_detect_sriov_bios(adev); | 1901 | amdgpu_device_detect_sriov_bios(adev); |
2300 | 1902 | ||
2301 | /* Post card if necessary */ | 1903 | /* Post card if necessary */ |
2302 | if (amdgpu_need_post(adev)) { | 1904 | if (amdgpu_device_need_post(adev)) { |
2303 | if (!adev->bios) { | 1905 | if (!adev->bios) { |
2304 | dev_err(adev->dev, "no vBIOS found\n"); | 1906 | dev_err(adev->dev, "no vBIOS found\n"); |
2305 | r = -EINVAL; | 1907 | r = -EINVAL; |
@@ -2345,7 +1947,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2345 | /* init the mode config */ | 1947 | /* init the mode config */ |
2346 | drm_mode_config_init(adev->ddev); | 1948 | drm_mode_config_init(adev->ddev); |
2347 | 1949 | ||
2348 | r = amdgpu_init(adev); | 1950 | r = amdgpu_device_ip_init(adev); |
2349 | if (r) { | 1951 | if (r) { |
2350 | /* failed in exclusive mode due to timeout */ | 1952 | /* failed in exclusive mode due to timeout */ |
2351 | if (amdgpu_sriov_vf(adev) && | 1953 | if (amdgpu_sriov_vf(adev) && |
@@ -2359,9 +1961,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2359 | r = -EAGAIN; | 1961 | r = -EAGAIN; |
2360 | goto failed; | 1962 | goto failed; |
2361 | } | 1963 | } |
2362 | dev_err(adev->dev, "amdgpu_init failed\n"); | 1964 | dev_err(adev->dev, "amdgpu_device_ip_init failed\n"); |
2363 | amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 0); | 1965 | amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_INIT_FAIL, 0, 0); |
2364 | amdgpu_fini(adev); | 1966 | amdgpu_device_ip_fini(adev); |
2365 | goto failed; | 1967 | goto failed; |
2366 | } | 1968 | } |
2367 | 1969 | ||
@@ -2397,7 +1999,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2397 | if (r) | 1999 | if (r) |
2398 | DRM_ERROR("registering pm debugfs failed (%d).\n", r); | 2000 | DRM_ERROR("registering pm debugfs failed (%d).\n", r); |
2399 | 2001 | ||
2400 | r = amdgpu_gem_debugfs_init(adev); | 2002 | r = amdgpu_debugfs_gem_init(adev); |
2401 | if (r) | 2003 | if (r) |
2402 | DRM_ERROR("registering gem debugfs failed (%d).\n", r); | 2004 | DRM_ERROR("registering gem debugfs failed (%d).\n", r); |
2403 | 2005 | ||
@@ -2405,17 +2007,13 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2405 | if (r) | 2007 | if (r) |
2406 | DRM_ERROR("registering register debugfs failed (%d).\n", r); | 2008 | DRM_ERROR("registering register debugfs failed (%d).\n", r); |
2407 | 2009 | ||
2408 | r = amdgpu_debugfs_test_ib_ring_init(adev); | ||
2409 | if (r) | ||
2410 | DRM_ERROR("registering register test ib ring debugfs failed (%d).\n", r); | ||
2411 | |||
2412 | r = amdgpu_debugfs_firmware_init(adev); | 2010 | r = amdgpu_debugfs_firmware_init(adev); |
2413 | if (r) | 2011 | if (r) |
2414 | DRM_ERROR("registering firmware debugfs failed (%d).\n", r); | 2012 | DRM_ERROR("registering firmware debugfs failed (%d).\n", r); |
2415 | 2013 | ||
2416 | r = amdgpu_debugfs_vbios_dump_init(adev); | 2014 | r = amdgpu_debugfs_init(adev); |
2417 | if (r) | 2015 | if (r) |
2418 | DRM_ERROR("Creating vbios dump debugfs failed (%d).\n", r); | 2016 | DRM_ERROR("Creating debugfs files failed (%d).\n", r); |
2419 | 2017 | ||
2420 | if ((amdgpu_testing & 1)) { | 2018 | if ((amdgpu_testing & 1)) { |
2421 | if (adev->accel_working) | 2019 | if (adev->accel_working) |
@@ -2433,9 +2031,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
2433 | /* enable clockgating, etc. after ib tests, etc. since some blocks require | 2031 | /* enable clockgating, etc. after ib tests, etc. since some blocks require |
2434 | * explicit gating rather than handling it automatically. | 2032 | * explicit gating rather than handling it automatically. |
2435 | */ | 2033 | */ |
2436 | r = amdgpu_late_init(adev); | 2034 | r = amdgpu_device_ip_late_init(adev); |
2437 | if (r) { | 2035 | if (r) { |
2438 | dev_err(adev->dev, "amdgpu_late_init failed\n"); | 2036 | dev_err(adev->dev, "amdgpu_device_ip_late_init failed\n"); |
2439 | amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r); | 2037 | amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_AMDGPU_LATE_INIT_FAIL, 0, r); |
2440 | goto failed; | 2038 | goto failed; |
2441 | } | 2039 | } |
@@ -2466,12 +2064,11 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
2466 | adev->shutdown = true; | 2064 | adev->shutdown = true; |
2467 | if (adev->mode_info.mode_config_initialized) | 2065 | if (adev->mode_info.mode_config_initialized) |
2468 | drm_crtc_force_disable_all(adev->ddev); | 2066 | drm_crtc_force_disable_all(adev->ddev); |
2469 | /* evict vram memory */ | 2067 | |
2470 | amdgpu_bo_evict_vram(adev); | ||
2471 | amdgpu_ib_pool_fini(adev); | 2068 | amdgpu_ib_pool_fini(adev); |
2472 | amdgpu_fence_driver_fini(adev); | 2069 | amdgpu_fence_driver_fini(adev); |
2473 | amdgpu_fbdev_fini(adev); | 2070 | amdgpu_fbdev_fini(adev); |
2474 | r = amdgpu_fini(adev); | 2071 | r = amdgpu_device_ip_fini(adev); |
2475 | if (adev->firmware.gpu_info_fw) { | 2072 | if (adev->firmware.gpu_info_fw) { |
2476 | release_firmware(adev->firmware.gpu_info_fw); | 2073 | release_firmware(adev->firmware.gpu_info_fw); |
2477 | adev->firmware.gpu_info_fw = NULL; | 2074 | adev->firmware.gpu_info_fw = NULL; |
@@ -2494,7 +2091,7 @@ void amdgpu_device_fini(struct amdgpu_device *adev) | |||
2494 | adev->rio_mem = NULL; | 2091 | adev->rio_mem = NULL; |
2495 | iounmap(adev->rmmio); | 2092 | iounmap(adev->rmmio); |
2496 | adev->rmmio = NULL; | 2093 | adev->rmmio = NULL; |
2497 | amdgpu_doorbell_fini(adev); | 2094 | amdgpu_device_doorbell_fini(adev); |
2498 | amdgpu_pm_sysfs_fini(adev); | 2095 | amdgpu_pm_sysfs_fini(adev); |
2499 | amdgpu_debugfs_regs_cleanup(adev); | 2096 | amdgpu_debugfs_regs_cleanup(adev); |
2500 | } | 2097 | } |
@@ -2575,7 +2172,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) | |||
2575 | 2172 | ||
2576 | amdgpu_fence_driver_suspend(adev); | 2173 | amdgpu_fence_driver_suspend(adev); |
2577 | 2174 | ||
2578 | r = amdgpu_suspend(adev); | 2175 | r = amdgpu_device_ip_suspend(adev); |
2579 | 2176 | ||
2580 | /* evict remaining vram memory | 2177 | /* evict remaining vram memory |
2581 | * This second call to evict vram is to evict the gart page table | 2178 | * This second call to evict vram is to evict the gart page table |
@@ -2583,7 +2180,6 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) | |||
2583 | */ | 2180 | */ |
2584 | amdgpu_bo_evict_vram(adev); | 2181 | amdgpu_bo_evict_vram(adev); |
2585 | 2182 | ||
2586 | amdgpu_atombios_scratch_regs_save(adev); | ||
2587 | pci_save_state(dev->pdev); | 2183 | pci_save_state(dev->pdev); |
2588 | if (suspend) { | 2184 | if (suspend) { |
2589 | /* Shut down the device */ | 2185 | /* Shut down the device */ |
@@ -2632,18 +2228,17 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) | |||
2632 | if (r) | 2228 | if (r) |
2633 | goto unlock; | 2229 | goto unlock; |
2634 | } | 2230 | } |
2635 | amdgpu_atombios_scratch_regs_restore(adev); | ||
2636 | 2231 | ||
2637 | /* post card */ | 2232 | /* post card */ |
2638 | if (amdgpu_need_post(adev)) { | 2233 | if (amdgpu_device_need_post(adev)) { |
2639 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); | 2234 | r = amdgpu_atom_asic_init(adev->mode_info.atom_context); |
2640 | if (r) | 2235 | if (r) |
2641 | DRM_ERROR("amdgpu asic init failed\n"); | 2236 | DRM_ERROR("amdgpu asic init failed\n"); |
2642 | } | 2237 | } |
2643 | 2238 | ||
2644 | r = amdgpu_resume(adev); | 2239 | r = amdgpu_device_ip_resume(adev); |
2645 | if (r) { | 2240 | if (r) { |
2646 | DRM_ERROR("amdgpu_resume failed (%d).\n", r); | 2241 | DRM_ERROR("amdgpu_device_ip_resume failed (%d).\n", r); |
2647 | goto unlock; | 2242 | goto unlock; |
2648 | } | 2243 | } |
2649 | amdgpu_fence_driver_resume(adev); | 2244 | amdgpu_fence_driver_resume(adev); |
@@ -2654,7 +2249,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool resume, bool fbcon) | |||
2654 | DRM_ERROR("ib ring test failed (%d).\n", r); | 2249 | DRM_ERROR("ib ring test failed (%d).\n", r); |
2655 | } | 2250 | } |
2656 | 2251 | ||
2657 | r = amdgpu_late_init(adev); | 2252 | r = amdgpu_device_ip_late_init(adev); |
2658 | if (r) | 2253 | if (r) |
2659 | goto unlock; | 2254 | goto unlock; |
2660 | 2255 | ||
@@ -2734,7 +2329,7 @@ unlock: | |||
2734 | return r; | 2329 | return r; |
2735 | } | 2330 | } |
2736 | 2331 | ||
2737 | static bool amdgpu_check_soft_reset(struct amdgpu_device *adev) | 2332 | static bool amdgpu_device_ip_check_soft_reset(struct amdgpu_device *adev) |
2738 | { | 2333 | { |
2739 | int i; | 2334 | int i; |
2740 | bool asic_hang = false; | 2335 | bool asic_hang = false; |
@@ -2756,7 +2351,7 @@ static bool amdgpu_check_soft_reset(struct amdgpu_device *adev) | |||
2756 | return asic_hang; | 2351 | return asic_hang; |
2757 | } | 2352 | } |
2758 | 2353 | ||
2759 | static int amdgpu_pre_soft_reset(struct amdgpu_device *adev) | 2354 | static int amdgpu_device_ip_pre_soft_reset(struct amdgpu_device *adev) |
2760 | { | 2355 | { |
2761 | int i, r = 0; | 2356 | int i, r = 0; |
2762 | 2357 | ||
@@ -2774,7 +2369,7 @@ static int amdgpu_pre_soft_reset(struct amdgpu_device *adev) | |||
2774 | return 0; | 2369 | return 0; |
2775 | } | 2370 | } |
2776 | 2371 | ||
2777 | static bool amdgpu_need_full_reset(struct amdgpu_device *adev) | 2372 | static bool amdgpu_device_ip_need_full_reset(struct amdgpu_device *adev) |
2778 | { | 2373 | { |
2779 | int i; | 2374 | int i; |
2780 | 2375 | ||
@@ -2795,7 +2390,7 @@ static bool amdgpu_need_full_reset(struct amdgpu_device *adev) | |||
2795 | return false; | 2390 | return false; |
2796 | } | 2391 | } |
2797 | 2392 | ||
2798 | static int amdgpu_soft_reset(struct amdgpu_device *adev) | 2393 | static int amdgpu_device_ip_soft_reset(struct amdgpu_device *adev) |
2799 | { | 2394 | { |
2800 | int i, r = 0; | 2395 | int i, r = 0; |
2801 | 2396 | ||
@@ -2813,7 +2408,7 @@ static int amdgpu_soft_reset(struct amdgpu_device *adev) | |||
2813 | return 0; | 2408 | return 0; |
2814 | } | 2409 | } |
2815 | 2410 | ||
2816 | static int amdgpu_post_soft_reset(struct amdgpu_device *adev) | 2411 | static int amdgpu_device_ip_post_soft_reset(struct amdgpu_device *adev) |
2817 | { | 2412 | { |
2818 | int i, r = 0; | 2413 | int i, r = 0; |
2819 | 2414 | ||
@@ -2830,18 +2425,10 @@ static int amdgpu_post_soft_reset(struct amdgpu_device *adev) | |||
2830 | return 0; | 2425 | return 0; |
2831 | } | 2426 | } |
2832 | 2427 | ||
2833 | bool amdgpu_need_backup(struct amdgpu_device *adev) | 2428 | static int amdgpu_device_recover_vram_from_shadow(struct amdgpu_device *adev, |
2834 | { | 2429 | struct amdgpu_ring *ring, |
2835 | if (adev->flags & AMD_IS_APU) | 2430 | struct amdgpu_bo *bo, |
2836 | return false; | 2431 | struct dma_fence **fence) |
2837 | |||
2838 | return amdgpu_lockup_timeout > 0 ? true : false; | ||
2839 | } | ||
2840 | |||
2841 | static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev, | ||
2842 | struct amdgpu_ring *ring, | ||
2843 | struct amdgpu_bo *bo, | ||
2844 | struct dma_fence **fence) | ||
2845 | { | 2432 | { |
2846 | uint32_t domain; | 2433 | uint32_t domain; |
2847 | int r; | 2434 | int r; |
@@ -2874,7 +2461,7 @@ err: | |||
2874 | } | 2461 | } |
2875 | 2462 | ||
2876 | /* | 2463 | /* |
2877 | * amdgpu_reset - reset ASIC/GPU for bare-metal or passthrough | 2464 | * amdgpu_device_reset - reset ASIC/GPU for bare-metal or passthrough |
2878 | * | 2465 | * |
2879 | * @adev: amdgpu device pointer | 2466 | * @adev: amdgpu device pointer |
2880 | * @reset_flags: output param tells caller the reset result | 2467 | * @reset_flags: output param tells caller the reset result |
@@ -2882,18 +2469,19 @@ err: | |||
2882 | * attempt to do soft-reset or full-reset and reinitialize Asic | 2469 | * attempt to do soft-reset or full-reset and reinitialize Asic |
2883 | * return 0 means successed otherwise failed | 2470 | * return 0 means successed otherwise failed |
2884 | */ | 2471 | */ |
2885 | static int amdgpu_reset(struct amdgpu_device *adev, uint64_t* reset_flags) | 2472 | static int amdgpu_device_reset(struct amdgpu_device *adev, |
2473 | uint64_t* reset_flags) | ||
2886 | { | 2474 | { |
2887 | bool need_full_reset, vram_lost = 0; | 2475 | bool need_full_reset, vram_lost = 0; |
2888 | int r; | 2476 | int r; |
2889 | 2477 | ||
2890 | need_full_reset = amdgpu_need_full_reset(adev); | 2478 | need_full_reset = amdgpu_device_ip_need_full_reset(adev); |
2891 | 2479 | ||
2892 | if (!need_full_reset) { | 2480 | if (!need_full_reset) { |
2893 | amdgpu_pre_soft_reset(adev); | 2481 | amdgpu_device_ip_pre_soft_reset(adev); |
2894 | r = amdgpu_soft_reset(adev); | 2482 | r = amdgpu_device_ip_soft_reset(adev); |
2895 | amdgpu_post_soft_reset(adev); | 2483 | amdgpu_device_ip_post_soft_reset(adev); |
2896 | if (r || amdgpu_check_soft_reset(adev)) { | 2484 | if (r || amdgpu_device_ip_check_soft_reset(adev)) { |
2897 | DRM_INFO("soft reset failed, will fallback to full reset!\n"); | 2485 | DRM_INFO("soft reset failed, will fallback to full reset!\n"); |
2898 | need_full_reset = true; | 2486 | need_full_reset = true; |
2899 | } | 2487 | } |
@@ -2901,22 +2489,20 @@ static int amdgpu_reset(struct amdgpu_device *adev, uint64_t* reset_flags) | |||
2901 | } | 2489 | } |
2902 | 2490 | ||
2903 | if (need_full_reset) { | 2491 | if (need_full_reset) { |
2904 | r = amdgpu_suspend(adev); | 2492 | r = amdgpu_device_ip_suspend(adev); |
2905 | 2493 | ||
2906 | retry: | 2494 | retry: |
2907 | amdgpu_atombios_scratch_regs_save(adev); | ||
2908 | r = amdgpu_asic_reset(adev); | 2495 | r = amdgpu_asic_reset(adev); |
2909 | amdgpu_atombios_scratch_regs_restore(adev); | ||
2910 | /* post card */ | 2496 | /* post card */ |
2911 | amdgpu_atom_asic_init(adev->mode_info.atom_context); | 2497 | amdgpu_atom_asic_init(adev->mode_info.atom_context); |
2912 | 2498 | ||
2913 | if (!r) { | 2499 | if (!r) { |
2914 | dev_info(adev->dev, "GPU reset succeeded, trying to resume\n"); | 2500 | dev_info(adev->dev, "GPU reset succeeded, trying to resume\n"); |
2915 | r = amdgpu_resume_phase1(adev); | 2501 | r = amdgpu_device_ip_resume_phase1(adev); |
2916 | if (r) | 2502 | if (r) |
2917 | goto out; | 2503 | goto out; |
2918 | 2504 | ||
2919 | vram_lost = amdgpu_check_vram_lost(adev); | 2505 | vram_lost = amdgpu_device_check_vram_lost(adev); |
2920 | if (vram_lost) { | 2506 | if (vram_lost) { |
2921 | DRM_ERROR("VRAM is lost!\n"); | 2507 | DRM_ERROR("VRAM is lost!\n"); |
2922 | atomic_inc(&adev->vram_lost_counter); | 2508 | atomic_inc(&adev->vram_lost_counter); |
@@ -2927,12 +2513,12 @@ retry: | |||
2927 | if (r) | 2513 | if (r) |
2928 | goto out; | 2514 | goto out; |
2929 | 2515 | ||
2930 | r = amdgpu_resume_phase2(adev); | 2516 | r = amdgpu_device_ip_resume_phase2(adev); |
2931 | if (r) | 2517 | if (r) |
2932 | goto out; | 2518 | goto out; |
2933 | 2519 | ||
2934 | if (vram_lost) | 2520 | if (vram_lost) |
2935 | amdgpu_fill_reset_magic(adev); | 2521 | amdgpu_device_fill_reset_magic(adev); |
2936 | } | 2522 | } |
2937 | } | 2523 | } |
2938 | 2524 | ||
@@ -2942,7 +2528,7 @@ out: | |||
2942 | r = amdgpu_ib_ring_tests(adev); | 2528 | r = amdgpu_ib_ring_tests(adev); |
2943 | if (r) { | 2529 | if (r) { |
2944 | dev_err(adev->dev, "ib ring test failed (%d).\n", r); | 2530 | dev_err(adev->dev, "ib ring test failed (%d).\n", r); |
2945 | r = amdgpu_suspend(adev); | 2531 | r = amdgpu_device_ip_suspend(adev); |
2946 | need_full_reset = true; | 2532 | need_full_reset = true; |
2947 | goto retry; | 2533 | goto retry; |
2948 | } | 2534 | } |
@@ -2960,7 +2546,7 @@ out: | |||
2960 | } | 2546 | } |
2961 | 2547 | ||
2962 | /* | 2548 | /* |
2963 | * amdgpu_reset_sriov - reset ASIC for SR-IOV vf | 2549 | * amdgpu_device_reset_sriov - reset ASIC for SR-IOV vf |
2964 | * | 2550 | * |
2965 | * @adev: amdgpu device pointer | 2551 | * @adev: amdgpu device pointer |
2966 | * @reset_flags: output param tells caller the reset result | 2552 | * @reset_flags: output param tells caller the reset result |
@@ -2968,7 +2554,9 @@ out: | |||
2968 | * do VF FLR and reinitialize Asic | 2554 | * do VF FLR and reinitialize Asic |
2969 | * return 0 means successed otherwise failed | 2555 | * return 0 means successed otherwise failed |
2970 | */ | 2556 | */ |
2971 | static int amdgpu_reset_sriov(struct amdgpu_device *adev, uint64_t *reset_flags, bool from_hypervisor) | 2557 | static int amdgpu_device_reset_sriov(struct amdgpu_device *adev, |
2558 | uint64_t *reset_flags, | ||
2559 | bool from_hypervisor) | ||
2972 | { | 2560 | { |
2973 | int r; | 2561 | int r; |
2974 | 2562 | ||
@@ -2980,7 +2568,7 @@ static int amdgpu_reset_sriov(struct amdgpu_device *adev, uint64_t *reset_flags, | |||
2980 | return r; | 2568 | return r; |
2981 | 2569 | ||
2982 | /* Resume IP prior to SMC */ | 2570 | /* Resume IP prior to SMC */ |
2983 | r = amdgpu_sriov_reinit_early(adev); | 2571 | r = amdgpu_device_ip_reinit_early_sriov(adev); |
2984 | if (r) | 2572 | if (r) |
2985 | goto error; | 2573 | goto error; |
2986 | 2574 | ||
@@ -2988,7 +2576,7 @@ static int amdgpu_reset_sriov(struct amdgpu_device *adev, uint64_t *reset_flags, | |||
2988 | amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); | 2576 | amdgpu_gtt_mgr_recover(&adev->mman.bdev.man[TTM_PL_TT]); |
2989 | 2577 | ||
2990 | /* now we are okay to resume SMC/CP/SDMA */ | 2578 | /* now we are okay to resume SMC/CP/SDMA */ |
2991 | r = amdgpu_sriov_reinit_late(adev); | 2579 | r = amdgpu_device_ip_reinit_late_sriov(adev); |
2992 | if (r) | 2580 | if (r) |
2993 | goto error; | 2581 | goto error; |
2994 | 2582 | ||
@@ -3015,25 +2603,33 @@ error: | |||
3015 | } | 2603 | } |
3016 | 2604 | ||
3017 | /** | 2605 | /** |
3018 | * amdgpu_gpu_recover - reset the asic and recover scheduler | 2606 | * amdgpu_device_gpu_recover - reset the asic and recover scheduler |
3019 | * | 2607 | * |
3020 | * @adev: amdgpu device pointer | 2608 | * @adev: amdgpu device pointer |
3021 | * @job: which job trigger hang | 2609 | * @job: which job trigger hang |
2610 | * @force forces reset regardless of amdgpu_gpu_recovery | ||
3022 | * | 2611 | * |
3023 | * Attempt to reset the GPU if it has hung (all asics). | 2612 | * Attempt to reset the GPU if it has hung (all asics). |
3024 | * Returns 0 for success or an error on failure. | 2613 | * Returns 0 for success or an error on failure. |
3025 | */ | 2614 | */ |
3026 | int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job) | 2615 | int amdgpu_device_gpu_recover(struct amdgpu_device *adev, |
2616 | struct amdgpu_job *job, bool force) | ||
3027 | { | 2617 | { |
3028 | struct drm_atomic_state *state = NULL; | 2618 | struct drm_atomic_state *state = NULL; |
3029 | uint64_t reset_flags = 0; | 2619 | uint64_t reset_flags = 0; |
3030 | int i, r, resched; | 2620 | int i, r, resched; |
3031 | 2621 | ||
3032 | if (!amdgpu_check_soft_reset(adev)) { | 2622 | if (!amdgpu_device_ip_check_soft_reset(adev)) { |
3033 | DRM_INFO("No hardware hang detected. Did some blocks stall?\n"); | 2623 | DRM_INFO("No hardware hang detected. Did some blocks stall?\n"); |
3034 | return 0; | 2624 | return 0; |
3035 | } | 2625 | } |
3036 | 2626 | ||
2627 | if (!force && (amdgpu_gpu_recovery == 0 || | ||
2628 | (amdgpu_gpu_recovery == -1 && !amdgpu_sriov_vf(adev)))) { | ||
2629 | DRM_INFO("GPU recovery disabled.\n"); | ||
2630 | return 0; | ||
2631 | } | ||
2632 | |||
3037 | dev_info(adev->dev, "GPU reset begin!\n"); | 2633 | dev_info(adev->dev, "GPU reset begin!\n"); |
3038 | 2634 | ||
3039 | mutex_lock(&adev->lock_reset); | 2635 | mutex_lock(&adev->lock_reset); |
@@ -3058,16 +2654,16 @@ int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job) | |||
3058 | continue; | 2654 | continue; |
3059 | 2655 | ||
3060 | kthread_park(ring->sched.thread); | 2656 | kthread_park(ring->sched.thread); |
3061 | amd_sched_hw_job_reset(&ring->sched, &job->base); | 2657 | drm_sched_hw_job_reset(&ring->sched, &job->base); |
3062 | 2658 | ||
3063 | /* after all hw jobs are reset, hw fence is meaningless, so force_completion */ | 2659 | /* after all hw jobs are reset, hw fence is meaningless, so force_completion */ |
3064 | amdgpu_fence_driver_force_completion(ring); | 2660 | amdgpu_fence_driver_force_completion(ring); |
3065 | } | 2661 | } |
3066 | 2662 | ||
3067 | if (amdgpu_sriov_vf(adev)) | 2663 | if (amdgpu_sriov_vf(adev)) |
3068 | r = amdgpu_reset_sriov(adev, &reset_flags, job ? false : true); | 2664 | r = amdgpu_device_reset_sriov(adev, &reset_flags, job ? false : true); |
3069 | else | 2665 | else |
3070 | r = amdgpu_reset(adev, &reset_flags); | 2666 | r = amdgpu_device_reset(adev, &reset_flags); |
3071 | 2667 | ||
3072 | if (!r) { | 2668 | if (!r) { |
3073 | if (((reset_flags & AMDGPU_RESET_INFO_FULLRESET) && !(adev->flags & AMD_IS_APU)) || | 2669 | if (((reset_flags & AMDGPU_RESET_INFO_FULLRESET) && !(adev->flags & AMD_IS_APU)) || |
@@ -3080,7 +2676,7 @@ int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job) | |||
3080 | mutex_lock(&adev->shadow_list_lock); | 2676 | mutex_lock(&adev->shadow_list_lock); |
3081 | list_for_each_entry_safe(bo, tmp, &adev->shadow_list, shadow_list) { | 2677 | list_for_each_entry_safe(bo, tmp, &adev->shadow_list, shadow_list) { |
3082 | next = NULL; | 2678 | next = NULL; |
3083 | amdgpu_recover_vram_from_shadow(adev, ring, bo, &next); | 2679 | amdgpu_device_recover_vram_from_shadow(adev, ring, bo, &next); |
3084 | if (fence) { | 2680 | if (fence) { |
3085 | r = dma_fence_wait(fence, false); | 2681 | r = dma_fence_wait(fence, false); |
3086 | if (r) { | 2682 | if (r) { |
@@ -3111,7 +2707,7 @@ int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job) | |||
3111 | if (job && job->ring->idx != i) | 2707 | if (job && job->ring->idx != i) |
3112 | continue; | 2708 | continue; |
3113 | 2709 | ||
3114 | amd_sched_job_recovery(&ring->sched); | 2710 | drm_sched_job_recovery(&ring->sched); |
3115 | kthread_unpark(ring->sched.thread); | 2711 | kthread_unpark(ring->sched.thread); |
3116 | } | 2712 | } |
3117 | } else { | 2713 | } else { |
@@ -3153,7 +2749,7 @@ int amdgpu_gpu_recover(struct amdgpu_device *adev, struct amdgpu_job *job) | |||
3153 | return r; | 2749 | return r; |
3154 | } | 2750 | } |
3155 | 2751 | ||
3156 | void amdgpu_get_pcie_info(struct amdgpu_device *adev) | 2752 | void amdgpu_device_get_pcie_info(struct amdgpu_device *adev) |
3157 | { | 2753 | { |
3158 | u32 mask; | 2754 | u32 mask; |
3159 | int ret; | 2755 | int ret; |
@@ -3245,773 +2841,3 @@ void amdgpu_get_pcie_info(struct amdgpu_device *adev) | |||
3245 | } | 2841 | } |
3246 | } | 2842 | } |
3247 | 2843 | ||
3248 | /* | ||
3249 | * Debugfs | ||
3250 | */ | ||
3251 | int amdgpu_debugfs_add_files(struct amdgpu_device *adev, | ||
3252 | const struct drm_info_list *files, | ||
3253 | unsigned nfiles) | ||
3254 | { | ||
3255 | unsigned i; | ||
3256 | |||
3257 | for (i = 0; i < adev->debugfs_count; i++) { | ||
3258 | if (adev->debugfs[i].files == files) { | ||
3259 | /* Already registered */ | ||
3260 | return 0; | ||
3261 | } | ||
3262 | } | ||
3263 | |||
3264 | i = adev->debugfs_count + 1; | ||
3265 | if (i > AMDGPU_DEBUGFS_MAX_COMPONENTS) { | ||
3266 | DRM_ERROR("Reached maximum number of debugfs components.\n"); | ||
3267 | DRM_ERROR("Report so we increase " | ||
3268 | "AMDGPU_DEBUGFS_MAX_COMPONENTS.\n"); | ||
3269 | return -EINVAL; | ||
3270 | } | ||
3271 | adev->debugfs[adev->debugfs_count].files = files; | ||
3272 | adev->debugfs[adev->debugfs_count].num_files = nfiles; | ||
3273 | adev->debugfs_count = i; | ||
3274 | #if defined(CONFIG_DEBUG_FS) | ||
3275 | drm_debugfs_create_files(files, nfiles, | ||
3276 | adev->ddev->primary->debugfs_root, | ||
3277 | adev->ddev->primary); | ||
3278 | #endif | ||
3279 | return 0; | ||
3280 | } | ||
3281 | |||
3282 | #if defined(CONFIG_DEBUG_FS) | ||
3283 | |||
3284 | static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf, | ||
3285 | size_t size, loff_t *pos) | ||
3286 | { | ||
3287 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3288 | ssize_t result = 0; | ||
3289 | int r; | ||
3290 | bool pm_pg_lock, use_bank; | ||
3291 | unsigned instance_bank, sh_bank, se_bank; | ||
3292 | |||
3293 | if (size & 0x3 || *pos & 0x3) | ||
3294 | return -EINVAL; | ||
3295 | |||
3296 | /* are we reading registers for which a PG lock is necessary? */ | ||
3297 | pm_pg_lock = (*pos >> 23) & 1; | ||
3298 | |||
3299 | if (*pos & (1ULL << 62)) { | ||
3300 | se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24; | ||
3301 | sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34; | ||
3302 | instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44; | ||
3303 | |||
3304 | if (se_bank == 0x3FF) | ||
3305 | se_bank = 0xFFFFFFFF; | ||
3306 | if (sh_bank == 0x3FF) | ||
3307 | sh_bank = 0xFFFFFFFF; | ||
3308 | if (instance_bank == 0x3FF) | ||
3309 | instance_bank = 0xFFFFFFFF; | ||
3310 | use_bank = 1; | ||
3311 | } else { | ||
3312 | use_bank = 0; | ||
3313 | } | ||
3314 | |||
3315 | *pos &= (1UL << 22) - 1; | ||
3316 | |||
3317 | if (use_bank) { | ||
3318 | if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) || | ||
3319 | (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) | ||
3320 | return -EINVAL; | ||
3321 | mutex_lock(&adev->grbm_idx_mutex); | ||
3322 | amdgpu_gfx_select_se_sh(adev, se_bank, | ||
3323 | sh_bank, instance_bank); | ||
3324 | } | ||
3325 | |||
3326 | if (pm_pg_lock) | ||
3327 | mutex_lock(&adev->pm.mutex); | ||
3328 | |||
3329 | while (size) { | ||
3330 | uint32_t value; | ||
3331 | |||
3332 | if (*pos > adev->rmmio_size) | ||
3333 | goto end; | ||
3334 | |||
3335 | value = RREG32(*pos >> 2); | ||
3336 | r = put_user(value, (uint32_t *)buf); | ||
3337 | if (r) { | ||
3338 | result = r; | ||
3339 | goto end; | ||
3340 | } | ||
3341 | |||
3342 | result += 4; | ||
3343 | buf += 4; | ||
3344 | *pos += 4; | ||
3345 | size -= 4; | ||
3346 | } | ||
3347 | |||
3348 | end: | ||
3349 | if (use_bank) { | ||
3350 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
3351 | mutex_unlock(&adev->grbm_idx_mutex); | ||
3352 | } | ||
3353 | |||
3354 | if (pm_pg_lock) | ||
3355 | mutex_unlock(&adev->pm.mutex); | ||
3356 | |||
3357 | return result; | ||
3358 | } | ||
3359 | |||
3360 | static ssize_t amdgpu_debugfs_regs_write(struct file *f, const char __user *buf, | ||
3361 | size_t size, loff_t *pos) | ||
3362 | { | ||
3363 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3364 | ssize_t result = 0; | ||
3365 | int r; | ||
3366 | bool pm_pg_lock, use_bank; | ||
3367 | unsigned instance_bank, sh_bank, se_bank; | ||
3368 | |||
3369 | if (size & 0x3 || *pos & 0x3) | ||
3370 | return -EINVAL; | ||
3371 | |||
3372 | /* are we reading registers for which a PG lock is necessary? */ | ||
3373 | pm_pg_lock = (*pos >> 23) & 1; | ||
3374 | |||
3375 | if (*pos & (1ULL << 62)) { | ||
3376 | se_bank = (*pos & GENMASK_ULL(33, 24)) >> 24; | ||
3377 | sh_bank = (*pos & GENMASK_ULL(43, 34)) >> 34; | ||
3378 | instance_bank = (*pos & GENMASK_ULL(53, 44)) >> 44; | ||
3379 | |||
3380 | if (se_bank == 0x3FF) | ||
3381 | se_bank = 0xFFFFFFFF; | ||
3382 | if (sh_bank == 0x3FF) | ||
3383 | sh_bank = 0xFFFFFFFF; | ||
3384 | if (instance_bank == 0x3FF) | ||
3385 | instance_bank = 0xFFFFFFFF; | ||
3386 | use_bank = 1; | ||
3387 | } else { | ||
3388 | use_bank = 0; | ||
3389 | } | ||
3390 | |||
3391 | *pos &= (1UL << 22) - 1; | ||
3392 | |||
3393 | if (use_bank) { | ||
3394 | if ((sh_bank != 0xFFFFFFFF && sh_bank >= adev->gfx.config.max_sh_per_se) || | ||
3395 | (se_bank != 0xFFFFFFFF && se_bank >= adev->gfx.config.max_shader_engines)) | ||
3396 | return -EINVAL; | ||
3397 | mutex_lock(&adev->grbm_idx_mutex); | ||
3398 | amdgpu_gfx_select_se_sh(adev, se_bank, | ||
3399 | sh_bank, instance_bank); | ||
3400 | } | ||
3401 | |||
3402 | if (pm_pg_lock) | ||
3403 | mutex_lock(&adev->pm.mutex); | ||
3404 | |||
3405 | while (size) { | ||
3406 | uint32_t value; | ||
3407 | |||
3408 | if (*pos > adev->rmmio_size) | ||
3409 | return result; | ||
3410 | |||
3411 | r = get_user(value, (uint32_t *)buf); | ||
3412 | if (r) | ||
3413 | return r; | ||
3414 | |||
3415 | WREG32(*pos >> 2, value); | ||
3416 | |||
3417 | result += 4; | ||
3418 | buf += 4; | ||
3419 | *pos += 4; | ||
3420 | size -= 4; | ||
3421 | } | ||
3422 | |||
3423 | if (use_bank) { | ||
3424 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff); | ||
3425 | mutex_unlock(&adev->grbm_idx_mutex); | ||
3426 | } | ||
3427 | |||
3428 | if (pm_pg_lock) | ||
3429 | mutex_unlock(&adev->pm.mutex); | ||
3430 | |||
3431 | return result; | ||
3432 | } | ||
3433 | |||
3434 | static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf, | ||
3435 | size_t size, loff_t *pos) | ||
3436 | { | ||
3437 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3438 | ssize_t result = 0; | ||
3439 | int r; | ||
3440 | |||
3441 | if (size & 0x3 || *pos & 0x3) | ||
3442 | return -EINVAL; | ||
3443 | |||
3444 | while (size) { | ||
3445 | uint32_t value; | ||
3446 | |||
3447 | value = RREG32_PCIE(*pos >> 2); | ||
3448 | r = put_user(value, (uint32_t *)buf); | ||
3449 | if (r) | ||
3450 | return r; | ||
3451 | |||
3452 | result += 4; | ||
3453 | buf += 4; | ||
3454 | *pos += 4; | ||
3455 | size -= 4; | ||
3456 | } | ||
3457 | |||
3458 | return result; | ||
3459 | } | ||
3460 | |||
3461 | static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user *buf, | ||
3462 | size_t size, loff_t *pos) | ||
3463 | { | ||
3464 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3465 | ssize_t result = 0; | ||
3466 | int r; | ||
3467 | |||
3468 | if (size & 0x3 || *pos & 0x3) | ||
3469 | return -EINVAL; | ||
3470 | |||
3471 | while (size) { | ||
3472 | uint32_t value; | ||
3473 | |||
3474 | r = get_user(value, (uint32_t *)buf); | ||
3475 | if (r) | ||
3476 | return r; | ||
3477 | |||
3478 | WREG32_PCIE(*pos >> 2, value); | ||
3479 | |||
3480 | result += 4; | ||
3481 | buf += 4; | ||
3482 | *pos += 4; | ||
3483 | size -= 4; | ||
3484 | } | ||
3485 | |||
3486 | return result; | ||
3487 | } | ||
3488 | |||
3489 | static ssize_t amdgpu_debugfs_regs_didt_read(struct file *f, char __user *buf, | ||
3490 | size_t size, loff_t *pos) | ||
3491 | { | ||
3492 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3493 | ssize_t result = 0; | ||
3494 | int r; | ||
3495 | |||
3496 | if (size & 0x3 || *pos & 0x3) | ||
3497 | return -EINVAL; | ||
3498 | |||
3499 | while (size) { | ||
3500 | uint32_t value; | ||
3501 | |||
3502 | value = RREG32_DIDT(*pos >> 2); | ||
3503 | r = put_user(value, (uint32_t *)buf); | ||
3504 | if (r) | ||
3505 | return r; | ||
3506 | |||
3507 | result += 4; | ||
3508 | buf += 4; | ||
3509 | *pos += 4; | ||
3510 | size -= 4; | ||
3511 | } | ||
3512 | |||
3513 | return result; | ||
3514 | } | ||
3515 | |||
3516 | static ssize_t amdgpu_debugfs_regs_didt_write(struct file *f, const char __user *buf, | ||
3517 | size_t size, loff_t *pos) | ||
3518 | { | ||
3519 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3520 | ssize_t result = 0; | ||
3521 | int r; | ||
3522 | |||
3523 | if (size & 0x3 || *pos & 0x3) | ||
3524 | return -EINVAL; | ||
3525 | |||
3526 | while (size) { | ||
3527 | uint32_t value; | ||
3528 | |||
3529 | r = get_user(value, (uint32_t *)buf); | ||
3530 | if (r) | ||
3531 | return r; | ||
3532 | |||
3533 | WREG32_DIDT(*pos >> 2, value); | ||
3534 | |||
3535 | result += 4; | ||
3536 | buf += 4; | ||
3537 | *pos += 4; | ||
3538 | size -= 4; | ||
3539 | } | ||
3540 | |||
3541 | return result; | ||
3542 | } | ||
3543 | |||
3544 | static ssize_t amdgpu_debugfs_regs_smc_read(struct file *f, char __user *buf, | ||
3545 | size_t size, loff_t *pos) | ||
3546 | { | ||
3547 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3548 | ssize_t result = 0; | ||
3549 | int r; | ||
3550 | |||
3551 | if (size & 0x3 || *pos & 0x3) | ||
3552 | return -EINVAL; | ||
3553 | |||
3554 | while (size) { | ||
3555 | uint32_t value; | ||
3556 | |||
3557 | value = RREG32_SMC(*pos); | ||
3558 | r = put_user(value, (uint32_t *)buf); | ||
3559 | if (r) | ||
3560 | return r; | ||
3561 | |||
3562 | result += 4; | ||
3563 | buf += 4; | ||
3564 | *pos += 4; | ||
3565 | size -= 4; | ||
3566 | } | ||
3567 | |||
3568 | return result; | ||
3569 | } | ||
3570 | |||
3571 | static ssize_t amdgpu_debugfs_regs_smc_write(struct file *f, const char __user *buf, | ||
3572 | size_t size, loff_t *pos) | ||
3573 | { | ||
3574 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3575 | ssize_t result = 0; | ||
3576 | int r; | ||
3577 | |||
3578 | if (size & 0x3 || *pos & 0x3) | ||
3579 | return -EINVAL; | ||
3580 | |||
3581 | while (size) { | ||
3582 | uint32_t value; | ||
3583 | |||
3584 | r = get_user(value, (uint32_t *)buf); | ||
3585 | if (r) | ||
3586 | return r; | ||
3587 | |||
3588 | WREG32_SMC(*pos, value); | ||
3589 | |||
3590 | result += 4; | ||
3591 | buf += 4; | ||
3592 | *pos += 4; | ||
3593 | size -= 4; | ||
3594 | } | ||
3595 | |||
3596 | return result; | ||
3597 | } | ||
3598 | |||
3599 | static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf, | ||
3600 | size_t size, loff_t *pos) | ||
3601 | { | ||
3602 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3603 | ssize_t result = 0; | ||
3604 | int r; | ||
3605 | uint32_t *config, no_regs = 0; | ||
3606 | |||
3607 | if (size & 0x3 || *pos & 0x3) | ||
3608 | return -EINVAL; | ||
3609 | |||
3610 | config = kmalloc_array(256, sizeof(*config), GFP_KERNEL); | ||
3611 | if (!config) | ||
3612 | return -ENOMEM; | ||
3613 | |||
3614 | /* version, increment each time something is added */ | ||
3615 | config[no_regs++] = 3; | ||
3616 | config[no_regs++] = adev->gfx.config.max_shader_engines; | ||
3617 | config[no_regs++] = adev->gfx.config.max_tile_pipes; | ||
3618 | config[no_regs++] = adev->gfx.config.max_cu_per_sh; | ||
3619 | config[no_regs++] = adev->gfx.config.max_sh_per_se; | ||
3620 | config[no_regs++] = adev->gfx.config.max_backends_per_se; | ||
3621 | config[no_regs++] = adev->gfx.config.max_texture_channel_caches; | ||
3622 | config[no_regs++] = adev->gfx.config.max_gprs; | ||
3623 | config[no_regs++] = adev->gfx.config.max_gs_threads; | ||
3624 | config[no_regs++] = adev->gfx.config.max_hw_contexts; | ||
3625 | config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_frontend; | ||
3626 | config[no_regs++] = adev->gfx.config.sc_prim_fifo_size_backend; | ||
3627 | config[no_regs++] = adev->gfx.config.sc_hiz_tile_fifo_size; | ||
3628 | config[no_regs++] = adev->gfx.config.sc_earlyz_tile_fifo_size; | ||
3629 | config[no_regs++] = adev->gfx.config.num_tile_pipes; | ||
3630 | config[no_regs++] = adev->gfx.config.backend_enable_mask; | ||
3631 | config[no_regs++] = adev->gfx.config.mem_max_burst_length_bytes; | ||
3632 | config[no_regs++] = adev->gfx.config.mem_row_size_in_kb; | ||
3633 | config[no_regs++] = adev->gfx.config.shader_engine_tile_size; | ||
3634 | config[no_regs++] = adev->gfx.config.num_gpus; | ||
3635 | config[no_regs++] = adev->gfx.config.multi_gpu_tile_size; | ||
3636 | config[no_regs++] = adev->gfx.config.mc_arb_ramcfg; | ||
3637 | config[no_regs++] = adev->gfx.config.gb_addr_config; | ||
3638 | config[no_regs++] = adev->gfx.config.num_rbs; | ||
3639 | |||
3640 | /* rev==1 */ | ||
3641 | config[no_regs++] = adev->rev_id; | ||
3642 | config[no_regs++] = adev->pg_flags; | ||
3643 | config[no_regs++] = adev->cg_flags; | ||
3644 | |||
3645 | /* rev==2 */ | ||
3646 | config[no_regs++] = adev->family; | ||
3647 | config[no_regs++] = adev->external_rev_id; | ||
3648 | |||
3649 | /* rev==3 */ | ||
3650 | config[no_regs++] = adev->pdev->device; | ||
3651 | config[no_regs++] = adev->pdev->revision; | ||
3652 | config[no_regs++] = adev->pdev->subsystem_device; | ||
3653 | config[no_regs++] = adev->pdev->subsystem_vendor; | ||
3654 | |||
3655 | while (size && (*pos < no_regs * 4)) { | ||
3656 | uint32_t value; | ||
3657 | |||
3658 | value = config[*pos >> 2]; | ||
3659 | r = put_user(value, (uint32_t *)buf); | ||
3660 | if (r) { | ||
3661 | kfree(config); | ||
3662 | return r; | ||
3663 | } | ||
3664 | |||
3665 | result += 4; | ||
3666 | buf += 4; | ||
3667 | *pos += 4; | ||
3668 | size -= 4; | ||
3669 | } | ||
3670 | |||
3671 | kfree(config); | ||
3672 | return result; | ||
3673 | } | ||
3674 | |||
3675 | static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf, | ||
3676 | size_t size, loff_t *pos) | ||
3677 | { | ||
3678 | struct amdgpu_device *adev = file_inode(f)->i_private; | ||
3679 | int idx, x, outsize, r, valuesize; | ||
3680 | uint32_t values[16]; | ||
3681 | |||
3682 | if (size & 3 || *pos & 0x3) | ||
3683 | return -EINVAL; | ||
3684 | |||
3685 | if (amdgpu_dpm == 0) | ||
3686 | return -EINVAL; | ||
3687 | |||
3688 | /* convert offset to sensor number */ | ||
3689 | idx = *pos >> 2; | ||
3690 | |||
3691 | valuesize = sizeof(values); | ||
3692 | if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->read_sensor) | ||
3693 | r = amdgpu_dpm_read_sensor(adev, idx, &values[0], &valuesize); | ||
3694 | else | ||
3695 | return -EINVAL; | ||
3696 | |||
3697 | if (size > valuesize) | ||
3698 | return -EINVAL; | ||
3699 | |||
3700 | outsize = 0; | ||
3701 | x = 0; | ||
3702 | if (!r) { | ||
3703 | while (size) { | ||
3704 | r = put_user(values[x++], (int32_t *)buf); | ||
3705 | buf += 4; | ||
3706 | size -= 4; | ||
3707 | outsize += 4; | ||
3708 | } | ||
3709 | } | ||
3710 | |||
3711 | return !r ? outsize : r; | ||
3712 | } | ||
3713 | |||
3714 | static ssize_t amdgpu_debugfs_wave_read(struct file *f, char __user *buf, | ||
3715 | size_t size, loff_t *pos) | ||
3716 | { | ||
3717 | struct amdgpu_device *adev = f->f_inode->i_private; | ||
3718 | int r, x; | ||
3719 | ssize_t result=0; | ||
3720 | uint32_t offset, se, sh, cu, wave, simd, data[32]; | ||
3721 | |||
3722 | if (size & 3 || *pos & 3) | ||
3723 | return -EINVAL; | ||
3724 | |||
3725 | /* decode offset */ | ||
3726 | offset = (*pos & GENMASK_ULL(6, 0)); | ||
3727 | se = (*pos & GENMASK_ULL(14, 7)) >> 7; | ||
3728 | sh = (*pos & GENMASK_ULL(22, 15)) >> 15; | ||
3729 | cu = (*pos & GENMASK_ULL(30, 23)) >> 23; | ||
3730 | wave = (*pos & GENMASK_ULL(36, 31)) >> 31; | ||
3731 | simd = (*pos & GENMASK_ULL(44, 37)) >> 37; | ||
3732 | |||
3733 | /* switch to the specific se/sh/cu */ | ||
3734 | mutex_lock(&adev->grbm_idx_mutex); | ||
3735 | amdgpu_gfx_select_se_sh(adev, se, sh, cu); | ||
3736 | |||
3737 | x = 0; | ||
3738 | if (adev->gfx.funcs->read_wave_data) | ||
3739 | adev->gfx.funcs->read_wave_data(adev, simd, wave, data, &x); | ||
3740 | |||
3741 | amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | ||
3742 | mutex_unlock(&adev->grbm_idx_mutex); | ||
3743 | |||
3744 | if (!x) | ||
3745 | return -EINVAL; | ||
3746 | |||
3747 | while (size && (offset < x * 4)) { | ||
3748 | uint32_t value; | ||
3749 | |||
3750 | value = data[offset >> 2]; | ||
3751 | r = put_user(value, (uint32_t *)buf); | ||
3752 | if (r) | ||
3753 | return r; | ||
3754 | |||
3755 | result += 4; | ||
3756 | buf += 4; | ||
3757 | offset += 4; | ||
3758 | size -= 4; | ||
3759 | } | ||
3760 | |||
3761 | return result; | ||
3762 | } | ||
3763 | |||
3764 | static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, | ||
3765 | size_t size, loff_t *pos) | ||
3766 | { | ||
3767 | struct amdgpu_device *adev = f->f_inode->i_private; | ||
3768 | int r; | ||
3769 | ssize_t result = 0; | ||
3770 | uint32_t offset, se, sh, cu, wave, simd, thread, bank, *data; | ||
3771 | |||
3772 | if (size & 3 || *pos & 3) | ||
3773 | return -EINVAL; | ||
3774 | |||
3775 | /* decode offset */ | ||
3776 | offset = *pos & GENMASK_ULL(11, 0); | ||
3777 | se = (*pos & GENMASK_ULL(19, 12)) >> 12; | ||
3778 | sh = (*pos & GENMASK_ULL(27, 20)) >> 20; | ||
3779 | cu = (*pos & GENMASK_ULL(35, 28)) >> 28; | ||
3780 | wave = (*pos & GENMASK_ULL(43, 36)) >> 36; | ||
3781 | simd = (*pos & GENMASK_ULL(51, 44)) >> 44; | ||
3782 | thread = (*pos & GENMASK_ULL(59, 52)) >> 52; | ||
3783 | bank = (*pos & GENMASK_ULL(61, 60)) >> 60; | ||
3784 | |||
3785 | data = kmalloc_array(1024, sizeof(*data), GFP_KERNEL); | ||
3786 | if (!data) | ||
3787 | return -ENOMEM; | ||
3788 | |||
3789 | /* switch to the specific se/sh/cu */ | ||
3790 | mutex_lock(&adev->grbm_idx_mutex); | ||
3791 | amdgpu_gfx_select_se_sh(adev, se, sh, cu); | ||
3792 | |||
3793 | if (bank == 0) { | ||
3794 | if (adev->gfx.funcs->read_wave_vgprs) | ||
3795 | adev->gfx.funcs->read_wave_vgprs(adev, simd, wave, thread, offset, size>>2, data); | ||
3796 | } else { | ||
3797 | if (adev->gfx.funcs->read_wave_sgprs) | ||
3798 | adev->gfx.funcs->read_wave_sgprs(adev, simd, wave, offset, size>>2, data); | ||
3799 | } | ||
3800 | |||
3801 | amdgpu_gfx_select_se_sh(adev, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); | ||
3802 | mutex_unlock(&adev->grbm_idx_mutex); | ||
3803 | |||
3804 | while (size) { | ||
3805 | uint32_t value; | ||
3806 | |||
3807 | value = data[offset++]; | ||
3808 | r = put_user(value, (uint32_t *)buf); | ||
3809 | if (r) { | ||
3810 | result = r; | ||
3811 | goto err; | ||
3812 | } | ||
3813 | |||
3814 | result += 4; | ||
3815 | buf += 4; | ||
3816 | size -= 4; | ||
3817 | } | ||
3818 | |||
3819 | err: | ||
3820 | kfree(data); | ||
3821 | return result; | ||
3822 | } | ||
3823 | |||
3824 | static const struct file_operations amdgpu_debugfs_regs_fops = { | ||
3825 | .owner = THIS_MODULE, | ||
3826 | .read = amdgpu_debugfs_regs_read, | ||
3827 | .write = amdgpu_debugfs_regs_write, | ||
3828 | .llseek = default_llseek | ||
3829 | }; | ||
3830 | static const struct file_operations amdgpu_debugfs_regs_didt_fops = { | ||
3831 | .owner = THIS_MODULE, | ||
3832 | .read = amdgpu_debugfs_regs_didt_read, | ||
3833 | .write = amdgpu_debugfs_regs_didt_write, | ||
3834 | .llseek = default_llseek | ||
3835 | }; | ||
3836 | static const struct file_operations amdgpu_debugfs_regs_pcie_fops = { | ||
3837 | .owner = THIS_MODULE, | ||
3838 | .read = amdgpu_debugfs_regs_pcie_read, | ||
3839 | .write = amdgpu_debugfs_regs_pcie_write, | ||
3840 | .llseek = default_llseek | ||
3841 | }; | ||
3842 | static const struct file_operations amdgpu_debugfs_regs_smc_fops = { | ||
3843 | .owner = THIS_MODULE, | ||
3844 | .read = amdgpu_debugfs_regs_smc_read, | ||
3845 | .write = amdgpu_debugfs_regs_smc_write, | ||
3846 | .llseek = default_llseek | ||
3847 | }; | ||
3848 | |||
3849 | static const struct file_operations amdgpu_debugfs_gca_config_fops = { | ||
3850 | .owner = THIS_MODULE, | ||
3851 | .read = amdgpu_debugfs_gca_config_read, | ||
3852 | .llseek = default_llseek | ||
3853 | }; | ||
3854 | |||
3855 | static const struct file_operations amdgpu_debugfs_sensors_fops = { | ||
3856 | .owner = THIS_MODULE, | ||
3857 | .read = amdgpu_debugfs_sensor_read, | ||
3858 | .llseek = default_llseek | ||
3859 | }; | ||
3860 | |||
3861 | static const struct file_operations amdgpu_debugfs_wave_fops = { | ||
3862 | .owner = THIS_MODULE, | ||
3863 | .read = amdgpu_debugfs_wave_read, | ||
3864 | .llseek = default_llseek | ||
3865 | }; | ||
3866 | static const struct file_operations amdgpu_debugfs_gpr_fops = { | ||
3867 | .owner = THIS_MODULE, | ||
3868 | .read = amdgpu_debugfs_gpr_read, | ||
3869 | .llseek = default_llseek | ||
3870 | }; | ||
3871 | |||
3872 | static const struct file_operations *debugfs_regs[] = { | ||
3873 | &amdgpu_debugfs_regs_fops, | ||
3874 | &amdgpu_debugfs_regs_didt_fops, | ||
3875 | &amdgpu_debugfs_regs_pcie_fops, | ||
3876 | &amdgpu_debugfs_regs_smc_fops, | ||
3877 | &amdgpu_debugfs_gca_config_fops, | ||
3878 | &amdgpu_debugfs_sensors_fops, | ||
3879 | &amdgpu_debugfs_wave_fops, | ||
3880 | &amdgpu_debugfs_gpr_fops, | ||
3881 | }; | ||
3882 | |||
3883 | static const char *debugfs_regs_names[] = { | ||
3884 | "amdgpu_regs", | ||
3885 | "amdgpu_regs_didt", | ||
3886 | "amdgpu_regs_pcie", | ||
3887 | "amdgpu_regs_smc", | ||
3888 | "amdgpu_gca_config", | ||
3889 | "amdgpu_sensors", | ||
3890 | "amdgpu_wave", | ||
3891 | "amdgpu_gpr", | ||
3892 | }; | ||
3893 | |||
3894 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) | ||
3895 | { | ||
3896 | struct drm_minor *minor = adev->ddev->primary; | ||
3897 | struct dentry *ent, *root = minor->debugfs_root; | ||
3898 | unsigned i, j; | ||
3899 | |||
3900 | for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) { | ||
3901 | ent = debugfs_create_file(debugfs_regs_names[i], | ||
3902 | S_IFREG | S_IRUGO, root, | ||
3903 | adev, debugfs_regs[i]); | ||
3904 | if (IS_ERR(ent)) { | ||
3905 | for (j = 0; j < i; j++) { | ||
3906 | debugfs_remove(adev->debugfs_regs[i]); | ||
3907 | adev->debugfs_regs[i] = NULL; | ||
3908 | } | ||
3909 | return PTR_ERR(ent); | ||
3910 | } | ||
3911 | |||
3912 | if (!i) | ||
3913 | i_size_write(ent->d_inode, adev->rmmio_size); | ||
3914 | adev->debugfs_regs[i] = ent; | ||
3915 | } | ||
3916 | |||
3917 | return 0; | ||
3918 | } | ||
3919 | |||
3920 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) | ||
3921 | { | ||
3922 | unsigned i; | ||
3923 | |||
3924 | for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) { | ||
3925 | if (adev->debugfs_regs[i]) { | ||
3926 | debugfs_remove(adev->debugfs_regs[i]); | ||
3927 | adev->debugfs_regs[i] = NULL; | ||
3928 | } | ||
3929 | } | ||
3930 | } | ||
3931 | |||
3932 | static int amdgpu_debugfs_test_ib(struct seq_file *m, void *data) | ||
3933 | { | ||
3934 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
3935 | struct drm_device *dev = node->minor->dev; | ||
3936 | struct amdgpu_device *adev = dev->dev_private; | ||
3937 | int r = 0, i; | ||
3938 | |||
3939 | /* hold on the scheduler */ | ||
3940 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | ||
3941 | struct amdgpu_ring *ring = adev->rings[i]; | ||
3942 | |||
3943 | if (!ring || !ring->sched.thread) | ||
3944 | continue; | ||
3945 | kthread_park(ring->sched.thread); | ||
3946 | } | ||
3947 | |||
3948 | seq_printf(m, "run ib test:\n"); | ||
3949 | r = amdgpu_ib_ring_tests(adev); | ||
3950 | if (r) | ||
3951 | seq_printf(m, "ib ring tests failed (%d).\n", r); | ||
3952 | else | ||
3953 | seq_printf(m, "ib ring tests passed.\n"); | ||
3954 | |||
3955 | /* go on the scheduler */ | ||
3956 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | ||
3957 | struct amdgpu_ring *ring = adev->rings[i]; | ||
3958 | |||
3959 | if (!ring || !ring->sched.thread) | ||
3960 | continue; | ||
3961 | kthread_unpark(ring->sched.thread); | ||
3962 | } | ||
3963 | |||
3964 | return 0; | ||
3965 | } | ||
3966 | |||
3967 | static const struct drm_info_list amdgpu_debugfs_test_ib_ring_list[] = { | ||
3968 | {"amdgpu_test_ib", &amdgpu_debugfs_test_ib} | ||
3969 | }; | ||
3970 | |||
3971 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev) | ||
3972 | { | ||
3973 | return amdgpu_debugfs_add_files(adev, | ||
3974 | amdgpu_debugfs_test_ib_ring_list, 1); | ||
3975 | } | ||
3976 | |||
3977 | int amdgpu_debugfs_init(struct drm_minor *minor) | ||
3978 | { | ||
3979 | return 0; | ||
3980 | } | ||
3981 | |||
3982 | static int amdgpu_debugfs_get_vbios_dump(struct seq_file *m, void *data) | ||
3983 | { | ||
3984 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
3985 | struct drm_device *dev = node->minor->dev; | ||
3986 | struct amdgpu_device *adev = dev->dev_private; | ||
3987 | |||
3988 | seq_write(m, adev->bios, adev->bios_size); | ||
3989 | return 0; | ||
3990 | } | ||
3991 | |||
3992 | static const struct drm_info_list amdgpu_vbios_dump_list[] = { | ||
3993 | {"amdgpu_vbios", | ||
3994 | amdgpu_debugfs_get_vbios_dump, | ||
3995 | 0, NULL}, | ||
3996 | }; | ||
3997 | |||
3998 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) | ||
3999 | { | ||
4000 | return amdgpu_debugfs_add_files(adev, | ||
4001 | amdgpu_vbios_dump_list, 1); | ||
4002 | } | ||
4003 | #else | ||
4004 | static int amdgpu_debugfs_test_ib_ring_init(struct amdgpu_device *adev) | ||
4005 | { | ||
4006 | return 0; | ||
4007 | } | ||
4008 | static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) | ||
4009 | { | ||
4010 | return 0; | ||
4011 | } | ||
4012 | static int amdgpu_debugfs_vbios_dump_init(struct amdgpu_device *adev) | ||
4013 | { | ||
4014 | return 0; | ||
4015 | } | ||
4016 | static void amdgpu_debugfs_regs_cleanup(struct amdgpu_device *adev) { } | ||
4017 | #endif | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 31383e004947..50afcf65181a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | |||
@@ -90,7 +90,7 @@ int amdgpu_disp_priority = 0; | |||
90 | int amdgpu_hw_i2c = 0; | 90 | int amdgpu_hw_i2c = 0; |
91 | int amdgpu_pcie_gen2 = -1; | 91 | int amdgpu_pcie_gen2 = -1; |
92 | int amdgpu_msi = -1; | 92 | int amdgpu_msi = -1; |
93 | int amdgpu_lockup_timeout = 0; | 93 | int amdgpu_lockup_timeout = 10000; |
94 | int amdgpu_dpm = -1; | 94 | int amdgpu_dpm = -1; |
95 | int amdgpu_fw_load_type = -1; | 95 | int amdgpu_fw_load_type = -1; |
96 | int amdgpu_aspm = -1; | 96 | int amdgpu_aspm = -1; |
@@ -128,6 +128,7 @@ int amdgpu_param_buf_per_se = 0; | |||
128 | int amdgpu_job_hang_limit = 0; | 128 | int amdgpu_job_hang_limit = 0; |
129 | int amdgpu_lbpw = -1; | 129 | int amdgpu_lbpw = -1; |
130 | int amdgpu_compute_multipipe = -1; | 130 | int amdgpu_compute_multipipe = -1; |
131 | int amdgpu_gpu_recovery = -1; /* auto */ | ||
131 | 132 | ||
132 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); | 133 | MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); |
133 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); | 134 | module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); |
@@ -165,7 +166,7 @@ module_param_named(pcie_gen2, amdgpu_pcie_gen2, int, 0444); | |||
165 | MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)"); | 166 | MODULE_PARM_DESC(msi, "MSI support (1 = enable, 0 = disable, -1 = auto)"); |
166 | module_param_named(msi, amdgpu_msi, int, 0444); | 167 | module_param_named(msi, amdgpu_msi, int, 0444); |
167 | 168 | ||
168 | MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms (default 0 = disable)"); | 169 | MODULE_PARM_DESC(lockup_timeout, "GPU lockup timeout in ms > 0 (default 10000)"); |
169 | module_param_named(lockup_timeout, amdgpu_lockup_timeout, int, 0444); | 170 | module_param_named(lockup_timeout, amdgpu_lockup_timeout, int, 0444); |
170 | 171 | ||
171 | MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)"); | 172 | MODULE_PARM_DESC(dpm, "DPM support (1 = enable, 0 = disable, -1 = auto)"); |
@@ -280,6 +281,9 @@ module_param_named(lbpw, amdgpu_lbpw, int, 0444); | |||
280 | MODULE_PARM_DESC(compute_multipipe, "Force compute queues to be spread across pipes (1 = enable, 0 = disable, -1 = auto)"); | 281 | MODULE_PARM_DESC(compute_multipipe, "Force compute queues to be spread across pipes (1 = enable, 0 = disable, -1 = auto)"); |
281 | module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444); | 282 | module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444); |
282 | 283 | ||
284 | MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto"); | ||
285 | module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444); | ||
286 | |||
283 | #ifdef CONFIG_DRM_AMDGPU_SI | 287 | #ifdef CONFIG_DRM_AMDGPU_SI |
284 | 288 | ||
285 | #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE) | 289 | #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE) |
@@ -645,7 +649,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev) | |||
645 | * unfortunately we can't detect certain | 649 | * unfortunately we can't detect certain |
646 | * hypervisors so just do this all the time. | 650 | * hypervisors so just do this all the time. |
647 | */ | 651 | */ |
648 | amdgpu_suspend(adev); | 652 | amdgpu_device_ip_suspend(adev); |
649 | } | 653 | } |
650 | 654 | ||
651 | static int amdgpu_pmops_suspend(struct device *dev) | 655 | static int amdgpu_pmops_suspend(struct device *dev) |
@@ -850,9 +854,6 @@ static struct drm_driver kms_driver = { | |||
850 | .disable_vblank = amdgpu_disable_vblank_kms, | 854 | .disable_vblank = amdgpu_disable_vblank_kms, |
851 | .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, | 855 | .get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos, |
852 | .get_scanout_position = amdgpu_get_crtc_scanout_position, | 856 | .get_scanout_position = amdgpu_get_crtc_scanout_position, |
853 | #if defined(CONFIG_DEBUG_FS) | ||
854 | .debugfs_init = amdgpu_debugfs_init, | ||
855 | #endif | ||
856 | .irq_preinstall = amdgpu_irq_preinstall, | 857 | .irq_preinstall = amdgpu_irq_preinstall, |
857 | .irq_postinstall = amdgpu_irq_postinstall, | 858 | .irq_postinstall = amdgpu_irq_postinstall, |
858 | .irq_uninstall = amdgpu_irq_uninstall, | 859 | .irq_uninstall = amdgpu_irq_uninstall, |
@@ -912,10 +913,6 @@ static int __init amdgpu_init(void) | |||
912 | if (r) | 913 | if (r) |
913 | goto error_fence; | 914 | goto error_fence; |
914 | 915 | ||
915 | r = amd_sched_fence_slab_init(); | ||
916 | if (r) | ||
917 | goto error_sched; | ||
918 | |||
919 | if (vgacon_text_force()) { | 916 | if (vgacon_text_force()) { |
920 | DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n"); | 917 | DRM_ERROR("VGACON disables amdgpu kernel modesetting.\n"); |
921 | return -EINVAL; | 918 | return -EINVAL; |
@@ -928,9 +925,6 @@ static int __init amdgpu_init(void) | |||
928 | /* let modprobe override vga console setting */ | 925 | /* let modprobe override vga console setting */ |
929 | return pci_register_driver(pdriver); | 926 | return pci_register_driver(pdriver); |
930 | 927 | ||
931 | error_sched: | ||
932 | amdgpu_fence_slab_fini(); | ||
933 | |||
934 | error_fence: | 928 | error_fence: |
935 | amdgpu_sync_fini(); | 929 | amdgpu_sync_fini(); |
936 | 930 | ||
@@ -944,7 +938,6 @@ static void __exit amdgpu_exit(void) | |||
944 | pci_unregister_driver(pdriver); | 938 | pci_unregister_driver(pdriver); |
945 | amdgpu_unregister_atpx_handler(); | 939 | amdgpu_unregister_atpx_handler(); |
946 | amdgpu_sync_fini(); | 940 | amdgpu_sync_fini(); |
947 | amd_sched_fence_slab_fini(); | ||
948 | amdgpu_fence_slab_fini(); | 941 | amdgpu_fence_slab_fini(); |
949 | } | 942 | } |
950 | 943 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index 604ac03a42e4..008e1984b7e3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
@@ -187,7 +187,7 @@ int amdgpu_fence_emit_polling(struct amdgpu_ring *ring, uint32_t *s) | |||
187 | 187 | ||
188 | seq = ++ring->fence_drv.sync_seq; | 188 | seq = ++ring->fence_drv.sync_seq; |
189 | amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, | 189 | amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr, |
190 | seq, AMDGPU_FENCE_FLAG_INT); | 190 | seq, 0); |
191 | 191 | ||
192 | *s = seq; | 192 | *s = seq; |
193 | 193 | ||
@@ -410,7 +410,6 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring, | |||
410 | int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, | 410 | int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, |
411 | unsigned num_hw_submission) | 411 | unsigned num_hw_submission) |
412 | { | 412 | { |
413 | long timeout; | ||
414 | int r; | 413 | int r; |
415 | 414 | ||
416 | /* Check that num_hw_submission is a power of two */ | 415 | /* Check that num_hw_submission is a power of two */ |
@@ -434,20 +433,9 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, | |||
434 | 433 | ||
435 | /* No need to setup the GPU scheduler for KIQ ring */ | 434 | /* No need to setup the GPU scheduler for KIQ ring */ |
436 | if (ring->funcs->type != AMDGPU_RING_TYPE_KIQ) { | 435 | if (ring->funcs->type != AMDGPU_RING_TYPE_KIQ) { |
437 | timeout = msecs_to_jiffies(amdgpu_lockup_timeout); | 436 | r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, |
438 | if (timeout == 0) { | ||
439 | /* | ||
440 | * FIXME: | ||
441 | * Delayed workqueue cannot use it directly, | ||
442 | * so the scheduler will not use delayed workqueue if | ||
443 | * MAX_SCHEDULE_TIMEOUT is set. | ||
444 | * Currently keep it simple and silly. | ||
445 | */ | ||
446 | timeout = MAX_SCHEDULE_TIMEOUT; | ||
447 | } | ||
448 | r = amd_sched_init(&ring->sched, &amdgpu_sched_ops, | ||
449 | num_hw_submission, amdgpu_job_hang_limit, | 437 | num_hw_submission, amdgpu_job_hang_limit, |
450 | timeout, ring->name); | 438 | msecs_to_jiffies(amdgpu_lockup_timeout), ring->name); |
451 | if (r) { | 439 | if (r) { |
452 | DRM_ERROR("Failed to create scheduler on ring %s.\n", | 440 | DRM_ERROR("Failed to create scheduler on ring %s.\n", |
453 | ring->name); | 441 | ring->name); |
@@ -503,7 +491,7 @@ void amdgpu_fence_driver_fini(struct amdgpu_device *adev) | |||
503 | } | 491 | } |
504 | amdgpu_irq_put(adev, ring->fence_drv.irq_src, | 492 | amdgpu_irq_put(adev, ring->fence_drv.irq_src, |
505 | ring->fence_drv.irq_type); | 493 | ring->fence_drv.irq_type); |
506 | amd_sched_fini(&ring->sched); | 494 | drm_sched_fini(&ring->sched); |
507 | del_timer_sync(&ring->fence_drv.fallback_timer); | 495 | del_timer_sync(&ring->fence_drv.fallback_timer); |
508 | for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) | 496 | for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j) |
509 | dma_fence_put(ring->fence_drv.fences[j]); | 497 | dma_fence_put(ring->fence_drv.fences[j]); |
@@ -705,7 +693,7 @@ static int amdgpu_debugfs_gpu_recover(struct seq_file *m, void *data) | |||
705 | struct amdgpu_device *adev = dev->dev_private; | 693 | struct amdgpu_device *adev = dev->dev_private; |
706 | 694 | ||
707 | seq_printf(m, "gpu recover\n"); | 695 | seq_printf(m, "gpu recover\n"); |
708 | amdgpu_gpu_recover(adev, NULL); | 696 | amdgpu_device_gpu_recover(adev, NULL, true); |
709 | 697 | ||
710 | return 0; | 698 | return 0; |
711 | } | 699 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c index 1f51897acc5b..0a4f34afaaaa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | |||
@@ -57,6 +57,51 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * amdgpu_dummy_page_init - init dummy page used by the driver | ||
61 | * | ||
62 | * @adev: amdgpu_device pointer | ||
63 | * | ||
64 | * Allocate the dummy page used by the driver (all asics). | ||
65 | * This dummy page is used by the driver as a filler for gart entries | ||
66 | * when pages are taken out of the GART | ||
67 | * Returns 0 on sucess, -ENOMEM on failure. | ||
68 | */ | ||
69 | static int amdgpu_gart_dummy_page_init(struct amdgpu_device *adev) | ||
70 | { | ||
71 | if (adev->dummy_page.page) | ||
72 | return 0; | ||
73 | adev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO); | ||
74 | if (adev->dummy_page.page == NULL) | ||
75 | return -ENOMEM; | ||
76 | adev->dummy_page.addr = pci_map_page(adev->pdev, adev->dummy_page.page, | ||
77 | 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | ||
78 | if (pci_dma_mapping_error(adev->pdev, adev->dummy_page.addr)) { | ||
79 | dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n"); | ||
80 | __free_page(adev->dummy_page.page); | ||
81 | adev->dummy_page.page = NULL; | ||
82 | return -ENOMEM; | ||
83 | } | ||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * amdgpu_dummy_page_fini - free dummy page used by the driver | ||
89 | * | ||
90 | * @adev: amdgpu_device pointer | ||
91 | * | ||
92 | * Frees the dummy page used by the driver (all asics). | ||
93 | */ | ||
94 | static void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev) | ||
95 | { | ||
96 | if (adev->dummy_page.page == NULL) | ||
97 | return; | ||
98 | pci_unmap_page(adev->pdev, adev->dummy_page.addr, | ||
99 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | ||
100 | __free_page(adev->dummy_page.page); | ||
101 | adev->dummy_page.page = NULL; | ||
102 | } | ||
103 | |||
104 | /** | ||
60 | * amdgpu_gart_table_vram_alloc - allocate vram for gart page table | 105 | * amdgpu_gart_table_vram_alloc - allocate vram for gart page table |
61 | * | 106 | * |
62 | * @adev: amdgpu_device pointer | 107 | * @adev: amdgpu_device pointer |
@@ -308,7 +353,7 @@ int amdgpu_gart_init(struct amdgpu_device *adev) | |||
308 | DRM_ERROR("Page size is smaller than GPU page size!\n"); | 353 | DRM_ERROR("Page size is smaller than GPU page size!\n"); |
309 | return -EINVAL; | 354 | return -EINVAL; |
310 | } | 355 | } |
311 | r = amdgpu_dummy_page_init(adev); | 356 | r = amdgpu_gart_dummy_page_init(adev); |
312 | if (r) | 357 | if (r) |
313 | return r; | 358 | return r; |
314 | /* Compute table size */ | 359 | /* Compute table size */ |
@@ -340,5 +385,5 @@ void amdgpu_gart_fini(struct amdgpu_device *adev) | |||
340 | vfree(adev->gart.pages); | 385 | vfree(adev->gart.pages); |
341 | adev->gart.pages = NULL; | 386 | adev->gart.pages = NULL; |
342 | #endif | 387 | #endif |
343 | amdgpu_dummy_page_fini(adev); | 388 | amdgpu_gart_dummy_page_fini(adev); |
344 | } | 389 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index eb75eb44efc6..10805edcf964 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -851,7 +851,7 @@ static const struct drm_info_list amdgpu_debugfs_gem_list[] = { | |||
851 | }; | 851 | }; |
852 | #endif | 852 | #endif |
853 | 853 | ||
854 | int amdgpu_gem_debugfs_init(struct amdgpu_device *adev) | 854 | int amdgpu_debugfs_gem_init(struct amdgpu_device *adev) |
855 | { | 855 | { |
856 | #if defined(CONFIG_DEBUG_FS) | 856 | #if defined(CONFIG_DEBUG_FS) |
857 | return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_gem_list, 1); | 857 | return amdgpu_debugfs_add_files(adev, amdgpu_debugfs_gem_list, 1); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c index ef043361009f..bb40d2529a30 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | |||
@@ -203,7 +203,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, | |||
203 | 203 | ||
204 | spin_lock_init(&kiq->ring_lock); | 204 | spin_lock_init(&kiq->ring_lock); |
205 | 205 | ||
206 | r = amdgpu_wb_get(adev, &adev->virt.reg_val_offs); | 206 | r = amdgpu_device_wb_get(adev, &adev->virt.reg_val_offs); |
207 | if (r) | 207 | if (r) |
208 | return r; | 208 | return r; |
209 | 209 | ||
@@ -229,7 +229,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, | |||
229 | void amdgpu_gfx_kiq_free_ring(struct amdgpu_ring *ring, | 229 | void amdgpu_gfx_kiq_free_ring(struct amdgpu_ring *ring, |
230 | struct amdgpu_irq_src *irq) | 230 | struct amdgpu_irq_src *irq) |
231 | { | 231 | { |
232 | amdgpu_wb_free(ring->adev, ring->adev->virt.reg_val_offs); | 232 | amdgpu_device_wb_free(ring->adev, ring->adev->virt.reg_val_offs); |
233 | amdgpu_ring_fini(ring); | 233 | amdgpu_ring_fini(ring); |
234 | } | 234 | } |
235 | 235 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c index f5f27e4f0f7f..06373d44b3da 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | |||
@@ -92,15 +92,15 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size, | |||
92 | } | 92 | } |
93 | return 0; | 93 | return 0; |
94 | } else { | 94 | } else { |
95 | r = amdgpu_wb_get(adev, &adev->irq.ih.wptr_offs); | 95 | r = amdgpu_device_wb_get(adev, &adev->irq.ih.wptr_offs); |
96 | if (r) { | 96 | if (r) { |
97 | dev_err(adev->dev, "(%d) ih wptr_offs wb alloc failed\n", r); | 97 | dev_err(adev->dev, "(%d) ih wptr_offs wb alloc failed\n", r); |
98 | return r; | 98 | return r; |
99 | } | 99 | } |
100 | 100 | ||
101 | r = amdgpu_wb_get(adev, &adev->irq.ih.rptr_offs); | 101 | r = amdgpu_device_wb_get(adev, &adev->irq.ih.rptr_offs); |
102 | if (r) { | 102 | if (r) { |
103 | amdgpu_wb_free(adev, adev->irq.ih.wptr_offs); | 103 | amdgpu_device_wb_free(adev, adev->irq.ih.wptr_offs); |
104 | dev_err(adev->dev, "(%d) ih rptr_offs wb alloc failed\n", r); | 104 | dev_err(adev->dev, "(%d) ih rptr_offs wb alloc failed\n", r); |
105 | return r; | 105 | return r; |
106 | } | 106 | } |
@@ -133,8 +133,8 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev) | |||
133 | amdgpu_bo_free_kernel(&adev->irq.ih.ring_obj, | 133 | amdgpu_bo_free_kernel(&adev->irq.ih.ring_obj, |
134 | &adev->irq.ih.gpu_addr, | 134 | &adev->irq.ih.gpu_addr, |
135 | (void **)&adev->irq.ih.ring); | 135 | (void **)&adev->irq.ih.ring); |
136 | amdgpu_wb_free(adev, adev->irq.ih.wptr_offs); | 136 | amdgpu_device_wb_free(adev, adev->irq.ih.wptr_offs); |
137 | amdgpu_wb_free(adev, adev->irq.ih.rptr_offs); | 137 | amdgpu_device_wb_free(adev, adev->irq.ih.rptr_offs); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c index c340774082ea..56bcd59c3399 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | |||
@@ -88,7 +88,7 @@ static void amdgpu_irq_reset_work_func(struct work_struct *work) | |||
88 | reset_work); | 88 | reset_work); |
89 | 89 | ||
90 | if (!amdgpu_sriov_vf(adev)) | 90 | if (!amdgpu_sriov_vf(adev)) |
91 | amdgpu_gpu_recover(adev, NULL); | 91 | amdgpu_device_gpu_recover(adev, NULL, false); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* Disable *all* interrupts */ | 94 | /* Disable *all* interrupts */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c index bdc210ac74f8..56d9ee5013a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "amdgpu.h" | 28 | #include "amdgpu.h" |
29 | #include "amdgpu_trace.h" | 29 | #include "amdgpu_trace.h" |
30 | 30 | ||
31 | static void amdgpu_job_timedout(struct amd_sched_job *s_job) | 31 | static void amdgpu_job_timedout(struct drm_sched_job *s_job) |
32 | { | 32 | { |
33 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); | 33 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); |
34 | 34 | ||
@@ -37,7 +37,7 @@ static void amdgpu_job_timedout(struct amd_sched_job *s_job) | |||
37 | atomic_read(&job->ring->fence_drv.last_seq), | 37 | atomic_read(&job->ring->fence_drv.last_seq), |
38 | job->ring->fence_drv.sync_seq); | 38 | job->ring->fence_drv.sync_seq); |
39 | 39 | ||
40 | amdgpu_gpu_recover(job->adev, job); | 40 | amdgpu_device_gpu_recover(job->adev, job, false); |
41 | } | 41 | } |
42 | 42 | ||
43 | int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, | 43 | int amdgpu_job_alloc(struct amdgpu_device *adev, unsigned num_ibs, |
@@ -96,7 +96,7 @@ void amdgpu_job_free_resources(struct amdgpu_job *job) | |||
96 | amdgpu_ib_free(job->adev, &job->ibs[i], f); | 96 | amdgpu_ib_free(job->adev, &job->ibs[i], f); |
97 | } | 97 | } |
98 | 98 | ||
99 | static void amdgpu_job_free_cb(struct amd_sched_job *s_job) | 99 | static void amdgpu_job_free_cb(struct drm_sched_job *s_job) |
100 | { | 100 | { |
101 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); | 101 | struct amdgpu_job *job = container_of(s_job, struct amdgpu_job, base); |
102 | 102 | ||
@@ -118,7 +118,7 @@ void amdgpu_job_free(struct amdgpu_job *job) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, | 120 | int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, |
121 | struct amd_sched_entity *entity, void *owner, | 121 | struct drm_sched_entity *entity, void *owner, |
122 | struct dma_fence **f) | 122 | struct dma_fence **f) |
123 | { | 123 | { |
124 | int r; | 124 | int r; |
@@ -127,7 +127,7 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, | |||
127 | if (!f) | 127 | if (!f) |
128 | return -EINVAL; | 128 | return -EINVAL; |
129 | 129 | ||
130 | r = amd_sched_job_init(&job->base, &ring->sched, entity, owner); | 130 | r = drm_sched_job_init(&job->base, &ring->sched, entity, owner); |
131 | if (r) | 131 | if (r) |
132 | return r; | 132 | return r; |
133 | 133 | ||
@@ -136,13 +136,13 @@ int amdgpu_job_submit(struct amdgpu_job *job, struct amdgpu_ring *ring, | |||
136 | *f = dma_fence_get(&job->base.s_fence->finished); | 136 | *f = dma_fence_get(&job->base.s_fence->finished); |
137 | amdgpu_job_free_resources(job); | 137 | amdgpu_job_free_resources(job); |
138 | amdgpu_ring_priority_get(job->ring, job->base.s_priority); | 138 | amdgpu_ring_priority_get(job->ring, job->base.s_priority); |
139 | amd_sched_entity_push_job(&job->base, entity); | 139 | drm_sched_entity_push_job(&job->base, entity); |
140 | 140 | ||
141 | return 0; | 141 | return 0; |
142 | } | 142 | } |
143 | 143 | ||
144 | static struct dma_fence *amdgpu_job_dependency(struct amd_sched_job *sched_job, | 144 | static struct dma_fence *amdgpu_job_dependency(struct drm_sched_job *sched_job, |
145 | struct amd_sched_entity *s_entity) | 145 | struct drm_sched_entity *s_entity) |
146 | { | 146 | { |
147 | struct amdgpu_job *job = to_amdgpu_job(sched_job); | 147 | struct amdgpu_job *job = to_amdgpu_job(sched_job); |
148 | struct amdgpu_vm *vm = job->vm; | 148 | struct amdgpu_vm *vm = job->vm; |
@@ -151,7 +151,7 @@ static struct dma_fence *amdgpu_job_dependency(struct amd_sched_job *sched_job, | |||
151 | struct dma_fence *fence = amdgpu_sync_get_fence(&job->sync, &explicit); | 151 | struct dma_fence *fence = amdgpu_sync_get_fence(&job->sync, &explicit); |
152 | 152 | ||
153 | if (fence && explicit) { | 153 | if (fence && explicit) { |
154 | if (amd_sched_dependency_optimized(fence, s_entity)) { | 154 | if (drm_sched_dependency_optimized(fence, s_entity)) { |
155 | r = amdgpu_sync_fence(job->adev, &job->sched_sync, fence, false); | 155 | r = amdgpu_sync_fence(job->adev, &job->sched_sync, fence, false); |
156 | if (r) | 156 | if (r) |
157 | DRM_ERROR("Error adding fence to sync (%d)\n", r); | 157 | DRM_ERROR("Error adding fence to sync (%d)\n", r); |
@@ -173,7 +173,7 @@ static struct dma_fence *amdgpu_job_dependency(struct amd_sched_job *sched_job, | |||
173 | return fence; | 173 | return fence; |
174 | } | 174 | } |
175 | 175 | ||
176 | static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job) | 176 | static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) |
177 | { | 177 | { |
178 | struct dma_fence *fence = NULL, *finished; | 178 | struct dma_fence *fence = NULL, *finished; |
179 | struct amdgpu_device *adev; | 179 | struct amdgpu_device *adev; |
@@ -211,7 +211,7 @@ static struct dma_fence *amdgpu_job_run(struct amd_sched_job *sched_job) | |||
211 | return fence; | 211 | return fence; |
212 | } | 212 | } |
213 | 213 | ||
214 | const struct amd_sched_backend_ops amdgpu_sched_ops = { | 214 | const struct drm_sched_backend_ops amdgpu_sched_ops = { |
215 | .dependency = amdgpu_job_dependency, | 215 | .dependency = amdgpu_job_dependency, |
216 | .run_job = amdgpu_job_run, | 216 | .run_job = amdgpu_job_run, |
217 | .timedout_job = amdgpu_job_timedout, | 217 | .timedout_job = amdgpu_job_timedout, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index dc0a8be98043..5c4c3e0d527b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | |||
@@ -37,6 +37,18 @@ | |||
37 | #include "amdgpu.h" | 37 | #include "amdgpu.h" |
38 | #include "amdgpu_trace.h" | 38 | #include "amdgpu_trace.h" |
39 | 39 | ||
40 | static bool amdgpu_need_backup(struct amdgpu_device *adev) | ||
41 | { | ||
42 | if (adev->flags & AMD_IS_APU) | ||
43 | return false; | ||
44 | |||
45 | if (amdgpu_gpu_recovery == 0 || | ||
46 | (amdgpu_gpu_recovery == -1 && !amdgpu_sriov_vf(adev))) | ||
47 | return false; | ||
48 | |||
49 | return true; | ||
50 | } | ||
51 | |||
40 | static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) | 52 | static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) |
41 | { | 53 | { |
42 | struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); | 54 | struct amdgpu_device *adev = amdgpu_ttm_adev(tbo->bdev); |
@@ -327,7 +339,12 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev, | |||
327 | uint64_t init_value, | 339 | uint64_t init_value, |
328 | struct amdgpu_bo **bo_ptr) | 340 | struct amdgpu_bo **bo_ptr) |
329 | { | 341 | { |
330 | struct ttm_operation_ctx ctx = { !kernel, false }; | 342 | struct ttm_operation_ctx ctx = { |
343 | .interruptible = !kernel, | ||
344 | .no_wait_gpu = false, | ||
345 | .allow_reserved_eviction = true, | ||
346 | .resv = resv | ||
347 | }; | ||
331 | struct amdgpu_bo *bo; | 348 | struct amdgpu_bo *bo; |
332 | enum ttm_bo_type type; | 349 | enum ttm_bo_type type; |
333 | unsigned long page_align; | 350 | unsigned long page_align; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c index 83205b93e62d..01a996c6b802 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | |||
@@ -1278,16 +1278,16 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable) | |||
1278 | /* XXX select vce level based on ring/task */ | 1278 | /* XXX select vce level based on ring/task */ |
1279 | adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL; | 1279 | adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL; |
1280 | mutex_unlock(&adev->pm.mutex); | 1280 | mutex_unlock(&adev->pm.mutex); |
1281 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 1281 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
1282 | AMD_CG_STATE_UNGATE); | 1282 | AMD_CG_STATE_UNGATE); |
1283 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 1283 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
1284 | AMD_PG_STATE_UNGATE); | 1284 | AMD_PG_STATE_UNGATE); |
1285 | amdgpu_pm_compute_clocks(adev); | 1285 | amdgpu_pm_compute_clocks(adev); |
1286 | } else { | 1286 | } else { |
1287 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 1287 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
1288 | AMD_PG_STATE_GATE); | 1288 | AMD_PG_STATE_GATE); |
1289 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 1289 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
1290 | AMD_CG_STATE_GATE); | 1290 | AMD_CG_STATE_GATE); |
1291 | mutex_lock(&adev->pm.mutex); | 1291 | mutex_lock(&adev->pm.mutex); |
1292 | adev->pm.dpm.vce_active = false; | 1292 | adev->pm.dpm.vce_active = false; |
1293 | mutex_unlock(&adev->pm.mutex); | 1293 | mutex_unlock(&adev->pm.mutex); |
@@ -1584,7 +1584,7 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data) | |||
1584 | struct drm_device *ddev = adev->ddev; | 1584 | struct drm_device *ddev = adev->ddev; |
1585 | u32 flags = 0; | 1585 | u32 flags = 0; |
1586 | 1586 | ||
1587 | amdgpu_get_clockgating_state(adev, &flags); | 1587 | amdgpu_device_ip_get_clockgating_state(adev, &flags); |
1588 | seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags); | 1588 | seq_printf(m, "Clock Gating Flags Mask: 0x%x\n", flags); |
1589 | amdgpu_parse_cg_state(m, flags); | 1589 | amdgpu_parse_cg_state(m, flags); |
1590 | seq_printf(m, "\n"); | 1590 | seq_printf(m, "\n"); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c index a98fbbb4739f..13044e66dcaf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | |||
@@ -164,7 +164,7 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring) | |||
164 | * Release a request for executing at @priority | 164 | * Release a request for executing at @priority |
165 | */ | 165 | */ |
166 | void amdgpu_ring_priority_put(struct amdgpu_ring *ring, | 166 | void amdgpu_ring_priority_put(struct amdgpu_ring *ring, |
167 | enum amd_sched_priority priority) | 167 | enum drm_sched_priority priority) |
168 | { | 168 | { |
169 | int i; | 169 | int i; |
170 | 170 | ||
@@ -175,7 +175,7 @@ void amdgpu_ring_priority_put(struct amdgpu_ring *ring, | |||
175 | return; | 175 | return; |
176 | 176 | ||
177 | /* no need to restore if the job is already at the lowest priority */ | 177 | /* no need to restore if the job is already at the lowest priority */ |
178 | if (priority == AMD_SCHED_PRIORITY_NORMAL) | 178 | if (priority == DRM_SCHED_PRIORITY_NORMAL) |
179 | return; | 179 | return; |
180 | 180 | ||
181 | mutex_lock(&ring->priority_mutex); | 181 | mutex_lock(&ring->priority_mutex); |
@@ -184,8 +184,8 @@ void amdgpu_ring_priority_put(struct amdgpu_ring *ring, | |||
184 | goto out_unlock; | 184 | goto out_unlock; |
185 | 185 | ||
186 | /* decay priority to the next level with a job available */ | 186 | /* decay priority to the next level with a job available */ |
187 | for (i = priority; i >= AMD_SCHED_PRIORITY_MIN; i--) { | 187 | for (i = priority; i >= DRM_SCHED_PRIORITY_MIN; i--) { |
188 | if (i == AMD_SCHED_PRIORITY_NORMAL | 188 | if (i == DRM_SCHED_PRIORITY_NORMAL |
189 | || atomic_read(&ring->num_jobs[i])) { | 189 | || atomic_read(&ring->num_jobs[i])) { |
190 | ring->priority = i; | 190 | ring->priority = i; |
191 | ring->funcs->set_priority(ring, i); | 191 | ring->funcs->set_priority(ring, i); |
@@ -206,7 +206,7 @@ out_unlock: | |||
206 | * Request a ring's priority to be raised to @priority (refcounted). | 206 | * Request a ring's priority to be raised to @priority (refcounted). |
207 | */ | 207 | */ |
208 | void amdgpu_ring_priority_get(struct amdgpu_ring *ring, | 208 | void amdgpu_ring_priority_get(struct amdgpu_ring *ring, |
209 | enum amd_sched_priority priority) | 209 | enum drm_sched_priority priority) |
210 | { | 210 | { |
211 | if (!ring->funcs->set_priority) | 211 | if (!ring->funcs->set_priority) |
212 | return; | 212 | return; |
@@ -263,25 +263,25 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
263 | return r; | 263 | return r; |
264 | } | 264 | } |
265 | 265 | ||
266 | r = amdgpu_wb_get(adev, &ring->rptr_offs); | 266 | r = amdgpu_device_wb_get(adev, &ring->rptr_offs); |
267 | if (r) { | 267 | if (r) { |
268 | dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); | 268 | dev_err(adev->dev, "(%d) ring rptr_offs wb alloc failed\n", r); |
269 | return r; | 269 | return r; |
270 | } | 270 | } |
271 | 271 | ||
272 | r = amdgpu_wb_get(adev, &ring->wptr_offs); | 272 | r = amdgpu_device_wb_get(adev, &ring->wptr_offs); |
273 | if (r) { | 273 | if (r) { |
274 | dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r); | 274 | dev_err(adev->dev, "(%d) ring wptr_offs wb alloc failed\n", r); |
275 | return r; | 275 | return r; |
276 | } | 276 | } |
277 | 277 | ||
278 | r = amdgpu_wb_get(adev, &ring->fence_offs); | 278 | r = amdgpu_device_wb_get(adev, &ring->fence_offs); |
279 | if (r) { | 279 | if (r) { |
280 | dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); | 280 | dev_err(adev->dev, "(%d) ring fence_offs wb alloc failed\n", r); |
281 | return r; | 281 | return r; |
282 | } | 282 | } |
283 | 283 | ||
284 | r = amdgpu_wb_get(adev, &ring->cond_exe_offs); | 284 | r = amdgpu_device_wb_get(adev, &ring->cond_exe_offs); |
285 | if (r) { | 285 | if (r) { |
286 | dev_err(adev->dev, "(%d) ring cond_exec_polling wb alloc failed\n", r); | 286 | dev_err(adev->dev, "(%d) ring cond_exec_polling wb alloc failed\n", r); |
287 | return r; | 287 | return r; |
@@ -317,12 +317,12 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
317 | } | 317 | } |
318 | 318 | ||
319 | ring->max_dw = max_dw; | 319 | ring->max_dw = max_dw; |
320 | ring->priority = AMD_SCHED_PRIORITY_NORMAL; | 320 | ring->priority = DRM_SCHED_PRIORITY_NORMAL; |
321 | mutex_init(&ring->priority_mutex); | 321 | mutex_init(&ring->priority_mutex); |
322 | INIT_LIST_HEAD(&ring->lru_list); | 322 | INIT_LIST_HEAD(&ring->lru_list); |
323 | amdgpu_ring_lru_touch(adev, ring); | 323 | amdgpu_ring_lru_touch(adev, ring); |
324 | 324 | ||
325 | for (i = 0; i < AMD_SCHED_PRIORITY_MAX; ++i) | 325 | for (i = 0; i < DRM_SCHED_PRIORITY_MAX; ++i) |
326 | atomic_set(&ring->num_jobs[i], 0); | 326 | atomic_set(&ring->num_jobs[i], 0); |
327 | 327 | ||
328 | if (amdgpu_debugfs_ring_init(adev, ring)) { | 328 | if (amdgpu_debugfs_ring_init(adev, ring)) { |
@@ -348,11 +348,11 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring) | |||
348 | if (!(ring->adev) || !(ring->adev->rings[ring->idx])) | 348 | if (!(ring->adev) || !(ring->adev->rings[ring->idx])) |
349 | return; | 349 | return; |
350 | 350 | ||
351 | amdgpu_wb_free(ring->adev, ring->rptr_offs); | 351 | amdgpu_device_wb_free(ring->adev, ring->rptr_offs); |
352 | amdgpu_wb_free(ring->adev, ring->wptr_offs); | 352 | amdgpu_device_wb_free(ring->adev, ring->wptr_offs); |
353 | 353 | ||
354 | amdgpu_wb_free(ring->adev, ring->cond_exe_offs); | 354 | amdgpu_device_wb_free(ring->adev, ring->cond_exe_offs); |
355 | amdgpu_wb_free(ring->adev, ring->fence_offs); | 355 | amdgpu_device_wb_free(ring->adev, ring->fence_offs); |
356 | 356 | ||
357 | amdgpu_bo_free_kernel(&ring->ring_obj, | 357 | amdgpu_bo_free_kernel(&ring->ring_obj, |
358 | &ring->gpu_addr, | 358 | &ring->gpu_addr, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h index a6b89e3932a5..010f69084af5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define __AMDGPU_RING_H__ | 25 | #define __AMDGPU_RING_H__ |
26 | 26 | ||
27 | #include <drm/amdgpu_drm.h> | 27 | #include <drm/amdgpu_drm.h> |
28 | #include "gpu_scheduler.h" | 28 | #include <drm/gpu_scheduler.h> |
29 | 29 | ||
30 | /* max number of rings */ | 30 | /* max number of rings */ |
31 | #define AMDGPU_MAX_RINGS 18 | 31 | #define AMDGPU_MAX_RINGS 18 |
@@ -154,14 +154,14 @@ struct amdgpu_ring_funcs { | |||
154 | void (*emit_tmz)(struct amdgpu_ring *ring, bool start); | 154 | void (*emit_tmz)(struct amdgpu_ring *ring, bool start); |
155 | /* priority functions */ | 155 | /* priority functions */ |
156 | void (*set_priority) (struct amdgpu_ring *ring, | 156 | void (*set_priority) (struct amdgpu_ring *ring, |
157 | enum amd_sched_priority priority); | 157 | enum drm_sched_priority priority); |
158 | }; | 158 | }; |
159 | 159 | ||
160 | struct amdgpu_ring { | 160 | struct amdgpu_ring { |
161 | struct amdgpu_device *adev; | 161 | struct amdgpu_device *adev; |
162 | const struct amdgpu_ring_funcs *funcs; | 162 | const struct amdgpu_ring_funcs *funcs; |
163 | struct amdgpu_fence_driver fence_drv; | 163 | struct amdgpu_fence_driver fence_drv; |
164 | struct amd_gpu_scheduler sched; | 164 | struct drm_gpu_scheduler sched; |
165 | struct list_head lru_list; | 165 | struct list_head lru_list; |
166 | 166 | ||
167 | struct amdgpu_bo *ring_obj; | 167 | struct amdgpu_bo *ring_obj; |
@@ -186,6 +186,7 @@ struct amdgpu_ring { | |||
186 | uint64_t eop_gpu_addr; | 186 | uint64_t eop_gpu_addr; |
187 | u32 doorbell_index; | 187 | u32 doorbell_index; |
188 | bool use_doorbell; | 188 | bool use_doorbell; |
189 | bool use_pollmem; | ||
189 | unsigned wptr_offs; | 190 | unsigned wptr_offs; |
190 | unsigned fence_offs; | 191 | unsigned fence_offs; |
191 | uint64_t current_ctx; | 192 | uint64_t current_ctx; |
@@ -196,7 +197,7 @@ struct amdgpu_ring { | |||
196 | unsigned vm_inv_eng; | 197 | unsigned vm_inv_eng; |
197 | bool has_compute_vm_bug; | 198 | bool has_compute_vm_bug; |
198 | 199 | ||
199 | atomic_t num_jobs[AMD_SCHED_PRIORITY_MAX]; | 200 | atomic_t num_jobs[DRM_SCHED_PRIORITY_MAX]; |
200 | struct mutex priority_mutex; | 201 | struct mutex priority_mutex; |
201 | /* protected by priority_mutex */ | 202 | /* protected by priority_mutex */ |
202 | int priority; | 203 | int priority; |
@@ -212,9 +213,9 @@ void amdgpu_ring_generic_pad_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib); | |||
212 | void amdgpu_ring_commit(struct amdgpu_ring *ring); | 213 | void amdgpu_ring_commit(struct amdgpu_ring *ring); |
213 | void amdgpu_ring_undo(struct amdgpu_ring *ring); | 214 | void amdgpu_ring_undo(struct amdgpu_ring *ring); |
214 | void amdgpu_ring_priority_get(struct amdgpu_ring *ring, | 215 | void amdgpu_ring_priority_get(struct amdgpu_ring *ring, |
215 | enum amd_sched_priority priority); | 216 | enum drm_sched_priority priority); |
216 | void amdgpu_ring_priority_put(struct amdgpu_ring *ring, | 217 | void amdgpu_ring_priority_put(struct amdgpu_ring *ring, |
217 | enum amd_sched_priority priority); | 218 | enum drm_sched_priority priority); |
218 | int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | 219 | int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, |
219 | unsigned ring_size, struct amdgpu_irq_src *irq_src, | 220 | unsigned ring_size, struct amdgpu_irq_src *irq_src, |
220 | unsigned irq_type); | 221 | unsigned irq_type); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c index 290cc3f9c433..86a0715d9431 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | |||
@@ -29,29 +29,29 @@ | |||
29 | 29 | ||
30 | #include "amdgpu_vm.h" | 30 | #include "amdgpu_vm.h" |
31 | 31 | ||
32 | enum amd_sched_priority amdgpu_to_sched_priority(int amdgpu_priority) | 32 | enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority) |
33 | { | 33 | { |
34 | switch (amdgpu_priority) { | 34 | switch (amdgpu_priority) { |
35 | case AMDGPU_CTX_PRIORITY_VERY_HIGH: | 35 | case AMDGPU_CTX_PRIORITY_VERY_HIGH: |
36 | return AMD_SCHED_PRIORITY_HIGH_HW; | 36 | return DRM_SCHED_PRIORITY_HIGH_HW; |
37 | case AMDGPU_CTX_PRIORITY_HIGH: | 37 | case AMDGPU_CTX_PRIORITY_HIGH: |
38 | return AMD_SCHED_PRIORITY_HIGH_SW; | 38 | return DRM_SCHED_PRIORITY_HIGH_SW; |
39 | case AMDGPU_CTX_PRIORITY_NORMAL: | 39 | case AMDGPU_CTX_PRIORITY_NORMAL: |
40 | return AMD_SCHED_PRIORITY_NORMAL; | 40 | return DRM_SCHED_PRIORITY_NORMAL; |
41 | case AMDGPU_CTX_PRIORITY_LOW: | 41 | case AMDGPU_CTX_PRIORITY_LOW: |
42 | case AMDGPU_CTX_PRIORITY_VERY_LOW: | 42 | case AMDGPU_CTX_PRIORITY_VERY_LOW: |
43 | return AMD_SCHED_PRIORITY_LOW; | 43 | return DRM_SCHED_PRIORITY_LOW; |
44 | case AMDGPU_CTX_PRIORITY_UNSET: | 44 | case AMDGPU_CTX_PRIORITY_UNSET: |
45 | return AMD_SCHED_PRIORITY_UNSET; | 45 | return DRM_SCHED_PRIORITY_UNSET; |
46 | default: | 46 | default: |
47 | WARN(1, "Invalid context priority %d\n", amdgpu_priority); | 47 | WARN(1, "Invalid context priority %d\n", amdgpu_priority); |
48 | return AMD_SCHED_PRIORITY_INVALID; | 48 | return DRM_SCHED_PRIORITY_INVALID; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, | 52 | static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, |
53 | int fd, | 53 | int fd, |
54 | enum amd_sched_priority priority) | 54 | enum drm_sched_priority priority) |
55 | { | 55 | { |
56 | struct file *filp = fcheck(fd); | 56 | struct file *filp = fcheck(fd); |
57 | struct drm_file *file; | 57 | struct drm_file *file; |
@@ -86,11 +86,11 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data, | |||
86 | { | 86 | { |
87 | union drm_amdgpu_sched *args = data; | 87 | union drm_amdgpu_sched *args = data; |
88 | struct amdgpu_device *adev = dev->dev_private; | 88 | struct amdgpu_device *adev = dev->dev_private; |
89 | enum amd_sched_priority priority; | 89 | enum drm_sched_priority priority; |
90 | int r; | 90 | int r; |
91 | 91 | ||
92 | priority = amdgpu_to_sched_priority(args->in.priority); | 92 | priority = amdgpu_to_sched_priority(args->in.priority); |
93 | if (args->in.flags || priority == AMD_SCHED_PRIORITY_INVALID) | 93 | if (args->in.flags || priority == DRM_SCHED_PRIORITY_INVALID) |
94 | return -EINVAL; | 94 | return -EINVAL; |
95 | 95 | ||
96 | switch (args->in.op) { | 96 | switch (args->in.op) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h index b28c067d3822..2a1a0c734bdd 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.h | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #include <drm/drmP.h> | 28 | #include <drm/drmP.h> |
29 | 29 | ||
30 | enum amd_sched_priority amdgpu_to_sched_priority(int amdgpu_priority); | 30 | enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority); |
31 | int amdgpu_sched_ioctl(struct drm_device *dev, void *data, | 31 | int amdgpu_sched_ioctl(struct drm_device *dev, void *data, |
32 | struct drm_file *filp); | 32 | struct drm_file *filp); |
33 | 33 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c index ebe1ffbab0c1..df65c66dc956 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | |||
@@ -64,7 +64,7 @@ void amdgpu_sync_create(struct amdgpu_sync *sync) | |||
64 | static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, | 64 | static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, |
65 | struct dma_fence *f) | 65 | struct dma_fence *f) |
66 | { | 66 | { |
67 | struct amd_sched_fence *s_fence = to_amd_sched_fence(f); | 67 | struct drm_sched_fence *s_fence = to_drm_sched_fence(f); |
68 | 68 | ||
69 | if (s_fence) { | 69 | if (s_fence) { |
70 | struct amdgpu_ring *ring; | 70 | struct amdgpu_ring *ring; |
@@ -85,7 +85,7 @@ static bool amdgpu_sync_same_dev(struct amdgpu_device *adev, | |||
85 | */ | 85 | */ |
86 | static void *amdgpu_sync_get_owner(struct dma_fence *f) | 86 | static void *amdgpu_sync_get_owner(struct dma_fence *f) |
87 | { | 87 | { |
88 | struct amd_sched_fence *s_fence = to_amd_sched_fence(f); | 88 | struct drm_sched_fence *s_fence = to_drm_sched_fence(f); |
89 | 89 | ||
90 | if (s_fence) | 90 | if (s_fence) |
91 | return s_fence->owner; | 91 | return s_fence->owner; |
@@ -120,7 +120,7 @@ static void amdgpu_sync_keep_later(struct dma_fence **keep, | |||
120 | * Tries to add the fence to an existing hash entry. Returns true when an entry | 120 | * Tries to add the fence to an existing hash entry. Returns true when an entry |
121 | * was found, false otherwise. | 121 | * was found, false otherwise. |
122 | */ | 122 | */ |
123 | static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f) | 123 | static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f, bool explicit) |
124 | { | 124 | { |
125 | struct amdgpu_sync_entry *e; | 125 | struct amdgpu_sync_entry *e; |
126 | 126 | ||
@@ -129,6 +129,10 @@ static bool amdgpu_sync_add_later(struct amdgpu_sync *sync, struct dma_fence *f) | |||
129 | continue; | 129 | continue; |
130 | 130 | ||
131 | amdgpu_sync_keep_later(&e->fence, f); | 131 | amdgpu_sync_keep_later(&e->fence, f); |
132 | |||
133 | /* Preserve eplicit flag to not loose pipe line sync */ | ||
134 | e->explicit |= explicit; | ||
135 | |||
132 | return true; | 136 | return true; |
133 | } | 137 | } |
134 | return false; | 138 | return false; |
@@ -148,12 +152,11 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync, | |||
148 | 152 | ||
149 | if (!f) | 153 | if (!f) |
150 | return 0; | 154 | return 0; |
151 | |||
152 | if (amdgpu_sync_same_dev(adev, f) && | 155 | if (amdgpu_sync_same_dev(adev, f) && |
153 | amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM) | 156 | amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM) |
154 | amdgpu_sync_keep_later(&sync->last_vm_update, f); | 157 | amdgpu_sync_keep_later(&sync->last_vm_update, f); |
155 | 158 | ||
156 | if (amdgpu_sync_add_later(sync, f)) | 159 | if (amdgpu_sync_add_later(sync, f, explicit)) |
157 | return 0; | 160 | return 0; |
158 | 161 | ||
159 | e = kmem_cache_alloc(amdgpu_sync_slab, GFP_KERNEL); | 162 | e = kmem_cache_alloc(amdgpu_sync_slab, GFP_KERNEL); |
@@ -245,7 +248,7 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync, | |||
245 | 248 | ||
246 | hash_for_each_safe(sync->fences, i, tmp, e, node) { | 249 | hash_for_each_safe(sync->fences, i, tmp, e, node) { |
247 | struct dma_fence *f = e->fence; | 250 | struct dma_fence *f = e->fence; |
248 | struct amd_sched_fence *s_fence = to_amd_sched_fence(f); | 251 | struct drm_sched_fence *s_fence = to_drm_sched_fence(f); |
249 | 252 | ||
250 | if (dma_fence_is_signaled(f)) { | 253 | if (dma_fence_is_signaled(f)) { |
251 | hash_del(&e->node); | 254 | hash_del(&e->node); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 952e0bf3bc84..f1b7d987bd57 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -76,7 +76,7 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
76 | { | 76 | { |
77 | struct drm_global_reference *global_ref; | 77 | struct drm_global_reference *global_ref; |
78 | struct amdgpu_ring *ring; | 78 | struct amdgpu_ring *ring; |
79 | struct amd_sched_rq *rq; | 79 | struct drm_sched_rq *rq; |
80 | int r; | 80 | int r; |
81 | 81 | ||
82 | adev->mman.mem_global_referenced = false; | 82 | adev->mman.mem_global_referenced = false; |
@@ -108,8 +108,8 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
108 | mutex_init(&adev->mman.gtt_window_lock); | 108 | mutex_init(&adev->mman.gtt_window_lock); |
109 | 109 | ||
110 | ring = adev->mman.buffer_funcs_ring; | 110 | ring = adev->mman.buffer_funcs_ring; |
111 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; | 111 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
112 | r = amd_sched_entity_init(&ring->sched, &adev->mman.entity, | 112 | r = drm_sched_entity_init(&ring->sched, &adev->mman.entity, |
113 | rq, amdgpu_sched_jobs, NULL); | 113 | rq, amdgpu_sched_jobs, NULL); |
114 | if (r) { | 114 | if (r) { |
115 | DRM_ERROR("Failed setting up TTM BO move run queue.\n"); | 115 | DRM_ERROR("Failed setting up TTM BO move run queue.\n"); |
@@ -131,7 +131,7 @@ error_mem: | |||
131 | static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) | 131 | static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) |
132 | { | 132 | { |
133 | if (adev->mman.mem_global_referenced) { | 133 | if (adev->mman.mem_global_referenced) { |
134 | amd_sched_entity_fini(adev->mman.entity.sched, | 134 | drm_sched_entity_fini(adev->mman.entity.sched, |
135 | &adev->mman.entity); | 135 | &adev->mman.entity); |
136 | mutex_destroy(&adev->mman.gtt_window_lock); | 136 | mutex_destroy(&adev->mman.gtt_window_lock); |
137 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); | 137 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); |
@@ -505,7 +505,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict, | |||
505 | if (unlikely(r)) { | 505 | if (unlikely(r)) { |
506 | goto out_cleanup; | 506 | goto out_cleanup; |
507 | } | 507 | } |
508 | r = ttm_bo_move_ttm(bo, ctx->interruptible, ctx->no_wait_gpu, new_mem); | 508 | r = ttm_bo_move_ttm(bo, ctx, new_mem); |
509 | out_cleanup: | 509 | out_cleanup: |
510 | ttm_bo_mem_put(bo, &tmp_mem); | 510 | ttm_bo_mem_put(bo, &tmp_mem); |
511 | return r; | 511 | return r; |
@@ -536,7 +536,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict, | |||
536 | if (unlikely(r)) { | 536 | if (unlikely(r)) { |
537 | return r; | 537 | return r; |
538 | } | 538 | } |
539 | r = ttm_bo_move_ttm(bo, ctx->interruptible, ctx->no_wait_gpu, &tmp_mem); | 539 | r = ttm_bo_move_ttm(bo, ctx, &tmp_mem); |
540 | if (unlikely(r)) { | 540 | if (unlikely(r)) { |
541 | goto out_cleanup; | 541 | goto out_cleanup; |
542 | } | 542 | } |
@@ -597,8 +597,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, | |||
597 | 597 | ||
598 | if (r) { | 598 | if (r) { |
599 | memcpy: | 599 | memcpy: |
600 | r = ttm_bo_move_memcpy(bo, ctx->interruptible, | 600 | r = ttm_bo_move_memcpy(bo, ctx, new_mem); |
601 | ctx->no_wait_gpu, new_mem); | ||
602 | if (r) { | 601 | if (r) { |
603 | return r; | 602 | return r; |
604 | } | 603 | } |
@@ -1270,6 +1269,101 @@ static struct ttm_bo_driver amdgpu_bo_driver = { | |||
1270 | .access_memory = &amdgpu_ttm_access_memory | 1269 | .access_memory = &amdgpu_ttm_access_memory |
1271 | }; | 1270 | }; |
1272 | 1271 | ||
1272 | /* | ||
1273 | * Firmware Reservation functions | ||
1274 | */ | ||
1275 | /** | ||
1276 | * amdgpu_ttm_fw_reserve_vram_fini - free fw reserved vram | ||
1277 | * | ||
1278 | * @adev: amdgpu_device pointer | ||
1279 | * | ||
1280 | * free fw reserved vram if it has been reserved. | ||
1281 | */ | ||
1282 | static void amdgpu_ttm_fw_reserve_vram_fini(struct amdgpu_device *adev) | ||
1283 | { | ||
1284 | amdgpu_bo_free_kernel(&adev->fw_vram_usage.reserved_bo, | ||
1285 | NULL, &adev->fw_vram_usage.va); | ||
1286 | } | ||
1287 | |||
1288 | /** | ||
1289 | * amdgpu_ttm_fw_reserve_vram_init - create bo vram reservation from fw | ||
1290 | * | ||
1291 | * @adev: amdgpu_device pointer | ||
1292 | * | ||
1293 | * create bo vram reservation from fw. | ||
1294 | */ | ||
1295 | static int amdgpu_ttm_fw_reserve_vram_init(struct amdgpu_device *adev) | ||
1296 | { | ||
1297 | struct ttm_operation_ctx ctx = { false, false }; | ||
1298 | int r = 0; | ||
1299 | int i; | ||
1300 | u64 vram_size = adev->mc.visible_vram_size; | ||
1301 | u64 offset = adev->fw_vram_usage.start_offset; | ||
1302 | u64 size = adev->fw_vram_usage.size; | ||
1303 | struct amdgpu_bo *bo; | ||
1304 | |||
1305 | adev->fw_vram_usage.va = NULL; | ||
1306 | adev->fw_vram_usage.reserved_bo = NULL; | ||
1307 | |||
1308 | if (adev->fw_vram_usage.size > 0 && | ||
1309 | adev->fw_vram_usage.size <= vram_size) { | ||
1310 | |||
1311 | r = amdgpu_bo_create(adev, adev->fw_vram_usage.size, | ||
1312 | PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, | ||
1313 | AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED | | ||
1314 | AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, NULL, NULL, 0, | ||
1315 | &adev->fw_vram_usage.reserved_bo); | ||
1316 | if (r) | ||
1317 | goto error_create; | ||
1318 | |||
1319 | r = amdgpu_bo_reserve(adev->fw_vram_usage.reserved_bo, false); | ||
1320 | if (r) | ||
1321 | goto error_reserve; | ||
1322 | |||
1323 | /* remove the original mem node and create a new one at the | ||
1324 | * request position | ||
1325 | */ | ||
1326 | bo = adev->fw_vram_usage.reserved_bo; | ||
1327 | offset = ALIGN(offset, PAGE_SIZE); | ||
1328 | for (i = 0; i < bo->placement.num_placement; ++i) { | ||
1329 | bo->placements[i].fpfn = offset >> PAGE_SHIFT; | ||
1330 | bo->placements[i].lpfn = (offset + size) >> PAGE_SHIFT; | ||
1331 | } | ||
1332 | |||
1333 | ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem); | ||
1334 | r = ttm_bo_mem_space(&bo->tbo, &bo->placement, | ||
1335 | &bo->tbo.mem, &ctx); | ||
1336 | if (r) | ||
1337 | goto error_pin; | ||
1338 | |||
1339 | r = amdgpu_bo_pin_restricted(adev->fw_vram_usage.reserved_bo, | ||
1340 | AMDGPU_GEM_DOMAIN_VRAM, | ||
1341 | adev->fw_vram_usage.start_offset, | ||
1342 | (adev->fw_vram_usage.start_offset + | ||
1343 | adev->fw_vram_usage.size), NULL); | ||
1344 | if (r) | ||
1345 | goto error_pin; | ||
1346 | r = amdgpu_bo_kmap(adev->fw_vram_usage.reserved_bo, | ||
1347 | &adev->fw_vram_usage.va); | ||
1348 | if (r) | ||
1349 | goto error_kmap; | ||
1350 | |||
1351 | amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); | ||
1352 | } | ||
1353 | return r; | ||
1354 | |||
1355 | error_kmap: | ||
1356 | amdgpu_bo_unpin(adev->fw_vram_usage.reserved_bo); | ||
1357 | error_pin: | ||
1358 | amdgpu_bo_unreserve(adev->fw_vram_usage.reserved_bo); | ||
1359 | error_reserve: | ||
1360 | amdgpu_bo_unref(&adev->fw_vram_usage.reserved_bo); | ||
1361 | error_create: | ||
1362 | adev->fw_vram_usage.va = NULL; | ||
1363 | adev->fw_vram_usage.reserved_bo = NULL; | ||
1364 | return r; | ||
1365 | } | ||
1366 | |||
1273 | int amdgpu_ttm_init(struct amdgpu_device *adev) | 1367 | int amdgpu_ttm_init(struct amdgpu_device *adev) |
1274 | { | 1368 | { |
1275 | uint64_t gtt_size; | 1369 | uint64_t gtt_size; |
@@ -1312,7 +1406,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1312 | *The reserved vram for firmware must be pinned to the specified | 1406 | *The reserved vram for firmware must be pinned to the specified |
1313 | *place on the VRAM, so reserve it early. | 1407 | *place on the VRAM, so reserve it early. |
1314 | */ | 1408 | */ |
1315 | r = amdgpu_fw_reserve_vram_init(adev); | 1409 | r = amdgpu_ttm_fw_reserve_vram_init(adev); |
1316 | if (r) { | 1410 | if (r) { |
1317 | return r; | 1411 | return r; |
1318 | } | 1412 | } |
@@ -1330,9 +1424,11 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) | |||
1330 | struct sysinfo si; | 1424 | struct sysinfo si; |
1331 | 1425 | ||
1332 | si_meminfo(&si); | 1426 | si_meminfo(&si); |
1333 | gtt_size = max(AMDGPU_DEFAULT_GTT_SIZE_MB << 20, | 1427 | gtt_size = min(max((AMDGPU_DEFAULT_GTT_SIZE_MB << 20), |
1334 | (uint64_t)si.totalram * si.mem_unit * 3/4); | 1428 | adev->mc.mc_vram_size), |
1335 | } else | 1429 | ((uint64_t)si.totalram * si.mem_unit * 3/4)); |
1430 | } | ||
1431 | else | ||
1336 | gtt_size = (uint64_t)amdgpu_gtt_size << 20; | 1432 | gtt_size = (uint64_t)amdgpu_gtt_size << 20; |
1337 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); | 1433 | r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); |
1338 | if (r) { | 1434 | if (r) { |
@@ -1396,7 +1492,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) | |||
1396 | 1492 | ||
1397 | amdgpu_ttm_debugfs_fini(adev); | 1493 | amdgpu_ttm_debugfs_fini(adev); |
1398 | amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL); | 1494 | amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL); |
1399 | amdgpu_fw_reserve_vram_fini(adev); | 1495 | amdgpu_ttm_fw_reserve_vram_fini(adev); |
1400 | 1496 | ||
1401 | ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM); | 1497 | ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_VRAM); |
1402 | ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT); | 1498 | ttm_bo_clean_mm(&adev->mman.bdev, TTM_PL_TT); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index 4f9433e61406..167856f6080f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define __AMDGPU_TTM_H__ | 25 | #define __AMDGPU_TTM_H__ |
26 | 26 | ||
27 | #include "amdgpu.h" | 27 | #include "amdgpu.h" |
28 | #include "gpu_scheduler.h" | 28 | #include <drm/gpu_scheduler.h> |
29 | 29 | ||
30 | #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) | 30 | #define AMDGPU_PL_GDS (TTM_PL_PRIV + 0) |
31 | #define AMDGPU_PL_GWS (TTM_PL_PRIV + 1) | 31 | #define AMDGPU_PL_GWS (TTM_PL_PRIV + 1) |
@@ -55,7 +55,7 @@ struct amdgpu_mman { | |||
55 | 55 | ||
56 | struct mutex gtt_window_lock; | 56 | struct mutex gtt_window_lock; |
57 | /* Scheduler entity for buffer moves */ | 57 | /* Scheduler entity for buffer moves */ |
58 | struct amd_sched_entity entity; | 58 | struct drm_sched_entity entity; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | struct amdgpu_copy_mem { | 61 | struct amdgpu_copy_mem { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c index 2f2a9e17fdb4..b2eae86bf906 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | |||
@@ -116,7 +116,7 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work); | |||
116 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | 116 | int amdgpu_uvd_sw_init(struct amdgpu_device *adev) |
117 | { | 117 | { |
118 | struct amdgpu_ring *ring; | 118 | struct amdgpu_ring *ring; |
119 | struct amd_sched_rq *rq; | 119 | struct drm_sched_rq *rq; |
120 | unsigned long bo_size; | 120 | unsigned long bo_size; |
121 | const char *fw_name; | 121 | const char *fw_name; |
122 | const struct common_firmware_header *hdr; | 122 | const struct common_firmware_header *hdr; |
@@ -230,8 +230,8 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
230 | } | 230 | } |
231 | 231 | ||
232 | ring = &adev->uvd.ring; | 232 | ring = &adev->uvd.ring; |
233 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 233 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
234 | r = amd_sched_entity_init(&ring->sched, &adev->uvd.entity, | 234 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity, |
235 | rq, amdgpu_sched_jobs, NULL); | 235 | rq, amdgpu_sched_jobs, NULL); |
236 | if (r != 0) { | 236 | if (r != 0) { |
237 | DRM_ERROR("Failed setting up UVD run queue.\n"); | 237 | DRM_ERROR("Failed setting up UVD run queue.\n"); |
@@ -244,7 +244,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | /* from uvd v5.0 HW addressing capacity increased to 64 bits */ | 246 | /* from uvd v5.0 HW addressing capacity increased to 64 bits */ |
247 | if (!amdgpu_ip_block_version_cmp(adev, AMD_IP_BLOCK_TYPE_UVD, 5, 0)) | 247 | if (!amdgpu_device_ip_block_version_cmp(adev, AMD_IP_BLOCK_TYPE_UVD, 5, 0)) |
248 | adev->uvd.address_64_bit = true; | 248 | adev->uvd.address_64_bit = true; |
249 | 249 | ||
250 | switch (adev->asic_type) { | 250 | switch (adev->asic_type) { |
@@ -272,7 +272,7 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev) | |||
272 | int i; | 272 | int i; |
273 | kfree(adev->uvd.saved_bo); | 273 | kfree(adev->uvd.saved_bo); |
274 | 274 | ||
275 | amd_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity); | 275 | drm_sched_entity_fini(&adev->uvd.ring.sched, &adev->uvd.entity); |
276 | 276 | ||
277 | amdgpu_bo_free_kernel(&adev->uvd.vcpu_bo, | 277 | amdgpu_bo_free_kernel(&adev->uvd.vcpu_bo, |
278 | &adev->uvd.gpu_addr, | 278 | &adev->uvd.gpu_addr, |
@@ -297,6 +297,8 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev) | |||
297 | if (adev->uvd.vcpu_bo == NULL) | 297 | if (adev->uvd.vcpu_bo == NULL) |
298 | return 0; | 298 | return 0; |
299 | 299 | ||
300 | cancel_delayed_work_sync(&adev->uvd.idle_work); | ||
301 | |||
300 | for (i = 0; i < adev->uvd.max_handles; ++i) | 302 | for (i = 0; i < adev->uvd.max_handles; ++i) |
301 | if (atomic_read(&adev->uvd.handles[i])) | 303 | if (atomic_read(&adev->uvd.handles[i])) |
302 | break; | 304 | break; |
@@ -304,8 +306,6 @@ int amdgpu_uvd_suspend(struct amdgpu_device *adev) | |||
304 | if (i == AMDGPU_MAX_UVD_HANDLES) | 306 | if (i == AMDGPU_MAX_UVD_HANDLES) |
305 | return 0; | 307 | return 0; |
306 | 308 | ||
307 | cancel_delayed_work_sync(&adev->uvd.idle_work); | ||
308 | |||
309 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); | 309 | size = amdgpu_bo_size(adev->uvd.vcpu_bo); |
310 | ptr = adev->uvd.cpu_addr; | 310 | ptr = adev->uvd.cpu_addr; |
311 | 311 | ||
@@ -346,6 +346,8 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) | |||
346 | ptr += le32_to_cpu(hdr->ucode_size_bytes); | 346 | ptr += le32_to_cpu(hdr->ucode_size_bytes); |
347 | } | 347 | } |
348 | memset_io(ptr, 0, size); | 348 | memset_io(ptr, 0, size); |
349 | /* to restore uvd fence seq */ | ||
350 | amdgpu_fence_driver_force_completion(&adev->uvd.ring); | ||
349 | } | 351 | } |
350 | 352 | ||
351 | return 0; | 353 | return 0; |
@@ -1153,10 +1155,10 @@ static void amdgpu_uvd_idle_work_handler(struct work_struct *work) | |||
1153 | } else { | 1155 | } else { |
1154 | amdgpu_asic_set_uvd_clocks(adev, 0, 0); | 1156 | amdgpu_asic_set_uvd_clocks(adev, 0, 0); |
1155 | /* shutdown the UVD block */ | 1157 | /* shutdown the UVD block */ |
1156 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1158 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1157 | AMD_PG_STATE_GATE); | 1159 | AMD_PG_STATE_GATE); |
1158 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1160 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1159 | AMD_CG_STATE_GATE); | 1161 | AMD_CG_STATE_GATE); |
1160 | } | 1162 | } |
1161 | } else { | 1163 | } else { |
1162 | schedule_delayed_work(&adev->uvd.idle_work, UVD_IDLE_TIMEOUT); | 1164 | schedule_delayed_work(&adev->uvd.idle_work, UVD_IDLE_TIMEOUT); |
@@ -1176,10 +1178,10 @@ void amdgpu_uvd_ring_begin_use(struct amdgpu_ring *ring) | |||
1176 | amdgpu_dpm_enable_uvd(adev, true); | 1178 | amdgpu_dpm_enable_uvd(adev, true); |
1177 | } else { | 1179 | } else { |
1178 | amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); | 1180 | amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); |
1179 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1181 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1180 | AMD_CG_STATE_UNGATE); | 1182 | AMD_CG_STATE_UNGATE); |
1181 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1183 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1182 | AMD_PG_STATE_UNGATE); | 1184 | AMD_PG_STATE_UNGATE); |
1183 | } | 1185 | } |
1184 | } | 1186 | } |
1185 | } | 1187 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h index 845eea993f75..32ea20b99e53 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | |||
@@ -51,8 +51,8 @@ struct amdgpu_uvd { | |||
51 | struct amdgpu_irq_src irq; | 51 | struct amdgpu_irq_src irq; |
52 | bool address_64_bit; | 52 | bool address_64_bit; |
53 | bool use_ctx_buf; | 53 | bool use_ctx_buf; |
54 | struct amd_sched_entity entity; | 54 | struct drm_sched_entity entity; |
55 | struct amd_sched_entity entity_enc; | 55 | struct drm_sched_entity entity_enc; |
56 | uint32_t srbm_soft_reset; | 56 | uint32_t srbm_soft_reset; |
57 | unsigned num_enc_rings; | 57 | unsigned num_enc_rings; |
58 | }; | 58 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c index ba6d846b08ff..9857d482c942 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | |||
@@ -85,7 +85,7 @@ static void amdgpu_vce_idle_work_handler(struct work_struct *work); | |||
85 | int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) | 85 | int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) |
86 | { | 86 | { |
87 | struct amdgpu_ring *ring; | 87 | struct amdgpu_ring *ring; |
88 | struct amd_sched_rq *rq; | 88 | struct drm_sched_rq *rq; |
89 | const char *fw_name; | 89 | const char *fw_name; |
90 | const struct common_firmware_header *hdr; | 90 | const struct common_firmware_header *hdr; |
91 | unsigned ucode_version, version_major, version_minor, binary_id; | 91 | unsigned ucode_version, version_major, version_minor, binary_id; |
@@ -174,8 +174,8 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size) | |||
174 | } | 174 | } |
175 | 175 | ||
176 | ring = &adev->vce.ring[0]; | 176 | ring = &adev->vce.ring[0]; |
177 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 177 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
178 | r = amd_sched_entity_init(&ring->sched, &adev->vce.entity, | 178 | r = drm_sched_entity_init(&ring->sched, &adev->vce.entity, |
179 | rq, amdgpu_sched_jobs, NULL); | 179 | rq, amdgpu_sched_jobs, NULL); |
180 | if (r != 0) { | 180 | if (r != 0) { |
181 | DRM_ERROR("Failed setting up VCE run queue.\n"); | 181 | DRM_ERROR("Failed setting up VCE run queue.\n"); |
@@ -207,7 +207,7 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev) | |||
207 | if (adev->vce.vcpu_bo == NULL) | 207 | if (adev->vce.vcpu_bo == NULL) |
208 | return 0; | 208 | return 0; |
209 | 209 | ||
210 | amd_sched_entity_fini(&adev->vce.ring[0].sched, &adev->vce.entity); | 210 | drm_sched_entity_fini(&adev->vce.ring[0].sched, &adev->vce.entity); |
211 | 211 | ||
212 | amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev->vce.gpu_addr, | 212 | amdgpu_bo_free_kernel(&adev->vce.vcpu_bo, &adev->vce.gpu_addr, |
213 | (void **)&adev->vce.cpu_addr); | 213 | (void **)&adev->vce.cpu_addr); |
@@ -311,10 +311,10 @@ static void amdgpu_vce_idle_work_handler(struct work_struct *work) | |||
311 | amdgpu_dpm_enable_vce(adev, false); | 311 | amdgpu_dpm_enable_vce(adev, false); |
312 | } else { | 312 | } else { |
313 | amdgpu_asic_set_vce_clocks(adev, 0, 0); | 313 | amdgpu_asic_set_vce_clocks(adev, 0, 0); |
314 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 314 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
315 | AMD_PG_STATE_GATE); | 315 | AMD_PG_STATE_GATE); |
316 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 316 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
317 | AMD_CG_STATE_GATE); | 317 | AMD_CG_STATE_GATE); |
318 | } | 318 | } |
319 | } else { | 319 | } else { |
320 | schedule_delayed_work(&adev->vce.idle_work, VCE_IDLE_TIMEOUT); | 320 | schedule_delayed_work(&adev->vce.idle_work, VCE_IDLE_TIMEOUT); |
@@ -343,10 +343,10 @@ void amdgpu_vce_ring_begin_use(struct amdgpu_ring *ring) | |||
343 | amdgpu_dpm_enable_vce(adev, true); | 343 | amdgpu_dpm_enable_vce(adev, true); |
344 | } else { | 344 | } else { |
345 | amdgpu_asic_set_vce_clocks(adev, 53300, 40000); | 345 | amdgpu_asic_set_vce_clocks(adev, 53300, 40000); |
346 | amdgpu_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 346 | amdgpu_device_ip_set_clockgating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
347 | AMD_CG_STATE_UNGATE); | 347 | AMD_CG_STATE_UNGATE); |
348 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, | 348 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCE, |
349 | AMD_PG_STATE_UNGATE); | 349 | AMD_PG_STATE_UNGATE); |
350 | 350 | ||
351 | } | 351 | } |
352 | } | 352 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h index 5ce54cde472d..162cae94e3b1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h | |||
@@ -46,7 +46,7 @@ struct amdgpu_vce { | |||
46 | struct amdgpu_ring ring[AMDGPU_MAX_VCE_RINGS]; | 46 | struct amdgpu_ring ring[AMDGPU_MAX_VCE_RINGS]; |
47 | struct amdgpu_irq_src irq; | 47 | struct amdgpu_irq_src irq; |
48 | unsigned harvest_config; | 48 | unsigned harvest_config; |
49 | struct amd_sched_entity entity; | 49 | struct drm_sched_entity entity; |
50 | uint32_t srbm_soft_reset; | 50 | uint32_t srbm_soft_reset; |
51 | unsigned num_rings; | 51 | unsigned num_rings; |
52 | }; | 52 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c index d7ba048c2f80..837962118dbc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include "soc15d.h" | 35 | #include "soc15d.h" |
36 | #include "soc15_common.h" | 36 | #include "soc15_common.h" |
37 | 37 | ||
38 | #include "soc15ip.h" | ||
39 | #include "vcn/vcn_1_0_offset.h" | 38 | #include "vcn/vcn_1_0_offset.h" |
40 | 39 | ||
41 | /* 1 second timeout */ | 40 | /* 1 second timeout */ |
@@ -51,7 +50,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work); | |||
51 | int amdgpu_vcn_sw_init(struct amdgpu_device *adev) | 50 | int amdgpu_vcn_sw_init(struct amdgpu_device *adev) |
52 | { | 51 | { |
53 | struct amdgpu_ring *ring; | 52 | struct amdgpu_ring *ring; |
54 | struct amd_sched_rq *rq; | 53 | struct drm_sched_rq *rq; |
55 | unsigned long bo_size; | 54 | unsigned long bo_size; |
56 | const char *fw_name; | 55 | const char *fw_name; |
57 | const struct common_firmware_header *hdr; | 56 | const struct common_firmware_header *hdr; |
@@ -104,8 +103,8 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev) | |||
104 | } | 103 | } |
105 | 104 | ||
106 | ring = &adev->vcn.ring_dec; | 105 | ring = &adev->vcn.ring_dec; |
107 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 106 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
108 | r = amd_sched_entity_init(&ring->sched, &adev->vcn.entity_dec, | 107 | r = drm_sched_entity_init(&ring->sched, &adev->vcn.entity_dec, |
109 | rq, amdgpu_sched_jobs, NULL); | 108 | rq, amdgpu_sched_jobs, NULL); |
110 | if (r != 0) { | 109 | if (r != 0) { |
111 | DRM_ERROR("Failed setting up VCN dec run queue.\n"); | 110 | DRM_ERROR("Failed setting up VCN dec run queue.\n"); |
@@ -113,8 +112,8 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev) | |||
113 | } | 112 | } |
114 | 113 | ||
115 | ring = &adev->vcn.ring_enc[0]; | 114 | ring = &adev->vcn.ring_enc[0]; |
116 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 115 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
117 | r = amd_sched_entity_init(&ring->sched, &adev->vcn.entity_enc, | 116 | r = drm_sched_entity_init(&ring->sched, &adev->vcn.entity_enc, |
118 | rq, amdgpu_sched_jobs, NULL); | 117 | rq, amdgpu_sched_jobs, NULL); |
119 | if (r != 0) { | 118 | if (r != 0) { |
120 | DRM_ERROR("Failed setting up VCN enc run queue.\n"); | 119 | DRM_ERROR("Failed setting up VCN enc run queue.\n"); |
@@ -130,9 +129,9 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev) | |||
130 | 129 | ||
131 | kfree(adev->vcn.saved_bo); | 130 | kfree(adev->vcn.saved_bo); |
132 | 131 | ||
133 | amd_sched_entity_fini(&adev->vcn.ring_dec.sched, &adev->vcn.entity_dec); | 132 | drm_sched_entity_fini(&adev->vcn.ring_dec.sched, &adev->vcn.entity_dec); |
134 | 133 | ||
135 | amd_sched_entity_fini(&adev->vcn.ring_enc[0].sched, &adev->vcn.entity_enc); | 134 | drm_sched_entity_fini(&adev->vcn.ring_enc[0].sched, &adev->vcn.entity_enc); |
136 | 135 | ||
137 | amdgpu_bo_free_kernel(&adev->vcn.vcpu_bo, | 136 | amdgpu_bo_free_kernel(&adev->vcn.vcpu_bo, |
138 | &adev->vcn.gpu_addr, | 137 | &adev->vcn.gpu_addr, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h index d50ba0657854..2fd7db891689 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h | |||
@@ -56,8 +56,8 @@ struct amdgpu_vcn { | |||
56 | struct amdgpu_ring ring_dec; | 56 | struct amdgpu_ring ring_dec; |
57 | struct amdgpu_ring ring_enc[AMDGPU_VCN_MAX_ENC_RINGS]; | 57 | struct amdgpu_ring ring_enc[AMDGPU_VCN_MAX_ENC_RINGS]; |
58 | struct amdgpu_irq_src irq; | 58 | struct amdgpu_irq_src irq; |
59 | struct amd_sched_entity entity_dec; | 59 | struct drm_sched_entity entity_dec; |
60 | struct amd_sched_entity entity_enc; | 60 | struct drm_sched_entity entity_enc; |
61 | unsigned num_enc_rings; | 61 | unsigned num_enc_rings; |
62 | }; | 62 | }; |
63 | 63 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 3ecdbdfb04dd..398abbcbf029 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -148,12 +148,23 @@ struct amdgpu_prt_cb { | |||
148 | static unsigned amdgpu_vm_level_shift(struct amdgpu_device *adev, | 148 | static unsigned amdgpu_vm_level_shift(struct amdgpu_device *adev, |
149 | unsigned level) | 149 | unsigned level) |
150 | { | 150 | { |
151 | if (level != adev->vm_manager.num_level) | 151 | unsigned shift = 0xff; |
152 | return 9 * (adev->vm_manager.num_level - level - 1) + | 152 | |
153 | switch (level) { | ||
154 | case AMDGPU_VM_PDB2: | ||
155 | case AMDGPU_VM_PDB1: | ||
156 | case AMDGPU_VM_PDB0: | ||
157 | shift = 9 * (AMDGPU_VM_PDB0 - level) + | ||
153 | adev->vm_manager.block_size; | 158 | adev->vm_manager.block_size; |
154 | else | 159 | break; |
155 | /* For the page tables on the leaves */ | 160 | case AMDGPU_VM_PTB: |
156 | return 0; | 161 | shift = 0; |
162 | break; | ||
163 | default: | ||
164 | dev_err(adev->dev, "the level%d isn't supported.\n", level); | ||
165 | } | ||
166 | |||
167 | return shift; | ||
157 | } | 168 | } |
158 | 169 | ||
159 | /** | 170 | /** |
@@ -166,12 +177,13 @@ static unsigned amdgpu_vm_level_shift(struct amdgpu_device *adev, | |||
166 | static unsigned amdgpu_vm_num_entries(struct amdgpu_device *adev, | 177 | static unsigned amdgpu_vm_num_entries(struct amdgpu_device *adev, |
167 | unsigned level) | 178 | unsigned level) |
168 | { | 179 | { |
169 | unsigned shift = amdgpu_vm_level_shift(adev, 0); | 180 | unsigned shift = amdgpu_vm_level_shift(adev, |
181 | adev->vm_manager.root_level); | ||
170 | 182 | ||
171 | if (level == 0) | 183 | if (level == adev->vm_manager.root_level) |
172 | /* For the root directory */ | 184 | /* For the root directory */ |
173 | return round_up(adev->vm_manager.max_pfn, 1 << shift) >> shift; | 185 | return round_up(adev->vm_manager.max_pfn, 1 << shift) >> shift; |
174 | else if (level != adev->vm_manager.num_level) | 186 | else if (level != AMDGPU_VM_PTB) |
175 | /* Everything in between */ | 187 | /* Everything in between */ |
176 | return 512; | 188 | return 512; |
177 | else | 189 | else |
@@ -329,9 +341,6 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
329 | to >= amdgpu_vm_num_entries(adev, level)) | 341 | to >= amdgpu_vm_num_entries(adev, level)) |
330 | return -EINVAL; | 342 | return -EINVAL; |
331 | 343 | ||
332 | if (to > parent->last_entry_used) | ||
333 | parent->last_entry_used = to; | ||
334 | |||
335 | ++level; | 344 | ++level; |
336 | saddr = saddr & ((1 << shift) - 1); | 345 | saddr = saddr & ((1 << shift) - 1); |
337 | eaddr = eaddr & ((1 << shift) - 1); | 346 | eaddr = eaddr & ((1 << shift) - 1); |
@@ -346,7 +355,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
346 | 355 | ||
347 | if (vm->pte_support_ats) { | 356 | if (vm->pte_support_ats) { |
348 | init_value = AMDGPU_PTE_DEFAULT_ATC; | 357 | init_value = AMDGPU_PTE_DEFAULT_ATC; |
349 | if (level != adev->vm_manager.num_level - 1) | 358 | if (level != AMDGPU_VM_PTB) |
350 | init_value |= AMDGPU_PDE_PTE; | 359 | init_value |= AMDGPU_PDE_PTE; |
351 | 360 | ||
352 | } | 361 | } |
@@ -386,10 +395,9 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
386 | spin_lock(&vm->status_lock); | 395 | spin_lock(&vm->status_lock); |
387 | list_add(&entry->base.vm_status, &vm->relocated); | 396 | list_add(&entry->base.vm_status, &vm->relocated); |
388 | spin_unlock(&vm->status_lock); | 397 | spin_unlock(&vm->status_lock); |
389 | entry->addr = 0; | ||
390 | } | 398 | } |
391 | 399 | ||
392 | if (level < adev->vm_manager.num_level) { | 400 | if (level < AMDGPU_VM_PTB) { |
393 | uint64_t sub_saddr = (pt_idx == from) ? saddr : 0; | 401 | uint64_t sub_saddr = (pt_idx == from) ? saddr : 0; |
394 | uint64_t sub_eaddr = (pt_idx == to) ? eaddr : | 402 | uint64_t sub_eaddr = (pt_idx == to) ? eaddr : |
395 | ((1 << shift) - 1); | 403 | ((1 << shift) - 1); |
@@ -435,7 +443,8 @@ int amdgpu_vm_alloc_pts(struct amdgpu_device *adev, | |||
435 | saddr /= AMDGPU_GPU_PAGE_SIZE; | 443 | saddr /= AMDGPU_GPU_PAGE_SIZE; |
436 | eaddr /= AMDGPU_GPU_PAGE_SIZE; | 444 | eaddr /= AMDGPU_GPU_PAGE_SIZE; |
437 | 445 | ||
438 | return amdgpu_vm_alloc_levels(adev, vm, &vm->root, saddr, eaddr, 0); | 446 | return amdgpu_vm_alloc_levels(adev, vm, &vm->root, saddr, eaddr, |
447 | adev->vm_manager.root_level); | ||
439 | } | 448 | } |
440 | 449 | ||
441 | /** | 450 | /** |
@@ -732,7 +741,7 @@ void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev) | |||
732 | 741 | ||
733 | has_compute_vm_bug = false; | 742 | has_compute_vm_bug = false; |
734 | 743 | ||
735 | ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX); | 744 | ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX); |
736 | if (ip_block) { | 745 | if (ip_block) { |
737 | /* Compute has a VM bug for GFX version < 7. | 746 | /* Compute has a VM bug for GFX version < 7. |
738 | Compute has a VM bug for GFX 8 MEC firmware version < 673.*/ | 747 | Compute has a VM bug for GFX 8 MEC firmware version < 673.*/ |
@@ -1060,162 +1069,52 @@ static int amdgpu_vm_wait_pd(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
1060 | } | 1069 | } |
1061 | 1070 | ||
1062 | /* | 1071 | /* |
1063 | * amdgpu_vm_update_level - update a single level in the hierarchy | 1072 | * amdgpu_vm_update_pde - update a single level in the hierarchy |
1064 | * | 1073 | * |
1065 | * @adev: amdgpu_device pointer | 1074 | * @param: parameters for the update |
1066 | * @vm: requested vm | 1075 | * @vm: requested vm |
1067 | * @parent: parent directory | 1076 | * @parent: parent directory |
1077 | * @entry: entry to update | ||
1068 | * | 1078 | * |
1069 | * Makes sure all entries in @parent are up to date. | 1079 | * Makes sure the requested entry in parent is up to date. |
1070 | * Returns 0 for success, error for failure. | ||
1071 | */ | 1080 | */ |
1072 | static int amdgpu_vm_update_level(struct amdgpu_device *adev, | 1081 | static void amdgpu_vm_update_pde(struct amdgpu_pte_update_params *params, |
1073 | struct amdgpu_vm *vm, | 1082 | struct amdgpu_vm *vm, |
1074 | struct amdgpu_vm_pt *parent) | 1083 | struct amdgpu_vm_pt *parent, |
1084 | struct amdgpu_vm_pt *entry) | ||
1075 | { | 1085 | { |
1076 | struct amdgpu_bo *shadow; | 1086 | struct amdgpu_bo *bo = entry->base.bo, *shadow = NULL, *pbo; |
1077 | struct amdgpu_ring *ring = NULL; | ||
1078 | uint64_t pd_addr, shadow_addr = 0; | 1087 | uint64_t pd_addr, shadow_addr = 0; |
1079 | uint64_t last_pde = ~0, last_pt = ~0, last_shadow = ~0; | 1088 | uint64_t pde, pt, flags; |
1080 | unsigned count = 0, pt_idx, ndw = 0; | 1089 | unsigned level; |
1081 | struct amdgpu_job *job; | ||
1082 | struct amdgpu_pte_update_params params; | ||
1083 | struct dma_fence *fence = NULL; | ||
1084 | uint32_t incr; | ||
1085 | |||
1086 | int r; | ||
1087 | 1090 | ||
1088 | if (!parent->entries) | 1091 | /* Don't update huge pages here */ |
1089 | return 0; | 1092 | if (entry->huge) |
1090 | 1093 | return; | |
1091 | memset(¶ms, 0, sizeof(params)); | ||
1092 | params.adev = adev; | ||
1093 | shadow = parent->base.bo->shadow; | ||
1094 | 1094 | ||
1095 | if (vm->use_cpu_for_update) { | 1095 | if (vm->use_cpu_for_update) { |
1096 | pd_addr = (unsigned long)amdgpu_bo_kptr(parent->base.bo); | 1096 | pd_addr = (unsigned long)amdgpu_bo_kptr(parent->base.bo); |
1097 | r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); | ||
1098 | if (unlikely(r)) | ||
1099 | return r; | ||
1100 | |||
1101 | params.func = amdgpu_vm_cpu_set_ptes; | ||
1102 | } else { | 1097 | } else { |
1103 | ring = container_of(vm->entity.sched, struct amdgpu_ring, | ||
1104 | sched); | ||
1105 | |||
1106 | /* padding, etc. */ | ||
1107 | ndw = 64; | ||
1108 | |||
1109 | /* assume the worst case */ | ||
1110 | ndw += parent->last_entry_used * 6; | ||
1111 | |||
1112 | pd_addr = amdgpu_bo_gpu_offset(parent->base.bo); | 1098 | pd_addr = amdgpu_bo_gpu_offset(parent->base.bo); |
1113 | 1099 | shadow = parent->base.bo->shadow; | |
1114 | if (shadow) { | 1100 | if (shadow) |
1115 | shadow_addr = amdgpu_bo_gpu_offset(shadow); | 1101 | shadow_addr = amdgpu_bo_gpu_offset(shadow); |
1116 | ndw *= 2; | ||
1117 | } else { | ||
1118 | shadow_addr = 0; | ||
1119 | } | ||
1120 | |||
1121 | r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job); | ||
1122 | if (r) | ||
1123 | return r; | ||
1124 | |||
1125 | params.ib = &job->ibs[0]; | ||
1126 | params.func = amdgpu_vm_do_set_ptes; | ||
1127 | } | 1102 | } |
1128 | 1103 | ||
1104 | for (level = 0, pbo = parent->base.bo->parent; pbo; ++level) | ||
1105 | pbo = pbo->parent; | ||
1129 | 1106 | ||
1130 | /* walk over the address space and update the directory */ | 1107 | level += params->adev->vm_manager.root_level; |
1131 | for (pt_idx = 0; pt_idx <= parent->last_entry_used; ++pt_idx) { | 1108 | pt = amdgpu_bo_gpu_offset(bo); |
1132 | struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; | 1109 | flags = AMDGPU_PTE_VALID; |
1133 | struct amdgpu_bo *bo = entry->base.bo; | 1110 | amdgpu_gart_get_vm_pde(params->adev, level, &pt, &flags); |
1134 | uint64_t pde, pt; | 1111 | if (shadow) { |
1135 | 1112 | pde = shadow_addr + (entry - parent->entries) * 8; | |
1136 | if (bo == NULL) | 1113 | params->func(params, pde, pt, 1, 0, flags); |
1137 | continue; | ||
1138 | |||
1139 | spin_lock(&vm->status_lock); | ||
1140 | list_del_init(&entry->base.vm_status); | ||
1141 | spin_unlock(&vm->status_lock); | ||
1142 | |||
1143 | pt = amdgpu_bo_gpu_offset(bo); | ||
1144 | pt = amdgpu_gart_get_vm_pde(adev, pt); | ||
1145 | /* Don't update huge pages here */ | ||
1146 | if ((parent->entries[pt_idx].addr & AMDGPU_PDE_PTE) || | ||
1147 | parent->entries[pt_idx].addr == (pt | AMDGPU_PTE_VALID)) | ||
1148 | continue; | ||
1149 | |||
1150 | parent->entries[pt_idx].addr = pt | AMDGPU_PTE_VALID; | ||
1151 | |||
1152 | pde = pd_addr + pt_idx * 8; | ||
1153 | incr = amdgpu_bo_size(bo); | ||
1154 | if (((last_pde + 8 * count) != pde) || | ||
1155 | ((last_pt + incr * count) != pt) || | ||
1156 | (count == AMDGPU_VM_MAX_UPDATE_SIZE)) { | ||
1157 | |||
1158 | if (count) { | ||
1159 | if (shadow) | ||
1160 | params.func(¶ms, | ||
1161 | last_shadow, | ||
1162 | last_pt, count, | ||
1163 | incr, | ||
1164 | AMDGPU_PTE_VALID); | ||
1165 | |||
1166 | params.func(¶ms, last_pde, | ||
1167 | last_pt, count, incr, | ||
1168 | AMDGPU_PTE_VALID); | ||
1169 | } | ||
1170 | |||
1171 | count = 1; | ||
1172 | last_pde = pde; | ||
1173 | last_shadow = shadow_addr + pt_idx * 8; | ||
1174 | last_pt = pt; | ||
1175 | } else { | ||
1176 | ++count; | ||
1177 | } | ||
1178 | } | ||
1179 | |||
1180 | if (count) { | ||
1181 | if (vm->root.base.bo->shadow) | ||
1182 | params.func(¶ms, last_shadow, last_pt, | ||
1183 | count, incr, AMDGPU_PTE_VALID); | ||
1184 | |||
1185 | params.func(¶ms, last_pde, last_pt, | ||
1186 | count, incr, AMDGPU_PTE_VALID); | ||
1187 | } | ||
1188 | |||
1189 | if (!vm->use_cpu_for_update) { | ||
1190 | if (params.ib->length_dw == 0) { | ||
1191 | amdgpu_job_free(job); | ||
1192 | } else { | ||
1193 | amdgpu_ring_pad_ib(ring, params.ib); | ||
1194 | amdgpu_sync_resv(adev, &job->sync, | ||
1195 | parent->base.bo->tbo.resv, | ||
1196 | AMDGPU_FENCE_OWNER_VM, false); | ||
1197 | if (shadow) | ||
1198 | amdgpu_sync_resv(adev, &job->sync, | ||
1199 | shadow->tbo.resv, | ||
1200 | AMDGPU_FENCE_OWNER_VM, false); | ||
1201 | |||
1202 | WARN_ON(params.ib->length_dw > ndw); | ||
1203 | r = amdgpu_job_submit(job, ring, &vm->entity, | ||
1204 | AMDGPU_FENCE_OWNER_VM, &fence); | ||
1205 | if (r) | ||
1206 | goto error_free; | ||
1207 | |||
1208 | amdgpu_bo_fence(parent->base.bo, fence, true); | ||
1209 | dma_fence_put(vm->last_update); | ||
1210 | vm->last_update = fence; | ||
1211 | } | ||
1212 | } | 1114 | } |
1213 | 1115 | ||
1214 | return 0; | 1116 | pde = pd_addr + (entry - parent->entries) * 8; |
1215 | 1117 | params->func(params, pde, pt, 1, 0, flags); | |
1216 | error_free: | ||
1217 | amdgpu_job_free(job); | ||
1218 | return r; | ||
1219 | } | 1118 | } |
1220 | 1119 | ||
1221 | /* | 1120 | /* |
@@ -1225,27 +1124,29 @@ error_free: | |||
1225 | * | 1124 | * |
1226 | * Mark all PD level as invalid after an error. | 1125 | * Mark all PD level as invalid after an error. |
1227 | */ | 1126 | */ |
1228 | static void amdgpu_vm_invalidate_level(struct amdgpu_vm *vm, | 1127 | static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev, |
1229 | struct amdgpu_vm_pt *parent) | 1128 | struct amdgpu_vm *vm, |
1129 | struct amdgpu_vm_pt *parent, | ||
1130 | unsigned level) | ||
1230 | { | 1131 | { |
1231 | unsigned pt_idx; | 1132 | unsigned pt_idx, num_entries; |
1232 | 1133 | ||
1233 | /* | 1134 | /* |
1234 | * Recurse into the subdirectories. This recursion is harmless because | 1135 | * Recurse into the subdirectories. This recursion is harmless because |
1235 | * we only have a maximum of 5 layers. | 1136 | * we only have a maximum of 5 layers. |
1236 | */ | 1137 | */ |
1237 | for (pt_idx = 0; pt_idx <= parent->last_entry_used; ++pt_idx) { | 1138 | num_entries = amdgpu_vm_num_entries(adev, level); |
1139 | for (pt_idx = 0; pt_idx < num_entries; ++pt_idx) { | ||
1238 | struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; | 1140 | struct amdgpu_vm_pt *entry = &parent->entries[pt_idx]; |
1239 | 1141 | ||
1240 | if (!entry->base.bo) | 1142 | if (!entry->base.bo) |
1241 | continue; | 1143 | continue; |
1242 | 1144 | ||
1243 | entry->addr = ~0ULL; | ||
1244 | spin_lock(&vm->status_lock); | 1145 | spin_lock(&vm->status_lock); |
1245 | if (list_empty(&entry->base.vm_status)) | 1146 | if (list_empty(&entry->base.vm_status)) |
1246 | list_add(&entry->base.vm_status, &vm->relocated); | 1147 | list_add(&entry->base.vm_status, &vm->relocated); |
1247 | spin_unlock(&vm->status_lock); | 1148 | spin_unlock(&vm->status_lock); |
1248 | amdgpu_vm_invalidate_level(vm, entry); | 1149 | amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); |
1249 | } | 1150 | } |
1250 | } | 1151 | } |
1251 | 1152 | ||
@@ -1261,38 +1162,63 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_vm *vm, | |||
1261 | int amdgpu_vm_update_directories(struct amdgpu_device *adev, | 1162 | int amdgpu_vm_update_directories(struct amdgpu_device *adev, |
1262 | struct amdgpu_vm *vm) | 1163 | struct amdgpu_vm *vm) |
1263 | { | 1164 | { |
1165 | struct amdgpu_pte_update_params params; | ||
1166 | struct amdgpu_job *job; | ||
1167 | unsigned ndw = 0; | ||
1264 | int r = 0; | 1168 | int r = 0; |
1265 | 1169 | ||
1170 | if (list_empty(&vm->relocated)) | ||
1171 | return 0; | ||
1172 | |||
1173 | restart: | ||
1174 | memset(¶ms, 0, sizeof(params)); | ||
1175 | params.adev = adev; | ||
1176 | |||
1177 | if (vm->use_cpu_for_update) { | ||
1178 | r = amdgpu_vm_wait_pd(adev, vm, AMDGPU_FENCE_OWNER_VM); | ||
1179 | if (unlikely(r)) | ||
1180 | return r; | ||
1181 | |||
1182 | params.func = amdgpu_vm_cpu_set_ptes; | ||
1183 | } else { | ||
1184 | ndw = 512 * 8; | ||
1185 | r = amdgpu_job_alloc_with_ib(adev, ndw * 4, &job); | ||
1186 | if (r) | ||
1187 | return r; | ||
1188 | |||
1189 | params.ib = &job->ibs[0]; | ||
1190 | params.func = amdgpu_vm_do_set_ptes; | ||
1191 | } | ||
1192 | |||
1266 | spin_lock(&vm->status_lock); | 1193 | spin_lock(&vm->status_lock); |
1267 | while (!list_empty(&vm->relocated)) { | 1194 | while (!list_empty(&vm->relocated)) { |
1268 | struct amdgpu_vm_bo_base *bo_base; | 1195 | struct amdgpu_vm_bo_base *bo_base, *parent; |
1196 | struct amdgpu_vm_pt *pt, *entry; | ||
1269 | struct amdgpu_bo *bo; | 1197 | struct amdgpu_bo *bo; |
1270 | 1198 | ||
1271 | bo_base = list_first_entry(&vm->relocated, | 1199 | bo_base = list_first_entry(&vm->relocated, |
1272 | struct amdgpu_vm_bo_base, | 1200 | struct amdgpu_vm_bo_base, |
1273 | vm_status); | 1201 | vm_status); |
1202 | list_del_init(&bo_base->vm_status); | ||
1274 | spin_unlock(&vm->status_lock); | 1203 | spin_unlock(&vm->status_lock); |
1275 | 1204 | ||
1276 | bo = bo_base->bo->parent; | 1205 | bo = bo_base->bo->parent; |
1277 | if (bo) { | 1206 | if (!bo) { |
1278 | struct amdgpu_vm_bo_base *parent; | ||
1279 | struct amdgpu_vm_pt *pt; | ||
1280 | |||
1281 | parent = list_first_entry(&bo->va, | ||
1282 | struct amdgpu_vm_bo_base, | ||
1283 | bo_list); | ||
1284 | pt = container_of(parent, struct amdgpu_vm_pt, base); | ||
1285 | |||
1286 | r = amdgpu_vm_update_level(adev, vm, pt); | ||
1287 | if (r) { | ||
1288 | amdgpu_vm_invalidate_level(vm, &vm->root); | ||
1289 | return r; | ||
1290 | } | ||
1291 | spin_lock(&vm->status_lock); | ||
1292 | } else { | ||
1293 | spin_lock(&vm->status_lock); | 1207 | spin_lock(&vm->status_lock); |
1294 | list_del_init(&bo_base->vm_status); | 1208 | continue; |
1295 | } | 1209 | } |
1210 | |||
1211 | parent = list_first_entry(&bo->va, struct amdgpu_vm_bo_base, | ||
1212 | bo_list); | ||
1213 | pt = container_of(parent, struct amdgpu_vm_pt, base); | ||
1214 | entry = container_of(bo_base, struct amdgpu_vm_pt, base); | ||
1215 | |||
1216 | amdgpu_vm_update_pde(¶ms, vm, pt, entry); | ||
1217 | |||
1218 | spin_lock(&vm->status_lock); | ||
1219 | if (!vm->use_cpu_for_update && | ||
1220 | (ndw - params.ib->length_dw) < 32) | ||
1221 | break; | ||
1296 | } | 1222 | } |
1297 | spin_unlock(&vm->status_lock); | 1223 | spin_unlock(&vm->status_lock); |
1298 | 1224 | ||
@@ -1300,8 +1226,44 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, | |||
1300 | /* Flush HDP */ | 1226 | /* Flush HDP */ |
1301 | mb(); | 1227 | mb(); |
1302 | amdgpu_gart_flush_gpu_tlb(adev, 0); | 1228 | amdgpu_gart_flush_gpu_tlb(adev, 0); |
1229 | } else if (params.ib->length_dw == 0) { | ||
1230 | amdgpu_job_free(job); | ||
1231 | } else { | ||
1232 | struct amdgpu_bo *root = vm->root.base.bo; | ||
1233 | struct amdgpu_ring *ring; | ||
1234 | struct dma_fence *fence; | ||
1235 | |||
1236 | ring = container_of(vm->entity.sched, struct amdgpu_ring, | ||
1237 | sched); | ||
1238 | |||
1239 | amdgpu_ring_pad_ib(ring, params.ib); | ||
1240 | amdgpu_sync_resv(adev, &job->sync, root->tbo.resv, | ||
1241 | AMDGPU_FENCE_OWNER_VM, false); | ||
1242 | if (root->shadow) | ||
1243 | amdgpu_sync_resv(adev, &job->sync, | ||
1244 | root->shadow->tbo.resv, | ||
1245 | AMDGPU_FENCE_OWNER_VM, false); | ||
1246 | |||
1247 | WARN_ON(params.ib->length_dw > ndw); | ||
1248 | r = amdgpu_job_submit(job, ring, &vm->entity, | ||
1249 | AMDGPU_FENCE_OWNER_VM, &fence); | ||
1250 | if (r) | ||
1251 | goto error; | ||
1252 | |||
1253 | amdgpu_bo_fence(root, fence, true); | ||
1254 | dma_fence_put(vm->last_update); | ||
1255 | vm->last_update = fence; | ||
1303 | } | 1256 | } |
1304 | 1257 | ||
1258 | if (!list_empty(&vm->relocated)) | ||
1259 | goto restart; | ||
1260 | |||
1261 | return 0; | ||
1262 | |||
1263 | error: | ||
1264 | amdgpu_vm_invalidate_level(adev, vm, &vm->root, | ||
1265 | adev->vm_manager.root_level); | ||
1266 | amdgpu_job_free(job); | ||
1305 | return r; | 1267 | return r; |
1306 | } | 1268 | } |
1307 | 1269 | ||
@@ -1319,19 +1281,19 @@ void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr, | |||
1319 | struct amdgpu_vm_pt **entry, | 1281 | struct amdgpu_vm_pt **entry, |
1320 | struct amdgpu_vm_pt **parent) | 1282 | struct amdgpu_vm_pt **parent) |
1321 | { | 1283 | { |
1322 | unsigned level = 0; | 1284 | unsigned level = p->adev->vm_manager.root_level; |
1323 | 1285 | ||
1324 | *parent = NULL; | 1286 | *parent = NULL; |
1325 | *entry = &p->vm->root; | 1287 | *entry = &p->vm->root; |
1326 | while ((*entry)->entries) { | 1288 | while ((*entry)->entries) { |
1327 | unsigned idx = addr >> amdgpu_vm_level_shift(p->adev, level++); | 1289 | unsigned shift = amdgpu_vm_level_shift(p->adev, level++); |
1328 | 1290 | ||
1329 | idx %= amdgpu_bo_size((*entry)->base.bo) / 8; | ||
1330 | *parent = *entry; | 1291 | *parent = *entry; |
1331 | *entry = &(*entry)->entries[idx]; | 1292 | *entry = &(*entry)->entries[addr >> shift]; |
1293 | addr &= (1ULL << shift) - 1; | ||
1332 | } | 1294 | } |
1333 | 1295 | ||
1334 | if (level != p->adev->vm_manager.num_level) | 1296 | if (level != AMDGPU_VM_PTB) |
1335 | *entry = NULL; | 1297 | *entry = NULL; |
1336 | } | 1298 | } |
1337 | 1299 | ||
@@ -1363,17 +1325,18 @@ static void amdgpu_vm_handle_huge_pages(struct amdgpu_pte_update_params *p, | |||
1363 | !(flags & AMDGPU_PTE_VALID)) { | 1325 | !(flags & AMDGPU_PTE_VALID)) { |
1364 | 1326 | ||
1365 | dst = amdgpu_bo_gpu_offset(entry->base.bo); | 1327 | dst = amdgpu_bo_gpu_offset(entry->base.bo); |
1366 | dst = amdgpu_gart_get_vm_pde(p->adev, dst); | ||
1367 | flags = AMDGPU_PTE_VALID; | 1328 | flags = AMDGPU_PTE_VALID; |
1368 | } else { | 1329 | } else { |
1369 | /* Set the huge page flag to stop scanning at this PDE */ | 1330 | /* Set the huge page flag to stop scanning at this PDE */ |
1370 | flags |= AMDGPU_PDE_PTE; | 1331 | flags |= AMDGPU_PDE_PTE; |
1371 | } | 1332 | } |
1372 | 1333 | ||
1373 | if (entry->addr == (dst | flags)) | 1334 | if (!entry->huge && !(flags & AMDGPU_PDE_PTE)) |
1374 | return; | 1335 | return; |
1336 | entry->huge = !!(flags & AMDGPU_PDE_PTE); | ||
1375 | 1337 | ||
1376 | entry->addr = (dst | flags); | 1338 | amdgpu_gart_get_vm_pde(p->adev, AMDGPU_VM_PDB0, |
1339 | &dst, &flags); | ||
1377 | 1340 | ||
1378 | if (use_cpu_update) { | 1341 | if (use_cpu_update) { |
1379 | /* In case a huge page is replaced with a system | 1342 | /* In case a huge page is replaced with a system |
@@ -1447,7 +1410,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, | |||
1447 | amdgpu_vm_handle_huge_pages(params, entry, parent, | 1410 | amdgpu_vm_handle_huge_pages(params, entry, parent, |
1448 | nptes, dst, flags); | 1411 | nptes, dst, flags); |
1449 | /* We don't need to update PTEs for huge pages */ | 1412 | /* We don't need to update PTEs for huge pages */ |
1450 | if (entry->addr & AMDGPU_PDE_PTE) | 1413 | if (entry->huge) |
1451 | continue; | 1414 | continue; |
1452 | 1415 | ||
1453 | pt = entry->base.bo; | 1416 | pt = entry->base.bo; |
@@ -1688,7 +1651,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, | |||
1688 | 1651 | ||
1689 | error_free: | 1652 | error_free: |
1690 | amdgpu_job_free(job); | 1653 | amdgpu_job_free(job); |
1691 | amdgpu_vm_invalidate_level(vm, &vm->root); | 1654 | amdgpu_vm_invalidate_level(adev, vm, &vm->root, |
1655 | adev->vm_manager.root_level); | ||
1692 | return r; | 1656 | return r; |
1693 | } | 1657 | } |
1694 | 1658 | ||
@@ -2604,7 +2568,19 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint32_t vm_size, | |||
2604 | tmp >>= amdgpu_vm_block_size - 9; | 2568 | tmp >>= amdgpu_vm_block_size - 9; |
2605 | tmp = DIV_ROUND_UP(fls64(tmp) - 1, 9) - 1; | 2569 | tmp = DIV_ROUND_UP(fls64(tmp) - 1, 9) - 1; |
2606 | adev->vm_manager.num_level = min(max_level, (unsigned)tmp); | 2570 | adev->vm_manager.num_level = min(max_level, (unsigned)tmp); |
2607 | 2571 | switch (adev->vm_manager.num_level) { | |
2572 | case 3: | ||
2573 | adev->vm_manager.root_level = AMDGPU_VM_PDB2; | ||
2574 | break; | ||
2575 | case 2: | ||
2576 | adev->vm_manager.root_level = AMDGPU_VM_PDB1; | ||
2577 | break; | ||
2578 | case 1: | ||
2579 | adev->vm_manager.root_level = AMDGPU_VM_PDB0; | ||
2580 | break; | ||
2581 | default: | ||
2582 | dev_err(adev->dev, "VMPT only supports 2~4+1 levels\n"); | ||
2583 | } | ||
2608 | /* block size depends on vm size and hw setup*/ | 2584 | /* block size depends on vm size and hw setup*/ |
2609 | if (amdgpu_vm_block_size != -1) | 2585 | if (amdgpu_vm_block_size != -1) |
2610 | adev->vm_manager.block_size = | 2586 | adev->vm_manager.block_size = |
@@ -2643,7 +2619,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2643 | AMDGPU_VM_PTE_COUNT(adev) * 8); | 2619 | AMDGPU_VM_PTE_COUNT(adev) * 8); |
2644 | unsigned ring_instance; | 2620 | unsigned ring_instance; |
2645 | struct amdgpu_ring *ring; | 2621 | struct amdgpu_ring *ring; |
2646 | struct amd_sched_rq *rq; | 2622 | struct drm_sched_rq *rq; |
2647 | int r, i; | 2623 | int r, i; |
2648 | u64 flags; | 2624 | u64 flags; |
2649 | uint64_t init_pde_value = 0; | 2625 | uint64_t init_pde_value = 0; |
@@ -2663,8 +2639,8 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2663 | ring_instance = atomic_inc_return(&adev->vm_manager.vm_pte_next_ring); | 2639 | ring_instance = atomic_inc_return(&adev->vm_manager.vm_pte_next_ring); |
2664 | ring_instance %= adev->vm_manager.vm_pte_num_rings; | 2640 | ring_instance %= adev->vm_manager.vm_pte_num_rings; |
2665 | ring = adev->vm_manager.vm_pte_rings[ring_instance]; | 2641 | ring = adev->vm_manager.vm_pte_rings[ring_instance]; |
2666 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL]; | 2642 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_KERNEL]; |
2667 | r = amd_sched_entity_init(&ring->sched, &vm->entity, | 2643 | r = drm_sched_entity_init(&ring->sched, &vm->entity, |
2668 | rq, amdgpu_sched_jobs, NULL); | 2644 | rq, amdgpu_sched_jobs, NULL); |
2669 | if (r) | 2645 | if (r) |
2670 | return r; | 2646 | return r; |
@@ -2698,7 +2674,9 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
2698 | flags |= (AMDGPU_GEM_CREATE_NO_CPU_ACCESS | | 2674 | flags |= (AMDGPU_GEM_CREATE_NO_CPU_ACCESS | |
2699 | AMDGPU_GEM_CREATE_SHADOW); | 2675 | AMDGPU_GEM_CREATE_SHADOW); |
2700 | 2676 | ||
2701 | r = amdgpu_bo_create(adev, amdgpu_vm_bo_size(adev, 0), align, true, | 2677 | r = amdgpu_bo_create(adev, |
2678 | amdgpu_vm_bo_size(adev, adev->vm_manager.root_level), | ||
2679 | align, true, | ||
2702 | AMDGPU_GEM_DOMAIN_VRAM, | 2680 | AMDGPU_GEM_DOMAIN_VRAM, |
2703 | flags, | 2681 | flags, |
2704 | NULL, NULL, init_pde_value, &vm->root.base.bo); | 2682 | NULL, NULL, init_pde_value, &vm->root.base.bo); |
@@ -2744,7 +2722,7 @@ error_free_root: | |||
2744 | vm->root.base.bo = NULL; | 2722 | vm->root.base.bo = NULL; |
2745 | 2723 | ||
2746 | error_free_sched_entity: | 2724 | error_free_sched_entity: |
2747 | amd_sched_entity_fini(&ring->sched, &vm->entity); | 2725 | drm_sched_entity_fini(&ring->sched, &vm->entity); |
2748 | 2726 | ||
2749 | return r; | 2727 | return r; |
2750 | } | 2728 | } |
@@ -2752,26 +2730,31 @@ error_free_sched_entity: | |||
2752 | /** | 2730 | /** |
2753 | * amdgpu_vm_free_levels - free PD/PT levels | 2731 | * amdgpu_vm_free_levels - free PD/PT levels |
2754 | * | 2732 | * |
2755 | * @level: PD/PT starting level to free | 2733 | * @adev: amdgpu device structure |
2734 | * @parent: PD/PT starting level to free | ||
2735 | * @level: level of parent structure | ||
2756 | * | 2736 | * |
2757 | * Free the page directory or page table level and all sub levels. | 2737 | * Free the page directory or page table level and all sub levels. |
2758 | */ | 2738 | */ |
2759 | static void amdgpu_vm_free_levels(struct amdgpu_vm_pt *level) | 2739 | static void amdgpu_vm_free_levels(struct amdgpu_device *adev, |
2740 | struct amdgpu_vm_pt *parent, | ||
2741 | unsigned level) | ||
2760 | { | 2742 | { |
2761 | unsigned i; | 2743 | unsigned i, num_entries = amdgpu_vm_num_entries(adev, level); |
2762 | 2744 | ||
2763 | if (level->base.bo) { | 2745 | if (parent->base.bo) { |
2764 | list_del(&level->base.bo_list); | 2746 | list_del(&parent->base.bo_list); |
2765 | list_del(&level->base.vm_status); | 2747 | list_del(&parent->base.vm_status); |
2766 | amdgpu_bo_unref(&level->base.bo->shadow); | 2748 | amdgpu_bo_unref(&parent->base.bo->shadow); |
2767 | amdgpu_bo_unref(&level->base.bo); | 2749 | amdgpu_bo_unref(&parent->base.bo); |
2768 | } | 2750 | } |
2769 | 2751 | ||
2770 | if (level->entries) | 2752 | if (parent->entries) |
2771 | for (i = 0; i <= level->last_entry_used; i++) | 2753 | for (i = 0; i < num_entries; i++) |
2772 | amdgpu_vm_free_levels(&level->entries[i]); | 2754 | amdgpu_vm_free_levels(adev, &parent->entries[i], |
2755 | level + 1); | ||
2773 | 2756 | ||
2774 | kvfree(level->entries); | 2757 | kvfree(parent->entries); |
2775 | } | 2758 | } |
2776 | 2759 | ||
2777 | /** | 2760 | /** |
@@ -2803,7 +2786,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
2803 | spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, flags); | 2786 | spin_unlock_irqrestore(&adev->vm_manager.pasid_lock, flags); |
2804 | } | 2787 | } |
2805 | 2788 | ||
2806 | amd_sched_entity_fini(vm->entity.sched, &vm->entity); | 2789 | drm_sched_entity_fini(vm->entity.sched, &vm->entity); |
2807 | 2790 | ||
2808 | if (!RB_EMPTY_ROOT(&vm->va.rb_root)) { | 2791 | if (!RB_EMPTY_ROOT(&vm->va.rb_root)) { |
2809 | dev_err(adev->dev, "still active bo inside vm\n"); | 2792 | dev_err(adev->dev, "still active bo inside vm\n"); |
@@ -2829,7 +2812,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
2829 | if (r) { | 2812 | if (r) { |
2830 | dev_err(adev->dev, "Leaking page tables because BO reservation failed\n"); | 2813 | dev_err(adev->dev, "Leaking page tables because BO reservation failed\n"); |
2831 | } else { | 2814 | } else { |
2832 | amdgpu_vm_free_levels(&vm->root); | 2815 | amdgpu_vm_free_levels(adev, &vm->root, |
2816 | adev->vm_manager.root_level); | ||
2833 | amdgpu_bo_unreserve(root); | 2817 | amdgpu_bo_unreserve(root); |
2834 | } | 2818 | } |
2835 | amdgpu_bo_unref(&root); | 2819 | amdgpu_bo_unref(&root); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h index 43ea131dd411..edd2ea52dc00 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | |||
@@ -24,10 +24,11 @@ | |||
24 | #ifndef __AMDGPU_VM_H__ | 24 | #ifndef __AMDGPU_VM_H__ |
25 | #define __AMDGPU_VM_H__ | 25 | #define __AMDGPU_VM_H__ |
26 | 26 | ||
27 | #include <linux/rbtree.h> | ||
28 | #include <linux/idr.h> | 27 | #include <linux/idr.h> |
28 | #include <linux/kfifo.h> | ||
29 | #include <linux/rbtree.h> | ||
30 | #include <drm/gpu_scheduler.h> | ||
29 | 31 | ||
30 | #include "gpu_scheduler.h" | ||
31 | #include "amdgpu_sync.h" | 32 | #include "amdgpu_sync.h" |
32 | #include "amdgpu_ring.h" | 33 | #include "amdgpu_ring.h" |
33 | 34 | ||
@@ -69,6 +70,12 @@ struct amdgpu_bo_list_entry; | |||
69 | /* PDE is handled as PTE for VEGA10 */ | 70 | /* PDE is handled as PTE for VEGA10 */ |
70 | #define AMDGPU_PDE_PTE (1ULL << 54) | 71 | #define AMDGPU_PDE_PTE (1ULL << 54) |
71 | 72 | ||
73 | /* PTE is handled as PDE for VEGA10 (Translate Further) */ | ||
74 | #define AMDGPU_PTE_TF (1ULL << 56) | ||
75 | |||
76 | /* PDE Block Fragment Size for VEGA10 */ | ||
77 | #define AMDGPU_PDE_BFS(a) ((uint64_t)a << 59) | ||
78 | |||
72 | /* VEGA10 only */ | 79 | /* VEGA10 only */ |
73 | #define AMDGPU_PTE_MTYPE(a) ((uint64_t)a << 57) | 80 | #define AMDGPU_PTE_MTYPE(a) ((uint64_t)a << 57) |
74 | #define AMDGPU_PTE_MTYPE_MASK AMDGPU_PTE_MTYPE(3ULL) | 81 | #define AMDGPU_PTE_MTYPE_MASK AMDGPU_PTE_MTYPE(3ULL) |
@@ -119,6 +126,16 @@ struct amdgpu_bo_list_entry; | |||
119 | #define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0) | 126 | #define AMDGPU_VM_USE_CPU_FOR_GFX (1 << 0) |
120 | #define AMDGPU_VM_USE_CPU_FOR_COMPUTE (1 << 1) | 127 | #define AMDGPU_VM_USE_CPU_FOR_COMPUTE (1 << 1) |
121 | 128 | ||
129 | /* VMPT level enumerate, and the hiberachy is: | ||
130 | * PDB2->PDB1->PDB0->PTB | ||
131 | */ | ||
132 | enum amdgpu_vm_level { | ||
133 | AMDGPU_VM_PDB2, | ||
134 | AMDGPU_VM_PDB1, | ||
135 | AMDGPU_VM_PDB0, | ||
136 | AMDGPU_VM_PTB | ||
137 | }; | ||
138 | |||
122 | /* base structure for tracking BO usage in a VM */ | 139 | /* base structure for tracking BO usage in a VM */ |
123 | struct amdgpu_vm_bo_base { | 140 | struct amdgpu_vm_bo_base { |
124 | /* constant after initialization */ | 141 | /* constant after initialization */ |
@@ -137,11 +154,10 @@ struct amdgpu_vm_bo_base { | |||
137 | 154 | ||
138 | struct amdgpu_vm_pt { | 155 | struct amdgpu_vm_pt { |
139 | struct amdgpu_vm_bo_base base; | 156 | struct amdgpu_vm_bo_base base; |
140 | uint64_t addr; | 157 | bool huge; |
141 | 158 | ||
142 | /* array of page tables, one for each directory entry */ | 159 | /* array of page tables, one for each directory entry */ |
143 | struct amdgpu_vm_pt *entries; | 160 | struct amdgpu_vm_pt *entries; |
144 | unsigned last_entry_used; | ||
145 | }; | 161 | }; |
146 | 162 | ||
147 | #define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr)) | 163 | #define AMDGPU_VM_FAULT(pasid, addr) (((u64)(pasid) << 48) | (addr)) |
@@ -175,7 +191,7 @@ struct amdgpu_vm { | |||
175 | spinlock_t freed_lock; | 191 | spinlock_t freed_lock; |
176 | 192 | ||
177 | /* Scheduler entity for page table updates */ | 193 | /* Scheduler entity for page table updates */ |
178 | struct amd_sched_entity entity; | 194 | struct drm_sched_entity entity; |
179 | 195 | ||
180 | /* client id and PASID (TODO: replace client_id with PASID) */ | 196 | /* client id and PASID (TODO: replace client_id with PASID) */ |
181 | u64 client_id; | 197 | u64 client_id; |
@@ -236,6 +252,7 @@ struct amdgpu_vm_manager { | |||
236 | uint32_t num_level; | 252 | uint32_t num_level; |
237 | uint32_t block_size; | 253 | uint32_t block_size; |
238 | uint32_t fragment_size; | 254 | uint32_t fragment_size; |
255 | enum amdgpu_vm_level root_level; | ||
239 | /* vram base address for page table entry */ | 256 | /* vram base address for page table entry */ |
240 | u64 vram_base_offset; | 257 | u64 vram_base_offset; |
241 | /* vm pte handling */ | 258 | /* vm pte handling */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index f11c0aacf19f..a0943aa8d1d3 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
@@ -891,12 +891,12 @@ static void ci_dpm_powergate_uvd(void *handle, bool gate) | |||
891 | 891 | ||
892 | if (gate) { | 892 | if (gate) { |
893 | /* stop the UVD block */ | 893 | /* stop the UVD block */ |
894 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 894 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
895 | AMD_PG_STATE_GATE); | 895 | AMD_PG_STATE_GATE); |
896 | ci_update_uvd_dpm(adev, gate); | 896 | ci_update_uvd_dpm(adev, gate); |
897 | } else { | 897 | } else { |
898 | amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 898 | amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
899 | AMD_PG_STATE_UNGATE); | 899 | AMD_PG_STATE_UNGATE); |
900 | ci_update_uvd_dpm(adev, gate); | 900 | ci_update_uvd_dpm(adev, gate); |
901 | } | 901 | } |
902 | } | 902 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index 8ba056a2a5da..8e59e65efd44 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -755,74 +755,74 @@ static void cik_init_golden_registers(struct amdgpu_device *adev) | |||
755 | 755 | ||
756 | switch (adev->asic_type) { | 756 | switch (adev->asic_type) { |
757 | case CHIP_BONAIRE: | 757 | case CHIP_BONAIRE: |
758 | amdgpu_program_register_sequence(adev, | 758 | amdgpu_device_program_register_sequence(adev, |
759 | bonaire_mgcg_cgcg_init, | 759 | bonaire_mgcg_cgcg_init, |
760 | ARRAY_SIZE(bonaire_mgcg_cgcg_init)); | 760 | ARRAY_SIZE(bonaire_mgcg_cgcg_init)); |
761 | amdgpu_program_register_sequence(adev, | 761 | amdgpu_device_program_register_sequence(adev, |
762 | bonaire_golden_registers, | 762 | bonaire_golden_registers, |
763 | ARRAY_SIZE(bonaire_golden_registers)); | 763 | ARRAY_SIZE(bonaire_golden_registers)); |
764 | amdgpu_program_register_sequence(adev, | 764 | amdgpu_device_program_register_sequence(adev, |
765 | bonaire_golden_common_registers, | 765 | bonaire_golden_common_registers, |
766 | ARRAY_SIZE(bonaire_golden_common_registers)); | 766 | ARRAY_SIZE(bonaire_golden_common_registers)); |
767 | amdgpu_program_register_sequence(adev, | 767 | amdgpu_device_program_register_sequence(adev, |
768 | bonaire_golden_spm_registers, | 768 | bonaire_golden_spm_registers, |
769 | ARRAY_SIZE(bonaire_golden_spm_registers)); | 769 | ARRAY_SIZE(bonaire_golden_spm_registers)); |
770 | break; | 770 | break; |
771 | case CHIP_KABINI: | 771 | case CHIP_KABINI: |
772 | amdgpu_program_register_sequence(adev, | 772 | amdgpu_device_program_register_sequence(adev, |
773 | kalindi_mgcg_cgcg_init, | 773 | kalindi_mgcg_cgcg_init, |
774 | ARRAY_SIZE(kalindi_mgcg_cgcg_init)); | 774 | ARRAY_SIZE(kalindi_mgcg_cgcg_init)); |
775 | amdgpu_program_register_sequence(adev, | 775 | amdgpu_device_program_register_sequence(adev, |
776 | kalindi_golden_registers, | 776 | kalindi_golden_registers, |
777 | ARRAY_SIZE(kalindi_golden_registers)); | 777 | ARRAY_SIZE(kalindi_golden_registers)); |
778 | amdgpu_program_register_sequence(adev, | 778 | amdgpu_device_program_register_sequence(adev, |
779 | kalindi_golden_common_registers, | 779 | kalindi_golden_common_registers, |
780 | ARRAY_SIZE(kalindi_golden_common_registers)); | 780 | ARRAY_SIZE(kalindi_golden_common_registers)); |
781 | amdgpu_program_register_sequence(adev, | 781 | amdgpu_device_program_register_sequence(adev, |
782 | kalindi_golden_spm_registers, | 782 | kalindi_golden_spm_registers, |
783 | ARRAY_SIZE(kalindi_golden_spm_registers)); | 783 | ARRAY_SIZE(kalindi_golden_spm_registers)); |
784 | break; | 784 | break; |
785 | case CHIP_MULLINS: | 785 | case CHIP_MULLINS: |
786 | amdgpu_program_register_sequence(adev, | 786 | amdgpu_device_program_register_sequence(adev, |
787 | kalindi_mgcg_cgcg_init, | 787 | kalindi_mgcg_cgcg_init, |
788 | ARRAY_SIZE(kalindi_mgcg_cgcg_init)); | 788 | ARRAY_SIZE(kalindi_mgcg_cgcg_init)); |
789 | amdgpu_program_register_sequence(adev, | 789 | amdgpu_device_program_register_sequence(adev, |
790 | godavari_golden_registers, | 790 | godavari_golden_registers, |
791 | ARRAY_SIZE(godavari_golden_registers)); | 791 | ARRAY_SIZE(godavari_golden_registers)); |
792 | amdgpu_program_register_sequence(adev, | 792 | amdgpu_device_program_register_sequence(adev, |
793 | kalindi_golden_common_registers, | 793 | kalindi_golden_common_registers, |
794 | ARRAY_SIZE(kalindi_golden_common_registers)); | 794 | ARRAY_SIZE(kalindi_golden_common_registers)); |
795 | amdgpu_program_register_sequence(adev, | 795 | amdgpu_device_program_register_sequence(adev, |
796 | kalindi_golden_spm_registers, | 796 | kalindi_golden_spm_registers, |
797 | ARRAY_SIZE(kalindi_golden_spm_registers)); | 797 | ARRAY_SIZE(kalindi_golden_spm_registers)); |
798 | break; | 798 | break; |
799 | case CHIP_KAVERI: | 799 | case CHIP_KAVERI: |
800 | amdgpu_program_register_sequence(adev, | 800 | amdgpu_device_program_register_sequence(adev, |
801 | spectre_mgcg_cgcg_init, | 801 | spectre_mgcg_cgcg_init, |
802 | ARRAY_SIZE(spectre_mgcg_cgcg_init)); | 802 | ARRAY_SIZE(spectre_mgcg_cgcg_init)); |
803 | amdgpu_program_register_sequence(adev, | 803 | amdgpu_device_program_register_sequence(adev, |
804 | spectre_golden_registers, | 804 | spectre_golden_registers, |
805 | ARRAY_SIZE(spectre_golden_registers)); | 805 | ARRAY_SIZE(spectre_golden_registers)); |
806 | amdgpu_program_register_sequence(adev, | 806 | amdgpu_device_program_register_sequence(adev, |
807 | spectre_golden_common_registers, | 807 | spectre_golden_common_registers, |
808 | ARRAY_SIZE(spectre_golden_common_registers)); | 808 | ARRAY_SIZE(spectre_golden_common_registers)); |
809 | amdgpu_program_register_sequence(adev, | 809 | amdgpu_device_program_register_sequence(adev, |
810 | spectre_golden_spm_registers, | 810 | spectre_golden_spm_registers, |
811 | ARRAY_SIZE(spectre_golden_spm_registers)); | 811 | ARRAY_SIZE(spectre_golden_spm_registers)); |
812 | break; | 812 | break; |
813 | case CHIP_HAWAII: | 813 | case CHIP_HAWAII: |
814 | amdgpu_program_register_sequence(adev, | 814 | amdgpu_device_program_register_sequence(adev, |
815 | hawaii_mgcg_cgcg_init, | 815 | hawaii_mgcg_cgcg_init, |
816 | ARRAY_SIZE(hawaii_mgcg_cgcg_init)); | 816 | ARRAY_SIZE(hawaii_mgcg_cgcg_init)); |
817 | amdgpu_program_register_sequence(adev, | 817 | amdgpu_device_program_register_sequence(adev, |
818 | hawaii_golden_registers, | 818 | hawaii_golden_registers, |
819 | ARRAY_SIZE(hawaii_golden_registers)); | 819 | ARRAY_SIZE(hawaii_golden_registers)); |
820 | amdgpu_program_register_sequence(adev, | 820 | amdgpu_device_program_register_sequence(adev, |
821 | hawaii_golden_common_registers, | 821 | hawaii_golden_common_registers, |
822 | ARRAY_SIZE(hawaii_golden_common_registers)); | 822 | ARRAY_SIZE(hawaii_golden_common_registers)); |
823 | amdgpu_program_register_sequence(adev, | 823 | amdgpu_device_program_register_sequence(adev, |
824 | hawaii_golden_spm_registers, | 824 | hawaii_golden_spm_registers, |
825 | ARRAY_SIZE(hawaii_golden_spm_registers)); | 825 | ARRAY_SIZE(hawaii_golden_spm_registers)); |
826 | break; | 826 | break; |
827 | default: | 827 | default: |
828 | break; | 828 | break; |
@@ -1246,7 +1246,7 @@ static int cik_gpu_pci_config_reset(struct amdgpu_device *adev) | |||
1246 | /* disable BM */ | 1246 | /* disable BM */ |
1247 | pci_clear_master(adev->pdev); | 1247 | pci_clear_master(adev->pdev); |
1248 | /* reset */ | 1248 | /* reset */ |
1249 | amdgpu_pci_config_reset(adev); | 1249 | amdgpu_device_pci_config_reset(adev); |
1250 | 1250 | ||
1251 | udelay(100); | 1251 | udelay(100); |
1252 | 1252 | ||
@@ -1866,7 +1866,7 @@ static int cik_common_early_init(void *handle) | |||
1866 | 1866 | ||
1867 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); | 1867 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); |
1868 | 1868 | ||
1869 | amdgpu_get_pcie_info(adev); | 1869 | amdgpu_device_get_pcie_info(adev); |
1870 | 1870 | ||
1871 | return 0; | 1871 | return 0; |
1872 | } | 1872 | } |
@@ -1974,77 +1974,77 @@ int cik_set_ip_blocks(struct amdgpu_device *adev) | |||
1974 | 1974 | ||
1975 | switch (adev->asic_type) { | 1975 | switch (adev->asic_type) { |
1976 | case CHIP_BONAIRE: | 1976 | case CHIP_BONAIRE: |
1977 | amdgpu_ip_block_add(adev, &cik_common_ip_block); | 1977 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
1978 | amdgpu_ip_block_add(adev, &gmc_v7_0_ip_block); | 1978 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
1979 | amdgpu_ip_block_add(adev, &cik_ih_ip_block); | 1979 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); |
1980 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1980 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1981 | if (adev->enable_virtual_display) | 1981 | if (adev->enable_virtual_display) |
1982 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1982 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1983 | #if defined(CONFIG_DRM_AMD_DC) | 1983 | #if defined(CONFIG_DRM_AMD_DC) |
1984 | else if (amdgpu_device_has_dc_support(adev)) | 1984 | else if (amdgpu_device_has_dc_support(adev)) |
1985 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1985 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1986 | #endif | 1986 | #endif |
1987 | else | 1987 | else |
1988 | amdgpu_ip_block_add(adev, &dce_v8_2_ip_block); | 1988 | amdgpu_device_ip_block_add(adev, &dce_v8_2_ip_block); |
1989 | amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block); | 1989 | amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); |
1990 | amdgpu_ip_block_add(adev, &cik_sdma_ip_block); | 1990 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); |
1991 | amdgpu_ip_block_add(adev, &uvd_v4_2_ip_block); | 1991 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
1992 | amdgpu_ip_block_add(adev, &vce_v2_0_ip_block); | 1992 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
1993 | break; | 1993 | break; |
1994 | case CHIP_HAWAII: | 1994 | case CHIP_HAWAII: |
1995 | amdgpu_ip_block_add(adev, &cik_common_ip_block); | 1995 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
1996 | amdgpu_ip_block_add(adev, &gmc_v7_0_ip_block); | 1996 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
1997 | amdgpu_ip_block_add(adev, &cik_ih_ip_block); | 1997 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); |
1998 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1998 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1999 | if (adev->enable_virtual_display) | 1999 | if (adev->enable_virtual_display) |
2000 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 2000 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2001 | #if defined(CONFIG_DRM_AMD_DC) | 2001 | #if defined(CONFIG_DRM_AMD_DC) |
2002 | else if (amdgpu_device_has_dc_support(adev)) | 2002 | else if (amdgpu_device_has_dc_support(adev)) |
2003 | amdgpu_ip_block_add(adev, &dm_ip_block); | 2003 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
2004 | #endif | 2004 | #endif |
2005 | else | 2005 | else |
2006 | amdgpu_ip_block_add(adev, &dce_v8_5_ip_block); | 2006 | amdgpu_device_ip_block_add(adev, &dce_v8_5_ip_block); |
2007 | amdgpu_ip_block_add(adev, &gfx_v7_3_ip_block); | 2007 | amdgpu_device_ip_block_add(adev, &gfx_v7_3_ip_block); |
2008 | amdgpu_ip_block_add(adev, &cik_sdma_ip_block); | 2008 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); |
2009 | amdgpu_ip_block_add(adev, &uvd_v4_2_ip_block); | 2009 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2010 | amdgpu_ip_block_add(adev, &vce_v2_0_ip_block); | 2010 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2011 | break; | 2011 | break; |
2012 | case CHIP_KAVERI: | 2012 | case CHIP_KAVERI: |
2013 | amdgpu_ip_block_add(adev, &cik_common_ip_block); | 2013 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2014 | amdgpu_ip_block_add(adev, &gmc_v7_0_ip_block); | 2014 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2015 | amdgpu_ip_block_add(adev, &cik_ih_ip_block); | 2015 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); |
2016 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 2016 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
2017 | if (adev->enable_virtual_display) | 2017 | if (adev->enable_virtual_display) |
2018 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 2018 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2019 | #if defined(CONFIG_DRM_AMD_DC) | 2019 | #if defined(CONFIG_DRM_AMD_DC) |
2020 | else if (amdgpu_device_has_dc_support(adev)) | 2020 | else if (amdgpu_device_has_dc_support(adev)) |
2021 | amdgpu_ip_block_add(adev, &dm_ip_block); | 2021 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
2022 | #endif | 2022 | #endif |
2023 | else | 2023 | else |
2024 | amdgpu_ip_block_add(adev, &dce_v8_1_ip_block); | 2024 | amdgpu_device_ip_block_add(adev, &dce_v8_1_ip_block); |
2025 | amdgpu_ip_block_add(adev, &gfx_v7_1_ip_block); | 2025 | amdgpu_device_ip_block_add(adev, &gfx_v7_1_ip_block); |
2026 | amdgpu_ip_block_add(adev, &cik_sdma_ip_block); | 2026 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); |
2027 | amdgpu_ip_block_add(adev, &uvd_v4_2_ip_block); | 2027 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2028 | amdgpu_ip_block_add(adev, &vce_v2_0_ip_block); | 2028 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2029 | break; | 2029 | break; |
2030 | case CHIP_KABINI: | 2030 | case CHIP_KABINI: |
2031 | case CHIP_MULLINS: | 2031 | case CHIP_MULLINS: |
2032 | amdgpu_ip_block_add(adev, &cik_common_ip_block); | 2032 | amdgpu_device_ip_block_add(adev, &cik_common_ip_block); |
2033 | amdgpu_ip_block_add(adev, &gmc_v7_0_ip_block); | 2033 | amdgpu_device_ip_block_add(adev, &gmc_v7_0_ip_block); |
2034 | amdgpu_ip_block_add(adev, &cik_ih_ip_block); | 2034 | amdgpu_device_ip_block_add(adev, &cik_ih_ip_block); |
2035 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 2035 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
2036 | if (adev->enable_virtual_display) | 2036 | if (adev->enable_virtual_display) |
2037 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 2037 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
2038 | #if defined(CONFIG_DRM_AMD_DC) | 2038 | #if defined(CONFIG_DRM_AMD_DC) |
2039 | else if (amdgpu_device_has_dc_support(adev)) | 2039 | else if (amdgpu_device_has_dc_support(adev)) |
2040 | amdgpu_ip_block_add(adev, &dm_ip_block); | 2040 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
2041 | #endif | 2041 | #endif |
2042 | else | 2042 | else |
2043 | amdgpu_ip_block_add(adev, &dce_v8_3_ip_block); | 2043 | amdgpu_device_ip_block_add(adev, &dce_v8_3_ip_block); |
2044 | amdgpu_ip_block_add(adev, &gfx_v7_2_ip_block); | 2044 | amdgpu_device_ip_block_add(adev, &gfx_v7_2_ip_block); |
2045 | amdgpu_ip_block_add(adev, &cik_sdma_ip_block); | 2045 | amdgpu_device_ip_block_add(adev, &cik_sdma_ip_block); |
2046 | amdgpu_ip_block_add(adev, &uvd_v4_2_ip_block); | 2046 | amdgpu_device_ip_block_add(adev, &uvd_v4_2_ip_block); |
2047 | amdgpu_ip_block_add(adev, &vce_v2_0_ip_block); | 2047 | amdgpu_device_ip_block_add(adev, &vce_v2_0_ip_block); |
2048 | break; | 2048 | break; |
2049 | default: | 2049 | default: |
2050 | /* FIXME: not supported yet */ | 2050 | /* FIXME: not supported yet */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c index ed26dcbc4f79..e406c93d01d6 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c | |||
@@ -626,7 +626,7 @@ static int cik_sdma_ring_test_ring(struct amdgpu_ring *ring) | |||
626 | u32 tmp; | 626 | u32 tmp; |
627 | u64 gpu_addr; | 627 | u64 gpu_addr; |
628 | 628 | ||
629 | r = amdgpu_wb_get(adev, &index); | 629 | r = amdgpu_device_wb_get(adev, &index); |
630 | if (r) { | 630 | if (r) { |
631 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | 631 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); |
632 | return r; | 632 | return r; |
@@ -639,7 +639,7 @@ static int cik_sdma_ring_test_ring(struct amdgpu_ring *ring) | |||
639 | r = amdgpu_ring_alloc(ring, 5); | 639 | r = amdgpu_ring_alloc(ring, 5); |
640 | if (r) { | 640 | if (r) { |
641 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | 641 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); |
642 | amdgpu_wb_free(adev, index); | 642 | amdgpu_device_wb_free(adev, index); |
643 | return r; | 643 | return r; |
644 | } | 644 | } |
645 | amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0)); | 645 | amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0)); |
@@ -663,7 +663,7 @@ static int cik_sdma_ring_test_ring(struct amdgpu_ring *ring) | |||
663 | ring->idx, tmp); | 663 | ring->idx, tmp); |
664 | r = -EINVAL; | 664 | r = -EINVAL; |
665 | } | 665 | } |
666 | amdgpu_wb_free(adev, index); | 666 | amdgpu_device_wb_free(adev, index); |
667 | 667 | ||
668 | return r; | 668 | return r; |
669 | } | 669 | } |
@@ -686,7 +686,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
686 | u64 gpu_addr; | 686 | u64 gpu_addr; |
687 | long r; | 687 | long r; |
688 | 688 | ||
689 | r = amdgpu_wb_get(adev, &index); | 689 | r = amdgpu_device_wb_get(adev, &index); |
690 | if (r) { | 690 | if (r) { |
691 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | 691 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); |
692 | return r; | 692 | return r; |
@@ -735,7 +735,7 @@ err1: | |||
735 | amdgpu_ib_free(adev, &ib, NULL); | 735 | amdgpu_ib_free(adev, &ib, NULL); |
736 | dma_fence_put(f); | 736 | dma_fence_put(f); |
737 | err0: | 737 | err0: |
738 | amdgpu_wb_free(adev, index); | 738 | amdgpu_device_wb_free(adev, index); |
739 | return r; | 739 | return r; |
740 | } | 740 | } |
741 | 741 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h b/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h index 003a131bad47..567a904804bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h +++ b/drivers/gpu/drm/amd/amdgpu/clearstate_gfx9.h | |||
@@ -48,7 +48,7 @@ static const unsigned int gfx9_SECT_CONTEXT_def_1[] = | |||
48 | 0x00000000, // DB_STENCIL_WRITE_BASE | 48 | 0x00000000, // DB_STENCIL_WRITE_BASE |
49 | 0x00000000, // DB_STENCIL_WRITE_BASE_HI | 49 | 0x00000000, // DB_STENCIL_WRITE_BASE_HI |
50 | 0x00000000, // DB_DFSM_CONTROL | 50 | 0x00000000, // DB_DFSM_CONTROL |
51 | 0x00000000, // DB_RENDER_FILTER | 51 | 0, // HOLE |
52 | 0x00000000, // DB_Z_INFO2 | 52 | 0x00000000, // DB_Z_INFO2 |
53 | 0x00000000, // DB_STENCIL_INFO2 | 53 | 0x00000000, // DB_STENCIL_INFO2 |
54 | 0, // HOLE | 54 | 0, // HOLE |
@@ -259,8 +259,8 @@ static const unsigned int gfx9_SECT_CONTEXT_def_2[] = | |||
259 | 0x00000000, // PA_SC_RIGHT_VERT_GRID | 259 | 0x00000000, // PA_SC_RIGHT_VERT_GRID |
260 | 0x00000000, // PA_SC_LEFT_VERT_GRID | 260 | 0x00000000, // PA_SC_LEFT_VERT_GRID |
261 | 0x00000000, // PA_SC_HORIZ_GRID | 261 | 0x00000000, // PA_SC_HORIZ_GRID |
262 | 0x00000000, // PA_SC_FOV_WINDOW_LR | 262 | 0, // HOLE |
263 | 0x00000000, // PA_SC_FOV_WINDOW_TB | 263 | 0, // HOLE |
264 | 0, // HOLE | 264 | 0, // HOLE |
265 | 0, // HOLE | 265 | 0, // HOLE |
266 | 0, // HOLE | 266 | 0, // HOLE |
@@ -701,7 +701,7 @@ static const unsigned int gfx9_SECT_CONTEXT_def_7[] = | |||
701 | { | 701 | { |
702 | 0x00000000, // VGT_GS_MAX_PRIMS_PER_SUBGROUP | 702 | 0x00000000, // VGT_GS_MAX_PRIMS_PER_SUBGROUP |
703 | 0x00000000, // VGT_DRAW_PAYLOAD_CNTL | 703 | 0x00000000, // VGT_DRAW_PAYLOAD_CNTL |
704 | 0x00000000, // VGT_INDEX_PAYLOAD_CNTL | 704 | 0, // HOLE |
705 | 0x00000000, // VGT_INSTANCE_STEP_RATE_0 | 705 | 0x00000000, // VGT_INSTANCE_STEP_RATE_0 |
706 | 0x00000000, // VGT_INSTANCE_STEP_RATE_1 | 706 | 0x00000000, // VGT_INSTANCE_STEP_RATE_1 |
707 | 0, // HOLE | 707 | 0, // HOLE |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index a397111c2ced..f34bc68aadfb 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | |||
@@ -145,20 +145,20 @@ static void dce_v10_0_init_golden_registers(struct amdgpu_device *adev) | |||
145 | { | 145 | { |
146 | switch (adev->asic_type) { | 146 | switch (adev->asic_type) { |
147 | case CHIP_FIJI: | 147 | case CHIP_FIJI: |
148 | amdgpu_program_register_sequence(adev, | 148 | amdgpu_device_program_register_sequence(adev, |
149 | fiji_mgcg_cgcg_init, | 149 | fiji_mgcg_cgcg_init, |
150 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); | 150 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
151 | amdgpu_program_register_sequence(adev, | 151 | amdgpu_device_program_register_sequence(adev, |
152 | golden_settings_fiji_a10, | 152 | golden_settings_fiji_a10, |
153 | ARRAY_SIZE(golden_settings_fiji_a10)); | 153 | ARRAY_SIZE(golden_settings_fiji_a10)); |
154 | break; | 154 | break; |
155 | case CHIP_TONGA: | 155 | case CHIP_TONGA: |
156 | amdgpu_program_register_sequence(adev, | 156 | amdgpu_device_program_register_sequence(adev, |
157 | tonga_mgcg_cgcg_init, | 157 | tonga_mgcg_cgcg_init, |
158 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); | 158 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
159 | amdgpu_program_register_sequence(adev, | 159 | amdgpu_device_program_register_sequence(adev, |
160 | golden_settings_tonga_a11, | 160 | golden_settings_tonga_a11, |
161 | ARRAY_SIZE(golden_settings_tonga_a11)); | 161 | ARRAY_SIZE(golden_settings_tonga_a11)); |
162 | break; | 162 | break; |
163 | default: | 163 | default: |
164 | break; | 164 | break; |
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 67e670989e81..26378bd6aba4 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | |||
@@ -154,28 +154,28 @@ static void dce_v11_0_init_golden_registers(struct amdgpu_device *adev) | |||
154 | { | 154 | { |
155 | switch (adev->asic_type) { | 155 | switch (adev->asic_type) { |
156 | case CHIP_CARRIZO: | 156 | case CHIP_CARRIZO: |
157 | amdgpu_program_register_sequence(adev, | 157 | amdgpu_device_program_register_sequence(adev, |
158 | cz_mgcg_cgcg_init, | 158 | cz_mgcg_cgcg_init, |
159 | ARRAY_SIZE(cz_mgcg_cgcg_init)); | 159 | ARRAY_SIZE(cz_mgcg_cgcg_init)); |
160 | amdgpu_program_register_sequence(adev, | 160 | amdgpu_device_program_register_sequence(adev, |
161 | cz_golden_settings_a11, | 161 | cz_golden_settings_a11, |
162 | ARRAY_SIZE(cz_golden_settings_a11)); | 162 | ARRAY_SIZE(cz_golden_settings_a11)); |
163 | break; | 163 | break; |
164 | case CHIP_STONEY: | 164 | case CHIP_STONEY: |
165 | amdgpu_program_register_sequence(adev, | 165 | amdgpu_device_program_register_sequence(adev, |
166 | stoney_golden_settings_a11, | 166 | stoney_golden_settings_a11, |
167 | ARRAY_SIZE(stoney_golden_settings_a11)); | 167 | ARRAY_SIZE(stoney_golden_settings_a11)); |
168 | break; | 168 | break; |
169 | case CHIP_POLARIS11: | 169 | case CHIP_POLARIS11: |
170 | case CHIP_POLARIS12: | 170 | case CHIP_POLARIS12: |
171 | amdgpu_program_register_sequence(adev, | 171 | amdgpu_device_program_register_sequence(adev, |
172 | polaris11_golden_settings_a11, | 172 | polaris11_golden_settings_a11, |
173 | ARRAY_SIZE(polaris11_golden_settings_a11)); | 173 | ARRAY_SIZE(polaris11_golden_settings_a11)); |
174 | break; | 174 | break; |
175 | case CHIP_POLARIS10: | 175 | case CHIP_POLARIS10: |
176 | amdgpu_program_register_sequence(adev, | 176 | amdgpu_device_program_register_sequence(adev, |
177 | polaris10_golden_settings_a11, | 177 | polaris10_golden_settings_a11, |
178 | ARRAY_SIZE(polaris10_golden_settings_a11)); | 178 | ARRAY_SIZE(polaris10_golden_settings_a11)); |
179 | break; | 179 | break; |
180 | default: | 180 | default: |
181 | break; | 181 | break; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index d02493cf9175..46550b588982 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | |||
@@ -679,55 +679,55 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev) | |||
679 | { | 679 | { |
680 | switch (adev->asic_type) { | 680 | switch (adev->asic_type) { |
681 | case CHIP_TOPAZ: | 681 | case CHIP_TOPAZ: |
682 | amdgpu_program_register_sequence(adev, | 682 | amdgpu_device_program_register_sequence(adev, |
683 | iceland_mgcg_cgcg_init, | 683 | iceland_mgcg_cgcg_init, |
684 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); | 684 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); |
685 | amdgpu_program_register_sequence(adev, | 685 | amdgpu_device_program_register_sequence(adev, |
686 | golden_settings_iceland_a11, | 686 | golden_settings_iceland_a11, |
687 | ARRAY_SIZE(golden_settings_iceland_a11)); | 687 | ARRAY_SIZE(golden_settings_iceland_a11)); |
688 | amdgpu_program_register_sequence(adev, | 688 | amdgpu_device_program_register_sequence(adev, |
689 | iceland_golden_common_all, | 689 | iceland_golden_common_all, |
690 | ARRAY_SIZE(iceland_golden_common_all)); | 690 | ARRAY_SIZE(iceland_golden_common_all)); |
691 | break; | 691 | break; |
692 | case CHIP_FIJI: | 692 | case CHIP_FIJI: |
693 | amdgpu_program_register_sequence(adev, | 693 | amdgpu_device_program_register_sequence(adev, |
694 | fiji_mgcg_cgcg_init, | 694 | fiji_mgcg_cgcg_init, |
695 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); | 695 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
696 | amdgpu_program_register_sequence(adev, | 696 | amdgpu_device_program_register_sequence(adev, |
697 | golden_settings_fiji_a10, | 697 | golden_settings_fiji_a10, |
698 | ARRAY_SIZE(golden_settings_fiji_a10)); | 698 | ARRAY_SIZE(golden_settings_fiji_a10)); |
699 | amdgpu_program_register_sequence(adev, | 699 | amdgpu_device_program_register_sequence(adev, |
700 | fiji_golden_common_all, | 700 | fiji_golden_common_all, |
701 | ARRAY_SIZE(fiji_golden_common_all)); | 701 | ARRAY_SIZE(fiji_golden_common_all)); |
702 | break; | 702 | break; |
703 | 703 | ||
704 | case CHIP_TONGA: | 704 | case CHIP_TONGA: |
705 | amdgpu_program_register_sequence(adev, | 705 | amdgpu_device_program_register_sequence(adev, |
706 | tonga_mgcg_cgcg_init, | 706 | tonga_mgcg_cgcg_init, |
707 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); | 707 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
708 | amdgpu_program_register_sequence(adev, | 708 | amdgpu_device_program_register_sequence(adev, |
709 | golden_settings_tonga_a11, | 709 | golden_settings_tonga_a11, |
710 | ARRAY_SIZE(golden_settings_tonga_a11)); | 710 | ARRAY_SIZE(golden_settings_tonga_a11)); |
711 | amdgpu_program_register_sequence(adev, | 711 | amdgpu_device_program_register_sequence(adev, |
712 | tonga_golden_common_all, | 712 | tonga_golden_common_all, |
713 | ARRAY_SIZE(tonga_golden_common_all)); | 713 | ARRAY_SIZE(tonga_golden_common_all)); |
714 | break; | 714 | break; |
715 | case CHIP_POLARIS11: | 715 | case CHIP_POLARIS11: |
716 | case CHIP_POLARIS12: | 716 | case CHIP_POLARIS12: |
717 | amdgpu_program_register_sequence(adev, | 717 | amdgpu_device_program_register_sequence(adev, |
718 | golden_settings_polaris11_a11, | 718 | golden_settings_polaris11_a11, |
719 | ARRAY_SIZE(golden_settings_polaris11_a11)); | 719 | ARRAY_SIZE(golden_settings_polaris11_a11)); |
720 | amdgpu_program_register_sequence(adev, | 720 | amdgpu_device_program_register_sequence(adev, |
721 | polaris11_golden_common_all, | 721 | polaris11_golden_common_all, |
722 | ARRAY_SIZE(polaris11_golden_common_all)); | 722 | ARRAY_SIZE(polaris11_golden_common_all)); |
723 | break; | 723 | break; |
724 | case CHIP_POLARIS10: | 724 | case CHIP_POLARIS10: |
725 | amdgpu_program_register_sequence(adev, | 725 | amdgpu_device_program_register_sequence(adev, |
726 | golden_settings_polaris10_a11, | 726 | golden_settings_polaris10_a11, |
727 | ARRAY_SIZE(golden_settings_polaris10_a11)); | 727 | ARRAY_SIZE(golden_settings_polaris10_a11)); |
728 | amdgpu_program_register_sequence(adev, | 728 | amdgpu_device_program_register_sequence(adev, |
729 | polaris10_golden_common_all, | 729 | polaris10_golden_common_all, |
730 | ARRAY_SIZE(polaris10_golden_common_all)); | 730 | ARRAY_SIZE(polaris10_golden_common_all)); |
731 | WREG32_SMC(ixCG_ACLK_CNTL, 0x0000001C); | 731 | WREG32_SMC(ixCG_ACLK_CNTL, 0x0000001C); |
732 | if (adev->pdev->revision == 0xc7 && | 732 | if (adev->pdev->revision == 0xc7 && |
733 | ((adev->pdev->subsystem_device == 0xb37 && adev->pdev->subsystem_vendor == 0x1002) || | 733 | ((adev->pdev->subsystem_device == 0xb37 && adev->pdev->subsystem_vendor == 0x1002) || |
@@ -738,26 +738,26 @@ static void gfx_v8_0_init_golden_registers(struct amdgpu_device *adev) | |||
738 | } | 738 | } |
739 | break; | 739 | break; |
740 | case CHIP_CARRIZO: | 740 | case CHIP_CARRIZO: |
741 | amdgpu_program_register_sequence(adev, | 741 | amdgpu_device_program_register_sequence(adev, |
742 | cz_mgcg_cgcg_init, | 742 | cz_mgcg_cgcg_init, |
743 | ARRAY_SIZE(cz_mgcg_cgcg_init)); | 743 | ARRAY_SIZE(cz_mgcg_cgcg_init)); |
744 | amdgpu_program_register_sequence(adev, | 744 | amdgpu_device_program_register_sequence(adev, |
745 | cz_golden_settings_a11, | 745 | cz_golden_settings_a11, |
746 | ARRAY_SIZE(cz_golden_settings_a11)); | 746 | ARRAY_SIZE(cz_golden_settings_a11)); |
747 | amdgpu_program_register_sequence(adev, | 747 | amdgpu_device_program_register_sequence(adev, |
748 | cz_golden_common_all, | 748 | cz_golden_common_all, |
749 | ARRAY_SIZE(cz_golden_common_all)); | 749 | ARRAY_SIZE(cz_golden_common_all)); |
750 | break; | 750 | break; |
751 | case CHIP_STONEY: | 751 | case CHIP_STONEY: |
752 | amdgpu_program_register_sequence(adev, | 752 | amdgpu_device_program_register_sequence(adev, |
753 | stoney_mgcg_cgcg_init, | 753 | stoney_mgcg_cgcg_init, |
754 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); | 754 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); |
755 | amdgpu_program_register_sequence(adev, | 755 | amdgpu_device_program_register_sequence(adev, |
756 | stoney_golden_settings_a11, | 756 | stoney_golden_settings_a11, |
757 | ARRAY_SIZE(stoney_golden_settings_a11)); | 757 | ARRAY_SIZE(stoney_golden_settings_a11)); |
758 | amdgpu_program_register_sequence(adev, | 758 | amdgpu_device_program_register_sequence(adev, |
759 | stoney_golden_common_all, | 759 | stoney_golden_common_all, |
760 | ARRAY_SIZE(stoney_golden_common_all)); | 760 | ARRAY_SIZE(stoney_golden_common_all)); |
761 | break; | 761 | break; |
762 | default: | 762 | default: |
763 | break; | 763 | break; |
@@ -5062,8 +5062,9 @@ static int gfx_v8_0_hw_fini(void *handle) | |||
5062 | gfx_v8_0_cp_enable(adev, false); | 5062 | gfx_v8_0_cp_enable(adev, false); |
5063 | gfx_v8_0_rlc_stop(adev); | 5063 | gfx_v8_0_rlc_stop(adev); |
5064 | 5064 | ||
5065 | amdgpu_set_powergating_state(adev, | 5065 | amdgpu_device_ip_set_powergating_state(adev, |
5066 | AMD_IP_BLOCK_TYPE_GFX, AMD_PG_STATE_UNGATE); | 5066 | AMD_IP_BLOCK_TYPE_GFX, |
5067 | AMD_PG_STATE_UNGATE); | ||
5067 | 5068 | ||
5068 | return 0; | 5069 | return 0; |
5069 | } | 5070 | } |
@@ -5480,8 +5481,9 @@ static int gfx_v8_0_late_init(void *handle) | |||
5480 | if (r) | 5481 | if (r) |
5481 | return r; | 5482 | return r; |
5482 | 5483 | ||
5483 | amdgpu_set_powergating_state(adev, | 5484 | amdgpu_device_ip_set_powergating_state(adev, |
5484 | AMD_IP_BLOCK_TYPE_GFX, AMD_PG_STATE_GATE); | 5485 | AMD_IP_BLOCK_TYPE_GFX, |
5486 | AMD_PG_STATE_GATE); | ||
5485 | 5487 | ||
5486 | return 0; | 5488 | return 0; |
5487 | } | 5489 | } |
@@ -5492,10 +5494,10 @@ static void gfx_v8_0_enable_gfx_static_mg_power_gating(struct amdgpu_device *ade | |||
5492 | if ((adev->asic_type == CHIP_POLARIS11) || | 5494 | if ((adev->asic_type == CHIP_POLARIS11) || |
5493 | (adev->asic_type == CHIP_POLARIS12)) | 5495 | (adev->asic_type == CHIP_POLARIS12)) |
5494 | /* Send msg to SMU via Powerplay */ | 5496 | /* Send msg to SMU via Powerplay */ |
5495 | amdgpu_set_powergating_state(adev, | 5497 | amdgpu_device_ip_set_powergating_state(adev, |
5496 | AMD_IP_BLOCK_TYPE_SMC, | 5498 | AMD_IP_BLOCK_TYPE_SMC, |
5497 | enable ? | 5499 | enable ? |
5498 | AMD_PG_STATE_GATE : AMD_PG_STATE_UNGATE); | 5500 | AMD_PG_STATE_GATE : AMD_PG_STATE_UNGATE); |
5499 | 5501 | ||
5500 | WREG32_FIELD(RLC_PG_CNTL, STATIC_PER_CU_PG_ENABLE, enable ? 1 : 0); | 5502 | WREG32_FIELD(RLC_PG_CNTL, STATIC_PER_CU_PG_ENABLE, enable ? 1 : 0); |
5501 | } | 5503 | } |
@@ -6472,10 +6474,10 @@ static void gfx_v8_0_hqd_set_priority(struct amdgpu_device *adev, | |||
6472 | mutex_unlock(&adev->srbm_mutex); | 6474 | mutex_unlock(&adev->srbm_mutex); |
6473 | } | 6475 | } |
6474 | static void gfx_v8_0_ring_set_priority_compute(struct amdgpu_ring *ring, | 6476 | static void gfx_v8_0_ring_set_priority_compute(struct amdgpu_ring *ring, |
6475 | enum amd_sched_priority priority) | 6477 | enum drm_sched_priority priority) |
6476 | { | 6478 | { |
6477 | struct amdgpu_device *adev = ring->adev; | 6479 | struct amdgpu_device *adev = ring->adev; |
6478 | bool acquire = priority == AMD_SCHED_PRIORITY_HIGH_HW; | 6480 | bool acquire = priority == DRM_SCHED_PRIORITY_HIGH_HW; |
6479 | 6481 | ||
6480 | if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE) | 6482 | if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE) |
6481 | return; | 6483 | return; |
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 6c5289ae67be..9f7be230734c 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "soc15.h" | 28 | #include "soc15.h" |
29 | #include "soc15d.h" | 29 | #include "soc15d.h" |
30 | 30 | ||
31 | #include "soc15ip.h" | ||
32 | #include "gc/gc_9_0_offset.h" | 31 | #include "gc/gc_9_0_offset.h" |
33 | #include "gc/gc_9_0_sh_mask.h" | 32 | #include "gc/gc_9_0_sh_mask.h" |
34 | #include "vega10_enum.h" | 33 | #include "vega10_enum.h" |
@@ -65,152 +64,84 @@ MODULE_FIRMWARE("amdgpu/raven_mec.bin"); | |||
65 | MODULE_FIRMWARE("amdgpu/raven_mec2.bin"); | 64 | MODULE_FIRMWARE("amdgpu/raven_mec2.bin"); |
66 | MODULE_FIRMWARE("amdgpu/raven_rlc.bin"); | 65 | MODULE_FIRMWARE("amdgpu/raven_rlc.bin"); |
67 | 66 | ||
68 | static const struct amdgpu_gds_reg_offset amdgpu_gds_reg_offset[] = | 67 | static const struct soc15_reg_golden golden_settings_gc_9_0[] = |
69 | { | 68 | { |
70 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE), | 69 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x08000000, 0x08000080), |
71 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), | 70 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0x08000000, 0x08000080), |
72 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID0), | 71 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x08000000, 0x08000080), |
73 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID0) }, | 72 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420), |
74 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID1_BASE), | 73 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000), |
75 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID1_SIZE), | 74 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x08000000, 0x08000080), |
76 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID1), | 75 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024), |
77 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID1) }, | 76 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001), |
78 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID2_BASE), | 77 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000), |
79 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID2_SIZE), | 78 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0x08000000, 0x08000080), |
80 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID2), | 79 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0x08000000, 0x08000080), |
81 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID2) }, | 80 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0x08000000, 0x08000080), |
82 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID3_BASE), | 81 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0x08000000, 0x08000080), |
83 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID3_SIZE), | 82 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0x08000000, 0x08000080), |
84 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID3), | 83 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSH_MEM_CONFIG, 0x00001000, 0x00001000), |
85 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID3) }, | 84 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSPI_CONFIG_CNTL_1, 0x0000000f, 0x01000107), |
86 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID4_BASE), | 85 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQC_CONFIG, 0x03000000, 0x020a2000), |
87 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID4_SIZE), | 86 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000), |
88 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID4), | 87 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x4a2c0e68), |
89 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID4) }, | 88 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0xb5d3f197), |
90 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID5_BASE), | 89 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), |
91 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID5_SIZE), | 90 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000003ff), |
92 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID5), | 91 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) |
93 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID5) }, | ||
94 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID6_BASE), | ||
95 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID6_SIZE), | ||
96 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID6), | ||
97 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID6) }, | ||
98 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID7_BASE), | ||
99 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID7_SIZE), | ||
100 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID7), | ||
101 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID7) }, | ||
102 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID8_BASE), | ||
103 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID8_SIZE), | ||
104 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID8), | ||
105 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID8) }, | ||
106 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID9_BASE), | ||
107 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID9_SIZE), | ||
108 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID9), | ||
109 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID9) }, | ||
110 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID10_BASE), | ||
111 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID10_SIZE), | ||
112 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID10), | ||
113 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID10) }, | ||
114 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID11_BASE), | ||
115 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID11_SIZE), | ||
116 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID11), | ||
117 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID11) }, | ||
118 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID12_BASE), | ||
119 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID12_SIZE), | ||
120 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID12), | ||
121 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID12)}, | ||
122 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID13_BASE), | ||
123 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID13_SIZE), | ||
124 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID13), | ||
125 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID13) }, | ||
126 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID14_BASE), | ||
127 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID14_SIZE), | ||
128 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID14), | ||
129 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID14) }, | ||
130 | { SOC15_REG_OFFSET(GC, 0, mmGDS_VMID15_BASE), | ||
131 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID15_SIZE), | ||
132 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID15), | ||
133 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID15) } | ||
134 | }; | 92 | }; |
135 | 93 | ||
136 | static const u32 golden_settings_gc_9_0[] = | 94 | static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] = |
137 | { | ||
138 | SOC15_REG_OFFSET(GC, 0, mmCPC_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
139 | SOC15_REG_OFFSET(GC, 0, mmCPF_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
140 | SOC15_REG_OFFSET(GC, 0, mmCPG_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
141 | SOC15_REG_OFFSET(GC, 0, mmDB_DEBUG2), 0xf00fffff, 0x00000420, | ||
142 | SOC15_REG_OFFSET(GC, 0, mmGB_GPU_ID), 0x0000000f, 0x00000000, | ||
143 | SOC15_REG_OFFSET(GC, 0, mmIA_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
144 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3), 0x00000003, 0x82400024, | ||
145 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_ENHANCE), 0x3fffffff, 0x00000001, | ||
146 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_LINE_STIPPLE_STATE), 0x0000ff0f, 0x00000000, | ||
147 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_0), 0x08000000, 0x08000080, | ||
148 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_1), 0x08000000, 0x08000080, | ||
149 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_2), 0x08000000, 0x08000080, | ||
150 | SOC15_REG_OFFSET(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
151 | SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_UTCL1_CNTL), 0x08000000, 0x08000080, | ||
152 | SOC15_REG_OFFSET(GC, 0, mmSH_MEM_CONFIG), 0x00001000, 0x00001000, | ||
153 | SOC15_REG_OFFSET(GC, 0, mmSPI_CONFIG_CNTL_1), 0x0000000f, 0x01000107, | ||
154 | SOC15_REG_OFFSET(GC, 0, mmSQC_CONFIG), 0x03000000, 0x020a2000, | ||
155 | SOC15_REG_OFFSET(GC, 0, mmTA_CNTL_AUX), 0xfffffeef, 0x010b0000, | ||
156 | SOC15_REG_OFFSET(GC, 0, mmTCP_CHAN_STEER_HI), 0xffffffff, 0x4a2c0e68, | ||
157 | SOC15_REG_OFFSET(GC, 0, mmTCP_CHAN_STEER_LO), 0xffffffff, 0xb5d3f197, | ||
158 | SOC15_REG_OFFSET(GC, 0, mmVGT_CACHE_INVALIDATION), 0x3fff3af3, 0x19200000, | ||
159 | SOC15_REG_OFFSET(GC, 0, mmVGT_GS_MAX_WAVE_ID), 0x00000fff, 0x000003ff, | ||
160 | SOC15_REG_OFFSET(GC, 0, mmWD_UTCL1_CNTL), 0x08000000, 0x08000080 | ||
161 | }; | ||
162 | |||
163 | static const u32 golden_settings_gc_9_0_vg10[] = | ||
164 | { | 95 | { |
165 | SOC15_REG_OFFSET(GC, 0, mmCB_HW_CONTROL), 0x0000f000, 0x00012107, | 96 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0x0000f000, 0x00012107), |
166 | SOC15_REG_OFFSET(GC, 0, mmCB_HW_CONTROL_3), 0x30000000, 0x10000000, | 97 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000), |
167 | SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG), 0xffff77ff, 0x2a114042, | 98 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x2a114042), |
168 | SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG_READ), 0xffff77ff, 0x2a114042, | 99 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x2a114042), |
169 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_ENHANCE_1), 0x00008000, 0x00048000, | 100 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0x00008000, 0x00048000), |
170 | SOC15_REG_OFFSET(GC, 0, mmRMI_UTCL1_CNTL2), 0x00030000, 0x00020000, | 101 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), |
171 | SOC15_REG_OFFSET(GC, 0, mmTD_CNTL), 0x00001800, 0x00000800 | 102 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x00001800, 0x00000800) |
172 | }; | 103 | }; |
173 | 104 | ||
174 | static const u32 golden_settings_gc_9_1[] = | 105 | static const struct soc15_reg_golden golden_settings_gc_9_1[] = |
175 | { | 106 | { |
176 | SOC15_REG_OFFSET(GC, 0, mmCB_HW_CONTROL), 0xfffdf3cf, 0x00014104, | 107 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL, 0xfffdf3cf, 0x00014104), |
177 | SOC15_REG_OFFSET(GC, 0, mmCPC_UTCL1_CNTL), 0x08000000, 0x08000080, | 108 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPC_UTCL1_CNTL, 0x08000000, 0x08000080), |
178 | SOC15_REG_OFFSET(GC, 0, mmCPF_UTCL1_CNTL), 0x08000000, 0x08000080, | 109 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPF_UTCL1_CNTL, 0x08000000, 0x08000080), |
179 | SOC15_REG_OFFSET(GC, 0, mmCPG_UTCL1_CNTL), 0x08000000, 0x08000080, | 110 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCPG_UTCL1_CNTL, 0x08000000, 0x08000080), |
180 | SOC15_REG_OFFSET(GC, 0, mmDB_DEBUG2), 0xf00fffff, 0x00000420, | 111 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmDB_DEBUG2, 0xf00fffff, 0x00000420), |
181 | SOC15_REG_OFFSET(GC, 0, mmGB_GPU_ID), 0x0000000f, 0x00000000, | 112 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_GPU_ID, 0x0000000f, 0x00000000), |
182 | SOC15_REG_OFFSET(GC, 0, mmIA_UTCL1_CNTL), 0x08000000, 0x08000080, | 113 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmIA_UTCL1_CNTL, 0x08000000, 0x08000080), |
183 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3), 0x00000003, 0x82400024, | 114 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_BINNER_EVENT_CNTL_3, 0x00000003, 0x82400024), |
184 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_ENHANCE), 0x3fffffff, 0x00000001, | 115 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE, 0x3fffffff, 0x00000001), |
185 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_LINE_STIPPLE_STATE), 0x0000ff0f, 0x00000000, | 116 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_LINE_STIPPLE_STATE, 0x0000ff0f, 0x00000000), |
186 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_0), 0x08000000, 0x08000080, | 117 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_0, 0x08000000, 0x08000080), |
187 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_1), 0x08000000, 0x08000080, | 118 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_1, 0x08000000, 0x08000080), |
188 | SOC15_REG_OFFSET(GC, 0, mmRLC_GPM_UTCL1_CNTL_2), 0x08000000, 0x08000080, | 119 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_GPM_UTCL1_CNTL_2, 0x08000000, 0x08000080), |
189 | SOC15_REG_OFFSET(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL), 0x08000000, 0x08000080, | 120 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_PREWALKER_UTCL1_CNTL, 0x08000000, 0x08000080), |
190 | SOC15_REG_OFFSET(GC, 0, mmRLC_SPM_UTCL1_CNTL), 0x08000000, 0x08000080, | 121 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRLC_SPM_UTCL1_CNTL, 0x08000000, 0x08000080), |
191 | SOC15_REG_OFFSET(GC, 0, mmTA_CNTL_AUX), 0xfffffeef, 0x010b0000, | 122 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTA_CNTL_AUX, 0xfffffeef, 0x010b0000), |
192 | SOC15_REG_OFFSET(GC, 0, mmTCP_CHAN_STEER_HI), 0xffffffff, 0x00000000, | 123 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_HI, 0xffffffff, 0x00000000), |
193 | SOC15_REG_OFFSET(GC, 0, mmTCP_CHAN_STEER_LO), 0xffffffff, 0x00003120, | 124 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_LO, 0xffffffff, 0x00003120), |
194 | SOC15_REG_OFFSET(GC, 0, mmVGT_CACHE_INVALIDATION), 0x3fff3af3, 0x19200000, | 125 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_CACHE_INVALIDATION, 0x3fff3af3, 0x19200000), |
195 | SOC15_REG_OFFSET(GC, 0, mmVGT_GS_MAX_WAVE_ID), 0x00000fff, 0x000000ff, | 126 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmVGT_GS_MAX_WAVE_ID, 0x00000fff, 0x000000ff), |
196 | SOC15_REG_OFFSET(GC, 0, mmWD_UTCL1_CNTL), 0x08000000, 0x08000080 | 127 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmWD_UTCL1_CNTL, 0x08000000, 0x08000080) |
197 | }; | 128 | }; |
198 | 129 | ||
199 | static const u32 golden_settings_gc_9_1_rv1[] = | 130 | static const struct soc15_reg_golden golden_settings_gc_9_1_rv1[] = |
200 | { | 131 | { |
201 | SOC15_REG_OFFSET(GC, 0, mmCB_HW_CONTROL_3), 0x30000000, 0x10000000, | 132 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000), |
202 | SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG), 0xffff77ff, 0x24000042, | 133 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xffff77ff, 0x24000042), |
203 | SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG_READ), 0xffff77ff, 0x24000042, | 134 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG_READ, 0xffff77ff, 0x24000042), |
204 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_ENHANCE_1), 0xffffffff, 0x04048000, | 135 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_ENHANCE_1, 0xffffffff, 0x04048000), |
205 | SOC15_REG_OFFSET(GC, 0, mmPA_SC_MODE_CNTL_1), 0x06000000, 0x06000000, | 136 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmPA_SC_MODE_CNTL_1, 0x06000000, 0x06000000), |
206 | SOC15_REG_OFFSET(GC, 0, mmRMI_UTCL1_CNTL2), 0x00030000, 0x00020000, | 137 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmRMI_UTCL1_CNTL2, 0x00030000, 0x00020000), |
207 | SOC15_REG_OFFSET(GC, 0, mmTD_CNTL), 0x01bd9f33, 0x00000800 | 138 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmTD_CNTL, 0x01bd9f33, 0x00000800) |
208 | }; | 139 | }; |
209 | 140 | ||
210 | static const u32 golden_settings_gc_9_x_common[] = | 141 | static const struct soc15_reg_golden golden_settings_gc_9_x_common[] = |
211 | { | 142 | { |
212 | SOC15_REG_OFFSET(GC, 0, mmGRBM_CAM_INDEX), 0xffffffff, 0x00000000, | 143 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_CAM_INDEX, 0xffffffff, 0x00000000), |
213 | SOC15_REG_OFFSET(GC, 0, mmGRBM_CAM_DATA), 0xffffffff, 0x2544c382 | 144 | SOC15_REG_GOLDEN_VALUE(GC, 0, mmGRBM_CAM_DATA, 0xffffffff, 0x2544c382) |
214 | }; | 145 | }; |
215 | 146 | ||
216 | #define VEGA10_GB_ADDR_CONFIG_GOLDEN 0x2a114042 | 147 | #define VEGA10_GB_ADDR_CONFIG_GOLDEN 0x2a114042 |
@@ -230,18 +161,18 @@ static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev) | |||
230 | { | 161 | { |
231 | switch (adev->asic_type) { | 162 | switch (adev->asic_type) { |
232 | case CHIP_VEGA10: | 163 | case CHIP_VEGA10: |
233 | amdgpu_program_register_sequence(adev, | 164 | soc15_program_register_sequence(adev, |
234 | golden_settings_gc_9_0, | 165 | golden_settings_gc_9_0, |
235 | ARRAY_SIZE(golden_settings_gc_9_0)); | 166 | ARRAY_SIZE(golden_settings_gc_9_0)); |
236 | amdgpu_program_register_sequence(adev, | 167 | soc15_program_register_sequence(adev, |
237 | golden_settings_gc_9_0_vg10, | 168 | golden_settings_gc_9_0_vg10, |
238 | ARRAY_SIZE(golden_settings_gc_9_0_vg10)); | 169 | ARRAY_SIZE(golden_settings_gc_9_0_vg10)); |
239 | break; | 170 | break; |
240 | case CHIP_RAVEN: | 171 | case CHIP_RAVEN: |
241 | amdgpu_program_register_sequence(adev, | 172 | soc15_program_register_sequence(adev, |
242 | golden_settings_gc_9_1, | 173 | golden_settings_gc_9_1, |
243 | ARRAY_SIZE(golden_settings_gc_9_1)); | 174 | ARRAY_SIZE(golden_settings_gc_9_1)); |
244 | amdgpu_program_register_sequence(adev, | 175 | soc15_program_register_sequence(adev, |
245 | golden_settings_gc_9_1_rv1, | 176 | golden_settings_gc_9_1_rv1, |
246 | ARRAY_SIZE(golden_settings_gc_9_1_rv1)); | 177 | ARRAY_SIZE(golden_settings_gc_9_1_rv1)); |
247 | break; | 178 | break; |
@@ -249,7 +180,7 @@ static void gfx_v9_0_init_golden_registers(struct amdgpu_device *adev) | |||
249 | break; | 180 | break; |
250 | } | 181 | } |
251 | 182 | ||
252 | amdgpu_program_register_sequence(adev, golden_settings_gc_9_x_common, | 183 | soc15_program_register_sequence(adev, golden_settings_gc_9_x_common, |
253 | (const u32)ARRAY_SIZE(golden_settings_gc_9_x_common)); | 184 | (const u32)ARRAY_SIZE(golden_settings_gc_9_x_common)); |
254 | } | 185 | } |
255 | 186 | ||
@@ -1137,7 +1068,7 @@ static int gfx_v9_0_ngg_init(struct amdgpu_device *adev) | |||
1137 | adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40); | 1068 | adev->gfx.ngg.gds_reserve_size = ALIGN(5 * 4, 0x40); |
1138 | adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size; | 1069 | adev->gds.mem.total_size -= adev->gfx.ngg.gds_reserve_size; |
1139 | adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size; | 1070 | adev->gds.mem.gfx_partition_size -= adev->gfx.ngg.gds_reserve_size; |
1140 | adev->gfx.ngg.gds_reserve_addr = amdgpu_gds_reg_offset[0].mem_base; | 1071 | adev->gfx.ngg.gds_reserve_addr = SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE); |
1141 | adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size; | 1072 | adev->gfx.ngg.gds_reserve_addr += adev->gds.mem.gfx_partition_size; |
1142 | 1073 | ||
1143 | /* Primitive Buffer */ | 1074 | /* Primitive Buffer */ |
@@ -1243,7 +1174,7 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev) | |||
1243 | } | 1174 | } |
1244 | 1175 | ||
1245 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 1176 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
1246 | amdgpu_gds_reg_offset[0].mem_size, | 1177 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), |
1247 | (adev->gds.mem.total_size + | 1178 | (adev->gds.mem.total_size + |
1248 | adev->gfx.ngg.gds_reserve_size) >> | 1179 | adev->gfx.ngg.gds_reserve_size) >> |
1249 | AMDGPU_GDS_SHIFT); | 1180 | AMDGPU_GDS_SHIFT); |
@@ -1259,7 +1190,7 @@ static int gfx_v9_0_ngg_en(struct amdgpu_device *adev) | |||
1259 | 1190 | ||
1260 | 1191 | ||
1261 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 1192 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
1262 | amdgpu_gds_reg_offset[0].mem_size, 0); | 1193 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE), 0); |
1263 | 1194 | ||
1264 | amdgpu_ring_commit(ring); | 1195 | amdgpu_ring_commit(ring); |
1265 | 1196 | ||
@@ -1598,11 +1529,18 @@ static void gfx_v9_0_gpu_init(struct amdgpu_device *adev) | |||
1598 | for (i = 0; i < 16; i++) { | 1529 | for (i = 0; i < 16; i++) { |
1599 | soc15_grbm_select(adev, 0, 0, 0, i); | 1530 | soc15_grbm_select(adev, 0, 0, 0, i); |
1600 | /* CP and shaders */ | 1531 | /* CP and shaders */ |
1601 | tmp = 0; | 1532 | if (i == 0) { |
1602 | tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE, | 1533 | tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, |
1603 | SH_MEM_ALIGNMENT_MODE_UNALIGNED); | 1534 | SH_MEM_ALIGNMENT_MODE_UNALIGNED); |
1604 | WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp); | 1535 | WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp); |
1605 | WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0); | 1536 | WREG32_SOC15(GC, 0, mmSH_MEM_BASES, 0); |
1537 | } else { | ||
1538 | tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, | ||
1539 | SH_MEM_ALIGNMENT_MODE_UNALIGNED); | ||
1540 | WREG32_SOC15(GC, 0, mmSH_MEM_CONFIG, tmp); | ||
1541 | tmp = adev->mc.shared_aperture_start >> 48; | ||
1542 | WREG32_SOC15(GC, 0, mmSH_MEM_BASES, tmp); | ||
1543 | } | ||
1606 | } | 1544 | } |
1607 | soc15_grbm_select(adev, 0, 0, 0, 0); | 1545 | soc15_grbm_select(adev, 0, 0, 0, 0); |
1608 | 1546 | ||
@@ -2474,7 +2412,7 @@ static int gfx_v9_0_kiq_kcq_enable(struct amdgpu_device *adev) | |||
2474 | PACKET3_MAP_QUEUES_PIPE(ring->pipe) | | 2412 | PACKET3_MAP_QUEUES_PIPE(ring->pipe) | |
2475 | PACKET3_MAP_QUEUES_ME((ring->me == 1 ? 0 : 1)) | | 2413 | PACKET3_MAP_QUEUES_ME((ring->me == 1 ? 0 : 1)) | |
2476 | PACKET3_MAP_QUEUES_QUEUE_TYPE(0) | /*queue_type: normal compute queue */ | 2414 | PACKET3_MAP_QUEUES_QUEUE_TYPE(0) | /*queue_type: normal compute queue */ |
2477 | PACKET3_MAP_QUEUES_ALLOC_FORMAT(1) | /* alloc format: all_on_one_pipe */ | 2415 | PACKET3_MAP_QUEUES_ALLOC_FORMAT(0) | /* alloc format: all_on_one_pipe */ |
2478 | PACKET3_MAP_QUEUES_ENGINE_SEL(0) | /* engine_sel: compute */ | 2416 | PACKET3_MAP_QUEUES_ENGINE_SEL(0) | /* engine_sel: compute */ |
2479 | PACKET3_MAP_QUEUES_NUM_QUEUES(1)); /* num_queues: must be 1 */ | 2417 | PACKET3_MAP_QUEUES_NUM_QUEUES(1)); /* num_queues: must be 1 */ |
2480 | amdgpu_ring_write(kiq_ring, PACKET3_MAP_QUEUES_DOORBELL_OFFSET(ring->doorbell_index)); | 2418 | amdgpu_ring_write(kiq_ring, PACKET3_MAP_QUEUES_DOORBELL_OFFSET(ring->doorbell_index)); |
@@ -3146,6 +3084,8 @@ static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring, | |||
3146 | uint32_t gws_base, uint32_t gws_size, | 3084 | uint32_t gws_base, uint32_t gws_size, |
3147 | uint32_t oa_base, uint32_t oa_size) | 3085 | uint32_t oa_base, uint32_t oa_size) |
3148 | { | 3086 | { |
3087 | struct amdgpu_device *adev = ring->adev; | ||
3088 | |||
3149 | gds_base = gds_base >> AMDGPU_GDS_SHIFT; | 3089 | gds_base = gds_base >> AMDGPU_GDS_SHIFT; |
3150 | gds_size = gds_size >> AMDGPU_GDS_SHIFT; | 3090 | gds_size = gds_size >> AMDGPU_GDS_SHIFT; |
3151 | 3091 | ||
@@ -3157,22 +3097,22 @@ static void gfx_v9_0_ring_emit_gds_switch(struct amdgpu_ring *ring, | |||
3157 | 3097 | ||
3158 | /* GDS Base */ | 3098 | /* GDS Base */ |
3159 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 3099 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
3160 | amdgpu_gds_reg_offset[vmid].mem_base, | 3100 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_BASE) + 2 * vmid, |
3161 | gds_base); | 3101 | gds_base); |
3162 | 3102 | ||
3163 | /* GDS Size */ | 3103 | /* GDS Size */ |
3164 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 3104 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
3165 | amdgpu_gds_reg_offset[vmid].mem_size, | 3105 | SOC15_REG_OFFSET(GC, 0, mmGDS_VMID0_SIZE) + 2 * vmid, |
3166 | gds_size); | 3106 | gds_size); |
3167 | 3107 | ||
3168 | /* GWS */ | 3108 | /* GWS */ |
3169 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 3109 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
3170 | amdgpu_gds_reg_offset[vmid].gws, | 3110 | SOC15_REG_OFFSET(GC, 0, mmGDS_GWS_VMID0) + vmid, |
3171 | gws_size << GDS_GWS_VMID0__SIZE__SHIFT | gws_base); | 3111 | gws_size << GDS_GWS_VMID0__SIZE__SHIFT | gws_base); |
3172 | 3112 | ||
3173 | /* OA */ | 3113 | /* OA */ |
3174 | gfx_v9_0_write_data_to_reg(ring, 0, false, | 3114 | gfx_v9_0_write_data_to_reg(ring, 0, false, |
3175 | amdgpu_gds_reg_offset[vmid].oa, | 3115 | SOC15_REG_OFFSET(GC, 0, mmGDS_OA_VMID0) + vmid, |
3176 | (1 << (oa_size + oa_base)) - (1 << oa_base)); | 3116 | (1 << (oa_size + oa_base)) - (1 << oa_base)); |
3177 | } | 3117 | } |
3178 | 3118 | ||
@@ -3617,13 +3557,9 @@ static void gfx_v9_0_ring_set_wptr_gfx(struct amdgpu_ring *ring) | |||
3617 | 3557 | ||
3618 | static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | 3558 | static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) |
3619 | { | 3559 | { |
3560 | struct amdgpu_device *adev = ring->adev; | ||
3620 | u32 ref_and_mask, reg_mem_engine; | 3561 | u32 ref_and_mask, reg_mem_engine; |
3621 | const struct nbio_hdp_flush_reg *nbio_hf_reg; | 3562 | const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio_funcs->hdp_flush_reg; |
3622 | |||
3623 | if (ring->adev->flags & AMD_IS_APU) | ||
3624 | nbio_hf_reg = &nbio_v7_0_hdp_flush_reg; | ||
3625 | else | ||
3626 | nbio_hf_reg = &nbio_v6_1_hdp_flush_reg; | ||
3627 | 3563 | ||
3628 | if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) { | 3564 | if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE) { |
3629 | switch (ring->me) { | 3565 | switch (ring->me) { |
@@ -3643,13 +3579,15 @@ static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | |||
3643 | } | 3579 | } |
3644 | 3580 | ||
3645 | gfx_v9_0_wait_reg_mem(ring, reg_mem_engine, 0, 1, | 3581 | gfx_v9_0_wait_reg_mem(ring, reg_mem_engine, 0, 1, |
3646 | nbio_hf_reg->hdp_flush_req_offset, | 3582 | adev->nbio_funcs->get_hdp_flush_req_offset(adev), |
3647 | nbio_hf_reg->hdp_flush_done_offset, | 3583 | adev->nbio_funcs->get_hdp_flush_done_offset(adev), |
3648 | ref_and_mask, ref_and_mask, 0x20); | 3584 | ref_and_mask, ref_and_mask, 0x20); |
3649 | } | 3585 | } |
3650 | 3586 | ||
3651 | static void gfx_v9_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | 3587 | static void gfx_v9_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) |
3652 | { | 3588 | { |
3589 | struct amdgpu_device *adev = ring->adev; | ||
3590 | |||
3653 | gfx_v9_0_write_data_to_reg(ring, 0, true, | 3591 | gfx_v9_0_write_data_to_reg(ring, 0, true, |
3654 | SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 1); | 3592 | SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 1); |
3655 | } | 3593 | } |
@@ -3750,10 +3688,11 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
3750 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 3688 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
3751 | int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); | 3689 | int usepfp = (ring->funcs->type == AMDGPU_RING_TYPE_GFX); |
3752 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 3690 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
3691 | uint64_t flags = AMDGPU_PTE_VALID; | ||
3753 | unsigned eng = ring->vm_inv_eng; | 3692 | unsigned eng = ring->vm_inv_eng; |
3754 | 3693 | ||
3755 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 3694 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
3756 | pd_addr |= AMDGPU_PTE_VALID; | 3695 | pd_addr |= flags; |
3757 | 3696 | ||
3758 | gfx_v9_0_write_data_to_reg(ring, usepfp, true, | 3697 | gfx_v9_0_write_data_to_reg(ring, usepfp, true, |
3759 | hub->ctx0_ptb_addr_lo32 + (2 * vm_id), | 3698 | hub->ctx0_ptb_addr_lo32 + (2 * vm_id), |
@@ -3811,6 +3750,8 @@ static void gfx_v9_0_ring_set_wptr_compute(struct amdgpu_ring *ring) | |||
3811 | static void gfx_v9_0_ring_emit_fence_kiq(struct amdgpu_ring *ring, u64 addr, | 3750 | static void gfx_v9_0_ring_emit_fence_kiq(struct amdgpu_ring *ring, u64 addr, |
3812 | u64 seq, unsigned int flags) | 3751 | u64 seq, unsigned int flags) |
3813 | { | 3752 | { |
3753 | struct amdgpu_device *adev = ring->adev; | ||
3754 | |||
3814 | /* we only allocate 32bit for each seq wb address */ | 3755 | /* we only allocate 32bit for each seq wb address */ |
3815 | BUG_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | 3756 | BUG_ON(flags & AMDGPU_FENCE_FLAG_64BIT); |
3816 | 3757 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c index f1effadfbaa6..56f5fe4e2fee 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfxhub_v1_0.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "amdgpu.h" | 23 | #include "amdgpu.h" |
24 | #include "gfxhub_v1_0.h" | 24 | #include "gfxhub_v1_0.h" |
25 | 25 | ||
26 | #include "soc15ip.h" | ||
27 | #include "gc/gc_9_0_offset.h" | 26 | #include "gc/gc_9_0_offset.h" |
28 | #include "gc/gc_9_0_sh_mask.h" | 27 | #include "gc/gc_9_0_sh_mask.h" |
29 | #include "gc/gc_9_0_default.h" | 28 | #include "gc/gc_9_0_default.h" |
@@ -144,8 +143,15 @@ static void gfxhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
144 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL2, tmp); | 143 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL2, tmp); |
145 | 144 | ||
146 | tmp = mmVM_L2_CNTL3_DEFAULT; | 145 | tmp = mmVM_L2_CNTL3_DEFAULT; |
147 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9); | 146 | if (adev->mc.translate_further) { |
148 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | 147 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12); |
148 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, | ||
149 | L2_CACHE_BIGK_FRAGMENT_SIZE, 9); | ||
150 | } else { | ||
151 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9); | ||
152 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, | ||
153 | L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | ||
154 | } | ||
149 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, tmp); | 155 | WREG32_SOC15(GC, 0, mmVM_L2_CNTL3, tmp); |
150 | 156 | ||
151 | tmp = mmVM_L2_CNTL4_DEFAULT; | 157 | tmp = mmVM_L2_CNTL4_DEFAULT; |
@@ -183,31 +189,40 @@ static void gfxhub_v1_0_disable_identity_aperture(struct amdgpu_device *adev) | |||
183 | 189 | ||
184 | static void gfxhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) | 190 | static void gfxhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) |
185 | { | 191 | { |
186 | int i; | 192 | unsigned num_level, block_size; |
187 | uint32_t tmp; | 193 | uint32_t tmp; |
194 | int i; | ||
195 | |||
196 | num_level = adev->vm_manager.num_level; | ||
197 | block_size = adev->vm_manager.block_size; | ||
198 | if (adev->mc.translate_further) | ||
199 | num_level -= 1; | ||
200 | else | ||
201 | block_size -= 9; | ||
188 | 202 | ||
189 | for (i = 0; i <= 14; i++) { | 203 | for (i = 0; i <= 14; i++) { |
190 | tmp = RREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL, i); | 204 | tmp = RREG32_SOC15_OFFSET(GC, 0, mmVM_CONTEXT1_CNTL, i); |
191 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1); | 205 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1); |
192 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH, | 206 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH, |
193 | adev->vm_manager.num_level); | 207 | num_level); |
194 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 208 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
195 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 209 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
196 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 210 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
197 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 211 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, |
212 | 1); | ||
198 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 213 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
199 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 214 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
200 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 215 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
201 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 216 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
202 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 217 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
203 | READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 218 | READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
204 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 219 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
205 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 220 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
206 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 221 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
207 | EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 222 | EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
208 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 223 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
209 | PAGE_TABLE_BLOCK_SIZE, | 224 | PAGE_TABLE_BLOCK_SIZE, |
210 | adev->vm_manager.block_size - 9); | 225 | block_size); |
211 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ | 226 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ |
212 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 227 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
213 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); | 228 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c index 468281f10e8d..e1a73c43f32d 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | |||
@@ -222,8 +222,8 @@ static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev, | |||
222 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | 222 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; |
223 | base <<= 24; | 223 | base <<= 24; |
224 | 224 | ||
225 | amdgpu_vram_location(adev, &adev->mc, base); | 225 | amdgpu_device_vram_location(adev, &adev->mc, base); |
226 | amdgpu_gart_location(adev, mc); | 226 | amdgpu_device_gart_location(adev, mc); |
227 | } | 227 | } |
228 | 228 | ||
229 | static void gmc_v6_0_mc_program(struct amdgpu_device *adev) | 229 | static void gmc_v6_0_mc_program(struct amdgpu_device *adev) |
@@ -395,10 +395,10 @@ static uint64_t gmc_v6_0_get_vm_pte_flags(struct amdgpu_device *adev, | |||
395 | return pte_flag; | 395 | return pte_flag; |
396 | } | 396 | } |
397 | 397 | ||
398 | static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr) | 398 | static void gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, int level, |
399 | uint64_t *addr, uint64_t *flags) | ||
399 | { | 400 | { |
400 | BUG_ON(addr & 0xFFFFFF0000000FFFULL); | 401 | BUG_ON(*addr & 0xFFFFFF0000000FFFULL); |
401 | return addr; | ||
402 | } | 402 | } |
403 | 403 | ||
404 | static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev, | 404 | static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev, |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c index 68a85051f4b7..356a9a71b8cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | |||
@@ -67,12 +67,12 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev) | |||
67 | { | 67 | { |
68 | switch (adev->asic_type) { | 68 | switch (adev->asic_type) { |
69 | case CHIP_TOPAZ: | 69 | case CHIP_TOPAZ: |
70 | amdgpu_program_register_sequence(adev, | 70 | amdgpu_device_program_register_sequence(adev, |
71 | iceland_mgcg_cgcg_init, | 71 | iceland_mgcg_cgcg_init, |
72 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); | 72 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); |
73 | amdgpu_program_register_sequence(adev, | 73 | amdgpu_device_program_register_sequence(adev, |
74 | golden_settings_iceland_a11, | 74 | golden_settings_iceland_a11, |
75 | ARRAY_SIZE(golden_settings_iceland_a11)); | 75 | ARRAY_SIZE(golden_settings_iceland_a11)); |
76 | break; | 76 | break; |
77 | default: | 77 | default: |
78 | break; | 78 | break; |
@@ -240,8 +240,8 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, | |||
240 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | 240 | u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; |
241 | base <<= 24; | 241 | base <<= 24; |
242 | 242 | ||
243 | amdgpu_vram_location(adev, &adev->mc, base); | 243 | amdgpu_device_vram_location(adev, &adev->mc, base); |
244 | amdgpu_gart_location(adev, mc); | 244 | amdgpu_device_gart_location(adev, mc); |
245 | } | 245 | } |
246 | 246 | ||
247 | /** | 247 | /** |
@@ -480,10 +480,10 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct amdgpu_device *adev, | |||
480 | return pte_flag; | 480 | return pte_flag; |
481 | } | 481 | } |
482 | 482 | ||
483 | static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr) | 483 | static void gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, int level, |
484 | uint64_t *addr, uint64_t *flags) | ||
484 | { | 485 | { |
485 | BUG_ON(addr & 0xFFFFFF0000000FFFULL); | 486 | BUG_ON(*addr & 0xFFFFFF0000000FFFULL); |
486 | return addr; | ||
487 | } | 487 | } |
488 | 488 | ||
489 | /** | 489 | /** |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c index 46ec97e70e5c..fce45578f5fd 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | |||
@@ -120,44 +120,44 @@ static void gmc_v8_0_init_golden_registers(struct amdgpu_device *adev) | |||
120 | { | 120 | { |
121 | switch (adev->asic_type) { | 121 | switch (adev->asic_type) { |
122 | case CHIP_FIJI: | 122 | case CHIP_FIJI: |
123 | amdgpu_program_register_sequence(adev, | 123 | amdgpu_device_program_register_sequence(adev, |
124 | fiji_mgcg_cgcg_init, | 124 | fiji_mgcg_cgcg_init, |
125 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); | 125 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
126 | amdgpu_program_register_sequence(adev, | 126 | amdgpu_device_program_register_sequence(adev, |
127 | golden_settings_fiji_a10, | 127 | golden_settings_fiji_a10, |
128 | ARRAY_SIZE(golden_settings_fiji_a10)); | 128 | ARRAY_SIZE(golden_settings_fiji_a10)); |
129 | break; | 129 | break; |
130 | case CHIP_TONGA: | 130 | case CHIP_TONGA: |
131 | amdgpu_program_register_sequence(adev, | 131 | amdgpu_device_program_register_sequence(adev, |
132 | tonga_mgcg_cgcg_init, | 132 | tonga_mgcg_cgcg_init, |
133 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); | 133 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
134 | amdgpu_program_register_sequence(adev, | 134 | amdgpu_device_program_register_sequence(adev, |
135 | golden_settings_tonga_a11, | 135 | golden_settings_tonga_a11, |
136 | ARRAY_SIZE(golden_settings_tonga_a11)); | 136 | ARRAY_SIZE(golden_settings_tonga_a11)); |
137 | break; | 137 | break; |
138 | case CHIP_POLARIS11: | 138 | case CHIP_POLARIS11: |
139 | case CHIP_POLARIS12: | 139 | case CHIP_POLARIS12: |
140 | amdgpu_program_register_sequence(adev, | 140 | amdgpu_device_program_register_sequence(adev, |
141 | golden_settings_polaris11_a11, | 141 | golden_settings_polaris11_a11, |
142 | ARRAY_SIZE(golden_settings_polaris11_a11)); | 142 | ARRAY_SIZE(golden_settings_polaris11_a11)); |
143 | break; | 143 | break; |
144 | case CHIP_POLARIS10: | 144 | case CHIP_POLARIS10: |
145 | amdgpu_program_register_sequence(adev, | 145 | amdgpu_device_program_register_sequence(adev, |
146 | golden_settings_polaris10_a11, | 146 | golden_settings_polaris10_a11, |
147 | ARRAY_SIZE(golden_settings_polaris10_a11)); | 147 | ARRAY_SIZE(golden_settings_polaris10_a11)); |
148 | break; | 148 | break; |
149 | case CHIP_CARRIZO: | 149 | case CHIP_CARRIZO: |
150 | amdgpu_program_register_sequence(adev, | 150 | amdgpu_device_program_register_sequence(adev, |
151 | cz_mgcg_cgcg_init, | 151 | cz_mgcg_cgcg_init, |
152 | ARRAY_SIZE(cz_mgcg_cgcg_init)); | 152 | ARRAY_SIZE(cz_mgcg_cgcg_init)); |
153 | break; | 153 | break; |
154 | case CHIP_STONEY: | 154 | case CHIP_STONEY: |
155 | amdgpu_program_register_sequence(adev, | 155 | amdgpu_device_program_register_sequence(adev, |
156 | stoney_mgcg_cgcg_init, | 156 | stoney_mgcg_cgcg_init, |
157 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); | 157 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); |
158 | amdgpu_program_register_sequence(adev, | 158 | amdgpu_device_program_register_sequence(adev, |
159 | golden_settings_stoney_common, | 159 | golden_settings_stoney_common, |
160 | ARRAY_SIZE(golden_settings_stoney_common)); | 160 | ARRAY_SIZE(golden_settings_stoney_common)); |
161 | break; | 161 | break; |
162 | default: | 162 | default: |
163 | break; | 163 | break; |
@@ -405,8 +405,8 @@ static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev, | |||
405 | base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; | 405 | base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF; |
406 | base <<= 24; | 406 | base <<= 24; |
407 | 407 | ||
408 | amdgpu_vram_location(adev, &adev->mc, base); | 408 | amdgpu_device_vram_location(adev, &adev->mc, base); |
409 | amdgpu_gart_location(adev, mc); | 409 | amdgpu_device_gart_location(adev, mc); |
410 | } | 410 | } |
411 | 411 | ||
412 | /** | 412 | /** |
@@ -677,10 +677,10 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct amdgpu_device *adev, | |||
677 | return pte_flag; | 677 | return pte_flag; |
678 | } | 678 | } |
679 | 679 | ||
680 | static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr) | 680 | static void gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, int level, |
681 | uint64_t *addr, uint64_t *flags) | ||
681 | { | 682 | { |
682 | BUG_ON(addr & 0xFFFFFF0000000FFFULL); | 683 | BUG_ON(*addr & 0xFFFFFF0000000FFFULL); |
683 | return addr; | ||
684 | } | 684 | } |
685 | 685 | ||
686 | /** | 686 | /** |
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c index cc972153d401..b776df4c999f 100644 --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include "gmc_v9_0.h" | 25 | #include "gmc_v9_0.h" |
26 | #include "amdgpu_atomfirmware.h" | 26 | #include "amdgpu_atomfirmware.h" |
27 | 27 | ||
28 | #include "soc15ip.h" | ||
29 | #include "hdp/hdp_4_0_offset.h" | 28 | #include "hdp/hdp_4_0_offset.h" |
30 | #include "hdp/hdp_4_0_sh_mask.h" | 29 | #include "hdp/hdp_4_0_sh_mask.h" |
31 | #include "gc/gc_9_0_sh_mask.h" | 30 | #include "gc/gc_9_0_sh_mask.h" |
@@ -35,11 +34,10 @@ | |||
35 | #include "mmhub/mmhub_1_0_offset.h" | 34 | #include "mmhub/mmhub_1_0_offset.h" |
36 | #include "athub/athub_1_0_offset.h" | 35 | #include "athub/athub_1_0_offset.h" |
37 | 36 | ||
37 | #include "soc15.h" | ||
38 | #include "soc15_common.h" | 38 | #include "soc15_common.h" |
39 | #include "umc/umc_6_0_sh_mask.h" | 39 | #include "umc/umc_6_0_sh_mask.h" |
40 | 40 | ||
41 | #include "nbio_v6_1.h" | ||
42 | #include "nbio_v7_0.h" | ||
43 | #include "gfxhub_v1_0.h" | 41 | #include "gfxhub_v1_0.h" |
44 | #include "mmhub_v1_0.h" | 42 | #include "mmhub_v1_0.h" |
45 | 43 | ||
@@ -74,16 +72,16 @@ static const u32 golden_settings_vega10_hdp[] = | |||
74 | 0xf6e, 0x0fffffff, 0x00000000, | 72 | 0xf6e, 0x0fffffff, 0x00000000, |
75 | }; | 73 | }; |
76 | 74 | ||
77 | static const u32 golden_settings_mmhub_1_0_0[] = | 75 | static const struct soc15_reg_golden golden_settings_mmhub_1_0_0[] = |
78 | { | 76 | { |
79 | SOC15_REG_OFFSET(MMHUB, 0, mmDAGB1_WRCLI2), 0x00000007, 0xfe5fe0fa, | 77 | SOC15_REG_GOLDEN_VALUE(MMHUB, 0, mmDAGB1_WRCLI2, 0x00000007, 0xfe5fe0fa), |
80 | SOC15_REG_OFFSET(MMHUB, 0, mmMMEA1_DRAM_WR_CLI2GRP_MAP0), 0x00000030, 0x55555565 | 78 | SOC15_REG_GOLDEN_VALUE(MMHUB, 0, mmMMEA1_DRAM_WR_CLI2GRP_MAP0, 0x00000030, 0x55555565) |
81 | }; | 79 | }; |
82 | 80 | ||
83 | static const u32 golden_settings_athub_1_0_0[] = | 81 | static const struct soc15_reg_golden golden_settings_athub_1_0_0[] = |
84 | { | 82 | { |
85 | SOC15_REG_OFFSET(ATHUB, 0, mmRPB_ARB_CNTL), 0x0000ff00, 0x00000800, | 83 | SOC15_REG_GOLDEN_VALUE(ATHUB, 0, mmRPB_ARB_CNTL, 0x0000ff00, 0x00000800), |
86 | SOC15_REG_OFFSET(ATHUB, 0, mmRPB_ARB_CNTL2), 0x00ff00ff, 0x00080008 | 84 | SOC15_REG_GOLDEN_VALUE(ATHUB, 0, mmRPB_ARB_CNTL2, 0x00ff00ff, 0x00080008) |
87 | }; | 85 | }; |
88 | 86 | ||
89 | /* Ecc related register addresses, (BASE + reg offset) */ | 87 | /* Ecc related register addresses, (BASE + reg offset) */ |
@@ -332,10 +330,7 @@ static void gmc_v9_0_gart_flush_gpu_tlb(struct amdgpu_device *adev, | |||
332 | unsigned i, j; | 330 | unsigned i, j; |
333 | 331 | ||
334 | /* flush hdp cache */ | 332 | /* flush hdp cache */ |
335 | if (adev->flags & AMD_IS_APU) | 333 | adev->nbio_funcs->hdp_flush(adev); |
336 | nbio_v7_0_hdp_flush(adev); | ||
337 | else | ||
338 | nbio_v6_1_hdp_flush(adev); | ||
339 | 334 | ||
340 | spin_lock(&adev->mc.invalidate_lock); | 335 | spin_lock(&adev->mc.invalidate_lock); |
341 | 336 | ||
@@ -474,11 +469,28 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev, | |||
474 | return pte_flag; | 469 | return pte_flag; |
475 | } | 470 | } |
476 | 471 | ||
477 | static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr) | 472 | static void gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, int level, |
473 | uint64_t *addr, uint64_t *flags) | ||
478 | { | 474 | { |
479 | addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start; | 475 | if (!(*flags & AMDGPU_PDE_PTE)) |
480 | BUG_ON(addr & 0xFFFF00000000003FULL); | 476 | *addr = adev->vm_manager.vram_base_offset + *addr - |
481 | return addr; | 477 | adev->mc.vram_start; |
478 | BUG_ON(*addr & 0xFFFF00000000003FULL); | ||
479 | |||
480 | if (!adev->mc.translate_further) | ||
481 | return; | ||
482 | |||
483 | if (level == AMDGPU_VM_PDB1) { | ||
484 | /* Set the block fragment size */ | ||
485 | if (!(*flags & AMDGPU_PDE_PTE)) | ||
486 | *flags |= AMDGPU_PDE_BFS(0x9); | ||
487 | |||
488 | } else if (level == AMDGPU_VM_PDB0) { | ||
489 | if (*flags & AMDGPU_PDE_PTE) | ||
490 | *flags &= ~AMDGPU_PDE_PTE; | ||
491 | else | ||
492 | *flags |= AMDGPU_PTE_TF; | ||
493 | } | ||
482 | } | 494 | } |
483 | 495 | ||
484 | static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = { | 496 | static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = { |
@@ -502,6 +514,14 @@ static int gmc_v9_0_early_init(void *handle) | |||
502 | gmc_v9_0_set_gart_funcs(adev); | 514 | gmc_v9_0_set_gart_funcs(adev); |
503 | gmc_v9_0_set_irq_funcs(adev); | 515 | gmc_v9_0_set_irq_funcs(adev); |
504 | 516 | ||
517 | adev->mc.shared_aperture_start = 0x2000000000000000ULL; | ||
518 | adev->mc.shared_aperture_end = | ||
519 | adev->mc.shared_aperture_start + (4ULL << 30) - 1; | ||
520 | adev->mc.private_aperture_start = | ||
521 | adev->mc.shared_aperture_end + 1; | ||
522 | adev->mc.private_aperture_end = | ||
523 | adev->mc.private_aperture_start + (4ULL << 30) - 1; | ||
524 | |||
505 | return 0; | 525 | return 0; |
506 | } | 526 | } |
507 | 527 | ||
@@ -633,8 +653,8 @@ static void gmc_v9_0_vram_gtt_location(struct amdgpu_device *adev, | |||
633 | u64 base = 0; | 653 | u64 base = 0; |
634 | if (!amdgpu_sriov_vf(adev)) | 654 | if (!amdgpu_sriov_vf(adev)) |
635 | base = mmhub_v1_0_get_fb_location(adev); | 655 | base = mmhub_v1_0_get_fb_location(adev); |
636 | amdgpu_vram_location(adev, &adev->mc, base); | 656 | amdgpu_device_vram_location(adev, &adev->mc, base); |
637 | amdgpu_gart_location(adev, mc); | 657 | amdgpu_device_gart_location(adev, mc); |
638 | /* base offset of vram pages */ | 658 | /* base offset of vram pages */ |
639 | if (adev->flags & AMD_IS_APU) | 659 | if (adev->flags & AMD_IS_APU) |
640 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); | 660 | adev->vm_manager.vram_base_offset = gfxhub_v1_0_get_mc_fb_offset(adev); |
@@ -700,8 +720,7 @@ static int gmc_v9_0_mc_init(struct amdgpu_device *adev) | |||
700 | 720 | ||
701 | /* size in MB on si */ | 721 | /* size in MB on si */ |
702 | adev->mc.mc_vram_size = | 722 | adev->mc.mc_vram_size = |
703 | ((adev->flags & AMD_IS_APU) ? nbio_v7_0_get_memsize(adev) : | 723 | adev->nbio_funcs->get_memsize(adev) * 1024ULL * 1024ULL; |
704 | nbio_v6_1_get_memsize(adev)) * 1024ULL * 1024ULL; | ||
705 | adev->mc.real_vram_size = adev->mc.mc_vram_size; | 724 | adev->mc.real_vram_size = adev->mc.mc_vram_size; |
706 | 725 | ||
707 | if (!(adev->flags & AMD_IS_APU)) { | 726 | if (!(adev->flags & AMD_IS_APU)) { |
@@ -769,11 +788,14 @@ static int gmc_v9_0_sw_init(void *handle) | |||
769 | switch (adev->asic_type) { | 788 | switch (adev->asic_type) { |
770 | case CHIP_RAVEN: | 789 | case CHIP_RAVEN: |
771 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; | 790 | adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; |
772 | if (adev->rev_id == 0x0 || adev->rev_id == 0x1) | 791 | if (adev->rev_id == 0x0 || adev->rev_id == 0x1) { |
773 | amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); | 792 | amdgpu_vm_adjust_size(adev, 256 * 1024, 9, 3, 48); |
774 | else | 793 | } else { |
775 | /* vm_size is 64GB for legacy 2-level page support */ | 794 | /* vm_size is 128TB + 512GB for legacy 3-level page support */ |
776 | amdgpu_vm_adjust_size(adev, 64, 9, 1, 48); | 795 | amdgpu_vm_adjust_size(adev, 128 * 1024 + 512, 9, 2, 48); |
796 | adev->mc.translate_further = | ||
797 | adev->vm_manager.num_level > 1; | ||
798 | } | ||
777 | break; | 799 | break; |
778 | case CHIP_VEGA10: | 800 | case CHIP_VEGA10: |
779 | /* XXX Don't know how to get VRAM type yet. */ | 801 | /* XXX Don't know how to get VRAM type yet. */ |
@@ -883,17 +905,18 @@ static int gmc_v9_0_sw_fini(void *handle) | |||
883 | 905 | ||
884 | static void gmc_v9_0_init_golden_registers(struct amdgpu_device *adev) | 906 | static void gmc_v9_0_init_golden_registers(struct amdgpu_device *adev) |
885 | { | 907 | { |
908 | |||
886 | switch (adev->asic_type) { | 909 | switch (adev->asic_type) { |
887 | case CHIP_VEGA10: | 910 | case CHIP_VEGA10: |
888 | amdgpu_program_register_sequence(adev, | 911 | soc15_program_register_sequence(adev, |
889 | golden_settings_mmhub_1_0_0, | 912 | golden_settings_mmhub_1_0_0, |
890 | ARRAY_SIZE(golden_settings_mmhub_1_0_0)); | 913 | ARRAY_SIZE(golden_settings_mmhub_1_0_0)); |
891 | amdgpu_program_register_sequence(adev, | 914 | soc15_program_register_sequence(adev, |
892 | golden_settings_athub_1_0_0, | 915 | golden_settings_athub_1_0_0, |
893 | ARRAY_SIZE(golden_settings_athub_1_0_0)); | 916 | ARRAY_SIZE(golden_settings_athub_1_0_0)); |
894 | break; | 917 | break; |
895 | case CHIP_RAVEN: | 918 | case CHIP_RAVEN: |
896 | amdgpu_program_register_sequence(adev, | 919 | soc15_program_register_sequence(adev, |
897 | golden_settings_athub_1_0_0, | 920 | golden_settings_athub_1_0_0, |
898 | ARRAY_SIZE(golden_settings_athub_1_0_0)); | 921 | ARRAY_SIZE(golden_settings_athub_1_0_0)); |
899 | break; | 922 | break; |
@@ -913,9 +936,9 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev) | |||
913 | bool value; | 936 | bool value; |
914 | u32 tmp; | 937 | u32 tmp; |
915 | 938 | ||
916 | amdgpu_program_register_sequence(adev, | 939 | amdgpu_device_program_register_sequence(adev, |
917 | golden_settings_vega10_hdp, | 940 | golden_settings_vega10_hdp, |
918 | ARRAY_SIZE(golden_settings_vega10_hdp)); | 941 | ARRAY_SIZE(golden_settings_vega10_hdp)); |
919 | 942 | ||
920 | if (adev->gart.robj == NULL) { | 943 | if (adev->gart.robj == NULL) { |
921 | dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); | 944 | dev_err(adev->dev, "No VRAM object for PCIE GART.\n"); |
@@ -948,10 +971,7 @@ static int gmc_v9_0_gart_enable(struct amdgpu_device *adev) | |||
948 | WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp); | 971 | WREG32_SOC15(HDP, 0, mmHDP_HOST_PATH_CNTL, tmp); |
949 | 972 | ||
950 | /* After HDP is initialized, flush HDP.*/ | 973 | /* After HDP is initialized, flush HDP.*/ |
951 | if (adev->flags & AMD_IS_APU) | 974 | adev->nbio_funcs->hdp_flush(adev); |
952 | nbio_v7_0_hdp_flush(adev); | ||
953 | else | ||
954 | nbio_v6_1_hdp_flush(adev); | ||
955 | 975 | ||
956 | if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) | 976 | if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) |
957 | value = false; | 977 | value = false; |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index f33d1ffdb20b..d9e9e52a0def 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
@@ -1682,8 +1682,8 @@ static void kv_dpm_powergate_uvd(void *handle, bool gate) | |||
1682 | 1682 | ||
1683 | if (gate) { | 1683 | if (gate) { |
1684 | /* stop the UVD block */ | 1684 | /* stop the UVD block */ |
1685 | ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1685 | ret = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1686 | AMD_PG_STATE_GATE); | 1686 | AMD_PG_STATE_GATE); |
1687 | kv_update_uvd_dpm(adev, gate); | 1687 | kv_update_uvd_dpm(adev, gate); |
1688 | if (pi->caps_uvd_pg) | 1688 | if (pi->caps_uvd_pg) |
1689 | /* power off the UVD block */ | 1689 | /* power off the UVD block */ |
@@ -1695,8 +1695,8 @@ static void kv_dpm_powergate_uvd(void *handle, bool gate) | |||
1695 | /* re-init the UVD block */ | 1695 | /* re-init the UVD block */ |
1696 | kv_update_uvd_dpm(adev, gate); | 1696 | kv_update_uvd_dpm(adev, gate); |
1697 | 1697 | ||
1698 | ret = amdgpu_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, | 1698 | ret = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_UVD, |
1699 | AMD_PG_STATE_UNGATE); | 1699 | AMD_PG_STATE_UNGATE); |
1700 | } | 1700 | } |
1701 | } | 1701 | } |
1702 | 1702 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c index bd160d8700e0..ffd5b7ee49c4 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "amdgpu.h" | 23 | #include "amdgpu.h" |
24 | #include "mmhub_v1_0.h" | 24 | #include "mmhub_v1_0.h" |
25 | 25 | ||
26 | #include "soc15ip.h" | ||
27 | #include "mmhub/mmhub_1_0_offset.h" | 26 | #include "mmhub/mmhub_1_0_offset.h" |
28 | #include "mmhub/mmhub_1_0_sh_mask.h" | 27 | #include "mmhub/mmhub_1_0_sh_mask.h" |
29 | #include "mmhub/mmhub_1_0_default.h" | 28 | #include "mmhub/mmhub_1_0_default.h" |
@@ -156,10 +155,15 @@ static void mmhub_v1_0_init_cache_regs(struct amdgpu_device *adev) | |||
156 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1); | 155 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1); |
157 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp); | 156 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL2, tmp); |
158 | 157 | ||
159 | tmp = mmVM_L2_CNTL3_DEFAULT; | 158 | if (adev->mc.translate_further) { |
160 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9); | 159 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12); |
161 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | 160 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, |
162 | WREG32_SOC15(MMHUB, 0, mmVM_L2_CNTL3, tmp); | 161 | L2_CACHE_BIGK_FRAGMENT_SIZE, 9); |
162 | } else { | ||
163 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9); | ||
164 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, | ||
165 | L2_CACHE_BIGK_FRAGMENT_SIZE, 6); | ||
166 | } | ||
163 | 167 | ||
164 | tmp = mmVM_L2_CNTL4_DEFAULT; | 168 | tmp = mmVM_L2_CNTL4_DEFAULT; |
165 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PDE_REQUEST_PHYSICAL, 0); | 169 | tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_PDE_REQUEST_PHYSICAL, 0); |
@@ -197,32 +201,40 @@ static void mmhub_v1_0_disable_identity_aperture(struct amdgpu_device *adev) | |||
197 | 201 | ||
198 | static void mmhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) | 202 | static void mmhub_v1_0_setup_vmid_config(struct amdgpu_device *adev) |
199 | { | 203 | { |
200 | int i; | 204 | unsigned num_level, block_size; |
201 | uint32_t tmp; | 205 | uint32_t tmp; |
206 | int i; | ||
207 | |||
208 | num_level = adev->vm_manager.num_level; | ||
209 | block_size = adev->vm_manager.block_size; | ||
210 | if (adev->mc.translate_further) | ||
211 | num_level -= 1; | ||
212 | else | ||
213 | block_size -= 9; | ||
202 | 214 | ||
203 | for (i = 0; i <= 14; i++) { | 215 | for (i = 0; i <= 14; i++) { |
204 | tmp = RREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i); | 216 | tmp = RREG32_SOC15_OFFSET(MMHUB, 0, mmVM_CONTEXT1_CNTL, i); |
217 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1); | ||
218 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH, | ||
219 | num_level); | ||
205 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 220 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
206 | ENABLE_CONTEXT, 1); | 221 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
207 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | ||
208 | PAGE_TABLE_DEPTH, adev->vm_manager.num_level); | ||
209 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | ||
210 | RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | ||
211 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 222 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
212 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 223 | DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, |
224 | 1); | ||
213 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 225 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
214 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 226 | PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
215 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 227 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
216 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 228 | VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
217 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 229 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
218 | READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 230 | READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
219 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 231 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
220 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 232 | WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
221 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 233 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
222 | EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); | 234 | EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1); |
223 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 235 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
224 | PAGE_TABLE_BLOCK_SIZE, | 236 | PAGE_TABLE_BLOCK_SIZE, |
225 | adev->vm_manager.block_size - 9); | 237 | block_size); |
226 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ | 238 | /* Send no-retry XNACK on fault to suppress VM fault storm. */ |
227 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, | 239 | tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, |
228 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); | 240 | RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0); |
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c index ad9054e3903c..271452d3999a 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | |||
@@ -22,7 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "amdgpu.h" | 24 | #include "amdgpu.h" |
25 | #include "soc15ip.h" | ||
26 | #include "nbio/nbio_6_1_offset.h" | 25 | #include "nbio/nbio_6_1_offset.h" |
27 | #include "nbio/nbio_6_1_sh_mask.h" | 26 | #include "nbio/nbio_6_1_sh_mask.h" |
28 | #include "gc/gc_9_0_offset.h" | 27 | #include "gc/gc_9_0_offset.h" |
@@ -254,7 +253,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) | |||
254 | } | 253 | } |
255 | 254 | ||
256 | /* Trigger recovery due to world switch failure */ | 255 | /* Trigger recovery due to world switch failure */ |
257 | amdgpu_gpu_recover(adev, NULL); | 256 | amdgpu_device_gpu_recover(adev, NULL, false); |
258 | } | 257 | } |
259 | 258 | ||
260 | static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev, | 259 | static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev, |
@@ -278,7 +277,7 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev, | |||
278 | int r; | 277 | int r; |
279 | 278 | ||
280 | /* trigger gpu-reset by hypervisor only if TDR disbaled */ | 279 | /* trigger gpu-reset by hypervisor only if TDR disbaled */ |
281 | if (amdgpu_lockup_timeout == 0) { | 280 | if (!amdgpu_gpu_recovery) { |
282 | /* see what event we get */ | 281 | /* see what event we get */ |
283 | r = xgpu_ai_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); | 282 | r = xgpu_ai_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); |
284 | 283 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c index df52824c0cd4..9fc1c37344ce 100644 --- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | |||
@@ -279,32 +279,32 @@ void xgpu_vi_init_golden_registers(struct amdgpu_device *adev) | |||
279 | { | 279 | { |
280 | switch (adev->asic_type) { | 280 | switch (adev->asic_type) { |
281 | case CHIP_FIJI: | 281 | case CHIP_FIJI: |
282 | amdgpu_program_register_sequence(adev, | 282 | amdgpu_device_program_register_sequence(adev, |
283 | xgpu_fiji_mgcg_cgcg_init, | 283 | xgpu_fiji_mgcg_cgcg_init, |
284 | ARRAY_SIZE( | 284 | ARRAY_SIZE( |
285 | xgpu_fiji_mgcg_cgcg_init)); | 285 | xgpu_fiji_mgcg_cgcg_init)); |
286 | amdgpu_program_register_sequence(adev, | 286 | amdgpu_device_program_register_sequence(adev, |
287 | xgpu_fiji_golden_settings_a10, | 287 | xgpu_fiji_golden_settings_a10, |
288 | ARRAY_SIZE( | 288 | ARRAY_SIZE( |
289 | xgpu_fiji_golden_settings_a10)); | 289 | xgpu_fiji_golden_settings_a10)); |
290 | amdgpu_program_register_sequence(adev, | 290 | amdgpu_device_program_register_sequence(adev, |
291 | xgpu_fiji_golden_common_all, | 291 | xgpu_fiji_golden_common_all, |
292 | ARRAY_SIZE( | 292 | ARRAY_SIZE( |
293 | xgpu_fiji_golden_common_all)); | 293 | xgpu_fiji_golden_common_all)); |
294 | break; | 294 | break; |
295 | case CHIP_TONGA: | 295 | case CHIP_TONGA: |
296 | amdgpu_program_register_sequence(adev, | 296 | amdgpu_device_program_register_sequence(adev, |
297 | xgpu_tonga_mgcg_cgcg_init, | 297 | xgpu_tonga_mgcg_cgcg_init, |
298 | ARRAY_SIZE( | 298 | ARRAY_SIZE( |
299 | xgpu_tonga_mgcg_cgcg_init)); | 299 | xgpu_tonga_mgcg_cgcg_init)); |
300 | amdgpu_program_register_sequence(adev, | 300 | amdgpu_device_program_register_sequence(adev, |
301 | xgpu_tonga_golden_settings_a11, | 301 | xgpu_tonga_golden_settings_a11, |
302 | ARRAY_SIZE( | 302 | ARRAY_SIZE( |
303 | xgpu_tonga_golden_settings_a11)); | 303 | xgpu_tonga_golden_settings_a11)); |
304 | amdgpu_program_register_sequence(adev, | 304 | amdgpu_device_program_register_sequence(adev, |
305 | xgpu_tonga_golden_common_all, | 305 | xgpu_tonga_golden_common_all, |
306 | ARRAY_SIZE( | 306 | ARRAY_SIZE( |
307 | xgpu_tonga_golden_common_all)); | 307 | xgpu_tonga_golden_common_all)); |
308 | break; | 308 | break; |
309 | default: | 309 | default: |
310 | BUG_ON("Doesn't support chip type.\n"); | 310 | BUG_ON("Doesn't support chip type.\n"); |
@@ -521,7 +521,7 @@ static void xgpu_vi_mailbox_flr_work(struct work_struct *work) | |||
521 | } | 521 | } |
522 | 522 | ||
523 | /* Trigger recovery due to world switch failure */ | 523 | /* Trigger recovery due to world switch failure */ |
524 | amdgpu_gpu_recover(adev, NULL); | 524 | amdgpu_device_gpu_recover(adev, NULL, false); |
525 | } | 525 | } |
526 | 526 | ||
527 | static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev, | 527 | static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev, |
@@ -545,7 +545,7 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, | |||
545 | int r; | 545 | int r; |
546 | 546 | ||
547 | /* trigger gpu-reset by hypervisor only if TDR disbaled */ | 547 | /* trigger gpu-reset by hypervisor only if TDR disbaled */ |
548 | if (amdgpu_lockup_timeout == 0) { | 548 | if (!amdgpu_gpu_recovery) { |
549 | /* see what event we get */ | 549 | /* see what event we get */ |
550 | r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); | 550 | r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION); |
551 | 551 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c index 76db711097c7..d4da663d5eb0 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "amdgpu_atombios.h" | 24 | #include "amdgpu_atombios.h" |
25 | #include "nbio_v6_1.h" | 25 | #include "nbio_v6_1.h" |
26 | 26 | ||
27 | #include "soc15ip.h" | ||
28 | #include "nbio/nbio_6_1_default.h" | 27 | #include "nbio/nbio_6_1_default.h" |
29 | #include "nbio/nbio_6_1_offset.h" | 28 | #include "nbio/nbio_6_1_offset.h" |
30 | #include "nbio/nbio_6_1_sh_mask.h" | 29 | #include "nbio/nbio_6_1_sh_mask.h" |
@@ -34,7 +33,7 @@ | |||
34 | #define smnPCIE_CNTL2 0x11180070 | 33 | #define smnPCIE_CNTL2 0x11180070 |
35 | #define smnPCIE_CONFIG_CNTL 0x11180044 | 34 | #define smnPCIE_CONFIG_CNTL 0x11180044 |
36 | 35 | ||
37 | u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev) | 36 | static u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev) |
38 | { | 37 | { |
39 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); | 38 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); |
40 | 39 | ||
@@ -44,19 +43,7 @@ u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev) | |||
44 | return tmp; | 43 | return tmp; |
45 | } | 44 | } |
46 | 45 | ||
47 | u32 nbio_v6_1_get_atombios_scratch_regs(struct amdgpu_device *adev, | 46 | static void nbio_v6_1_mc_access_enable(struct amdgpu_device *adev, bool enable) |
48 | uint32_t idx) | ||
49 | { | ||
50 | return RREG32_SOC15_OFFSET(NBIO, 0, mmBIOS_SCRATCH_0, idx); | ||
51 | } | ||
52 | |||
53 | void nbio_v6_1_set_atombios_scratch_regs(struct amdgpu_device *adev, | ||
54 | uint32_t idx, uint32_t val) | ||
55 | { | ||
56 | WREG32_SOC15_OFFSET(NBIO, 0, mmBIOS_SCRATCH_0, idx, val); | ||
57 | } | ||
58 | |||
59 | void nbio_v6_1_mc_access_enable(struct amdgpu_device *adev, bool enable) | ||
60 | { | 47 | { |
61 | if (enable) | 48 | if (enable) |
62 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, | 49 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, |
@@ -66,26 +53,23 @@ void nbio_v6_1_mc_access_enable(struct amdgpu_device *adev, bool enable) | |||
66 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0); | 53 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0); |
67 | } | 54 | } |
68 | 55 | ||
69 | void nbio_v6_1_hdp_flush(struct amdgpu_device *adev) | 56 | static void nbio_v6_1_hdp_flush(struct amdgpu_device *adev) |
70 | { | 57 | { |
71 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL, 0); | 58 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmBIF_BX_PF0_HDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
72 | } | 59 | } |
73 | 60 | ||
74 | u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev) | 61 | static u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev) |
75 | { | 62 | { |
76 | return RREG32_SOC15(NBIO, 0, mmRCC_PF_0_0_RCC_CONFIG_MEMSIZE); | 63 | return RREG32_SOC15(NBIO, 0, mmRCC_PF_0_0_RCC_CONFIG_MEMSIZE); |
77 | } | 64 | } |
78 | 65 | ||
79 | static const u32 nbio_sdma_doorbell_range_reg[] = | 66 | static void nbio_v6_1_sdma_doorbell_range(struct amdgpu_device *adev, int instance, |
80 | { | ||
81 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE), | ||
82 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE) | ||
83 | }; | ||
84 | |||
85 | void nbio_v6_1_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | ||
86 | bool use_doorbell, int doorbell_index) | 67 | bool use_doorbell, int doorbell_index) |
87 | { | 68 | { |
88 | u32 doorbell_range = RREG32(nbio_sdma_doorbell_range_reg[instance]); | 69 | u32 reg = instance == 0 ? SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE) : |
70 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE); | ||
71 | |||
72 | u32 doorbell_range = RREG32(reg); | ||
89 | 73 | ||
90 | if (use_doorbell) { | 74 | if (use_doorbell) { |
91 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); | 75 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); |
@@ -93,17 +77,18 @@ void nbio_v6_1_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | |||
93 | } else | 77 | } else |
94 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); | 78 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); |
95 | 79 | ||
96 | WREG32(nbio_sdma_doorbell_range_reg[instance], doorbell_range); | 80 | WREG32(reg, doorbell_range); |
81 | |||
97 | } | 82 | } |
98 | 83 | ||
99 | void nbio_v6_1_enable_doorbell_aperture(struct amdgpu_device *adev, | 84 | static void nbio_v6_1_enable_doorbell_aperture(struct amdgpu_device *adev, |
100 | bool enable) | 85 | bool enable) |
101 | { | 86 | { |
102 | WREG32_FIELD15(NBIO, 0, RCC_PF_0_0_RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0); | 87 | WREG32_FIELD15(NBIO, 0, RCC_PF_0_0_RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0); |
103 | } | 88 | } |
104 | 89 | ||
105 | void nbio_v6_1_enable_doorbell_selfring_aperture(struct amdgpu_device *adev, | 90 | static void nbio_v6_1_enable_doorbell_selfring_aperture(struct amdgpu_device *adev, |
106 | bool enable) | 91 | bool enable) |
107 | { | 92 | { |
108 | u32 tmp = 0; | 93 | u32 tmp = 0; |
109 | 94 | ||
@@ -122,8 +107,8 @@ void nbio_v6_1_enable_doorbell_selfring_aperture(struct amdgpu_device *adev, | |||
122 | } | 107 | } |
123 | 108 | ||
124 | 109 | ||
125 | void nbio_v6_1_ih_doorbell_range(struct amdgpu_device *adev, | 110 | static void nbio_v6_1_ih_doorbell_range(struct amdgpu_device *adev, |
126 | bool use_doorbell, int doorbell_index) | 111 | bool use_doorbell, int doorbell_index) |
127 | { | 112 | { |
128 | u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0 , mmBIF_IH_DOORBELL_RANGE); | 113 | u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0 , mmBIF_IH_DOORBELL_RANGE); |
129 | 114 | ||
@@ -136,7 +121,7 @@ void nbio_v6_1_ih_doorbell_range(struct amdgpu_device *adev, | |||
136 | WREG32_SOC15(NBIO, 0, mmBIF_IH_DOORBELL_RANGE, ih_doorbell_range); | 121 | WREG32_SOC15(NBIO, 0, mmBIF_IH_DOORBELL_RANGE, ih_doorbell_range); |
137 | } | 122 | } |
138 | 123 | ||
139 | void nbio_v6_1_ih_control(struct amdgpu_device *adev) | 124 | static void nbio_v6_1_ih_control(struct amdgpu_device *adev) |
140 | { | 125 | { |
141 | u32 interrupt_cntl; | 126 | u32 interrupt_cntl; |
142 | 127 | ||
@@ -152,8 +137,8 @@ void nbio_v6_1_ih_control(struct amdgpu_device *adev) | |||
152 | WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl); | 137 | WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl); |
153 | } | 138 | } |
154 | 139 | ||
155 | void nbio_v6_1_update_medium_grain_clock_gating(struct amdgpu_device *adev, | 140 | static void nbio_v6_1_update_medium_grain_clock_gating(struct amdgpu_device *adev, |
156 | bool enable) | 141 | bool enable) |
157 | { | 142 | { |
158 | uint32_t def, data; | 143 | uint32_t def, data; |
159 | 144 | ||
@@ -180,8 +165,8 @@ void nbio_v6_1_update_medium_grain_clock_gating(struct amdgpu_device *adev, | |||
180 | WREG32_PCIE(smnCPM_CONTROL, data); | 165 | WREG32_PCIE(smnCPM_CONTROL, data); |
181 | } | 166 | } |
182 | 167 | ||
183 | void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, | 168 | static void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, |
184 | bool enable) | 169 | bool enable) |
185 | { | 170 | { |
186 | uint32_t def, data; | 171 | uint32_t def, data; |
187 | 172 | ||
@@ -200,7 +185,8 @@ void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, | |||
200 | WREG32_PCIE(smnPCIE_CNTL2, data); | 185 | WREG32_PCIE(smnPCIE_CNTL2, data); |
201 | } | 186 | } |
202 | 187 | ||
203 | void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, u32 *flags) | 188 | static void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, |
189 | u32 *flags) | ||
204 | { | 190 | { |
205 | int data; | 191 | int data; |
206 | 192 | ||
@@ -215,9 +201,27 @@ void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, u32 *flags) | |||
215 | *flags |= AMD_CG_SUPPORT_BIF_LS; | 201 | *flags |= AMD_CG_SUPPORT_BIF_LS; |
216 | } | 202 | } |
217 | 203 | ||
218 | const struct nbio_hdp_flush_reg nbio_v6_1_hdp_flush_reg = { | 204 | static u32 nbio_v6_1_get_hdp_flush_req_offset(struct amdgpu_device *adev) |
219 | .hdp_flush_req_offset = SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_GPU_HDP_FLUSH_REQ), | 205 | { |
220 | .hdp_flush_done_offset = SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_GPU_HDP_FLUSH_DONE), | 206 | return SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_GPU_HDP_FLUSH_REQ); |
207 | } | ||
208 | |||
209 | static u32 nbio_v6_1_get_hdp_flush_done_offset(struct amdgpu_device *adev) | ||
210 | { | ||
211 | return SOC15_REG_OFFSET(NBIO, 0, mmBIF_BX_PF0_GPU_HDP_FLUSH_DONE); | ||
212 | } | ||
213 | |||
214 | static u32 nbio_v6_1_get_pcie_index_offset(struct amdgpu_device *adev) | ||
215 | { | ||
216 | return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX); | ||
217 | } | ||
218 | |||
219 | static u32 nbio_v6_1_get_pcie_data_offset(struct amdgpu_device *adev) | ||
220 | { | ||
221 | return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA); | ||
222 | } | ||
223 | |||
224 | static const struct nbio_hdp_flush_reg nbio_v6_1_hdp_flush_reg = { | ||
221 | .ref_and_mask_cp0 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP0_MASK, | 225 | .ref_and_mask_cp0 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP0_MASK, |
222 | .ref_and_mask_cp1 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP1_MASK, | 226 | .ref_and_mask_cp1 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP1_MASK, |
223 | .ref_and_mask_cp2 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP2_MASK, | 227 | .ref_and_mask_cp2 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__CP2_MASK, |
@@ -232,12 +236,7 @@ const struct nbio_hdp_flush_reg nbio_v6_1_hdp_flush_reg = { | |||
232 | .ref_and_mask_sdma1 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__SDMA1_MASK | 236 | .ref_and_mask_sdma1 = BIF_BX_PF0_GPU_HDP_FLUSH_DONE__SDMA1_MASK |
233 | }; | 237 | }; |
234 | 238 | ||
235 | const struct nbio_pcie_index_data nbio_v6_1_pcie_index_data = { | 239 | static void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev) |
236 | .index_offset = SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX), | ||
237 | .data_offset = SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA), | ||
238 | }; | ||
239 | |||
240 | void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev) | ||
241 | { | 240 | { |
242 | uint32_t reg; | 241 | uint32_t reg; |
243 | 242 | ||
@@ -254,7 +253,7 @@ void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev) | |||
254 | } | 253 | } |
255 | } | 254 | } |
256 | 255 | ||
257 | void nbio_v6_1_init_registers(struct amdgpu_device *adev) | 256 | static void nbio_v6_1_init_registers(struct amdgpu_device *adev) |
258 | { | 257 | { |
259 | uint32_t def, data; | 258 | uint32_t def, data; |
260 | 259 | ||
@@ -265,3 +264,25 @@ void nbio_v6_1_init_registers(struct amdgpu_device *adev) | |||
265 | if (def != data) | 264 | if (def != data) |
266 | WREG32_PCIE(smnPCIE_CONFIG_CNTL, data); | 265 | WREG32_PCIE(smnPCIE_CONFIG_CNTL, data); |
267 | } | 266 | } |
267 | |||
268 | const struct amdgpu_nbio_funcs nbio_v6_1_funcs = { | ||
269 | .hdp_flush_reg = &nbio_v6_1_hdp_flush_reg, | ||
270 | .get_hdp_flush_req_offset = nbio_v6_1_get_hdp_flush_req_offset, | ||
271 | .get_hdp_flush_done_offset = nbio_v6_1_get_hdp_flush_done_offset, | ||
272 | .get_pcie_index_offset = nbio_v6_1_get_pcie_index_offset, | ||
273 | .get_pcie_data_offset = nbio_v6_1_get_pcie_data_offset, | ||
274 | .get_rev_id = nbio_v6_1_get_rev_id, | ||
275 | .mc_access_enable = nbio_v6_1_mc_access_enable, | ||
276 | .hdp_flush = nbio_v6_1_hdp_flush, | ||
277 | .get_memsize = nbio_v6_1_get_memsize, | ||
278 | .sdma_doorbell_range = nbio_v6_1_sdma_doorbell_range, | ||
279 | .enable_doorbell_aperture = nbio_v6_1_enable_doorbell_aperture, | ||
280 | .enable_doorbell_selfring_aperture = nbio_v6_1_enable_doorbell_selfring_aperture, | ||
281 | .ih_doorbell_range = nbio_v6_1_ih_doorbell_range, | ||
282 | .update_medium_grain_clock_gating = nbio_v6_1_update_medium_grain_clock_gating, | ||
283 | .update_medium_grain_light_sleep = nbio_v6_1_update_medium_grain_light_sleep, | ||
284 | .get_clockgating_state = nbio_v6_1_get_clockgating_state, | ||
285 | .ih_control = nbio_v6_1_ih_control, | ||
286 | .init_registers = nbio_v6_1_init_registers, | ||
287 | .detect_hw_virt = nbio_v6_1_detect_hw_virt, | ||
288 | }; | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h index 14ca8d45a46c..0743a6f016f3 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v6_1.h | |||
@@ -26,30 +26,6 @@ | |||
26 | 26 | ||
27 | #include "soc15_common.h" | 27 | #include "soc15_common.h" |
28 | 28 | ||
29 | extern const struct nbio_hdp_flush_reg nbio_v6_1_hdp_flush_reg; | 29 | extern const struct amdgpu_nbio_funcs nbio_v6_1_funcs; |
30 | extern const struct nbio_pcie_index_data nbio_v6_1_pcie_index_data; | ||
31 | int nbio_v6_1_init(struct amdgpu_device *adev); | ||
32 | u32 nbio_v6_1_get_atombios_scratch_regs(struct amdgpu_device *adev, | ||
33 | uint32_t idx); | ||
34 | void nbio_v6_1_set_atombios_scratch_regs(struct amdgpu_device *adev, | ||
35 | uint32_t idx, uint32_t val); | ||
36 | void nbio_v6_1_mc_access_enable(struct amdgpu_device *adev, bool enable); | ||
37 | void nbio_v6_1_hdp_flush(struct amdgpu_device *adev); | ||
38 | u32 nbio_v6_1_get_memsize(struct amdgpu_device *adev); | ||
39 | void nbio_v6_1_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | ||
40 | bool use_doorbell, int doorbell_index); | ||
41 | void nbio_v6_1_enable_doorbell_aperture(struct amdgpu_device *adev, | ||
42 | bool enable); | ||
43 | void nbio_v6_1_enable_doorbell_selfring_aperture(struct amdgpu_device *adev, | ||
44 | bool enable); | ||
45 | void nbio_v6_1_ih_doorbell_range(struct amdgpu_device *adev, | ||
46 | bool use_doorbell, int doorbell_index); | ||
47 | void nbio_v6_1_ih_control(struct amdgpu_device *adev); | ||
48 | u32 nbio_v6_1_get_rev_id(struct amdgpu_device *adev); | ||
49 | void nbio_v6_1_update_medium_grain_clock_gating(struct amdgpu_device *adev, bool enable); | ||
50 | void nbio_v6_1_update_medium_grain_light_sleep(struct amdgpu_device *adev, bool enable); | ||
51 | void nbio_v6_1_get_clockgating_state(struct amdgpu_device *adev, u32 *flags); | ||
52 | void nbio_v6_1_detect_hw_virt(struct amdgpu_device *adev); | ||
53 | void nbio_v6_1_init_registers(struct amdgpu_device *adev); | ||
54 | 30 | ||
55 | #endif | 31 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c index 1fb77174e02c..17a9131a4598 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "amdgpu_atombios.h" | 24 | #include "amdgpu_atombios.h" |
25 | #include "nbio_v7_0.h" | 25 | #include "nbio_v7_0.h" |
26 | 26 | ||
27 | #include "soc15ip.h" | ||
28 | #include "nbio/nbio_7_0_default.h" | 27 | #include "nbio/nbio_7_0_default.h" |
29 | #include "nbio/nbio_7_0_offset.h" | 28 | #include "nbio/nbio_7_0_offset.h" |
30 | #include "nbio/nbio_7_0_sh_mask.h" | 29 | #include "nbio/nbio_7_0_sh_mask.h" |
@@ -32,7 +31,10 @@ | |||
32 | 31 | ||
33 | #define smnNBIF_MGCG_CTRL_LCLK 0x1013a05c | 32 | #define smnNBIF_MGCG_CTRL_LCLK 0x1013a05c |
34 | 33 | ||
35 | u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev) | 34 | #define smnCPM_CONTROL 0x11180460 |
35 | #define smnPCIE_CNTL2 0x11180070 | ||
36 | |||
37 | static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev) | ||
36 | { | 38 | { |
37 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); | 39 | u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0); |
38 | 40 | ||
@@ -42,19 +44,7 @@ u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev) | |||
42 | return tmp; | 44 | return tmp; |
43 | } | 45 | } |
44 | 46 | ||
45 | u32 nbio_v7_0_get_atombios_scratch_regs(struct amdgpu_device *adev, | 47 | static void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable) |
46 | uint32_t idx) | ||
47 | { | ||
48 | return RREG32_SOC15_OFFSET(NBIO, 0, mmBIOS_SCRATCH_0, idx); | ||
49 | } | ||
50 | |||
51 | void nbio_v7_0_set_atombios_scratch_regs(struct amdgpu_device *adev, | ||
52 | uint32_t idx, uint32_t val) | ||
53 | { | ||
54 | WREG32_SOC15_OFFSET(NBIO, 0, mmBIOS_SCRATCH_0, idx, val); | ||
55 | } | ||
56 | |||
57 | void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable) | ||
58 | { | 48 | { |
59 | if (enable) | 49 | if (enable) |
60 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, | 50 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, |
@@ -63,26 +53,23 @@ void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable) | |||
63 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0); | 53 | WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0); |
64 | } | 54 | } |
65 | 55 | ||
66 | void nbio_v7_0_hdp_flush(struct amdgpu_device *adev) | 56 | static void nbio_v7_0_hdp_flush(struct amdgpu_device *adev) |
67 | { | 57 | { |
68 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0); | 58 | WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0); |
69 | } | 59 | } |
70 | 60 | ||
71 | u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev) | 61 | static u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev) |
72 | { | 62 | { |
73 | return RREG32_SOC15(NBIO, 0, mmRCC_CONFIG_MEMSIZE); | 63 | return RREG32_SOC15(NBIO, 0, mmRCC_CONFIG_MEMSIZE); |
74 | } | 64 | } |
75 | 65 | ||
76 | static const u32 nbio_sdma_doorbell_range_reg[] = | 66 | static void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance, |
67 | bool use_doorbell, int doorbell_index) | ||
77 | { | 68 | { |
78 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE), | 69 | u32 reg = instance == 0 ? SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE) : |
79 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE) | 70 | SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE); |
80 | }; | ||
81 | 71 | ||
82 | void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | 72 | u32 doorbell_range = RREG32(reg); |
83 | bool use_doorbell, int doorbell_index) | ||
84 | { | ||
85 | u32 doorbell_range = RREG32(nbio_sdma_doorbell_range_reg[instance]); | ||
86 | 73 | ||
87 | if (use_doorbell) { | 74 | if (use_doorbell) { |
88 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); | 75 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index); |
@@ -90,17 +77,23 @@ void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | |||
90 | } else | 77 | } else |
91 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); | 78 | doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0); |
92 | 79 | ||
93 | WREG32(nbio_sdma_doorbell_range_reg[instance], doorbell_range); | 80 | WREG32(reg, doorbell_range); |
94 | } | 81 | } |
95 | 82 | ||
96 | void nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device *adev, | 83 | static void nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device *adev, |
97 | bool enable) | 84 | bool enable) |
98 | { | 85 | { |
99 | WREG32_FIELD15(NBIO, 0, RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0); | 86 | WREG32_FIELD15(NBIO, 0, RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0); |
100 | } | 87 | } |
101 | 88 | ||
102 | void nbio_v7_0_ih_doorbell_range(struct amdgpu_device *adev, | 89 | static void nbio_v7_0_enable_doorbell_selfring_aperture(struct amdgpu_device *adev, |
103 | bool use_doorbell, int doorbell_index) | 90 | bool enable) |
91 | { | ||
92 | |||
93 | } | ||
94 | |||
95 | static void nbio_v7_0_ih_doorbell_range(struct amdgpu_device *adev, | ||
96 | bool use_doorbell, int doorbell_index) | ||
104 | { | 97 | { |
105 | u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0 , mmBIF_IH_DOORBELL_RANGE); | 98 | u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0 , mmBIF_IH_DOORBELL_RANGE); |
106 | 99 | ||
@@ -130,8 +123,8 @@ static void nbio_7_0_write_syshub_ind_mmr(struct amdgpu_device *adev, uint32_t o | |||
130 | WREG32_SOC15(NBIO, 0, mmSYSHUB_DATA, data); | 123 | WREG32_SOC15(NBIO, 0, mmSYSHUB_DATA, data); |
131 | } | 124 | } |
132 | 125 | ||
133 | void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev, | 126 | static void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev, |
134 | bool enable) | 127 | bool enable) |
135 | { | 128 | { |
136 | uint32_t def, data; | 129 | uint32_t def, data; |
137 | 130 | ||
@@ -169,7 +162,43 @@ void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev, | |||
169 | nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK, data); | 162 | nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK, data); |
170 | } | 163 | } |
171 | 164 | ||
172 | void nbio_v7_0_ih_control(struct amdgpu_device *adev) | 165 | static void nbio_v7_0_update_medium_grain_light_sleep(struct amdgpu_device *adev, |
166 | bool enable) | ||
167 | { | ||
168 | uint32_t def, data; | ||
169 | |||
170 | def = data = RREG32_PCIE(smnPCIE_CNTL2); | ||
171 | if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS)) { | ||
172 | data |= (PCIE_CNTL2__SLV_MEM_LS_EN_MASK | | ||
173 | PCIE_CNTL2__MST_MEM_LS_EN_MASK | | ||
174 | PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK); | ||
175 | } else { | ||
176 | data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK | | ||
177 | PCIE_CNTL2__MST_MEM_LS_EN_MASK | | ||
178 | PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK); | ||
179 | } | ||
180 | |||
181 | if (def != data) | ||
182 | WREG32_PCIE(smnPCIE_CNTL2, data); | ||
183 | } | ||
184 | |||
185 | static void nbio_v7_0_get_clockgating_state(struct amdgpu_device *adev, | ||
186 | u32 *flags) | ||
187 | { | ||
188 | int data; | ||
189 | |||
190 | /* AMD_CG_SUPPORT_BIF_MGCG */ | ||
191 | data = RREG32_PCIE(smnCPM_CONTROL); | ||
192 | if (data & CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK) | ||
193 | *flags |= AMD_CG_SUPPORT_BIF_MGCG; | ||
194 | |||
195 | /* AMD_CG_SUPPORT_BIF_LS */ | ||
196 | data = RREG32_PCIE(smnPCIE_CNTL2); | ||
197 | if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK) | ||
198 | *flags |= AMD_CG_SUPPORT_BIF_LS; | ||
199 | } | ||
200 | |||
201 | static void nbio_v7_0_ih_control(struct amdgpu_device *adev) | ||
173 | { | 202 | { |
174 | u32 interrupt_cntl; | 203 | u32 interrupt_cntl; |
175 | 204 | ||
@@ -185,9 +214,27 @@ void nbio_v7_0_ih_control(struct amdgpu_device *adev) | |||
185 | WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl); | 214 | WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl); |
186 | } | 215 | } |
187 | 216 | ||
217 | static u32 nbio_v7_0_get_hdp_flush_req_offset(struct amdgpu_device *adev) | ||
218 | { | ||
219 | return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_REQ); | ||
220 | } | ||
221 | |||
222 | static u32 nbio_v7_0_get_hdp_flush_done_offset(struct amdgpu_device *adev) | ||
223 | { | ||
224 | return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_DONE); | ||
225 | } | ||
226 | |||
227 | static u32 nbio_v7_0_get_pcie_index_offset(struct amdgpu_device *adev) | ||
228 | { | ||
229 | return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX2); | ||
230 | } | ||
231 | |||
232 | static u32 nbio_v7_0_get_pcie_data_offset(struct amdgpu_device *adev) | ||
233 | { | ||
234 | return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA2); | ||
235 | } | ||
236 | |||
188 | const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { | 237 | const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { |
189 | .hdp_flush_req_offset = SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_REQ), | ||
190 | .hdp_flush_done_offset = SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_DONE), | ||
191 | .ref_and_mask_cp0 = GPU_HDP_FLUSH_DONE__CP0_MASK, | 238 | .ref_and_mask_cp0 = GPU_HDP_FLUSH_DONE__CP0_MASK, |
192 | .ref_and_mask_cp1 = GPU_HDP_FLUSH_DONE__CP1_MASK, | 239 | .ref_and_mask_cp1 = GPU_HDP_FLUSH_DONE__CP1_MASK, |
193 | .ref_and_mask_cp2 = GPU_HDP_FLUSH_DONE__CP2_MASK, | 240 | .ref_and_mask_cp2 = GPU_HDP_FLUSH_DONE__CP2_MASK, |
@@ -202,7 +249,35 @@ const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = { | |||
202 | .ref_and_mask_sdma1 = GPU_HDP_FLUSH_DONE__SDMA1_MASK, | 249 | .ref_and_mask_sdma1 = GPU_HDP_FLUSH_DONE__SDMA1_MASK, |
203 | }; | 250 | }; |
204 | 251 | ||
205 | const struct nbio_pcie_index_data nbio_v7_0_pcie_index_data = { | 252 | static void nbio_v7_0_detect_hw_virt(struct amdgpu_device *adev) |
206 | .index_offset = SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX2), | 253 | { |
207 | .data_offset = SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA2) | 254 | if (is_virtual_machine()) /* passthrough mode exclus sriov mod */ |
255 | adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE; | ||
256 | } | ||
257 | |||
258 | static void nbio_v7_0_init_registers(struct amdgpu_device *adev) | ||
259 | { | ||
260 | |||
261 | } | ||
262 | |||
263 | const struct amdgpu_nbio_funcs nbio_v7_0_funcs = { | ||
264 | .hdp_flush_reg = &nbio_v7_0_hdp_flush_reg, | ||
265 | .get_hdp_flush_req_offset = nbio_v7_0_get_hdp_flush_req_offset, | ||
266 | .get_hdp_flush_done_offset = nbio_v7_0_get_hdp_flush_done_offset, | ||
267 | .get_pcie_index_offset = nbio_v7_0_get_pcie_index_offset, | ||
268 | .get_pcie_data_offset = nbio_v7_0_get_pcie_data_offset, | ||
269 | .get_rev_id = nbio_v7_0_get_rev_id, | ||
270 | .mc_access_enable = nbio_v7_0_mc_access_enable, | ||
271 | .hdp_flush = nbio_v7_0_hdp_flush, | ||
272 | .get_memsize = nbio_v7_0_get_memsize, | ||
273 | .sdma_doorbell_range = nbio_v7_0_sdma_doorbell_range, | ||
274 | .enable_doorbell_aperture = nbio_v7_0_enable_doorbell_aperture, | ||
275 | .enable_doorbell_selfring_aperture = nbio_v7_0_enable_doorbell_selfring_aperture, | ||
276 | .ih_doorbell_range = nbio_v7_0_ih_doorbell_range, | ||
277 | .update_medium_grain_clock_gating = nbio_v7_0_update_medium_grain_clock_gating, | ||
278 | .update_medium_grain_light_sleep = nbio_v7_0_update_medium_grain_light_sleep, | ||
279 | .get_clockgating_state = nbio_v7_0_get_clockgating_state, | ||
280 | .ih_control = nbio_v7_0_ih_control, | ||
281 | .init_registers = nbio_v7_0_init_registers, | ||
282 | .detect_hw_virt = nbio_v7_0_detect_hw_virt, | ||
208 | }; | 283 | }; |
diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.h b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.h index df8fa90f40d7..508d549c5029 100644 --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.h +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.h | |||
@@ -26,24 +26,6 @@ | |||
26 | 26 | ||
27 | #include "soc15_common.h" | 27 | #include "soc15_common.h" |
28 | 28 | ||
29 | extern const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg; | 29 | extern const struct amdgpu_nbio_funcs nbio_v7_0_funcs; |
30 | extern const struct nbio_pcie_index_data nbio_v7_0_pcie_index_data; | 30 | |
31 | int nbio_v7_0_init(struct amdgpu_device *adev); | ||
32 | u32 nbio_v7_0_get_atombios_scratch_regs(struct amdgpu_device *adev, | ||
33 | uint32_t idx); | ||
34 | void nbio_v7_0_set_atombios_scratch_regs(struct amdgpu_device *adev, | ||
35 | uint32_t idx, uint32_t val); | ||
36 | void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable); | ||
37 | void nbio_v7_0_hdp_flush(struct amdgpu_device *adev); | ||
38 | u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev); | ||
39 | void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance, | ||
40 | bool use_doorbell, int doorbell_index); | ||
41 | void nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device *adev, | ||
42 | bool enable); | ||
43 | void nbio_v7_0_ih_doorbell_range(struct amdgpu_device *adev, | ||
44 | bool use_doorbell, int doorbell_index); | ||
45 | void nbio_v7_0_ih_control(struct amdgpu_device *adev); | ||
46 | u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev); | ||
47 | void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev, | ||
48 | bool enable); | ||
49 | #endif | 31 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c index 78fe3f2917a0..5a9fe24697f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include "soc15_common.h" | 30 | #include "soc15_common.h" |
31 | #include "psp_v10_0.h" | 31 | #include "psp_v10_0.h" |
32 | 32 | ||
33 | #include "soc15ip.h" | ||
34 | #include "mp/mp_10_0_offset.h" | 33 | #include "mp/mp_10_0_offset.h" |
35 | #include "gc/gc_9_1_offset.h" | 34 | #include "gc/gc_9_1_offset.h" |
36 | #include "sdma0/sdma0_4_1_offset.h" | 35 | #include "sdma0/sdma0_4_1_offset.h" |
@@ -298,9 +297,10 @@ int psp_v10_0_cmd_submit(struct psp_context *psp, | |||
298 | } | 297 | } |
299 | 298 | ||
300 | static int | 299 | static int |
301 | psp_v10_0_sram_map(unsigned int *sram_offset, unsigned int *sram_addr_reg_offset, | 300 | psp_v10_0_sram_map(struct amdgpu_device *adev, |
302 | unsigned int *sram_data_reg_offset, | 301 | unsigned int *sram_offset, unsigned int *sram_addr_reg_offset, |
303 | enum AMDGPU_UCODE_ID ucode_id) | 302 | unsigned int *sram_data_reg_offset, |
303 | enum AMDGPU_UCODE_ID ucode_id) | ||
304 | { | 304 | { |
305 | int ret = 0; | 305 | int ret = 0; |
306 | 306 | ||
@@ -395,7 +395,7 @@ bool psp_v10_0_compare_sram_data(struct psp_context *psp, | |||
395 | uint32_t *ucode_mem = NULL; | 395 | uint32_t *ucode_mem = NULL; |
396 | struct amdgpu_device *adev = psp->adev; | 396 | struct amdgpu_device *adev = psp->adev; |
397 | 397 | ||
398 | err = psp_v10_0_sram_map(&fw_sram_reg_val, &fw_sram_addr_reg_offset, | 398 | err = psp_v10_0_sram_map(adev, &fw_sram_reg_val, &fw_sram_addr_reg_offset, |
399 | &fw_sram_data_reg_offset, ucode_type); | 399 | &fw_sram_data_reg_offset, ucode_type); |
400 | if (err) | 400 | if (err) |
401 | return false; | 401 | return false; |
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c index e75a23d858ef..19bd1934e63d 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include "soc15_common.h" | 31 | #include "soc15_common.h" |
32 | #include "psp_v3_1.h" | 32 | #include "psp_v3_1.h" |
33 | 33 | ||
34 | #include "soc15ip.h" | ||
35 | #include "mp/mp_9_0_offset.h" | 34 | #include "mp/mp_9_0_offset.h" |
36 | #include "mp/mp_9_0_sh_mask.h" | 35 | #include "mp/mp_9_0_sh_mask.h" |
37 | #include "gc/gc_9_0_offset.h" | 36 | #include "gc/gc_9_0_offset.h" |
@@ -410,9 +409,10 @@ int psp_v3_1_cmd_submit(struct psp_context *psp, | |||
410 | } | 409 | } |
411 | 410 | ||
412 | static int | 411 | static int |
413 | psp_v3_1_sram_map(unsigned int *sram_offset, unsigned int *sram_addr_reg_offset, | 412 | psp_v3_1_sram_map(struct amdgpu_device *adev, |
414 | unsigned int *sram_data_reg_offset, | 413 | unsigned int *sram_offset, unsigned int *sram_addr_reg_offset, |
415 | enum AMDGPU_UCODE_ID ucode_id) | 414 | unsigned int *sram_data_reg_offset, |
415 | enum AMDGPU_UCODE_ID ucode_id) | ||
416 | { | 416 | { |
417 | int ret = 0; | 417 | int ret = 0; |
418 | 418 | ||
@@ -507,7 +507,7 @@ bool psp_v3_1_compare_sram_data(struct psp_context *psp, | |||
507 | uint32_t *ucode_mem = NULL; | 507 | uint32_t *ucode_mem = NULL; |
508 | struct amdgpu_device *adev = psp->adev; | 508 | struct amdgpu_device *adev = psp->adev; |
509 | 509 | ||
510 | err = psp_v3_1_sram_map(&fw_sram_reg_val, &fw_sram_addr_reg_offset, | 510 | err = psp_v3_1_sram_map(adev, &fw_sram_reg_val, &fw_sram_addr_reg_offset, |
511 | &fw_sram_data_reg_offset, ucode_type); | 511 | &fw_sram_data_reg_offset, ucode_type); |
512 | if (err) | 512 | if (err) |
513 | return false; | 513 | return false; |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c index 121e628e7cdb..401552bae7f5 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | |||
@@ -93,12 +93,12 @@ static void sdma_v2_4_init_golden_registers(struct amdgpu_device *adev) | |||
93 | { | 93 | { |
94 | switch (adev->asic_type) { | 94 | switch (adev->asic_type) { |
95 | case CHIP_TOPAZ: | 95 | case CHIP_TOPAZ: |
96 | amdgpu_program_register_sequence(adev, | 96 | amdgpu_device_program_register_sequence(adev, |
97 | iceland_mgcg_cgcg_init, | 97 | iceland_mgcg_cgcg_init, |
98 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); | 98 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); |
99 | amdgpu_program_register_sequence(adev, | 99 | amdgpu_device_program_register_sequence(adev, |
100 | golden_settings_iceland_a11, | 100 | golden_settings_iceland_a11, |
101 | ARRAY_SIZE(golden_settings_iceland_a11)); | 101 | ARRAY_SIZE(golden_settings_iceland_a11)); |
102 | break; | 102 | break; |
103 | default: | 103 | default: |
104 | break; | 104 | break; |
@@ -600,7 +600,7 @@ static int sdma_v2_4_ring_test_ring(struct amdgpu_ring *ring) | |||
600 | u32 tmp; | 600 | u32 tmp; |
601 | u64 gpu_addr; | 601 | u64 gpu_addr; |
602 | 602 | ||
603 | r = amdgpu_wb_get(adev, &index); | 603 | r = amdgpu_device_wb_get(adev, &index); |
604 | if (r) { | 604 | if (r) { |
605 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | 605 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); |
606 | return r; | 606 | return r; |
@@ -613,7 +613,7 @@ static int sdma_v2_4_ring_test_ring(struct amdgpu_ring *ring) | |||
613 | r = amdgpu_ring_alloc(ring, 5); | 613 | r = amdgpu_ring_alloc(ring, 5); |
614 | if (r) { | 614 | if (r) { |
615 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | 615 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); |
616 | amdgpu_wb_free(adev, index); | 616 | amdgpu_device_wb_free(adev, index); |
617 | return r; | 617 | return r; |
618 | } | 618 | } |
619 | 619 | ||
@@ -639,7 +639,7 @@ static int sdma_v2_4_ring_test_ring(struct amdgpu_ring *ring) | |||
639 | ring->idx, tmp); | 639 | ring->idx, tmp); |
640 | r = -EINVAL; | 640 | r = -EINVAL; |
641 | } | 641 | } |
642 | amdgpu_wb_free(adev, index); | 642 | amdgpu_device_wb_free(adev, index); |
643 | 643 | ||
644 | return r; | 644 | return r; |
645 | } | 645 | } |
@@ -662,7 +662,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
662 | u64 gpu_addr; | 662 | u64 gpu_addr; |
663 | long r; | 663 | long r; |
664 | 664 | ||
665 | r = amdgpu_wb_get(adev, &index); | 665 | r = amdgpu_device_wb_get(adev, &index); |
666 | if (r) { | 666 | if (r) { |
667 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | 667 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); |
668 | return r; | 668 | return r; |
@@ -715,7 +715,7 @@ err1: | |||
715 | amdgpu_ib_free(adev, &ib, NULL); | 715 | amdgpu_ib_free(adev, &ib, NULL); |
716 | dma_fence_put(f); | 716 | dma_fence_put(f); |
717 | err0: | 717 | err0: |
718 | amdgpu_wb_free(adev, index); | 718 | amdgpu_device_wb_free(adev, index); |
719 | return r; | 719 | return r; |
720 | } | 720 | } |
721 | 721 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c index c8c93f9dac21..0735d4d0e56a 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | |||
@@ -192,47 +192,47 @@ static void sdma_v3_0_init_golden_registers(struct amdgpu_device *adev) | |||
192 | { | 192 | { |
193 | switch (adev->asic_type) { | 193 | switch (adev->asic_type) { |
194 | case CHIP_FIJI: | 194 | case CHIP_FIJI: |
195 | amdgpu_program_register_sequence(adev, | 195 | amdgpu_device_program_register_sequence(adev, |
196 | fiji_mgcg_cgcg_init, | 196 | fiji_mgcg_cgcg_init, |
197 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); | 197 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
198 | amdgpu_program_register_sequence(adev, | 198 | amdgpu_device_program_register_sequence(adev, |
199 | golden_settings_fiji_a10, | 199 | golden_settings_fiji_a10, |
200 | ARRAY_SIZE(golden_settings_fiji_a10)); | 200 | ARRAY_SIZE(golden_settings_fiji_a10)); |
201 | break; | 201 | break; |
202 | case CHIP_TONGA: | 202 | case CHIP_TONGA: |
203 | amdgpu_program_register_sequence(adev, | 203 | amdgpu_device_program_register_sequence(adev, |
204 | tonga_mgcg_cgcg_init, | 204 | tonga_mgcg_cgcg_init, |
205 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); | 205 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
206 | amdgpu_program_register_sequence(adev, | 206 | amdgpu_device_program_register_sequence(adev, |
207 | golden_settings_tonga_a11, | 207 | golden_settings_tonga_a11, |
208 | ARRAY_SIZE(golden_settings_tonga_a11)); | 208 | ARRAY_SIZE(golden_settings_tonga_a11)); |
209 | break; | 209 | break; |
210 | case CHIP_POLARIS11: | 210 | case CHIP_POLARIS11: |
211 | case CHIP_POLARIS12: | 211 | case CHIP_POLARIS12: |
212 | amdgpu_program_register_sequence(adev, | 212 | amdgpu_device_program_register_sequence(adev, |
213 | golden_settings_polaris11_a11, | 213 | golden_settings_polaris11_a11, |
214 | ARRAY_SIZE(golden_settings_polaris11_a11)); | 214 | ARRAY_SIZE(golden_settings_polaris11_a11)); |
215 | break; | 215 | break; |
216 | case CHIP_POLARIS10: | 216 | case CHIP_POLARIS10: |
217 | amdgpu_program_register_sequence(adev, | 217 | amdgpu_device_program_register_sequence(adev, |
218 | golden_settings_polaris10_a11, | 218 | golden_settings_polaris10_a11, |
219 | ARRAY_SIZE(golden_settings_polaris10_a11)); | 219 | ARRAY_SIZE(golden_settings_polaris10_a11)); |
220 | break; | 220 | break; |
221 | case CHIP_CARRIZO: | 221 | case CHIP_CARRIZO: |
222 | amdgpu_program_register_sequence(adev, | 222 | amdgpu_device_program_register_sequence(adev, |
223 | cz_mgcg_cgcg_init, | 223 | cz_mgcg_cgcg_init, |
224 | ARRAY_SIZE(cz_mgcg_cgcg_init)); | 224 | ARRAY_SIZE(cz_mgcg_cgcg_init)); |
225 | amdgpu_program_register_sequence(adev, | 225 | amdgpu_device_program_register_sequence(adev, |
226 | cz_golden_settings_a11, | 226 | cz_golden_settings_a11, |
227 | ARRAY_SIZE(cz_golden_settings_a11)); | 227 | ARRAY_SIZE(cz_golden_settings_a11)); |
228 | break; | 228 | break; |
229 | case CHIP_STONEY: | 229 | case CHIP_STONEY: |
230 | amdgpu_program_register_sequence(adev, | 230 | amdgpu_device_program_register_sequence(adev, |
231 | stoney_mgcg_cgcg_init, | 231 | stoney_mgcg_cgcg_init, |
232 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); | 232 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); |
233 | amdgpu_program_register_sequence(adev, | 233 | amdgpu_device_program_register_sequence(adev, |
234 | stoney_golden_settings_a11, | 234 | stoney_golden_settings_a11, |
235 | ARRAY_SIZE(stoney_golden_settings_a11)); | 235 | ARRAY_SIZE(stoney_golden_settings_a11)); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | break; | 238 | break; |
@@ -355,7 +355,7 @@ static uint64_t sdma_v3_0_ring_get_wptr(struct amdgpu_ring *ring) | |||
355 | struct amdgpu_device *adev = ring->adev; | 355 | struct amdgpu_device *adev = ring->adev; |
356 | u32 wptr; | 356 | u32 wptr; |
357 | 357 | ||
358 | if (ring->use_doorbell) { | 358 | if (ring->use_doorbell || ring->use_pollmem) { |
359 | /* XXX check if swapping is necessary on BE */ | 359 | /* XXX check if swapping is necessary on BE */ |
360 | wptr = ring->adev->wb.wb[ring->wptr_offs] >> 2; | 360 | wptr = ring->adev->wb.wb[ring->wptr_offs] >> 2; |
361 | } else { | 361 | } else { |
@@ -380,10 +380,13 @@ static void sdma_v3_0_ring_set_wptr(struct amdgpu_ring *ring) | |||
380 | 380 | ||
381 | if (ring->use_doorbell) { | 381 | if (ring->use_doorbell) { |
382 | u32 *wb = (u32 *)&adev->wb.wb[ring->wptr_offs]; | 382 | u32 *wb = (u32 *)&adev->wb.wb[ring->wptr_offs]; |
383 | |||
384 | /* XXX check if swapping is necessary on BE */ | 383 | /* XXX check if swapping is necessary on BE */ |
385 | WRITE_ONCE(*wb, (lower_32_bits(ring->wptr) << 2)); | 384 | WRITE_ONCE(*wb, (lower_32_bits(ring->wptr) << 2)); |
386 | WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr) << 2); | 385 | WDOORBELL32(ring->doorbell_index, lower_32_bits(ring->wptr) << 2); |
386 | } else if (ring->use_pollmem) { | ||
387 | u32 *wb = (u32 *)&adev->wb.wb[ring->wptr_offs]; | ||
388 | |||
389 | WRITE_ONCE(*wb, (lower_32_bits(ring->wptr) << 2)); | ||
387 | } else { | 390 | } else { |
388 | int me = (ring == &ring->adev->sdma.instance[0].ring) ? 0 : 1; | 391 | int me = (ring == &ring->adev->sdma.instance[0].ring) ? 0 : 1; |
389 | 392 | ||
@@ -718,10 +721,14 @@ static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev) | |||
718 | WREG32(mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI + sdma_offsets[i], | 721 | WREG32(mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI + sdma_offsets[i], |
719 | upper_32_bits(wptr_gpu_addr)); | 722 | upper_32_bits(wptr_gpu_addr)); |
720 | wptr_poll_cntl = RREG32(mmSDMA0_GFX_RB_WPTR_POLL_CNTL + sdma_offsets[i]); | 723 | wptr_poll_cntl = RREG32(mmSDMA0_GFX_RB_WPTR_POLL_CNTL + sdma_offsets[i]); |
721 | if (amdgpu_sriov_vf(adev)) | 724 | if (ring->use_pollmem) |
722 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 1); | 725 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, |
726 | SDMA0_GFX_RB_WPTR_POLL_CNTL, | ||
727 | ENABLE, 1); | ||
723 | else | 728 | else |
724 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 0); | 729 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, |
730 | SDMA0_GFX_RB_WPTR_POLL_CNTL, | ||
731 | ENABLE, 0); | ||
725 | WREG32(mmSDMA0_GFX_RB_WPTR_POLL_CNTL + sdma_offsets[i], wptr_poll_cntl); | 732 | WREG32(mmSDMA0_GFX_RB_WPTR_POLL_CNTL + sdma_offsets[i], wptr_poll_cntl); |
726 | 733 | ||
727 | /* enable DMA RB */ | 734 | /* enable DMA RB */ |
@@ -860,7 +867,7 @@ static int sdma_v3_0_ring_test_ring(struct amdgpu_ring *ring) | |||
860 | u32 tmp; | 867 | u32 tmp; |
861 | u64 gpu_addr; | 868 | u64 gpu_addr; |
862 | 869 | ||
863 | r = amdgpu_wb_get(adev, &index); | 870 | r = amdgpu_device_wb_get(adev, &index); |
864 | if (r) { | 871 | if (r) { |
865 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | 872 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); |
866 | return r; | 873 | return r; |
@@ -873,7 +880,7 @@ static int sdma_v3_0_ring_test_ring(struct amdgpu_ring *ring) | |||
873 | r = amdgpu_ring_alloc(ring, 5); | 880 | r = amdgpu_ring_alloc(ring, 5); |
874 | if (r) { | 881 | if (r) { |
875 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | 882 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); |
876 | amdgpu_wb_free(adev, index); | 883 | amdgpu_device_wb_free(adev, index); |
877 | return r; | 884 | return r; |
878 | } | 885 | } |
879 | 886 | ||
@@ -899,7 +906,7 @@ static int sdma_v3_0_ring_test_ring(struct amdgpu_ring *ring) | |||
899 | ring->idx, tmp); | 906 | ring->idx, tmp); |
900 | r = -EINVAL; | 907 | r = -EINVAL; |
901 | } | 908 | } |
902 | amdgpu_wb_free(adev, index); | 909 | amdgpu_device_wb_free(adev, index); |
903 | 910 | ||
904 | return r; | 911 | return r; |
905 | } | 912 | } |
@@ -922,7 +929,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
922 | u64 gpu_addr; | 929 | u64 gpu_addr; |
923 | long r; | 930 | long r; |
924 | 931 | ||
925 | r = amdgpu_wb_get(adev, &index); | 932 | r = amdgpu_device_wb_get(adev, &index); |
926 | if (r) { | 933 | if (r) { |
927 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | 934 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); |
928 | return r; | 935 | return r; |
@@ -974,7 +981,7 @@ err1: | |||
974 | amdgpu_ib_free(adev, &ib, NULL); | 981 | amdgpu_ib_free(adev, &ib, NULL); |
975 | dma_fence_put(f); | 982 | dma_fence_put(f); |
976 | err0: | 983 | err0: |
977 | amdgpu_wb_free(adev, index); | 984 | amdgpu_device_wb_free(adev, index); |
978 | return r; | 985 | return r; |
979 | } | 986 | } |
980 | 987 | ||
@@ -1203,9 +1210,13 @@ static int sdma_v3_0_sw_init(void *handle) | |||
1203 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1210 | for (i = 0; i < adev->sdma.num_instances; i++) { |
1204 | ring = &adev->sdma.instance[i].ring; | 1211 | ring = &adev->sdma.instance[i].ring; |
1205 | ring->ring_obj = NULL; | 1212 | ring->ring_obj = NULL; |
1206 | ring->use_doorbell = true; | 1213 | if (!amdgpu_sriov_vf(adev)) { |
1207 | ring->doorbell_index = (i == 0) ? | 1214 | ring->use_doorbell = true; |
1208 | AMDGPU_DOORBELL_sDMA_ENGINE0 : AMDGPU_DOORBELL_sDMA_ENGINE1; | 1215 | ring->doorbell_index = (i == 0) ? |
1216 | AMDGPU_DOORBELL_sDMA_ENGINE0 : AMDGPU_DOORBELL_sDMA_ENGINE1; | ||
1217 | } else { | ||
1218 | ring->use_pollmem = true; | ||
1219 | } | ||
1209 | 1220 | ||
1210 | sprintf(ring->name, "sdma%d", i); | 1221 | sprintf(ring->name, "sdma%d", i); |
1211 | r = amdgpu_ring_init(adev, ring, 1024, | 1222 | r = amdgpu_ring_init(adev, ring, 1024, |
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c index 4c55f21e37a8..73477c5ed9b4 100644 --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "amdgpu_ucode.h" | 27 | #include "amdgpu_ucode.h" |
28 | #include "amdgpu_trace.h" | 28 | #include "amdgpu_trace.h" |
29 | 29 | ||
30 | #include "soc15ip.h" | ||
31 | #include "sdma0/sdma0_4_0_offset.h" | 30 | #include "sdma0/sdma0_4_0_offset.h" |
32 | #include "sdma0/sdma0_4_0_sh_mask.h" | 31 | #include "sdma0/sdma0_4_0_sh_mask.h" |
33 | #include "sdma1/sdma1_4_0_offset.h" | 32 | #include "sdma1/sdma1_4_0_offset.h" |
@@ -53,95 +52,83 @@ static void sdma_v4_0_set_buffer_funcs(struct amdgpu_device *adev); | |||
53 | static void sdma_v4_0_set_vm_pte_funcs(struct amdgpu_device *adev); | 52 | static void sdma_v4_0_set_vm_pte_funcs(struct amdgpu_device *adev); |
54 | static void sdma_v4_0_set_irq_funcs(struct amdgpu_device *adev); | 53 | static void sdma_v4_0_set_irq_funcs(struct amdgpu_device *adev); |
55 | 54 | ||
56 | static const u32 golden_settings_sdma_4[] = { | 55 | static const struct soc15_reg_golden golden_settings_sdma_4[] = { |
57 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CHICKEN_BITS), 0xfe931f07, 0x02831d07, | 56 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CHICKEN_BITS, 0xfe931f07, 0x02831d07), |
58 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CLK_CTRL), 0xff000ff0, 0x3f000100, | 57 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CLK_CTRL, 0xff000ff0, 0x3f000100), |
59 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GFX_IB_CNTL), 0x800f0100, 0x00000100, | 58 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GFX_IB_CNTL, 0x800f0100, 0x00000100), |
60 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), 0xfffffff7, 0x00403000, | 59 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GFX_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
61 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_PAGE_IB_CNTL), 0x800f0100, 0x00000100, | 60 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_PAGE_IB_CNTL, 0x800f0100, 0x00000100), |
62 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_PAGE_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 61 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_PAGE_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
63 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_POWER_CNTL), 0x003ff006, 0x0003c000, | 62 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_POWER_CNTL, 0x003ff006, 0x0003c000), |
64 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC0_IB_CNTL), 0x800f0100, 0x00000100, | 63 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_IB_CNTL, 0x800f0100, 0x00000100), |
65 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 64 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
66 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL), 0x800f0100, 0x00000100, | 65 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0100, 0x00000100), |
67 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 66 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
68 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_UTCL1_PAGE), 0x000003ff, 0x000003c0, | 67 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0), |
69 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_CHICKEN_BITS), 0xfe931f07, 0x02831f07, | 68 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CHICKEN_BITS, 0xfe931f07, 0x02831f07), |
70 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_CLK_CTRL), 0xffffffff, 0x3f000100, | 69 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_CLK_CTRL, 0xffffffff, 0x3f000100), |
71 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_GFX_IB_CNTL), 0x800f0100, 0x00000100, | 70 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_IB_CNTL, 0x800f0100, 0x00000100), |
72 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 71 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GFX_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
73 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_PAGE_IB_CNTL), 0x800f0100, 0x00000100, | 72 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_PAGE_IB_CNTL, 0x800f0100, 0x00000100), |
74 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_PAGE_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 73 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_PAGE_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
75 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_POWER_CNTL), 0x003ff000, 0x0003c000, | 74 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_POWER_CNTL, 0x003ff000, 0x0003c000), |
76 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_RLC0_IB_CNTL), 0x800f0100, 0x00000100, | 75 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC0_IB_CNTL, 0x800f0100, 0x00000100), |
77 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_RLC0_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 76 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC0_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
78 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_RLC1_IB_CNTL), 0x800f0100, 0x00000100, | 77 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_IB_CNTL, 0x800f0100, 0x00000100), |
79 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_RLC1_RB_WPTR_POLL_CNTL), 0x0000fff0, 0x00403000, | 78 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_RLC1_RB_WPTR_POLL_CNTL, 0x0000fff0, 0x00403000), |
80 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_UTCL1_PAGE), 0x000003ff, 0x000003c0 | 79 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_UTCL1_PAGE, 0x000003ff, 0x000003c0) |
81 | }; | 80 | }; |
82 | 81 | ||
83 | static const u32 golden_settings_sdma_vg10[] = { | 82 | static const struct soc15_reg_golden golden_settings_sdma_vg10[] = { |
84 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG), 0x0018773f, 0x00104002, | 83 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00104002), |
85 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ), 0x0018773f, 0x00104002, | 84 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002), |
86 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG), 0x0018773f, 0x00104002, | 85 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG, 0x0018773f, 0x00104002), |
87 | SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ), 0x0018773f, 0x00104002 | 86 | SOC15_REG_GOLDEN_VALUE(SDMA1, 0, mmSDMA1_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00104002) |
88 | }; | 87 | }; |
89 | 88 | ||
90 | static const u32 golden_settings_sdma_4_1[] = | 89 | static const struct soc15_reg_golden golden_settings_sdma_4_1[] = |
91 | { | 90 | { |
92 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CHICKEN_BITS), 0xfe931f07, 0x02831d07, | 91 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CHICKEN_BITS, 0xfe931f07, 0x02831d07), |
93 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_CLK_CTRL), 0xffffffff, 0x3f000100, | 92 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_CLK_CTRL, 0xffffffff, 0x3f000100), |
94 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GFX_IB_CNTL), 0x800f0111, 0x00000100, | 93 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GFX_IB_CNTL, 0x800f0111, 0x00000100), |
95 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), 0xfffffff7, 0x00403000, | 94 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GFX_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
96 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_POWER_CNTL), 0xfc3fffff, 0x40000051, | 95 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_POWER_CNTL, 0xfc3fffff, 0x40000051), |
97 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC0_IB_CNTL), 0x800f0111, 0x00000100, | 96 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_IB_CNTL, 0x800f0111, 0x00000100), |
98 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL), 0xfffffff7, 0x00403000, | 97 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC0_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
99 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL), 0x800f0111, 0x00000100, | 98 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_IB_CNTL, 0x800f0111, 0x00000100), |
100 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL), 0xfffffff7, 0x00403000, | 99 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_RLC1_RB_WPTR_POLL_CNTL, 0xfffffff7, 0x00403000), |
101 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_UTCL1_PAGE), 0x000003ff, 0x000003c0 | 100 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_UTCL1_PAGE, 0x000003ff, 0x000003c0) |
102 | }; | 101 | }; |
103 | 102 | ||
104 | static const u32 golden_settings_sdma_rv1[] = | 103 | static const struct soc15_reg_golden golden_settings_sdma_rv1[] = |
105 | { | 104 | { |
106 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG), 0x0018773f, 0x00000002, | 105 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG, 0x0018773f, 0x00000002), |
107 | SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ), 0x0018773f, 0x00000002 | 106 | SOC15_REG_GOLDEN_VALUE(SDMA0, 0, mmSDMA0_GB_ADDR_CONFIG_READ, 0x0018773f, 0x00000002) |
108 | }; | 107 | }; |
109 | 108 | ||
110 | static u32 sdma_v4_0_get_reg_offset(u32 instance, u32 internal_offset) | 109 | static u32 sdma_v4_0_get_reg_offset(struct amdgpu_device *adev, |
110 | u32 instance, u32 offset) | ||
111 | { | 111 | { |
112 | u32 base = 0; | 112 | return ( 0 == instance ? (adev->reg_offset[SDMA0_HWIP][0][0] + offset) : |
113 | 113 | (adev->reg_offset[SDMA1_HWIP][0][0] + offset)); | |
114 | switch (instance) { | ||
115 | case 0: | ||
116 | base = SDMA0_BASE.instance[0].segment[0]; | ||
117 | break; | ||
118 | case 1: | ||
119 | base = SDMA1_BASE.instance[0].segment[0]; | ||
120 | break; | ||
121 | default: | ||
122 | BUG(); | ||
123 | break; | ||
124 | } | ||
125 | |||
126 | return base + internal_offset; | ||
127 | } | 114 | } |
128 | 115 | ||
129 | static void sdma_v4_0_init_golden_registers(struct amdgpu_device *adev) | 116 | static void sdma_v4_0_init_golden_registers(struct amdgpu_device *adev) |
130 | { | 117 | { |
131 | switch (adev->asic_type) { | 118 | switch (adev->asic_type) { |
132 | case CHIP_VEGA10: | 119 | case CHIP_VEGA10: |
133 | amdgpu_program_register_sequence(adev, | 120 | soc15_program_register_sequence(adev, |
134 | golden_settings_sdma_4, | 121 | golden_settings_sdma_4, |
135 | ARRAY_SIZE(golden_settings_sdma_4)); | 122 | ARRAY_SIZE(golden_settings_sdma_4)); |
136 | amdgpu_program_register_sequence(adev, | 123 | soc15_program_register_sequence(adev, |
137 | golden_settings_sdma_vg10, | 124 | golden_settings_sdma_vg10, |
138 | ARRAY_SIZE(golden_settings_sdma_vg10)); | 125 | ARRAY_SIZE(golden_settings_sdma_vg10)); |
139 | break; | 126 | break; |
140 | case CHIP_RAVEN: | 127 | case CHIP_RAVEN: |
141 | amdgpu_program_register_sequence(adev, | 128 | soc15_program_register_sequence(adev, |
142 | golden_settings_sdma_4_1, | 129 | golden_settings_sdma_4_1, |
143 | ARRAY_SIZE(golden_settings_sdma_4_1)); | 130 | ARRAY_SIZE(golden_settings_sdma_4_1)); |
144 | amdgpu_program_register_sequence(adev, | 131 | soc15_program_register_sequence(adev, |
145 | golden_settings_sdma_rv1, | 132 | golden_settings_sdma_rv1, |
146 | ARRAY_SIZE(golden_settings_sdma_rv1)); | 133 | ARRAY_SIZE(golden_settings_sdma_rv1)); |
147 | break; | 134 | break; |
@@ -265,8 +252,8 @@ static uint64_t sdma_v4_0_ring_get_wptr(struct amdgpu_ring *ring) | |||
265 | int me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1; | 252 | int me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1; |
266 | 253 | ||
267 | wptr = &local_wptr; | 254 | wptr = &local_wptr; |
268 | lowbit = RREG32(sdma_v4_0_get_reg_offset(me, mmSDMA0_GFX_RB_WPTR)) >> 2; | 255 | lowbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR)) >> 2; |
269 | highbit = RREG32(sdma_v4_0_get_reg_offset(me, mmSDMA0_GFX_RB_WPTR_HI)) >> 2; | 256 | highbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR_HI)) >> 2; |
270 | 257 | ||
271 | DRM_DEBUG("wptr [%i]high== 0x%08x low==0x%08x\n", | 258 | DRM_DEBUG("wptr [%i]high== 0x%08x low==0x%08x\n", |
272 | me, highbit, lowbit); | 259 | me, highbit, lowbit); |
@@ -315,8 +302,8 @@ static void sdma_v4_0_ring_set_wptr(struct amdgpu_ring *ring) | |||
315 | lower_32_bits(ring->wptr << 2), | 302 | lower_32_bits(ring->wptr << 2), |
316 | me, | 303 | me, |
317 | upper_32_bits(ring->wptr << 2)); | 304 | upper_32_bits(ring->wptr << 2)); |
318 | WREG32(sdma_v4_0_get_reg_offset(me, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr << 2)); | 305 | WREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr << 2)); |
319 | WREG32(sdma_v4_0_get_reg_offset(me, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr << 2)); | 306 | WREG32(sdma_v4_0_get_reg_offset(adev, me, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr << 2)); |
320 | } | 307 | } |
321 | } | 308 | } |
322 | 309 | ||
@@ -370,13 +357,9 @@ static void sdma_v4_0_ring_emit_ib(struct amdgpu_ring *ring, | |||
370 | */ | 357 | */ |
371 | static void sdma_v4_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | 358 | static void sdma_v4_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) |
372 | { | 359 | { |
360 | struct amdgpu_device *adev = ring->adev; | ||
373 | u32 ref_and_mask = 0; | 361 | u32 ref_and_mask = 0; |
374 | const struct nbio_hdp_flush_reg *nbio_hf_reg; | 362 | const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio_funcs->hdp_flush_reg; |
375 | |||
376 | if (ring->adev->flags & AMD_IS_APU) | ||
377 | nbio_hf_reg = &nbio_v7_0_hdp_flush_reg; | ||
378 | else | ||
379 | nbio_hf_reg = &nbio_v6_1_hdp_flush_reg; | ||
380 | 363 | ||
381 | if (ring == &ring->adev->sdma.instance[0].ring) | 364 | if (ring == &ring->adev->sdma.instance[0].ring) |
382 | ref_and_mask = nbio_hf_reg->ref_and_mask_sdma0; | 365 | ref_and_mask = nbio_hf_reg->ref_and_mask_sdma0; |
@@ -386,8 +369,8 @@ static void sdma_v4_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | |||
386 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) | | 369 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) | |
387 | SDMA_PKT_POLL_REGMEM_HEADER_HDP_FLUSH(1) | | 370 | SDMA_PKT_POLL_REGMEM_HEADER_HDP_FLUSH(1) | |
388 | SDMA_PKT_POLL_REGMEM_HEADER_FUNC(3)); /* == */ | 371 | SDMA_PKT_POLL_REGMEM_HEADER_FUNC(3)); /* == */ |
389 | amdgpu_ring_write(ring, nbio_hf_reg->hdp_flush_done_offset << 2); | 372 | amdgpu_ring_write(ring, (adev->nbio_funcs->get_hdp_flush_done_offset(adev)) << 2); |
390 | amdgpu_ring_write(ring, nbio_hf_reg->hdp_flush_req_offset << 2); | 373 | amdgpu_ring_write(ring, (adev->nbio_funcs->get_hdp_flush_req_offset(adev)) << 2); |
391 | amdgpu_ring_write(ring, ref_and_mask); /* reference */ | 374 | amdgpu_ring_write(ring, ref_and_mask); /* reference */ |
392 | amdgpu_ring_write(ring, ref_and_mask); /* mask */ | 375 | amdgpu_ring_write(ring, ref_and_mask); /* mask */ |
393 | amdgpu_ring_write(ring, SDMA_PKT_POLL_REGMEM_DW5_RETRY_COUNT(0xfff) | | 376 | amdgpu_ring_write(ring, SDMA_PKT_POLL_REGMEM_DW5_RETRY_COUNT(0xfff) | |
@@ -396,6 +379,8 @@ static void sdma_v4_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | |||
396 | 379 | ||
397 | static void sdma_v4_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | 380 | static void sdma_v4_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) |
398 | { | 381 | { |
382 | struct amdgpu_device *adev = ring->adev; | ||
383 | |||
399 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) | | 384 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) | |
400 | SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf)); | 385 | SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf)); |
401 | amdgpu_ring_write(ring, SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE)); | 386 | amdgpu_ring_write(ring, SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE)); |
@@ -460,12 +445,12 @@ static void sdma_v4_0_gfx_stop(struct amdgpu_device *adev) | |||
460 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size); | 445 | amdgpu_ttm_set_active_vram_size(adev, adev->mc.visible_vram_size); |
461 | 446 | ||
462 | for (i = 0; i < adev->sdma.num_instances; i++) { | 447 | for (i = 0; i < adev->sdma.num_instances; i++) { |
463 | rb_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL)); | 448 | rb_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL)); |
464 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0); | 449 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 0); |
465 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL), rb_cntl); | 450 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl); |
466 | ib_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_IB_CNTL)); | 451 | ib_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL)); |
467 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0); | 452 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 0); |
468 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_IB_CNTL), ib_cntl); | 453 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl); |
469 | } | 454 | } |
470 | 455 | ||
471 | sdma0->ready = false; | 456 | sdma0->ready = false; |
@@ -522,18 +507,18 @@ static void sdma_v4_0_ctx_switch_enable(struct amdgpu_device *adev, bool enable) | |||
522 | } | 507 | } |
523 | 508 | ||
524 | for (i = 0; i < adev->sdma.num_instances; i++) { | 509 | for (i = 0; i < adev->sdma.num_instances; i++) { |
525 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL)); | 510 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_CNTL)); |
526 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, | 511 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL, |
527 | AUTO_CTXSW_ENABLE, enable ? 1 : 0); | 512 | AUTO_CTXSW_ENABLE, enable ? 1 : 0); |
528 | if (enable && amdgpu_sdma_phase_quantum) { | 513 | if (enable && amdgpu_sdma_phase_quantum) { |
529 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE0_QUANTUM), | 514 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_PHASE0_QUANTUM), |
530 | phase_quantum); | 515 | phase_quantum); |
531 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE1_QUANTUM), | 516 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_PHASE1_QUANTUM), |
532 | phase_quantum); | 517 | phase_quantum); |
533 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_PHASE2_QUANTUM), | 518 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_PHASE2_QUANTUM), |
534 | phase_quantum); | 519 | phase_quantum); |
535 | } | 520 | } |
536 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL), f32_cntl); | 521 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_CNTL), f32_cntl); |
537 | } | 522 | } |
538 | 523 | ||
539 | } | 524 | } |
@@ -557,9 +542,9 @@ static void sdma_v4_0_enable(struct amdgpu_device *adev, bool enable) | |||
557 | } | 542 | } |
558 | 543 | ||
559 | for (i = 0; i < adev->sdma.num_instances; i++) { | 544 | for (i = 0; i < adev->sdma.num_instances; i++) { |
560 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_F32_CNTL)); | 545 | f32_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL)); |
561 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_F32_CNTL, HALT, enable ? 0 : 1); | 546 | f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_F32_CNTL, HALT, enable ? 0 : 1); |
562 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_F32_CNTL), f32_cntl); | 547 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL), f32_cntl); |
563 | } | 548 | } |
564 | } | 549 | } |
565 | 550 | ||
@@ -587,48 +572,48 @@ static int sdma_v4_0_gfx_resume(struct amdgpu_device *adev) | |||
587 | ring = &adev->sdma.instance[i].ring; | 572 | ring = &adev->sdma.instance[i].ring; |
588 | wb_offset = (ring->rptr_offs * 4); | 573 | wb_offset = (ring->rptr_offs * 4); |
589 | 574 | ||
590 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_SEM_WAIT_FAIL_TIMER_CNTL), 0); | 575 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_SEM_WAIT_FAIL_TIMER_CNTL), 0); |
591 | 576 | ||
592 | /* Set ring buffer size in dwords */ | 577 | /* Set ring buffer size in dwords */ |
593 | rb_bufsz = order_base_2(ring->ring_size / 4); | 578 | rb_bufsz = order_base_2(ring->ring_size / 4); |
594 | rb_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL)); | 579 | rb_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL)); |
595 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SIZE, rb_bufsz); | 580 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SIZE, rb_bufsz); |
596 | #ifdef __BIG_ENDIAN | 581 | #ifdef __BIG_ENDIAN |
597 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SWAP_ENABLE, 1); | 582 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SWAP_ENABLE, 1); |
598 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, | 583 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, |
599 | RPTR_WRITEBACK_SWAP_ENABLE, 1); | 584 | RPTR_WRITEBACK_SWAP_ENABLE, 1); |
600 | #endif | 585 | #endif |
601 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL), rb_cntl); | 586 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl); |
602 | 587 | ||
603 | /* Initialize the ring buffer's read and write pointers */ | 588 | /* Initialize the ring buffer's read and write pointers */ |
604 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_RPTR), 0); | 589 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_RPTR), 0); |
605 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_RPTR_HI), 0); | 590 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_RPTR_HI), 0); |
606 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR), 0); | 591 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR), 0); |
607 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_HI), 0); | 592 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_HI), 0); |
608 | 593 | ||
609 | /* set the wb address whether it's enabled or not */ | 594 | /* set the wb address whether it's enabled or not */ |
610 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_RPTR_ADDR_HI), | 595 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_RPTR_ADDR_HI), |
611 | upper_32_bits(adev->wb.gpu_addr + wb_offset) & 0xFFFFFFFF); | 596 | upper_32_bits(adev->wb.gpu_addr + wb_offset) & 0xFFFFFFFF); |
612 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_RPTR_ADDR_LO), | 597 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_RPTR_ADDR_LO), |
613 | lower_32_bits(adev->wb.gpu_addr + wb_offset) & 0xFFFFFFFC); | 598 | lower_32_bits(adev->wb.gpu_addr + wb_offset) & 0xFFFFFFFC); |
614 | 599 | ||
615 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RPTR_WRITEBACK_ENABLE, 1); | 600 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RPTR_WRITEBACK_ENABLE, 1); |
616 | 601 | ||
617 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_BASE), ring->gpu_addr >> 8); | 602 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_BASE), ring->gpu_addr >> 8); |
618 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_BASE_HI), ring->gpu_addr >> 40); | 603 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_BASE_HI), ring->gpu_addr >> 40); |
619 | 604 | ||
620 | ring->wptr = 0; | 605 | ring->wptr = 0; |
621 | 606 | ||
622 | /* before programing wptr to a less value, need set minor_ptr_update first */ | 607 | /* before programing wptr to a less value, need set minor_ptr_update first */ |
623 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_MINOR_PTR_UPDATE), 1); | 608 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_MINOR_PTR_UPDATE), 1); |
624 | 609 | ||
625 | if (!amdgpu_sriov_vf(adev)) { /* only bare-metal use register write for wptr */ | 610 | if (!amdgpu_sriov_vf(adev)) { /* only bare-metal use register write for wptr */ |
626 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr) << 2); | 611 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR), lower_32_bits(ring->wptr) << 2); |
627 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr) << 2); | 612 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_HI), upper_32_bits(ring->wptr) << 2); |
628 | } | 613 | } |
629 | 614 | ||
630 | doorbell = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_DOORBELL)); | 615 | doorbell = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL)); |
631 | doorbell_offset = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_DOORBELL_OFFSET)); | 616 | doorbell_offset = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL_OFFSET)); |
632 | 617 | ||
633 | if (ring->use_doorbell) { | 618 | if (ring->use_doorbell) { |
634 | doorbell = REG_SET_FIELD(doorbell, SDMA0_GFX_DOORBELL, ENABLE, 1); | 619 | doorbell = REG_SET_FIELD(doorbell, SDMA0_GFX_DOORBELL, ENABLE, 1); |
@@ -637,55 +622,53 @@ static int sdma_v4_0_gfx_resume(struct amdgpu_device *adev) | |||
637 | } else { | 622 | } else { |
638 | doorbell = REG_SET_FIELD(doorbell, SDMA0_GFX_DOORBELL, ENABLE, 0); | 623 | doorbell = REG_SET_FIELD(doorbell, SDMA0_GFX_DOORBELL, ENABLE, 0); |
639 | } | 624 | } |
640 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_DOORBELL), doorbell); | 625 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL), doorbell); |
641 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_DOORBELL_OFFSET), doorbell_offset); | 626 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_DOORBELL_OFFSET), doorbell_offset); |
642 | if (adev->flags & AMD_IS_APU) | 627 | adev->nbio_funcs->sdma_doorbell_range(adev, i, ring->use_doorbell, |
643 | nbio_v7_0_sdma_doorbell_range(adev, i, ring->use_doorbell, ring->doorbell_index); | 628 | ring->doorbell_index); |
644 | else | ||
645 | nbio_v6_1_sdma_doorbell_range(adev, i, ring->use_doorbell, ring->doorbell_index); | ||
646 | 629 | ||
647 | if (amdgpu_sriov_vf(adev)) | 630 | if (amdgpu_sriov_vf(adev)) |
648 | sdma_v4_0_ring_set_wptr(ring); | 631 | sdma_v4_0_ring_set_wptr(ring); |
649 | 632 | ||
650 | /* set minor_ptr_update to 0 after wptr programed */ | 633 | /* set minor_ptr_update to 0 after wptr programed */ |
651 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_MINOR_PTR_UPDATE), 0); | 634 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_MINOR_PTR_UPDATE), 0); |
652 | 635 | ||
653 | /* set utc l1 enable flag always to 1 */ | 636 | /* set utc l1 enable flag always to 1 */ |
654 | temp = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL)); | 637 | temp = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_CNTL)); |
655 | temp = REG_SET_FIELD(temp, SDMA0_CNTL, UTC_L1_ENABLE, 1); | 638 | temp = REG_SET_FIELD(temp, SDMA0_CNTL, UTC_L1_ENABLE, 1); |
656 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_CNTL), temp); | 639 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_CNTL), temp); |
657 | 640 | ||
658 | if (!amdgpu_sriov_vf(adev)) { | 641 | if (!amdgpu_sriov_vf(adev)) { |
659 | /* unhalt engine */ | 642 | /* unhalt engine */ |
660 | temp = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_F32_CNTL)); | 643 | temp = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL)); |
661 | temp = REG_SET_FIELD(temp, SDMA0_F32_CNTL, HALT, 0); | 644 | temp = REG_SET_FIELD(temp, SDMA0_F32_CNTL, HALT, 0); |
662 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_F32_CNTL), temp); | 645 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL), temp); |
663 | } | 646 | } |
664 | 647 | ||
665 | /* setup the wptr shadow polling */ | 648 | /* setup the wptr shadow polling */ |
666 | wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4); | 649 | wptr_gpu_addr = adev->wb.gpu_addr + (ring->wptr_offs * 4); |
667 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_LO), | 650 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_LO), |
668 | lower_32_bits(wptr_gpu_addr)); | 651 | lower_32_bits(wptr_gpu_addr)); |
669 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI), | 652 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_POLL_ADDR_HI), |
670 | upper_32_bits(wptr_gpu_addr)); | 653 | upper_32_bits(wptr_gpu_addr)); |
671 | wptr_poll_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL)); | 654 | wptr_poll_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL)); |
672 | if (amdgpu_sriov_vf(adev)) | 655 | if (amdgpu_sriov_vf(adev)) |
673 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 1); | 656 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 1); |
674 | else | 657 | else |
675 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 0); | 658 | wptr_poll_cntl = REG_SET_FIELD(wptr_poll_cntl, SDMA0_GFX_RB_WPTR_POLL_CNTL, F32_POLL_ENABLE, 0); |
676 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), wptr_poll_cntl); | 659 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_WPTR_POLL_CNTL), wptr_poll_cntl); |
677 | 660 | ||
678 | /* enable DMA RB */ | 661 | /* enable DMA RB */ |
679 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 1); | 662 | rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_ENABLE, 1); |
680 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_RB_CNTL), rb_cntl); | 663 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl); |
681 | 664 | ||
682 | ib_cntl = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_IB_CNTL)); | 665 | ib_cntl = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL)); |
683 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 1); | 666 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_ENABLE, 1); |
684 | #ifdef __BIG_ENDIAN | 667 | #ifdef __BIG_ENDIAN |
685 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_SWAP_ENABLE, 1); | 668 | ib_cntl = REG_SET_FIELD(ib_cntl, SDMA0_GFX_IB_CNTL, IB_SWAP_ENABLE, 1); |
686 | #endif | 669 | #endif |
687 | /* enable DMA IBs */ | 670 | /* enable DMA IBs */ |
688 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_GFX_IB_CNTL), ib_cntl); | 671 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_GFX_IB_CNTL), ib_cntl); |
689 | 672 | ||
690 | ring->ready = true; | 673 | ring->ready = true; |
691 | 674 | ||
@@ -816,12 +799,12 @@ static int sdma_v4_0_load_microcode(struct amdgpu_device *adev) | |||
816 | (adev->sdma.instance[i].fw->data + | 799 | (adev->sdma.instance[i].fw->data + |
817 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); | 800 | le32_to_cpu(hdr->header.ucode_array_offset_bytes)); |
818 | 801 | ||
819 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_UCODE_ADDR), 0); | 802 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_UCODE_ADDR), 0); |
820 | 803 | ||
821 | for (j = 0; j < fw_size; j++) | 804 | for (j = 0; j < fw_size; j++) |
822 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_UCODE_DATA), le32_to_cpup(fw_data++)); | 805 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_UCODE_DATA), le32_to_cpup(fw_data++)); |
823 | 806 | ||
824 | WREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_UCODE_ADDR), adev->sdma.instance[i].fw_version); | 807 | WREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_UCODE_ADDR), adev->sdma.instance[i].fw_version); |
825 | } | 808 | } |
826 | 809 | ||
827 | return 0; | 810 | return 0; |
@@ -886,7 +869,7 @@ static int sdma_v4_0_ring_test_ring(struct amdgpu_ring *ring) | |||
886 | u32 tmp; | 869 | u32 tmp; |
887 | u64 gpu_addr; | 870 | u64 gpu_addr; |
888 | 871 | ||
889 | r = amdgpu_wb_get(adev, &index); | 872 | r = amdgpu_device_wb_get(adev, &index); |
890 | if (r) { | 873 | if (r) { |
891 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | 874 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); |
892 | return r; | 875 | return r; |
@@ -899,7 +882,7 @@ static int sdma_v4_0_ring_test_ring(struct amdgpu_ring *ring) | |||
899 | r = amdgpu_ring_alloc(ring, 5); | 882 | r = amdgpu_ring_alloc(ring, 5); |
900 | if (r) { | 883 | if (r) { |
901 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | 884 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); |
902 | amdgpu_wb_free(adev, index); | 885 | amdgpu_device_wb_free(adev, index); |
903 | return r; | 886 | return r; |
904 | } | 887 | } |
905 | 888 | ||
@@ -925,7 +908,7 @@ static int sdma_v4_0_ring_test_ring(struct amdgpu_ring *ring) | |||
925 | ring->idx, tmp); | 908 | ring->idx, tmp); |
926 | r = -EINVAL; | 909 | r = -EINVAL; |
927 | } | 910 | } |
928 | amdgpu_wb_free(adev, index); | 911 | amdgpu_device_wb_free(adev, index); |
929 | 912 | ||
930 | return r; | 913 | return r; |
931 | } | 914 | } |
@@ -948,7 +931,7 @@ static int sdma_v4_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
948 | u32 tmp = 0; | 931 | u32 tmp = 0; |
949 | u64 gpu_addr; | 932 | u64 gpu_addr; |
950 | 933 | ||
951 | r = amdgpu_wb_get(adev, &index); | 934 | r = amdgpu_device_wb_get(adev, &index); |
952 | if (r) { | 935 | if (r) { |
953 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | 936 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); |
954 | return r; | 937 | return r; |
@@ -1000,7 +983,7 @@ err1: | |||
1000 | amdgpu_ib_free(adev, &ib, NULL); | 983 | amdgpu_ib_free(adev, &ib, NULL); |
1001 | dma_fence_put(f); | 984 | dma_fence_put(f); |
1002 | err0: | 985 | err0: |
1003 | amdgpu_wb_free(adev, index); | 986 | amdgpu_device_wb_free(adev, index); |
1004 | return r; | 987 | return r; |
1005 | } | 988 | } |
1006 | 989 | ||
@@ -1156,10 +1139,11 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1156 | { | 1139 | { |
1157 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 1140 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
1158 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 1141 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
1142 | uint64_t flags = AMDGPU_PTE_VALID; | ||
1159 | unsigned eng = ring->vm_inv_eng; | 1143 | unsigned eng = ring->vm_inv_eng; |
1160 | 1144 | ||
1161 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 1145 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
1162 | pd_addr |= AMDGPU_PTE_VALID; | 1146 | pd_addr |= flags; |
1163 | 1147 | ||
1164 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) | | 1148 | amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) | |
1165 | SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf)); | 1149 | SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf)); |
@@ -1317,7 +1301,7 @@ static bool sdma_v4_0_is_idle(void *handle) | |||
1317 | u32 i; | 1301 | u32 i; |
1318 | 1302 | ||
1319 | for (i = 0; i < adev->sdma.num_instances; i++) { | 1303 | for (i = 0; i < adev->sdma.num_instances; i++) { |
1320 | u32 tmp = RREG32(sdma_v4_0_get_reg_offset(i, mmSDMA0_STATUS_REG)); | 1304 | u32 tmp = RREG32(sdma_v4_0_get_reg_offset(adev, i, mmSDMA0_STATUS_REG)); |
1321 | 1305 | ||
1322 | if (!(tmp & SDMA0_STATUS_REG__IDLE_MASK)) | 1306 | if (!(tmp & SDMA0_STATUS_REG__IDLE_MASK)) |
1323 | return false; | 1307 | return false; |
@@ -1333,8 +1317,8 @@ static int sdma_v4_0_wait_for_idle(void *handle) | |||
1333 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 1317 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
1334 | 1318 | ||
1335 | for (i = 0; i < adev->usec_timeout; i++) { | 1319 | for (i = 0; i < adev->usec_timeout; i++) { |
1336 | sdma0 = RREG32(sdma_v4_0_get_reg_offset(0, mmSDMA0_STATUS_REG)); | 1320 | sdma0 = RREG32(sdma_v4_0_get_reg_offset(adev, 0, mmSDMA0_STATUS_REG)); |
1337 | sdma1 = RREG32(sdma_v4_0_get_reg_offset(1, mmSDMA0_STATUS_REG)); | 1321 | sdma1 = RREG32(sdma_v4_0_get_reg_offset(adev, 1, mmSDMA0_STATUS_REG)); |
1338 | 1322 | ||
1339 | if (sdma0 & sdma1 & SDMA0_STATUS_REG__IDLE_MASK) | 1323 | if (sdma0 & sdma1 & SDMA0_STATUS_REG__IDLE_MASK) |
1340 | return 0; | 1324 | return 0; |
@@ -1358,8 +1342,8 @@ static int sdma_v4_0_set_trap_irq_state(struct amdgpu_device *adev, | |||
1358 | u32 sdma_cntl; | 1342 | u32 sdma_cntl; |
1359 | 1343 | ||
1360 | u32 reg_offset = (type == AMDGPU_SDMA_IRQ_TRAP0) ? | 1344 | u32 reg_offset = (type == AMDGPU_SDMA_IRQ_TRAP0) ? |
1361 | sdma_v4_0_get_reg_offset(0, mmSDMA0_CNTL) : | 1345 | sdma_v4_0_get_reg_offset(adev, 0, mmSDMA0_CNTL) : |
1362 | sdma_v4_0_get_reg_offset(1, mmSDMA0_CNTL); | 1346 | sdma_v4_0_get_reg_offset(adev, 1, mmSDMA0_CNTL); |
1363 | 1347 | ||
1364 | sdma_cntl = RREG32(reg_offset); | 1348 | sdma_cntl = RREG32(reg_offset); |
1365 | sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA0_CNTL, TRAP_ENABLE, | 1349 | sdma_cntl = REG_SET_FIELD(sdma_cntl, SDMA0_CNTL, TRAP_ENABLE, |
diff --git a/drivers/gpu/drm/amd/amdgpu/si.c b/drivers/gpu/drm/amd/amdgpu/si.c index 49eef3090f08..543101d5a5ed 100644 --- a/drivers/gpu/drm/amd/amdgpu/si.c +++ b/drivers/gpu/drm/amd/amdgpu/si.c | |||
@@ -1390,65 +1390,65 @@ static void si_init_golden_registers(struct amdgpu_device *adev) | |||
1390 | { | 1390 | { |
1391 | switch (adev->asic_type) { | 1391 | switch (adev->asic_type) { |
1392 | case CHIP_TAHITI: | 1392 | case CHIP_TAHITI: |
1393 | amdgpu_program_register_sequence(adev, | 1393 | amdgpu_device_program_register_sequence(adev, |
1394 | tahiti_golden_registers, | 1394 | tahiti_golden_registers, |
1395 | ARRAY_SIZE(tahiti_golden_registers)); | 1395 | ARRAY_SIZE(tahiti_golden_registers)); |
1396 | amdgpu_program_register_sequence(adev, | 1396 | amdgpu_device_program_register_sequence(adev, |
1397 | tahiti_golden_rlc_registers, | 1397 | tahiti_golden_rlc_registers, |
1398 | ARRAY_SIZE(tahiti_golden_rlc_registers)); | 1398 | ARRAY_SIZE(tahiti_golden_rlc_registers)); |
1399 | amdgpu_program_register_sequence(adev, | 1399 | amdgpu_device_program_register_sequence(adev, |
1400 | tahiti_mgcg_cgcg_init, | 1400 | tahiti_mgcg_cgcg_init, |
1401 | ARRAY_SIZE(tahiti_mgcg_cgcg_init)); | 1401 | ARRAY_SIZE(tahiti_mgcg_cgcg_init)); |
1402 | amdgpu_program_register_sequence(adev, | 1402 | amdgpu_device_program_register_sequence(adev, |
1403 | tahiti_golden_registers2, | 1403 | tahiti_golden_registers2, |
1404 | ARRAY_SIZE(tahiti_golden_registers2)); | 1404 | ARRAY_SIZE(tahiti_golden_registers2)); |
1405 | break; | 1405 | break; |
1406 | case CHIP_PITCAIRN: | 1406 | case CHIP_PITCAIRN: |
1407 | amdgpu_program_register_sequence(adev, | 1407 | amdgpu_device_program_register_sequence(adev, |
1408 | pitcairn_golden_registers, | 1408 | pitcairn_golden_registers, |
1409 | ARRAY_SIZE(pitcairn_golden_registers)); | 1409 | ARRAY_SIZE(pitcairn_golden_registers)); |
1410 | amdgpu_program_register_sequence(adev, | 1410 | amdgpu_device_program_register_sequence(adev, |
1411 | pitcairn_golden_rlc_registers, | 1411 | pitcairn_golden_rlc_registers, |
1412 | ARRAY_SIZE(pitcairn_golden_rlc_registers)); | 1412 | ARRAY_SIZE(pitcairn_golden_rlc_registers)); |
1413 | amdgpu_program_register_sequence(adev, | 1413 | amdgpu_device_program_register_sequence(adev, |
1414 | pitcairn_mgcg_cgcg_init, | 1414 | pitcairn_mgcg_cgcg_init, |
1415 | ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); | 1415 | ARRAY_SIZE(pitcairn_mgcg_cgcg_init)); |
1416 | break; | 1416 | break; |
1417 | case CHIP_VERDE: | 1417 | case CHIP_VERDE: |
1418 | amdgpu_program_register_sequence(adev, | 1418 | amdgpu_device_program_register_sequence(adev, |
1419 | verde_golden_registers, | 1419 | verde_golden_registers, |
1420 | ARRAY_SIZE(verde_golden_registers)); | 1420 | ARRAY_SIZE(verde_golden_registers)); |
1421 | amdgpu_program_register_sequence(adev, | 1421 | amdgpu_device_program_register_sequence(adev, |
1422 | verde_golden_rlc_registers, | 1422 | verde_golden_rlc_registers, |
1423 | ARRAY_SIZE(verde_golden_rlc_registers)); | 1423 | ARRAY_SIZE(verde_golden_rlc_registers)); |
1424 | amdgpu_program_register_sequence(adev, | 1424 | amdgpu_device_program_register_sequence(adev, |
1425 | verde_mgcg_cgcg_init, | 1425 | verde_mgcg_cgcg_init, |
1426 | ARRAY_SIZE(verde_mgcg_cgcg_init)); | 1426 | ARRAY_SIZE(verde_mgcg_cgcg_init)); |
1427 | amdgpu_program_register_sequence(adev, | 1427 | amdgpu_device_program_register_sequence(adev, |
1428 | verde_pg_init, | 1428 | verde_pg_init, |
1429 | ARRAY_SIZE(verde_pg_init)); | 1429 | ARRAY_SIZE(verde_pg_init)); |
1430 | break; | 1430 | break; |
1431 | case CHIP_OLAND: | 1431 | case CHIP_OLAND: |
1432 | amdgpu_program_register_sequence(adev, | 1432 | amdgpu_device_program_register_sequence(adev, |
1433 | oland_golden_registers, | 1433 | oland_golden_registers, |
1434 | ARRAY_SIZE(oland_golden_registers)); | 1434 | ARRAY_SIZE(oland_golden_registers)); |
1435 | amdgpu_program_register_sequence(adev, | 1435 | amdgpu_device_program_register_sequence(adev, |
1436 | oland_golden_rlc_registers, | 1436 | oland_golden_rlc_registers, |
1437 | ARRAY_SIZE(oland_golden_rlc_registers)); | 1437 | ARRAY_SIZE(oland_golden_rlc_registers)); |
1438 | amdgpu_program_register_sequence(adev, | 1438 | amdgpu_device_program_register_sequence(adev, |
1439 | oland_mgcg_cgcg_init, | 1439 | oland_mgcg_cgcg_init, |
1440 | ARRAY_SIZE(oland_mgcg_cgcg_init)); | 1440 | ARRAY_SIZE(oland_mgcg_cgcg_init)); |
1441 | break; | 1441 | break; |
1442 | case CHIP_HAINAN: | 1442 | case CHIP_HAINAN: |
1443 | amdgpu_program_register_sequence(adev, | 1443 | amdgpu_device_program_register_sequence(adev, |
1444 | hainan_golden_registers, | 1444 | hainan_golden_registers, |
1445 | ARRAY_SIZE(hainan_golden_registers)); | 1445 | ARRAY_SIZE(hainan_golden_registers)); |
1446 | amdgpu_program_register_sequence(adev, | 1446 | amdgpu_device_program_register_sequence(adev, |
1447 | hainan_golden_registers2, | 1447 | hainan_golden_registers2, |
1448 | ARRAY_SIZE(hainan_golden_registers2)); | 1448 | ARRAY_SIZE(hainan_golden_registers2)); |
1449 | amdgpu_program_register_sequence(adev, | 1449 | amdgpu_device_program_register_sequence(adev, |
1450 | hainan_mgcg_cgcg_init, | 1450 | hainan_mgcg_cgcg_init, |
1451 | ARRAY_SIZE(hainan_mgcg_cgcg_init)); | 1451 | ARRAY_SIZE(hainan_mgcg_cgcg_init)); |
1452 | break; | 1452 | break; |
1453 | 1453 | ||
1454 | 1454 | ||
@@ -1959,42 +1959,42 @@ int si_set_ip_blocks(struct amdgpu_device *adev) | |||
1959 | case CHIP_VERDE: | 1959 | case CHIP_VERDE: |
1960 | case CHIP_TAHITI: | 1960 | case CHIP_TAHITI: |
1961 | case CHIP_PITCAIRN: | 1961 | case CHIP_PITCAIRN: |
1962 | amdgpu_ip_block_add(adev, &si_common_ip_block); | 1962 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
1963 | amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); | 1963 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
1964 | amdgpu_ip_block_add(adev, &si_ih_ip_block); | 1964 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); |
1965 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1965 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1966 | if (adev->enable_virtual_display) | 1966 | if (adev->enable_virtual_display) |
1967 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1967 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1968 | else | 1968 | else |
1969 | amdgpu_ip_block_add(adev, &dce_v6_0_ip_block); | 1969 | amdgpu_device_ip_block_add(adev, &dce_v6_0_ip_block); |
1970 | amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); | 1970 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); |
1971 | amdgpu_ip_block_add(adev, &si_dma_ip_block); | 1971 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); |
1972 | /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */ | 1972 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ |
1973 | /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */ | 1973 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ |
1974 | break; | 1974 | break; |
1975 | case CHIP_OLAND: | 1975 | case CHIP_OLAND: |
1976 | amdgpu_ip_block_add(adev, &si_common_ip_block); | 1976 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
1977 | amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); | 1977 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
1978 | amdgpu_ip_block_add(adev, &si_ih_ip_block); | 1978 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); |
1979 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1979 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1980 | if (adev->enable_virtual_display) | 1980 | if (adev->enable_virtual_display) |
1981 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1981 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1982 | else | 1982 | else |
1983 | amdgpu_ip_block_add(adev, &dce_v6_4_ip_block); | 1983 | amdgpu_device_ip_block_add(adev, &dce_v6_4_ip_block); |
1984 | amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); | 1984 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); |
1985 | amdgpu_ip_block_add(adev, &si_dma_ip_block); | 1985 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); |
1986 | /* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */ | 1986 | /* amdgpu_device_ip_block_add(adev, &uvd_v3_1_ip_block); */ |
1987 | /* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */ | 1987 | /* amdgpu_device_ip_block_add(adev, &vce_v1_0_ip_block); */ |
1988 | break; | 1988 | break; |
1989 | case CHIP_HAINAN: | 1989 | case CHIP_HAINAN: |
1990 | amdgpu_ip_block_add(adev, &si_common_ip_block); | 1990 | amdgpu_device_ip_block_add(adev, &si_common_ip_block); |
1991 | amdgpu_ip_block_add(adev, &gmc_v6_0_ip_block); | 1991 | amdgpu_device_ip_block_add(adev, &gmc_v6_0_ip_block); |
1992 | amdgpu_ip_block_add(adev, &si_ih_ip_block); | 1992 | amdgpu_device_ip_block_add(adev, &si_ih_ip_block); |
1993 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1993 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1994 | if (adev->enable_virtual_display) | 1994 | if (adev->enable_virtual_display) |
1995 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1995 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1996 | amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block); | 1996 | amdgpu_device_ip_block_add(adev, &gfx_v6_0_ip_block); |
1997 | amdgpu_ip_block_add(adev, &si_dma_ip_block); | 1997 | amdgpu_device_ip_block_add(adev, &si_dma_ip_block); |
1998 | break; | 1998 | break; |
1999 | default: | 1999 | default: |
2000 | BUG(); | 2000 | BUG(); |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dma.c b/drivers/gpu/drm/amd/amdgpu/si_dma.c index ee469a906cd3..9adca5d8b045 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dma.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dma.c | |||
@@ -221,7 +221,7 @@ static int si_dma_ring_test_ring(struct amdgpu_ring *ring) | |||
221 | u32 tmp; | 221 | u32 tmp; |
222 | u64 gpu_addr; | 222 | u64 gpu_addr; |
223 | 223 | ||
224 | r = amdgpu_wb_get(adev, &index); | 224 | r = amdgpu_device_wb_get(adev, &index); |
225 | if (r) { | 225 | if (r) { |
226 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); | 226 | dev_err(adev->dev, "(%d) failed to allocate wb slot\n", r); |
227 | return r; | 227 | return r; |
@@ -234,7 +234,7 @@ static int si_dma_ring_test_ring(struct amdgpu_ring *ring) | |||
234 | r = amdgpu_ring_alloc(ring, 4); | 234 | r = amdgpu_ring_alloc(ring, 4); |
235 | if (r) { | 235 | if (r) { |
236 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); | 236 | DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", ring->idx, r); |
237 | amdgpu_wb_free(adev, index); | 237 | amdgpu_device_wb_free(adev, index); |
238 | return r; | 238 | return r; |
239 | } | 239 | } |
240 | 240 | ||
@@ -258,7 +258,7 @@ static int si_dma_ring_test_ring(struct amdgpu_ring *ring) | |||
258 | ring->idx, tmp); | 258 | ring->idx, tmp); |
259 | r = -EINVAL; | 259 | r = -EINVAL; |
260 | } | 260 | } |
261 | amdgpu_wb_free(adev, index); | 261 | amdgpu_device_wb_free(adev, index); |
262 | 262 | ||
263 | return r; | 263 | return r; |
264 | } | 264 | } |
@@ -281,7 +281,7 @@ static int si_dma_ring_test_ib(struct amdgpu_ring *ring, long timeout) | |||
281 | u64 gpu_addr; | 281 | u64 gpu_addr; |
282 | long r; | 282 | long r; |
283 | 283 | ||
284 | r = amdgpu_wb_get(adev, &index); | 284 | r = amdgpu_device_wb_get(adev, &index); |
285 | if (r) { | 285 | if (r) { |
286 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); | 286 | dev_err(adev->dev, "(%ld) failed to allocate wb slot\n", r); |
287 | return r; | 287 | return r; |
@@ -328,7 +328,7 @@ err1: | |||
328 | amdgpu_ib_free(adev, &ib, NULL); | 328 | amdgpu_ib_free(adev, &ib, NULL); |
329 | dma_fence_put(f); | 329 | dma_fence_put(f); |
330 | err0: | 330 | err0: |
331 | amdgpu_wb_free(adev, index); | 331 | amdgpu_device_wb_free(adev, index); |
332 | return r; | 332 | return r; |
333 | } | 333 | } |
334 | 334 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c index f134ca0c093c..8f2cff7b7e0c 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.c +++ b/drivers/gpu/drm/amd/amdgpu/soc15.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include "atom.h" | 34 | #include "atom.h" |
35 | #include "amd_pcie.h" | 35 | #include "amd_pcie.h" |
36 | 36 | ||
37 | #include "soc15ip.h" | ||
38 | #include "uvd/uvd_7_0_offset.h" | 37 | #include "uvd/uvd_7_0_offset.h" |
39 | #include "gc/gc_9_0_offset.h" | 38 | #include "gc/gc_9_0_offset.h" |
40 | #include "gc/gc_9_0_sh_mask.h" | 39 | #include "gc/gc_9_0_sh_mask.h" |
@@ -101,15 +100,8 @@ static u32 soc15_pcie_rreg(struct amdgpu_device *adev, u32 reg) | |||
101 | { | 100 | { |
102 | unsigned long flags, address, data; | 101 | unsigned long flags, address, data; |
103 | u32 r; | 102 | u32 r; |
104 | const struct nbio_pcie_index_data *nbio_pcie_id; | 103 | address = adev->nbio_funcs->get_pcie_index_offset(adev); |
105 | 104 | data = adev->nbio_funcs->get_pcie_data_offset(adev); | |
106 | if (adev->flags & AMD_IS_APU) | ||
107 | nbio_pcie_id = &nbio_v7_0_pcie_index_data; | ||
108 | else | ||
109 | nbio_pcie_id = &nbio_v6_1_pcie_index_data; | ||
110 | |||
111 | address = nbio_pcie_id->index_offset; | ||
112 | data = nbio_pcie_id->data_offset; | ||
113 | 105 | ||
114 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | 106 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
115 | WREG32(address, reg); | 107 | WREG32(address, reg); |
@@ -122,15 +114,9 @@ static u32 soc15_pcie_rreg(struct amdgpu_device *adev, u32 reg) | |||
122 | static void soc15_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | 114 | static void soc15_pcie_wreg(struct amdgpu_device *adev, u32 reg, u32 v) |
123 | { | 115 | { |
124 | unsigned long flags, address, data; | 116 | unsigned long flags, address, data; |
125 | const struct nbio_pcie_index_data *nbio_pcie_id; | ||
126 | 117 | ||
127 | if (adev->flags & AMD_IS_APU) | 118 | address = adev->nbio_funcs->get_pcie_index_offset(adev); |
128 | nbio_pcie_id = &nbio_v7_0_pcie_index_data; | 119 | data = adev->nbio_funcs->get_pcie_data_offset(adev); |
129 | else | ||
130 | nbio_pcie_id = &nbio_v6_1_pcie_index_data; | ||
131 | |||
132 | address = nbio_pcie_id->index_offset; | ||
133 | data = nbio_pcie_id->data_offset; | ||
134 | 120 | ||
135 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); | 121 | spin_lock_irqsave(&adev->pcie_idx_lock, flags); |
136 | WREG32(address, reg); | 122 | WREG32(address, reg); |
@@ -242,41 +228,9 @@ static void soc15_se_cac_wreg(struct amdgpu_device *adev, u32 reg, u32 v) | |||
242 | 228 | ||
243 | static u32 soc15_get_config_memsize(struct amdgpu_device *adev) | 229 | static u32 soc15_get_config_memsize(struct amdgpu_device *adev) |
244 | { | 230 | { |
245 | if (adev->flags & AMD_IS_APU) | 231 | return adev->nbio_funcs->get_memsize(adev); |
246 | return nbio_v7_0_get_memsize(adev); | ||
247 | else | ||
248 | return nbio_v6_1_get_memsize(adev); | ||
249 | } | 232 | } |
250 | 233 | ||
251 | static const u32 vega10_golden_init[] = | ||
252 | { | ||
253 | }; | ||
254 | |||
255 | static const u32 raven_golden_init[] = | ||
256 | { | ||
257 | }; | ||
258 | |||
259 | static void soc15_init_golden_registers(struct amdgpu_device *adev) | ||
260 | { | ||
261 | /* Some of the registers might be dependent on GRBM_GFX_INDEX */ | ||
262 | mutex_lock(&adev->grbm_idx_mutex); | ||
263 | |||
264 | switch (adev->asic_type) { | ||
265 | case CHIP_VEGA10: | ||
266 | amdgpu_program_register_sequence(adev, | ||
267 | vega10_golden_init, | ||
268 | ARRAY_SIZE(vega10_golden_init)); | ||
269 | break; | ||
270 | case CHIP_RAVEN: | ||
271 | amdgpu_program_register_sequence(adev, | ||
272 | raven_golden_init, | ||
273 | ARRAY_SIZE(raven_golden_init)); | ||
274 | break; | ||
275 | default: | ||
276 | break; | ||
277 | } | ||
278 | mutex_unlock(&adev->grbm_idx_mutex); | ||
279 | } | ||
280 | static u32 soc15_get_xclk(struct amdgpu_device *adev) | 234 | static u32 soc15_get_xclk(struct amdgpu_device *adev) |
281 | { | 235 | { |
282 | return adev->clock.spll.reference_freq; | 236 | return adev->clock.spll.reference_freq; |
@@ -332,25 +286,34 @@ static bool soc15_read_bios_from_rom(struct amdgpu_device *adev, | |||
332 | return true; | 286 | return true; |
333 | } | 287 | } |
334 | 288 | ||
335 | static struct amdgpu_allowed_register_entry soc15_allowed_read_registers[] = { | 289 | struct soc15_allowed_register_entry { |
336 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS)}, | 290 | uint32_t hwip; |
337 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS2)}, | 291 | uint32_t inst; |
338 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS_SE0)}, | 292 | uint32_t seg; |
339 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS_SE1)}, | 293 | uint32_t reg_offset; |
340 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS_SE2)}, | 294 | bool grbm_indexed; |
341 | { SOC15_REG_OFFSET(GC, 0, mmGRBM_STATUS_SE3)}, | 295 | }; |
342 | { SOC15_REG_OFFSET(SDMA0, 0, mmSDMA0_STATUS_REG)}, | 296 | |
343 | { SOC15_REG_OFFSET(SDMA1, 0, mmSDMA1_STATUS_REG)}, | 297 | |
344 | { SOC15_REG_OFFSET(GC, 0, mmCP_STAT)}, | 298 | static struct soc15_allowed_register_entry soc15_allowed_read_registers[] = { |
345 | { SOC15_REG_OFFSET(GC, 0, mmCP_STALLED_STAT1)}, | 299 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS)}, |
346 | { SOC15_REG_OFFSET(GC, 0, mmCP_STALLED_STAT2)}, | 300 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS2)}, |
347 | { SOC15_REG_OFFSET(GC, 0, mmCP_STALLED_STAT3)}, | 301 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE0)}, |
348 | { SOC15_REG_OFFSET(GC, 0, mmCP_CPF_BUSY_STAT)}, | 302 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE1)}, |
349 | { SOC15_REG_OFFSET(GC, 0, mmCP_CPF_STALLED_STAT1)}, | 303 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE2)}, |
350 | { SOC15_REG_OFFSET(GC, 0, mmCP_CPF_STATUS)}, | 304 | { SOC15_REG_ENTRY(GC, 0, mmGRBM_STATUS_SE3)}, |
351 | { SOC15_REG_OFFSET(GC, 0, mmCP_CPC_STALLED_STAT1)}, | 305 | { SOC15_REG_ENTRY(SDMA0, 0, mmSDMA0_STATUS_REG)}, |
352 | { SOC15_REG_OFFSET(GC, 0, mmCP_CPC_STATUS)}, | 306 | { SOC15_REG_ENTRY(SDMA1, 0, mmSDMA1_STATUS_REG)}, |
353 | { SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG)}, | 307 | { SOC15_REG_ENTRY(GC, 0, mmCP_STAT)}, |
308 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT1)}, | ||
309 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT2)}, | ||
310 | { SOC15_REG_ENTRY(GC, 0, mmCP_STALLED_STAT3)}, | ||
311 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_BUSY_STAT)}, | ||
312 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STALLED_STAT1)}, | ||
313 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPF_STATUS)}, | ||
314 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STALLED_STAT1)}, | ||
315 | { SOC15_REG_ENTRY(GC, 0, mmCP_CPC_STATUS)}, | ||
316 | { SOC15_REG_ENTRY(GC, 0, mmGB_ADDR_CONFIG)}, | ||
354 | }; | 317 | }; |
355 | 318 | ||
356 | static uint32_t soc15_read_indexed_register(struct amdgpu_device *adev, u32 se_num, | 319 | static uint32_t soc15_read_indexed_register(struct amdgpu_device *adev, u32 se_num, |
@@ -377,12 +340,9 @@ static uint32_t soc15_get_register_value(struct amdgpu_device *adev, | |||
377 | if (indexed) { | 340 | if (indexed) { |
378 | return soc15_read_indexed_register(adev, se_num, sh_num, reg_offset); | 341 | return soc15_read_indexed_register(adev, se_num, sh_num, reg_offset); |
379 | } else { | 342 | } else { |
380 | switch (reg_offset) { | 343 | if (reg_offset == SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG)) |
381 | case SOC15_REG_OFFSET(GC, 0, mmGB_ADDR_CONFIG): | ||
382 | return adev->gfx.config.gb_addr_config; | 344 | return adev->gfx.config.gb_addr_config; |
383 | default: | 345 | return RREG32(reg_offset); |
384 | return RREG32(reg_offset); | ||
385 | } | ||
386 | } | 346 | } |
387 | } | 347 | } |
388 | 348 | ||
@@ -390,10 +350,13 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num, | |||
390 | u32 sh_num, u32 reg_offset, u32 *value) | 350 | u32 sh_num, u32 reg_offset, u32 *value) |
391 | { | 351 | { |
392 | uint32_t i; | 352 | uint32_t i; |
353 | struct soc15_allowed_register_entry *en; | ||
393 | 354 | ||
394 | *value = 0; | 355 | *value = 0; |
395 | for (i = 0; i < ARRAY_SIZE(soc15_allowed_read_registers); i++) { | 356 | for (i = 0; i < ARRAY_SIZE(soc15_allowed_read_registers); i++) { |
396 | if (reg_offset != soc15_allowed_read_registers[i].reg_offset) | 357 | en = &soc15_allowed_read_registers[i]; |
358 | if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg] | ||
359 | + en->reg_offset)) | ||
397 | continue; | 360 | continue; |
398 | 361 | ||
399 | *value = soc15_get_register_value(adev, | 362 | *value = soc15_get_register_value(adev, |
@@ -404,6 +367,43 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num, | |||
404 | return -EINVAL; | 367 | return -EINVAL; |
405 | } | 368 | } |
406 | 369 | ||
370 | |||
371 | /** | ||
372 | * soc15_program_register_sequence - program an array of registers. | ||
373 | * | ||
374 | * @adev: amdgpu_device pointer | ||
375 | * @regs: pointer to the register array | ||
376 | * @array_size: size of the register array | ||
377 | * | ||
378 | * Programs an array or registers with and and or masks. | ||
379 | * This is a helper for setting golden registers. | ||
380 | */ | ||
381 | |||
382 | void soc15_program_register_sequence(struct amdgpu_device *adev, | ||
383 | const struct soc15_reg_golden *regs, | ||
384 | const u32 array_size) | ||
385 | { | ||
386 | const struct soc15_reg_golden *entry; | ||
387 | u32 tmp, reg; | ||
388 | int i; | ||
389 | |||
390 | for (i = 0; i < array_size; ++i) { | ||
391 | entry = ®s[i]; | ||
392 | reg = adev->reg_offset[entry->hwip][entry->instance][entry->segment] + entry->reg; | ||
393 | |||
394 | if (entry->and_mask == 0xffffffff) { | ||
395 | tmp = entry->or_mask; | ||
396 | } else { | ||
397 | tmp = RREG32(reg); | ||
398 | tmp &= ~(entry->and_mask); | ||
399 | tmp |= entry->or_mask; | ||
400 | } | ||
401 | WREG32(reg, tmp); | ||
402 | } | ||
403 | |||
404 | } | ||
405 | |||
406 | |||
407 | static int soc15_asic_reset(struct amdgpu_device *adev) | 407 | static int soc15_asic_reset(struct amdgpu_device *adev) |
408 | { | 408 | { |
409 | u32 i; | 409 | u32 i; |
@@ -428,9 +428,8 @@ static int soc15_asic_reset(struct amdgpu_device *adev) | |||
428 | 428 | ||
429 | /* wait for asic to come out of reset */ | 429 | /* wait for asic to come out of reset */ |
430 | for (i = 0; i < adev->usec_timeout; i++) { | 430 | for (i = 0; i < adev->usec_timeout; i++) { |
431 | u32 memsize = (adev->flags & AMD_IS_APU) ? | 431 | u32 memsize = adev->nbio_funcs->get_memsize(adev); |
432 | nbio_v7_0_get_memsize(adev) : | 432 | |
433 | nbio_v6_1_get_memsize(adev); | ||
434 | if (memsize != 0xffffffff) | 433 | if (memsize != 0xffffffff) |
435 | break; | 434 | break; |
436 | udelay(1); | 435 | udelay(1); |
@@ -495,14 +494,10 @@ static void soc15_program_aspm(struct amdgpu_device *adev) | |||
495 | } | 494 | } |
496 | 495 | ||
497 | static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev, | 496 | static void soc15_enable_doorbell_aperture(struct amdgpu_device *adev, |
498 | bool enable) | 497 | bool enable) |
499 | { | 498 | { |
500 | if (adev->flags & AMD_IS_APU) { | 499 | adev->nbio_funcs->enable_doorbell_aperture(adev, enable); |
501 | nbio_v7_0_enable_doorbell_aperture(adev, enable); | 500 | adev->nbio_funcs->enable_doorbell_selfring_aperture(adev, enable); |
502 | } else { | ||
503 | nbio_v6_1_enable_doorbell_aperture(adev, enable); | ||
504 | nbio_v6_1_enable_doorbell_selfring_aperture(adev, enable); | ||
505 | } | ||
506 | } | 501 | } |
507 | 502 | ||
508 | static const struct amdgpu_ip_block_version vega10_common_ip_block = | 503 | static const struct amdgpu_ip_block_version vega10_common_ip_block = |
@@ -516,50 +511,65 @@ static const struct amdgpu_ip_block_version vega10_common_ip_block = | |||
516 | 511 | ||
517 | int soc15_set_ip_blocks(struct amdgpu_device *adev) | 512 | int soc15_set_ip_blocks(struct amdgpu_device *adev) |
518 | { | 513 | { |
519 | nbio_v6_1_detect_hw_virt(adev); | 514 | /* Set IP register base before any HW register access */ |
515 | switch (adev->asic_type) { | ||
516 | case CHIP_VEGA10: | ||
517 | case CHIP_RAVEN: | ||
518 | vega10_reg_base_init(adev); | ||
519 | break; | ||
520 | default: | ||
521 | return -EINVAL; | ||
522 | } | ||
523 | |||
524 | if (adev->flags & AMD_IS_APU) | ||
525 | adev->nbio_funcs = &nbio_v7_0_funcs; | ||
526 | else | ||
527 | adev->nbio_funcs = &nbio_v6_1_funcs; | ||
528 | |||
529 | adev->nbio_funcs->detect_hw_virt(adev); | ||
520 | 530 | ||
521 | if (amdgpu_sriov_vf(adev)) | 531 | if (amdgpu_sriov_vf(adev)) |
522 | adev->virt.ops = &xgpu_ai_virt_ops; | 532 | adev->virt.ops = &xgpu_ai_virt_ops; |
523 | 533 | ||
524 | switch (adev->asic_type) { | 534 | switch (adev->asic_type) { |
525 | case CHIP_VEGA10: | 535 | case CHIP_VEGA10: |
526 | amdgpu_ip_block_add(adev, &vega10_common_ip_block); | 536 | amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); |
527 | amdgpu_ip_block_add(adev, &gmc_v9_0_ip_block); | 537 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); |
528 | amdgpu_ip_block_add(adev, &vega10_ih_ip_block); | 538 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); |
529 | if (amdgpu_fw_load_type == 2 || amdgpu_fw_load_type == -1) | 539 | if (amdgpu_fw_load_type == 2 || amdgpu_fw_load_type == -1) |
530 | amdgpu_ip_block_add(adev, &psp_v3_1_ip_block); | 540 | amdgpu_device_ip_block_add(adev, &psp_v3_1_ip_block); |
531 | if (!amdgpu_sriov_vf(adev)) | 541 | if (!amdgpu_sriov_vf(adev)) |
532 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 542 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
533 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 543 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
534 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 544 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
535 | #if defined(CONFIG_DRM_AMD_DC) | 545 | #if defined(CONFIG_DRM_AMD_DC) |
536 | else if (amdgpu_device_has_dc_support(adev)) | 546 | else if (amdgpu_device_has_dc_support(adev)) |
537 | amdgpu_ip_block_add(adev, &dm_ip_block); | 547 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
538 | #else | 548 | #else |
539 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." | 549 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." |
540 | #endif | 550 | #endif |
541 | amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block); | 551 | amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); |
542 | amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block); | 552 | amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); |
543 | amdgpu_ip_block_add(adev, &uvd_v7_0_ip_block); | 553 | amdgpu_device_ip_block_add(adev, &uvd_v7_0_ip_block); |
544 | amdgpu_ip_block_add(adev, &vce_v4_0_ip_block); | 554 | amdgpu_device_ip_block_add(adev, &vce_v4_0_ip_block); |
545 | break; | 555 | break; |
546 | case CHIP_RAVEN: | 556 | case CHIP_RAVEN: |
547 | amdgpu_ip_block_add(adev, &vega10_common_ip_block); | 557 | amdgpu_device_ip_block_add(adev, &vega10_common_ip_block); |
548 | amdgpu_ip_block_add(adev, &gmc_v9_0_ip_block); | 558 | amdgpu_device_ip_block_add(adev, &gmc_v9_0_ip_block); |
549 | amdgpu_ip_block_add(adev, &vega10_ih_ip_block); | 559 | amdgpu_device_ip_block_add(adev, &vega10_ih_ip_block); |
550 | amdgpu_ip_block_add(adev, &psp_v10_0_ip_block); | 560 | amdgpu_device_ip_block_add(adev, &psp_v10_0_ip_block); |
551 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 561 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
552 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 562 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
553 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 563 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
554 | #if defined(CONFIG_DRM_AMD_DC) | 564 | #if defined(CONFIG_DRM_AMD_DC) |
555 | else if (amdgpu_device_has_dc_support(adev)) | 565 | else if (amdgpu_device_has_dc_support(adev)) |
556 | amdgpu_ip_block_add(adev, &dm_ip_block); | 566 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
557 | #else | 567 | #else |
558 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." | 568 | # warning "Enable CONFIG_DRM_AMD_DC for display support on SOC15." |
559 | #endif | 569 | #endif |
560 | amdgpu_ip_block_add(adev, &gfx_v9_0_ip_block); | 570 | amdgpu_device_ip_block_add(adev, &gfx_v9_0_ip_block); |
561 | amdgpu_ip_block_add(adev, &sdma_v4_0_ip_block); | 571 | amdgpu_device_ip_block_add(adev, &sdma_v4_0_ip_block); |
562 | amdgpu_ip_block_add(adev, &vcn_v1_0_ip_block); | 572 | amdgpu_device_ip_block_add(adev, &vcn_v1_0_ip_block); |
563 | break; | 573 | break; |
564 | default: | 574 | default: |
565 | return -EINVAL; | 575 | return -EINVAL; |
@@ -570,10 +580,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) | |||
570 | 580 | ||
571 | static uint32_t soc15_get_rev_id(struct amdgpu_device *adev) | 581 | static uint32_t soc15_get_rev_id(struct amdgpu_device *adev) |
572 | { | 582 | { |
573 | if (adev->flags & AMD_IS_APU) | 583 | return adev->nbio_funcs->get_rev_id(adev); |
574 | return nbio_v7_0_get_rev_id(adev); | ||
575 | else | ||
576 | return nbio_v6_1_get_rev_id(adev); | ||
577 | } | 584 | } |
578 | 585 | ||
579 | static const struct amdgpu_asic_funcs soc15_asic_funcs = | 586 | static const struct amdgpu_asic_funcs soc15_asic_funcs = |
@@ -609,8 +616,8 @@ static int soc15_common_early_init(void *handle) | |||
609 | 616 | ||
610 | adev->asic_funcs = &soc15_asic_funcs; | 617 | adev->asic_funcs = &soc15_asic_funcs; |
611 | 618 | ||
612 | if (amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP) && | 619 | if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP) && |
613 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_PSP))) | 620 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_PSP))) |
614 | psp_enabled = true; | 621 | psp_enabled = true; |
615 | 622 | ||
616 | adev->rev_id = soc15_get_rev_id(adev); | 623 | adev->rev_id = soc15_get_rev_id(adev); |
@@ -675,7 +682,7 @@ static int soc15_common_early_init(void *handle) | |||
675 | 682 | ||
676 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); | 683 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); |
677 | 684 | ||
678 | amdgpu_get_pcie_info(adev); | 685 | amdgpu_device_get_pcie_info(adev); |
679 | 686 | ||
680 | return 0; | 687 | return 0; |
681 | } | 688 | } |
@@ -709,15 +716,12 @@ static int soc15_common_hw_init(void *handle) | |||
709 | { | 716 | { |
710 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 717 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
711 | 718 | ||
712 | /* move the golden regs per IP block */ | ||
713 | soc15_init_golden_registers(adev); | ||
714 | /* enable pcie gen2/3 link */ | 719 | /* enable pcie gen2/3 link */ |
715 | soc15_pcie_gen3_enable(adev); | 720 | soc15_pcie_gen3_enable(adev); |
716 | /* enable aspm */ | 721 | /* enable aspm */ |
717 | soc15_program_aspm(adev); | 722 | soc15_program_aspm(adev); |
718 | /* setup nbio registers */ | 723 | /* setup nbio registers */ |
719 | if (!(adev->flags & AMD_IS_APU)) | 724 | adev->nbio_funcs->init_registers(adev); |
720 | nbio_v6_1_init_registers(adev); | ||
721 | /* enable the doorbell aperture */ | 725 | /* enable the doorbell aperture */ |
722 | soc15_enable_doorbell_aperture(adev, true); | 726 | soc15_enable_doorbell_aperture(adev, true); |
723 | 727 | ||
@@ -878,9 +882,9 @@ static int soc15_common_set_clockgating_state(void *handle, | |||
878 | 882 | ||
879 | switch (adev->asic_type) { | 883 | switch (adev->asic_type) { |
880 | case CHIP_VEGA10: | 884 | case CHIP_VEGA10: |
881 | nbio_v6_1_update_medium_grain_clock_gating(adev, | 885 | adev->nbio_funcs->update_medium_grain_clock_gating(adev, |
882 | state == AMD_CG_STATE_GATE ? true : false); | 886 | state == AMD_CG_STATE_GATE ? true : false); |
883 | nbio_v6_1_update_medium_grain_light_sleep(adev, | 887 | adev->nbio_funcs->update_medium_grain_light_sleep(adev, |
884 | state == AMD_CG_STATE_GATE ? true : false); | 888 | state == AMD_CG_STATE_GATE ? true : false); |
885 | soc15_update_hdp_light_sleep(adev, | 889 | soc15_update_hdp_light_sleep(adev, |
886 | state == AMD_CG_STATE_GATE ? true : false); | 890 | state == AMD_CG_STATE_GATE ? true : false); |
@@ -894,9 +898,9 @@ static int soc15_common_set_clockgating_state(void *handle, | |||
894 | state == AMD_CG_STATE_GATE ? true : false); | 898 | state == AMD_CG_STATE_GATE ? true : false); |
895 | break; | 899 | break; |
896 | case CHIP_RAVEN: | 900 | case CHIP_RAVEN: |
897 | nbio_v7_0_update_medium_grain_clock_gating(adev, | 901 | adev->nbio_funcs->update_medium_grain_clock_gating(adev, |
898 | state == AMD_CG_STATE_GATE ? true : false); | 902 | state == AMD_CG_STATE_GATE ? true : false); |
899 | nbio_v6_1_update_medium_grain_light_sleep(adev, | 903 | adev->nbio_funcs->update_medium_grain_light_sleep(adev, |
900 | state == AMD_CG_STATE_GATE ? true : false); | 904 | state == AMD_CG_STATE_GATE ? true : false); |
901 | soc15_update_hdp_light_sleep(adev, | 905 | soc15_update_hdp_light_sleep(adev, |
902 | state == AMD_CG_STATE_GATE ? true : false); | 906 | state == AMD_CG_STATE_GATE ? true : false); |
@@ -921,7 +925,7 @@ static void soc15_common_get_clockgating_state(void *handle, u32 *flags) | |||
921 | if (amdgpu_sriov_vf(adev)) | 925 | if (amdgpu_sriov_vf(adev)) |
922 | *flags = 0; | 926 | *flags = 0; |
923 | 927 | ||
924 | nbio_v6_1_get_clockgating_state(adev, flags); | 928 | adev->nbio_funcs->get_clockgating_state(adev, flags); |
925 | 929 | ||
926 | /* AMD_CG_SUPPORT_HDP_LS */ | 930 | /* AMD_CG_SUPPORT_HDP_LS */ |
927 | data = RREG32(SOC15_REG_OFFSET(HDP, 0, mmHDP_MEM_POWER_LS)); | 931 | data = RREG32(SOC15_REG_OFFSET(HDP, 0, mmHDP_MEM_POWER_LS)); |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.h b/drivers/gpu/drm/amd/amdgpu/soc15.h index acb3cdb119f2..26b3feac5d06 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15.h | |||
@@ -29,8 +29,28 @@ | |||
29 | 29 | ||
30 | extern const struct amd_ip_funcs soc15_common_ip_funcs; | 30 | extern const struct amd_ip_funcs soc15_common_ip_funcs; |
31 | 31 | ||
32 | struct soc15_reg_golden { | ||
33 | u32 hwip; | ||
34 | u32 instance; | ||
35 | u32 segment; | ||
36 | u32 reg; | ||
37 | u32 and_mask; | ||
38 | u32 or_mask; | ||
39 | }; | ||
40 | |||
41 | #define SOC15_REG_ENTRY(ip, inst, reg) ip##_HWIP, inst, reg##_BASE_IDX, reg | ||
42 | |||
43 | #define SOC15_REG_GOLDEN_VALUE(ip, inst, reg, and_mask, or_mask) \ | ||
44 | { ip##_HWIP, inst, reg##_BASE_IDX, reg, and_mask, or_mask } | ||
45 | |||
32 | void soc15_grbm_select(struct amdgpu_device *adev, | 46 | void soc15_grbm_select(struct amdgpu_device *adev, |
33 | u32 me, u32 pipe, u32 queue, u32 vmid); | 47 | u32 me, u32 pipe, u32 queue, u32 vmid); |
34 | int soc15_set_ip_blocks(struct amdgpu_device *adev); | 48 | int soc15_set_ip_blocks(struct amdgpu_device *adev); |
35 | 49 | ||
50 | void soc15_program_register_sequence(struct amdgpu_device *adev, | ||
51 | const struct soc15_reg_golden *registers, | ||
52 | const u32 array_size); | ||
53 | |||
54 | int vega10_reg_base_init(struct amdgpu_device *adev); | ||
55 | |||
36 | #endif | 56 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/soc15_common.h b/drivers/gpu/drm/amd/amdgpu/soc15_common.h index 7a8e4e28abb2..def865067edd 100644 --- a/drivers/gpu/drm/amd/amdgpu/soc15_common.h +++ b/drivers/gpu/drm/amd/amdgpu/soc15_common.h | |||
@@ -24,72 +24,28 @@ | |||
24 | #ifndef __SOC15_COMMON_H__ | 24 | #ifndef __SOC15_COMMON_H__ |
25 | #define __SOC15_COMMON_H__ | 25 | #define __SOC15_COMMON_H__ |
26 | 26 | ||
27 | struct nbio_hdp_flush_reg { | ||
28 | u32 hdp_flush_req_offset; | ||
29 | u32 hdp_flush_done_offset; | ||
30 | u32 ref_and_mask_cp0; | ||
31 | u32 ref_and_mask_cp1; | ||
32 | u32 ref_and_mask_cp2; | ||
33 | u32 ref_and_mask_cp3; | ||
34 | u32 ref_and_mask_cp4; | ||
35 | u32 ref_and_mask_cp5; | ||
36 | u32 ref_and_mask_cp6; | ||
37 | u32 ref_and_mask_cp7; | ||
38 | u32 ref_and_mask_cp8; | ||
39 | u32 ref_and_mask_cp9; | ||
40 | u32 ref_and_mask_sdma0; | ||
41 | u32 ref_and_mask_sdma1; | ||
42 | }; | ||
43 | |||
44 | struct nbio_pcie_index_data { | ||
45 | u32 index_offset; | ||
46 | u32 data_offset; | ||
47 | }; | ||
48 | |||
49 | /* Register Access Macros */ | 27 | /* Register Access Macros */ |
50 | #define SOC15_REG_OFFSET(ip, inst, reg) (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 28 | #define SOC15_REG_OFFSET(ip, inst, reg) (adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) |
51 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
52 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
53 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
54 | (ip##_BASE__INST##inst##_SEG4 + reg))))) | ||
55 | 29 | ||
56 | #define WREG32_FIELD15(ip, idx, reg, field, val) \ | 30 | #define WREG32_FIELD15(ip, idx, reg, field, val) \ |
57 | WREG32(SOC15_REG_OFFSET(ip, idx, mm##reg), (RREG32(SOC15_REG_OFFSET(ip, idx, mm##reg)) & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field)) | 31 | WREG32(adev->reg_offset[ip##_HWIP][idx][mm##reg##_BASE_IDX] + mm##reg, \ |
32 | (RREG32(adev->reg_offset[ip##_HWIP][idx][mm##reg##_BASE_IDX] + mm##reg) \ | ||
33 | & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field)) | ||
58 | 34 | ||
59 | #define RREG32_SOC15(ip, inst, reg) \ | 35 | #define RREG32_SOC15(ip, inst, reg) \ |
60 | RREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 36 | RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) |
61 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
62 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
63 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
64 | (ip##_BASE__INST##inst##_SEG4 + reg)))))) | ||
65 | 37 | ||
66 | #define RREG32_SOC15_OFFSET(ip, inst, reg, offset) \ | 38 | #define RREG32_SOC15_OFFSET(ip, inst, reg, offset) \ |
67 | RREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 39 | RREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset) |
68 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
69 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
70 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
71 | (ip##_BASE__INST##inst##_SEG4 + reg))))) + offset) | ||
72 | 40 | ||
73 | #define WREG32_SOC15(ip, inst, reg, value) \ | 41 | #define WREG32_SOC15(ip, inst, reg, value) \ |
74 | WREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 42 | WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg), value) |
75 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
76 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
77 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
78 | (ip##_BASE__INST##inst##_SEG4 + reg))))), value) | ||
79 | 43 | ||
80 | #define WREG32_SOC15_NO_KIQ(ip, inst, reg, value) \ | 44 | #define WREG32_SOC15_NO_KIQ(ip, inst, reg, value) \ |
81 | WREG32_NO_KIQ( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 45 | WREG32_NO_KIQ((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg), value) |
82 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
83 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
84 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
85 | (ip##_BASE__INST##inst##_SEG4 + reg))))), value) | ||
86 | 46 | ||
87 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ | 47 | #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \ |
88 | WREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \ | 48 | WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset, value) |
89 | (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \ | ||
90 | (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \ | ||
91 | (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \ | ||
92 | (ip##_BASE__INST##inst##_SEG4 + reg))))) + offset, value) | ||
93 | 49 | ||
94 | #endif | 50 | #endif |
95 | 51 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c index 0e8b887cf03e..86123448a8ff 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | |||
@@ -412,10 +412,10 @@ static int uvd_v6_0_sw_init(void *handle) | |||
412 | return r; | 412 | return r; |
413 | 413 | ||
414 | if (uvd_v6_0_enc_support(adev)) { | 414 | if (uvd_v6_0_enc_support(adev)) { |
415 | struct amd_sched_rq *rq; | 415 | struct drm_sched_rq *rq; |
416 | ring = &adev->uvd.ring_enc[0]; | 416 | ring = &adev->uvd.ring_enc[0]; |
417 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 417 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
418 | r = amd_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, | 418 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, |
419 | rq, amdgpu_sched_jobs, NULL); | 419 | rq, amdgpu_sched_jobs, NULL); |
420 | if (r) { | 420 | if (r) { |
421 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); | 421 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); |
@@ -456,7 +456,7 @@ static int uvd_v6_0_sw_fini(void *handle) | |||
456 | return r; | 456 | return r; |
457 | 457 | ||
458 | if (uvd_v6_0_enc_support(adev)) { | 458 | if (uvd_v6_0_enc_support(adev)) { |
459 | amd_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); | 459 | drm_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); |
460 | 460 | ||
461 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 461 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) |
462 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); | 462 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); |
diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c index 660fa41dc877..4ec4447d33c0 100644 --- a/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +++ b/drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "soc15_common.h" | 29 | #include "soc15_common.h" |
30 | #include "mmsch_v1_0.h" | 30 | #include "mmsch_v1_0.h" |
31 | 31 | ||
32 | #include "soc15ip.h" | ||
33 | #include "uvd/uvd_7_0_offset.h" | 32 | #include "uvd/uvd_7_0_offset.h" |
34 | #include "uvd/uvd_7_0_sh_mask.h" | 33 | #include "uvd/uvd_7_0_sh_mask.h" |
35 | #include "vce/vce_4_0_offset.h" | 34 | #include "vce/vce_4_0_offset.h" |
@@ -385,7 +384,7 @@ static int uvd_v7_0_early_init(void *handle) | |||
385 | static int uvd_v7_0_sw_init(void *handle) | 384 | static int uvd_v7_0_sw_init(void *handle) |
386 | { | 385 | { |
387 | struct amdgpu_ring *ring; | 386 | struct amdgpu_ring *ring; |
388 | struct amd_sched_rq *rq; | 387 | struct drm_sched_rq *rq; |
389 | int i, r; | 388 | int i, r; |
390 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; | 389 | struct amdgpu_device *adev = (struct amdgpu_device *)handle; |
391 | 390 | ||
@@ -416,8 +415,8 @@ static int uvd_v7_0_sw_init(void *handle) | |||
416 | } | 415 | } |
417 | 416 | ||
418 | ring = &adev->uvd.ring_enc[0]; | 417 | ring = &adev->uvd.ring_enc[0]; |
419 | rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL]; | 418 | rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL]; |
420 | r = amd_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, | 419 | r = drm_sched_entity_init(&ring->sched, &adev->uvd.entity_enc, |
421 | rq, amdgpu_sched_jobs, NULL); | 420 | rq, amdgpu_sched_jobs, NULL); |
422 | if (r) { | 421 | if (r) { |
423 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); | 422 | DRM_ERROR("Failed setting up UVD ENC run queue.\n"); |
@@ -472,7 +471,7 @@ static int uvd_v7_0_sw_fini(void *handle) | |||
472 | if (r) | 471 | if (r) |
473 | return r; | 472 | return r; |
474 | 473 | ||
475 | amd_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); | 474 | drm_sched_entity_fini(&adev->uvd.ring_enc[0].sched, &adev->uvd.entity_enc); |
476 | 475 | ||
477 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) | 476 | for (i = 0; i < adev->uvd.num_enc_rings; ++i) |
478 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); | 477 | amdgpu_ring_fini(&adev->uvd.ring_enc[i]); |
@@ -1086,6 +1085,8 @@ static void uvd_v7_0_stop(struct amdgpu_device *adev) | |||
1086 | static void uvd_v7_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, | 1085 | static void uvd_v7_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, |
1087 | unsigned flags) | 1086 | unsigned flags) |
1088 | { | 1087 | { |
1088 | struct amdgpu_device *adev = ring->adev; | ||
1089 | |||
1089 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | 1090 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); |
1090 | 1091 | ||
1091 | amdgpu_ring_write(ring, | 1092 | amdgpu_ring_write(ring, |
@@ -1123,6 +1124,7 @@ static void uvd_v7_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq | |||
1123 | static void uvd_v7_0_enc_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, | 1124 | static void uvd_v7_0_enc_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, |
1124 | u64 seq, unsigned flags) | 1125 | u64 seq, unsigned flags) |
1125 | { | 1126 | { |
1127 | |||
1126 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | 1128 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); |
1127 | 1129 | ||
1128 | amdgpu_ring_write(ring, HEVC_ENC_CMD_FENCE); | 1130 | amdgpu_ring_write(ring, HEVC_ENC_CMD_FENCE); |
@@ -1141,6 +1143,8 @@ static void uvd_v7_0_enc_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, | |||
1141 | */ | 1143 | */ |
1142 | static void uvd_v7_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | 1144 | static void uvd_v7_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) |
1143 | { | 1145 | { |
1146 | struct amdgpu_device *adev = ring->adev; | ||
1147 | |||
1144 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(NBIF, 0, | 1148 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(NBIF, 0, |
1145 | mmHDP_MEM_COHERENCY_FLUSH_CNTL), 0)); | 1149 | mmHDP_MEM_COHERENCY_FLUSH_CNTL), 0)); |
1146 | amdgpu_ring_write(ring, 0); | 1150 | amdgpu_ring_write(ring, 0); |
@@ -1155,6 +1159,8 @@ static void uvd_v7_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) | |||
1155 | */ | 1159 | */ |
1156 | static void uvd_v7_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | 1160 | static void uvd_v7_0_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) |
1157 | { | 1161 | { |
1162 | struct amdgpu_device *adev = ring->adev; | ||
1163 | |||
1158 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 0)); | 1164 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 0)); |
1159 | amdgpu_ring_write(ring, 1); | 1165 | amdgpu_ring_write(ring, 1); |
1160 | } | 1166 | } |
@@ -1214,6 +1220,8 @@ static void uvd_v7_0_ring_emit_ib(struct amdgpu_ring *ring, | |||
1214 | struct amdgpu_ib *ib, | 1220 | struct amdgpu_ib *ib, |
1215 | unsigned vm_id, bool ctx_switch) | 1221 | unsigned vm_id, bool ctx_switch) |
1216 | { | 1222 | { |
1223 | struct amdgpu_device *adev = ring->adev; | ||
1224 | |||
1217 | amdgpu_ring_write(ring, | 1225 | amdgpu_ring_write(ring, |
1218 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); | 1226 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); |
1219 | amdgpu_ring_write(ring, vm_id); | 1227 | amdgpu_ring_write(ring, vm_id); |
@@ -1250,6 +1258,8 @@ static void uvd_v7_0_enc_ring_emit_ib(struct amdgpu_ring *ring, | |||
1250 | static void uvd_v7_0_vm_reg_write(struct amdgpu_ring *ring, | 1258 | static void uvd_v7_0_vm_reg_write(struct amdgpu_ring *ring, |
1251 | uint32_t data0, uint32_t data1) | 1259 | uint32_t data0, uint32_t data1) |
1252 | { | 1260 | { |
1261 | struct amdgpu_device *adev = ring->adev; | ||
1262 | |||
1253 | amdgpu_ring_write(ring, | 1263 | amdgpu_ring_write(ring, |
1254 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1264 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1255 | amdgpu_ring_write(ring, data0); | 1265 | amdgpu_ring_write(ring, data0); |
@@ -1264,6 +1274,8 @@ static void uvd_v7_0_vm_reg_write(struct amdgpu_ring *ring, | |||
1264 | static void uvd_v7_0_vm_reg_wait(struct amdgpu_ring *ring, | 1274 | static void uvd_v7_0_vm_reg_wait(struct amdgpu_ring *ring, |
1265 | uint32_t data0, uint32_t data1, uint32_t mask) | 1275 | uint32_t data0, uint32_t data1, uint32_t mask) |
1266 | { | 1276 | { |
1277 | struct amdgpu_device *adev = ring->adev; | ||
1278 | |||
1267 | amdgpu_ring_write(ring, | 1279 | amdgpu_ring_write(ring, |
1268 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 1280 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); |
1269 | amdgpu_ring_write(ring, data0); | 1281 | amdgpu_ring_write(ring, data0); |
@@ -1283,11 +1295,12 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1283 | { | 1295 | { |
1284 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 1296 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
1285 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 1297 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
1286 | uint32_t data0, data1, mask; | 1298 | uint64_t flags = AMDGPU_PTE_VALID; |
1287 | unsigned eng = ring->vm_inv_eng; | 1299 | unsigned eng = ring->vm_inv_eng; |
1300 | uint32_t data0, data1, mask; | ||
1288 | 1301 | ||
1289 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 1302 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
1290 | pd_addr |= AMDGPU_PTE_VALID; | 1303 | pd_addr |= flags; |
1291 | 1304 | ||
1292 | data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2; | 1305 | data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2; |
1293 | data1 = upper_32_bits(pd_addr); | 1306 | data1 = upper_32_bits(pd_addr); |
@@ -1314,6 +1327,16 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1314 | uvd_v7_0_vm_reg_wait(ring, data0, data1, mask); | 1327 | uvd_v7_0_vm_reg_wait(ring, data0, data1, mask); |
1315 | } | 1328 | } |
1316 | 1329 | ||
1330 | static void uvd_v7_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
1331 | { | ||
1332 | int i; | ||
1333 | struct amdgpu_device *adev = ring->adev; | ||
1334 | |||
1335 | for (i = 0; i < count; i++) | ||
1336 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0)); | ||
1337 | |||
1338 | } | ||
1339 | |||
1317 | static void uvd_v7_0_enc_ring_insert_end(struct amdgpu_ring *ring) | 1340 | static void uvd_v7_0_enc_ring_insert_end(struct amdgpu_ring *ring) |
1318 | { | 1341 | { |
1319 | amdgpu_ring_write(ring, HEVC_ENC_CMD_END); | 1342 | amdgpu_ring_write(ring, HEVC_ENC_CMD_END); |
@@ -1324,10 +1347,11 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1324 | { | 1347 | { |
1325 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 1348 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
1326 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 1349 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
1350 | uint64_t flags = AMDGPU_PTE_VALID; | ||
1327 | unsigned eng = ring->vm_inv_eng; | 1351 | unsigned eng = ring->vm_inv_eng; |
1328 | 1352 | ||
1329 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 1353 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
1330 | pd_addr |= AMDGPU_PTE_VALID; | 1354 | pd_addr |= flags; |
1331 | 1355 | ||
1332 | amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE); | 1356 | amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE); |
1333 | amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2); | 1357 | amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2); |
@@ -1681,7 +1705,7 @@ const struct amd_ip_funcs uvd_v7_0_ip_funcs = { | |||
1681 | static const struct amdgpu_ring_funcs uvd_v7_0_ring_vm_funcs = { | 1705 | static const struct amdgpu_ring_funcs uvd_v7_0_ring_vm_funcs = { |
1682 | .type = AMDGPU_RING_TYPE_UVD, | 1706 | .type = AMDGPU_RING_TYPE_UVD, |
1683 | .align_mask = 0xf, | 1707 | .align_mask = 0xf, |
1684 | .nop = PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0), | 1708 | .nop = PACKET0(0x81ff, 0), |
1685 | .support_64bit_ptrs = false, | 1709 | .support_64bit_ptrs = false, |
1686 | .vmhub = AMDGPU_MMHUB, | 1710 | .vmhub = AMDGPU_MMHUB, |
1687 | .get_rptr = uvd_v7_0_ring_get_rptr, | 1711 | .get_rptr = uvd_v7_0_ring_get_rptr, |
@@ -1700,7 +1724,7 @@ static const struct amdgpu_ring_funcs uvd_v7_0_ring_vm_funcs = { | |||
1700 | .emit_hdp_invalidate = uvd_v7_0_ring_emit_hdp_invalidate, | 1724 | .emit_hdp_invalidate = uvd_v7_0_ring_emit_hdp_invalidate, |
1701 | .test_ring = uvd_v7_0_ring_test_ring, | 1725 | .test_ring = uvd_v7_0_ring_test_ring, |
1702 | .test_ib = amdgpu_uvd_ring_test_ib, | 1726 | .test_ib = amdgpu_uvd_ring_test_ib, |
1703 | .insert_nop = amdgpu_ring_insert_nop, | 1727 | .insert_nop = uvd_v7_0_ring_insert_nop, |
1704 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1728 | .pad_ib = amdgpu_ring_generic_pad_ib, |
1705 | .begin_use = amdgpu_uvd_ring_begin_use, | 1729 | .begin_use = amdgpu_uvd_ring_begin_use, |
1706 | .end_use = amdgpu_uvd_ring_end_use, | 1730 | .end_use = amdgpu_uvd_ring_end_use, |
diff --git a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c index f2f713650074..308949d6edde 100755 --- a/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vce_v4_0.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include "soc15_common.h" | 32 | #include "soc15_common.h" |
33 | #include "mmsch_v1_0.h" | 33 | #include "mmsch_v1_0.h" |
34 | 34 | ||
35 | #include "soc15ip.h" | ||
36 | #include "vce/vce_4_0_offset.h" | 35 | #include "vce/vce_4_0_offset.h" |
37 | #include "vce/vce_4_0_default.h" | 36 | #include "vce/vce_4_0_default.h" |
38 | #include "vce/vce_4_0_sh_mask.h" | 37 | #include "vce/vce_4_0_sh_mask.h" |
@@ -424,7 +423,7 @@ static int vce_v4_0_sw_init(void *handle) | |||
424 | if (r) | 423 | if (r) |
425 | return r; | 424 | return r; |
426 | 425 | ||
427 | size = (VCE_V4_0_STACK_SIZE + VCE_V4_0_DATA_SIZE) * 2; | 426 | size = VCE_V4_0_STACK_SIZE + VCE_V4_0_DATA_SIZE; |
428 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) | 427 | if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) |
429 | size += VCE_V4_0_FW_SIZE; | 428 | size += VCE_V4_0_FW_SIZE; |
430 | 429 | ||
@@ -970,10 +969,11 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring, | |||
970 | { | 969 | { |
971 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 970 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
972 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 971 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
972 | uint64_t flags = AMDGPU_PTE_VALID; | ||
973 | unsigned eng = ring->vm_inv_eng; | 973 | unsigned eng = ring->vm_inv_eng; |
974 | 974 | ||
975 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 975 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
976 | pd_addr |= AMDGPU_PTE_VALID; | 976 | pd_addr |= flags; |
977 | 977 | ||
978 | amdgpu_ring_write(ring, VCE_CMD_REG_WRITE); | 978 | amdgpu_ring_write(ring, VCE_CMD_REG_WRITE); |
979 | amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2); | 979 | amdgpu_ring_write(ring, (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2); |
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c index e4673f792545..deb3fba790a5 100644 --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "soc15d.h" | 28 | #include "soc15d.h" |
29 | #include "soc15_common.h" | 29 | #include "soc15_common.h" |
30 | 30 | ||
31 | #include "soc15ip.h" | ||
32 | #include "vcn/vcn_1_0_offset.h" | 31 | #include "vcn/vcn_1_0_offset.h" |
33 | #include "vcn/vcn_1_0_sh_mask.h" | 32 | #include "vcn/vcn_1_0_sh_mask.h" |
34 | #include "hdp/hdp_4_0_offset.h" | 33 | #include "hdp/hdp_4_0_offset.h" |
@@ -744,6 +743,8 @@ static void vcn_v1_0_dec_ring_set_wptr(struct amdgpu_ring *ring) | |||
744 | */ | 743 | */ |
745 | static void vcn_v1_0_dec_ring_insert_start(struct amdgpu_ring *ring) | 744 | static void vcn_v1_0_dec_ring_insert_start(struct amdgpu_ring *ring) |
746 | { | 745 | { |
746 | struct amdgpu_device *adev = ring->adev; | ||
747 | |||
747 | amdgpu_ring_write(ring, | 748 | amdgpu_ring_write(ring, |
748 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 749 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); |
749 | amdgpu_ring_write(ring, 0); | 750 | amdgpu_ring_write(ring, 0); |
@@ -761,6 +762,8 @@ static void vcn_v1_0_dec_ring_insert_start(struct amdgpu_ring *ring) | |||
761 | */ | 762 | */ |
762 | static void vcn_v1_0_dec_ring_insert_end(struct amdgpu_ring *ring) | 763 | static void vcn_v1_0_dec_ring_insert_end(struct amdgpu_ring *ring) |
763 | { | 764 | { |
765 | struct amdgpu_device *adev = ring->adev; | ||
766 | |||
764 | amdgpu_ring_write(ring, | 767 | amdgpu_ring_write(ring, |
765 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); | 768 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_CMD), 0)); |
766 | amdgpu_ring_write(ring, VCN_DEC_CMD_PACKET_END << 1); | 769 | amdgpu_ring_write(ring, VCN_DEC_CMD_PACKET_END << 1); |
@@ -777,6 +780,8 @@ static void vcn_v1_0_dec_ring_insert_end(struct amdgpu_ring *ring) | |||
777 | static void vcn_v1_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, | 780 | static void vcn_v1_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 seq, |
778 | unsigned flags) | 781 | unsigned flags) |
779 | { | 782 | { |
783 | struct amdgpu_device *adev = ring->adev; | ||
784 | |||
780 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); | 785 | WARN_ON(flags & AMDGPU_FENCE_FLAG_64BIT); |
781 | 786 | ||
782 | amdgpu_ring_write(ring, | 787 | amdgpu_ring_write(ring, |
@@ -812,6 +817,8 @@ static void vcn_v1_0_dec_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 | |||
812 | */ | 817 | */ |
813 | static void vcn_v1_0_dec_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) | 818 | static void vcn_v1_0_dec_ring_emit_hdp_invalidate(struct amdgpu_ring *ring) |
814 | { | 819 | { |
820 | struct amdgpu_device *adev = ring->adev; | ||
821 | |||
815 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 0)); | 822 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(HDP, 0, mmHDP_READ_CACHE_INVALIDATE), 0)); |
816 | amdgpu_ring_write(ring, 1); | 823 | amdgpu_ring_write(ring, 1); |
817 | } | 824 | } |
@@ -828,6 +835,8 @@ static void vcn_v1_0_dec_ring_emit_ib(struct amdgpu_ring *ring, | |||
828 | struct amdgpu_ib *ib, | 835 | struct amdgpu_ib *ib, |
829 | unsigned vm_id, bool ctx_switch) | 836 | unsigned vm_id, bool ctx_switch) |
830 | { | 837 | { |
838 | struct amdgpu_device *adev = ring->adev; | ||
839 | |||
831 | amdgpu_ring_write(ring, | 840 | amdgpu_ring_write(ring, |
832 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); | 841 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_LMI_RBC_IB_VMID), 0)); |
833 | amdgpu_ring_write(ring, vm_id); | 842 | amdgpu_ring_write(ring, vm_id); |
@@ -846,6 +855,8 @@ static void vcn_v1_0_dec_ring_emit_ib(struct amdgpu_ring *ring, | |||
846 | static void vcn_v1_0_dec_vm_reg_write(struct amdgpu_ring *ring, | 855 | static void vcn_v1_0_dec_vm_reg_write(struct amdgpu_ring *ring, |
847 | uint32_t data0, uint32_t data1) | 856 | uint32_t data0, uint32_t data1) |
848 | { | 857 | { |
858 | struct amdgpu_device *adev = ring->adev; | ||
859 | |||
849 | amdgpu_ring_write(ring, | 860 | amdgpu_ring_write(ring, |
850 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 861 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); |
851 | amdgpu_ring_write(ring, data0); | 862 | amdgpu_ring_write(ring, data0); |
@@ -860,6 +871,8 @@ static void vcn_v1_0_dec_vm_reg_write(struct amdgpu_ring *ring, | |||
860 | static void vcn_v1_0_dec_vm_reg_wait(struct amdgpu_ring *ring, | 871 | static void vcn_v1_0_dec_vm_reg_wait(struct amdgpu_ring *ring, |
861 | uint32_t data0, uint32_t data1, uint32_t mask) | 872 | uint32_t data0, uint32_t data1, uint32_t mask) |
862 | { | 873 | { |
874 | struct amdgpu_device *adev = ring->adev; | ||
875 | |||
863 | amdgpu_ring_write(ring, | 876 | amdgpu_ring_write(ring, |
864 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); | 877 | PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_GPCOM_VCPU_DATA0), 0)); |
865 | amdgpu_ring_write(ring, data0); | 878 | amdgpu_ring_write(ring, data0); |
@@ -879,11 +892,12 @@ static void vcn_v1_0_dec_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
879 | { | 892 | { |
880 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 893 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
881 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 894 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
882 | uint32_t data0, data1, mask; | 895 | uint64_t flags = AMDGPU_PTE_VALID; |
883 | unsigned eng = ring->vm_inv_eng; | 896 | unsigned eng = ring->vm_inv_eng; |
897 | uint32_t data0, data1, mask; | ||
884 | 898 | ||
885 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 899 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
886 | pd_addr |= AMDGPU_PTE_VALID; | 900 | pd_addr |= flags; |
887 | 901 | ||
888 | data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2; | 902 | data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2; |
889 | data1 = upper_32_bits(pd_addr); | 903 | data1 = upper_32_bits(pd_addr); |
@@ -1011,10 +1025,11 @@ static void vcn_v1_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring, | |||
1011 | { | 1025 | { |
1012 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; | 1026 | struct amdgpu_vmhub *hub = &ring->adev->vmhub[ring->funcs->vmhub]; |
1013 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); | 1027 | uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id); |
1028 | uint64_t flags = AMDGPU_PTE_VALID; | ||
1014 | unsigned eng = ring->vm_inv_eng; | 1029 | unsigned eng = ring->vm_inv_eng; |
1015 | 1030 | ||
1016 | pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr); | 1031 | amdgpu_gart_get_vm_pde(ring->adev, -1, &pd_addr, &flags); |
1017 | pd_addr |= AMDGPU_PTE_VALID; | 1032 | pd_addr |= flags; |
1018 | 1033 | ||
1019 | amdgpu_ring_write(ring, VCN_ENC_CMD_REG_WRITE); | 1034 | amdgpu_ring_write(ring, VCN_ENC_CMD_REG_WRITE); |
1020 | amdgpu_ring_write(ring, | 1035 | amdgpu_ring_write(ring, |
@@ -1077,6 +1092,17 @@ static int vcn_v1_0_process_interrupt(struct amdgpu_device *adev, | |||
1077 | return 0; | 1092 | return 0; |
1078 | } | 1093 | } |
1079 | 1094 | ||
1095 | static void vcn_v1_0_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count) | ||
1096 | { | ||
1097 | int i; | ||
1098 | struct amdgpu_device *adev = ring->adev; | ||
1099 | |||
1100 | for (i = 0; i < count; i++) | ||
1101 | amdgpu_ring_write(ring, PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0)); | ||
1102 | |||
1103 | } | ||
1104 | |||
1105 | |||
1080 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { | 1106 | static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { |
1081 | .name = "vcn_v1_0", | 1107 | .name = "vcn_v1_0", |
1082 | .early_init = vcn_v1_0_early_init, | 1108 | .early_init = vcn_v1_0_early_init, |
@@ -1100,7 +1126,7 @@ static const struct amd_ip_funcs vcn_v1_0_ip_funcs = { | |||
1100 | static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { | 1126 | static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { |
1101 | .type = AMDGPU_RING_TYPE_VCN_DEC, | 1127 | .type = AMDGPU_RING_TYPE_VCN_DEC, |
1102 | .align_mask = 0xf, | 1128 | .align_mask = 0xf, |
1103 | .nop = PACKET0(SOC15_REG_OFFSET(UVD, 0, mmUVD_NO_OP), 0), | 1129 | .nop = PACKET0(0x81ff, 0), |
1104 | .support_64bit_ptrs = false, | 1130 | .support_64bit_ptrs = false, |
1105 | .vmhub = AMDGPU_MMHUB, | 1131 | .vmhub = AMDGPU_MMHUB, |
1106 | .get_rptr = vcn_v1_0_dec_ring_get_rptr, | 1132 | .get_rptr = vcn_v1_0_dec_ring_get_rptr, |
@@ -1118,7 +1144,7 @@ static const struct amdgpu_ring_funcs vcn_v1_0_dec_ring_vm_funcs = { | |||
1118 | .emit_hdp_invalidate = vcn_v1_0_dec_ring_emit_hdp_invalidate, | 1144 | .emit_hdp_invalidate = vcn_v1_0_dec_ring_emit_hdp_invalidate, |
1119 | .test_ring = amdgpu_vcn_dec_ring_test_ring, | 1145 | .test_ring = amdgpu_vcn_dec_ring_test_ring, |
1120 | .test_ib = amdgpu_vcn_dec_ring_test_ib, | 1146 | .test_ib = amdgpu_vcn_dec_ring_test_ib, |
1121 | .insert_nop = amdgpu_ring_insert_nop, | 1147 | .insert_nop = vcn_v1_0_ring_insert_nop, |
1122 | .insert_start = vcn_v1_0_dec_ring_insert_start, | 1148 | .insert_start = vcn_v1_0_dec_ring_insert_start, |
1123 | .insert_end = vcn_v1_0_dec_ring_insert_end, | 1149 | .insert_end = vcn_v1_0_dec_ring_insert_end, |
1124 | .pad_ib = amdgpu_ring_generic_pad_ib, | 1150 | .pad_ib = amdgpu_ring_generic_pad_ib, |
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c index ca778cd4e6e8..e1d7dae0989b 100644 --- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include "amdgpu_ih.h" | 25 | #include "amdgpu_ih.h" |
26 | #include "soc15.h" | 26 | #include "soc15.h" |
27 | 27 | ||
28 | |||
29 | #include "soc15ip.h" | ||
30 | #include "oss/osssys_4_0_offset.h" | 28 | #include "oss/osssys_4_0_offset.h" |
31 | #include "oss/osssys_4_0_sh_mask.h" | 29 | #include "oss/osssys_4_0_sh_mask.h" |
32 | 30 | ||
@@ -97,10 +95,7 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev) | |||
97 | /* disable irqs */ | 95 | /* disable irqs */ |
98 | vega10_ih_disable_interrupts(adev); | 96 | vega10_ih_disable_interrupts(adev); |
99 | 97 | ||
100 | if (adev->flags & AMD_IS_APU) | 98 | adev->nbio_funcs->ih_control(adev); |
101 | nbio_v7_0_ih_control(adev); | ||
102 | else | ||
103 | nbio_v6_1_ih_control(adev); | ||
104 | 99 | ||
105 | ih_rb_cntl = RREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL); | 100 | ih_rb_cntl = RREG32_SOC15(OSSSYS, 0, mmIH_RB_CNTL); |
106 | /* Ring Buffer base. [39:8] of 40-bit address of the beginning of the ring buffer*/ | 101 | /* Ring Buffer base. [39:8] of 40-bit address of the beginning of the ring buffer*/ |
@@ -151,10 +146,8 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev) | |||
151 | ENABLE, 0); | 146 | ENABLE, 0); |
152 | } | 147 | } |
153 | WREG32_SOC15(OSSSYS, 0, mmIH_DOORBELL_RPTR, ih_doorbell_rtpr); | 148 | WREG32_SOC15(OSSSYS, 0, mmIH_DOORBELL_RPTR, ih_doorbell_rtpr); |
154 | if (adev->flags & AMD_IS_APU) | 149 | adev->nbio_funcs->ih_doorbell_range(adev, adev->irq.ih.use_doorbell, |
155 | nbio_v7_0_ih_doorbell_range(adev, adev->irq.ih.use_doorbell, adev->irq.ih.doorbell_index); | 150 | adev->irq.ih.doorbell_index); |
156 | else | ||
157 | nbio_v6_1_ih_doorbell_range(adev, adev->irq.ih.use_doorbell, adev->irq.ih.doorbell_index); | ||
158 | 151 | ||
159 | tmp = RREG32_SOC15(OSSSYS, 0, mmIH_STORM_CLIENT_LIST_CNTL); | 152 | tmp = RREG32_SOC15(OSSSYS, 0, mmIH_STORM_CLIENT_LIST_CNTL); |
160 | tmp = REG_SET_FIELD(tmp, IH_STORM_CLIENT_LIST_CNTL, | 153 | tmp = REG_SET_FIELD(tmp, IH_STORM_CLIENT_LIST_CNTL, |
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c new file mode 100644 index 000000000000..b7bdd04793d6 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | #include "amdgpu.h" | ||
24 | #include "soc15.h" | ||
25 | |||
26 | #include "soc15_common.h" | ||
27 | #include "soc15ip.h" | ||
28 | |||
29 | int vega10_reg_base_init(struct amdgpu_device *adev) | ||
30 | { | ||
31 | /* HW has more IP blocks, only initialized the blocke beend by our driver */ | ||
32 | uint32_t i; | ||
33 | for (i = 0 ; i < MAX_INSTANCE ; ++i) { | ||
34 | adev->reg_offset[GC_HWIP][i] = (uint32_t *)(&(GC_BASE.instance[i])); | ||
35 | adev->reg_offset[HDP_HWIP][i] = (uint32_t *)(&(HDP_BASE.instance[i])); | ||
36 | adev->reg_offset[MMHUB_HWIP][i] = (uint32_t *)(&(MMHUB_BASE.instance[i])); | ||
37 | adev->reg_offset[ATHUB_HWIP][i] = (uint32_t *)(&(ATHUB_BASE.instance[i])); | ||
38 | adev->reg_offset[NBIO_HWIP][i] = (uint32_t *)(&(NBIO_BASE.instance[i])); | ||
39 | adev->reg_offset[MP0_HWIP][i] = (uint32_t *)(&(MP0_BASE.instance[i])); | ||
40 | adev->reg_offset[UVD_HWIP][i] = (uint32_t *)(&(UVD_BASE.instance[i])); | ||
41 | adev->reg_offset[VCE_HWIP][i] = (uint32_t *)(&(VCE_BASE.instance[i])); | ||
42 | adev->reg_offset[VCN_HWIP][i] = (uint32_t *)(&(VCN_BASE.instance[i])); | ||
43 | adev->reg_offset[DF_HWIP][i] = (uint32_t *)(&(DF_BASE.instance[i])); | ||
44 | adev->reg_offset[DCE_HWIP][i] = (uint32_t *)(&(DCE_BASE.instance[i])); | ||
45 | adev->reg_offset[OSSSYS_HWIP][i] = (uint32_t *)(&(OSSSYS_BASE.instance[i])); | ||
46 | adev->reg_offset[SDMA0_HWIP][i] = (uint32_t *)(&(SDMA0_BASE.instance[i])); | ||
47 | adev->reg_offset[SDMA1_HWIP][i] = (uint32_t *)(&(SDMA1_BASE.instance[i])); | ||
48 | adev->reg_offset[SMUIO_HWIP][i] = (uint32_t *)(&(SMUIO_BASE.instance[i])); | ||
49 | adev->reg_offset[PWR_HWIP][i] = (uint32_t *)(&(PWR_BASE.instance[i])); | ||
50 | adev->reg_offset[NBIF_HWIP][i] = (uint32_t *)(&(NBIF_BASE.instance[i])); | ||
51 | |||
52 | } | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | |||
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index bb8ca9489546..da2b99c2d95f 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c | |||
@@ -282,29 +282,29 @@ static void vi_init_golden_registers(struct amdgpu_device *adev) | |||
282 | 282 | ||
283 | switch (adev->asic_type) { | 283 | switch (adev->asic_type) { |
284 | case CHIP_TOPAZ: | 284 | case CHIP_TOPAZ: |
285 | amdgpu_program_register_sequence(adev, | 285 | amdgpu_device_program_register_sequence(adev, |
286 | iceland_mgcg_cgcg_init, | 286 | iceland_mgcg_cgcg_init, |
287 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); | 287 | ARRAY_SIZE(iceland_mgcg_cgcg_init)); |
288 | break; | 288 | break; |
289 | case CHIP_FIJI: | 289 | case CHIP_FIJI: |
290 | amdgpu_program_register_sequence(adev, | 290 | amdgpu_device_program_register_sequence(adev, |
291 | fiji_mgcg_cgcg_init, | 291 | fiji_mgcg_cgcg_init, |
292 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); | 292 | ARRAY_SIZE(fiji_mgcg_cgcg_init)); |
293 | break; | 293 | break; |
294 | case CHIP_TONGA: | 294 | case CHIP_TONGA: |
295 | amdgpu_program_register_sequence(adev, | 295 | amdgpu_device_program_register_sequence(adev, |
296 | tonga_mgcg_cgcg_init, | 296 | tonga_mgcg_cgcg_init, |
297 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); | 297 | ARRAY_SIZE(tonga_mgcg_cgcg_init)); |
298 | break; | 298 | break; |
299 | case CHIP_CARRIZO: | 299 | case CHIP_CARRIZO: |
300 | amdgpu_program_register_sequence(adev, | 300 | amdgpu_device_program_register_sequence(adev, |
301 | cz_mgcg_cgcg_init, | 301 | cz_mgcg_cgcg_init, |
302 | ARRAY_SIZE(cz_mgcg_cgcg_init)); | 302 | ARRAY_SIZE(cz_mgcg_cgcg_init)); |
303 | break; | 303 | break; |
304 | case CHIP_STONEY: | 304 | case CHIP_STONEY: |
305 | amdgpu_program_register_sequence(adev, | 305 | amdgpu_device_program_register_sequence(adev, |
306 | stoney_mgcg_cgcg_init, | 306 | stoney_mgcg_cgcg_init, |
307 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); | 307 | ARRAY_SIZE(stoney_mgcg_cgcg_init)); |
308 | break; | 308 | break; |
309 | case CHIP_POLARIS11: | 309 | case CHIP_POLARIS11: |
310 | case CHIP_POLARIS10: | 310 | case CHIP_POLARIS10: |
@@ -449,14 +449,18 @@ static bool vi_read_bios_from_rom(struct amdgpu_device *adev, | |||
449 | 449 | ||
450 | static void vi_detect_hw_virtualization(struct amdgpu_device *adev) | 450 | static void vi_detect_hw_virtualization(struct amdgpu_device *adev) |
451 | { | 451 | { |
452 | uint32_t reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER); | 452 | uint32_t reg = 0; |
453 | /* bit0: 0 means pf and 1 means vf */ | 453 | |
454 | /* bit31: 0 means disable IOV and 1 means enable */ | 454 | if (adev->asic_type == CHIP_TONGA || |
455 | if (reg & 1) | 455 | adev->asic_type == CHIP_FIJI) { |
456 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF; | 456 | reg = RREG32(mmBIF_IOV_FUNC_IDENTIFIER); |
457 | 457 | /* bit0: 0 means pf and 1 means vf */ | |
458 | if (reg & 0x80000000) | 458 | if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, FUNC_IDENTIFIER)) |
459 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; | 459 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_IS_VF; |
460 | /* bit31: 0 means disable IOV and 1 means enable */ | ||
461 | if (REG_GET_FIELD(reg, BIF_IOV_FUNC_IDENTIFIER, IOV_ENABLE)) | ||
462 | adev->virt.caps |= AMDGPU_SRIOV_CAPS_ENABLE_IOV; | ||
463 | } | ||
460 | 464 | ||
461 | if (reg == 0) { | 465 | if (reg == 0) { |
462 | if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */ | 466 | if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */ |
@@ -667,7 +671,7 @@ static int vi_gpu_pci_config_reset(struct amdgpu_device *adev) | |||
667 | /* disable BM */ | 671 | /* disable BM */ |
668 | pci_clear_master(adev->pdev); | 672 | pci_clear_master(adev->pdev); |
669 | /* reset */ | 673 | /* reset */ |
670 | amdgpu_pci_config_reset(adev); | 674 | amdgpu_device_pci_config_reset(adev); |
671 | 675 | ||
672 | udelay(100); | 676 | udelay(100); |
673 | 677 | ||
@@ -891,8 +895,8 @@ static int vi_common_early_init(void *handle) | |||
891 | 895 | ||
892 | adev->asic_funcs = &vi_asic_funcs; | 896 | adev->asic_funcs = &vi_asic_funcs; |
893 | 897 | ||
894 | if (amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_SMC) && | 898 | if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_SMC) && |
895 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC))) | 899 | (amdgpu_ip_block_mask & (1 << AMD_IP_BLOCK_TYPE_SMC))) |
896 | smc_enabled = true; | 900 | smc_enabled = true; |
897 | 901 | ||
898 | adev->rev_id = vi_get_rev_id(adev); | 902 | adev->rev_id = vi_get_rev_id(adev); |
@@ -1074,7 +1078,7 @@ static int vi_common_early_init(void *handle) | |||
1074 | /* vi use smc load by default */ | 1078 | /* vi use smc load by default */ |
1075 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); | 1079 | adev->firmware.load_type = amdgpu_ucode_get_load_type(adev, amdgpu_fw_load_type); |
1076 | 1080 | ||
1077 | amdgpu_get_pcie_info(adev); | 1081 | amdgpu_device_get_pcie_info(adev); |
1078 | 1082 | ||
1079 | return 0; | 1083 | return 0; |
1080 | } | 1084 | } |
@@ -1487,115 +1491,115 @@ int vi_set_ip_blocks(struct amdgpu_device *adev) | |||
1487 | switch (adev->asic_type) { | 1491 | switch (adev->asic_type) { |
1488 | case CHIP_TOPAZ: | 1492 | case CHIP_TOPAZ: |
1489 | /* topaz has no DCE, UVD, VCE */ | 1493 | /* topaz has no DCE, UVD, VCE */ |
1490 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1494 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1491 | amdgpu_ip_block_add(adev, &gmc_v7_4_ip_block); | 1495 | amdgpu_device_ip_block_add(adev, &gmc_v7_4_ip_block); |
1492 | amdgpu_ip_block_add(adev, &iceland_ih_ip_block); | 1496 | amdgpu_device_ip_block_add(adev, &iceland_ih_ip_block); |
1493 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1497 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1494 | if (adev->enable_virtual_display) | 1498 | if (adev->enable_virtual_display) |
1495 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1499 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1496 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); | 1500 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); |
1497 | amdgpu_ip_block_add(adev, &sdma_v2_4_ip_block); | 1501 | amdgpu_device_ip_block_add(adev, &sdma_v2_4_ip_block); |
1498 | break; | 1502 | break; |
1499 | case CHIP_FIJI: | 1503 | case CHIP_FIJI: |
1500 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1504 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1501 | amdgpu_ip_block_add(adev, &gmc_v8_5_ip_block); | 1505 | amdgpu_device_ip_block_add(adev, &gmc_v8_5_ip_block); |
1502 | amdgpu_ip_block_add(adev, &tonga_ih_ip_block); | 1506 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); |
1503 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1507 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1504 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 1508 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
1505 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1509 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1506 | #if defined(CONFIG_DRM_AMD_DC) | 1510 | #if defined(CONFIG_DRM_AMD_DC) |
1507 | else if (amdgpu_device_has_dc_support(adev)) | 1511 | else if (amdgpu_device_has_dc_support(adev)) |
1508 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1512 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1509 | #endif | 1513 | #endif |
1510 | else | 1514 | else |
1511 | amdgpu_ip_block_add(adev, &dce_v10_1_ip_block); | 1515 | amdgpu_device_ip_block_add(adev, &dce_v10_1_ip_block); |
1512 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); | 1516 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); |
1513 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); | 1517 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); |
1514 | if (!amdgpu_sriov_vf(adev)) { | 1518 | if (!amdgpu_sriov_vf(adev)) { |
1515 | amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block); | 1519 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); |
1516 | amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | 1520 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); |
1517 | } | 1521 | } |
1518 | break; | 1522 | break; |
1519 | case CHIP_TONGA: | 1523 | case CHIP_TONGA: |
1520 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1524 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1521 | amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block); | 1525 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1522 | amdgpu_ip_block_add(adev, &tonga_ih_ip_block); | 1526 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); |
1523 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1527 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1524 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) | 1528 | if (adev->enable_virtual_display || amdgpu_sriov_vf(adev)) |
1525 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1529 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1526 | #if defined(CONFIG_DRM_AMD_DC) | 1530 | #if defined(CONFIG_DRM_AMD_DC) |
1527 | else if (amdgpu_device_has_dc_support(adev)) | 1531 | else if (amdgpu_device_has_dc_support(adev)) |
1528 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1532 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1529 | #endif | 1533 | #endif |
1530 | else | 1534 | else |
1531 | amdgpu_ip_block_add(adev, &dce_v10_0_ip_block); | 1535 | amdgpu_device_ip_block_add(adev, &dce_v10_0_ip_block); |
1532 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); | 1536 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); |
1533 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); | 1537 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); |
1534 | if (!amdgpu_sriov_vf(adev)) { | 1538 | if (!amdgpu_sriov_vf(adev)) { |
1535 | amdgpu_ip_block_add(adev, &uvd_v5_0_ip_block); | 1539 | amdgpu_device_ip_block_add(adev, &uvd_v5_0_ip_block); |
1536 | amdgpu_ip_block_add(adev, &vce_v3_0_ip_block); | 1540 | amdgpu_device_ip_block_add(adev, &vce_v3_0_ip_block); |
1537 | } | 1541 | } |
1538 | break; | 1542 | break; |
1539 | case CHIP_POLARIS11: | 1543 | case CHIP_POLARIS11: |
1540 | case CHIP_POLARIS10: | 1544 | case CHIP_POLARIS10: |
1541 | case CHIP_POLARIS12: | 1545 | case CHIP_POLARIS12: |
1542 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1546 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1543 | amdgpu_ip_block_add(adev, &gmc_v8_1_ip_block); | 1547 | amdgpu_device_ip_block_add(adev, &gmc_v8_1_ip_block); |
1544 | amdgpu_ip_block_add(adev, &tonga_ih_ip_block); | 1548 | amdgpu_device_ip_block_add(adev, &tonga_ih_ip_block); |
1545 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1549 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1546 | if (adev->enable_virtual_display) | 1550 | if (adev->enable_virtual_display) |
1547 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1551 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1548 | #if defined(CONFIG_DRM_AMD_DC) | 1552 | #if defined(CONFIG_DRM_AMD_DC) |
1549 | else if (amdgpu_device_has_dc_support(adev)) | 1553 | else if (amdgpu_device_has_dc_support(adev)) |
1550 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1554 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1551 | #endif | 1555 | #endif |
1552 | else | 1556 | else |
1553 | amdgpu_ip_block_add(adev, &dce_v11_2_ip_block); | 1557 | amdgpu_device_ip_block_add(adev, &dce_v11_2_ip_block); |
1554 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); | 1558 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); |
1555 | amdgpu_ip_block_add(adev, &sdma_v3_1_ip_block); | 1559 | amdgpu_device_ip_block_add(adev, &sdma_v3_1_ip_block); |
1556 | amdgpu_ip_block_add(adev, &uvd_v6_3_ip_block); | 1560 | amdgpu_device_ip_block_add(adev, &uvd_v6_3_ip_block); |
1557 | amdgpu_ip_block_add(adev, &vce_v3_4_ip_block); | 1561 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); |
1558 | break; | 1562 | break; |
1559 | case CHIP_CARRIZO: | 1563 | case CHIP_CARRIZO: |
1560 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1564 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1561 | amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block); | 1565 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1562 | amdgpu_ip_block_add(adev, &cz_ih_ip_block); | 1566 | amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); |
1563 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1567 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1564 | if (adev->enable_virtual_display) | 1568 | if (adev->enable_virtual_display) |
1565 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1569 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1566 | #if defined(CONFIG_DRM_AMD_DC) | 1570 | #if defined(CONFIG_DRM_AMD_DC) |
1567 | else if (amdgpu_device_has_dc_support(adev)) | 1571 | else if (amdgpu_device_has_dc_support(adev)) |
1568 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1572 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1569 | #endif | 1573 | #endif |
1570 | else | 1574 | else |
1571 | amdgpu_ip_block_add(adev, &dce_v11_0_ip_block); | 1575 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); |
1572 | amdgpu_ip_block_add(adev, &gfx_v8_0_ip_block); | 1576 | amdgpu_device_ip_block_add(adev, &gfx_v8_0_ip_block); |
1573 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); | 1577 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); |
1574 | amdgpu_ip_block_add(adev, &uvd_v6_0_ip_block); | 1578 | amdgpu_device_ip_block_add(adev, &uvd_v6_0_ip_block); |
1575 | amdgpu_ip_block_add(adev, &vce_v3_1_ip_block); | 1579 | amdgpu_device_ip_block_add(adev, &vce_v3_1_ip_block); |
1576 | #if defined(CONFIG_DRM_AMD_ACP) | 1580 | #if defined(CONFIG_DRM_AMD_ACP) |
1577 | amdgpu_ip_block_add(adev, &acp_ip_block); | 1581 | amdgpu_device_ip_block_add(adev, &acp_ip_block); |
1578 | #endif | 1582 | #endif |
1579 | break; | 1583 | break; |
1580 | case CHIP_STONEY: | 1584 | case CHIP_STONEY: |
1581 | amdgpu_ip_block_add(adev, &vi_common_ip_block); | 1585 | amdgpu_device_ip_block_add(adev, &vi_common_ip_block); |
1582 | amdgpu_ip_block_add(adev, &gmc_v8_0_ip_block); | 1586 | amdgpu_device_ip_block_add(adev, &gmc_v8_0_ip_block); |
1583 | amdgpu_ip_block_add(adev, &cz_ih_ip_block); | 1587 | amdgpu_device_ip_block_add(adev, &cz_ih_ip_block); |
1584 | amdgpu_ip_block_add(adev, &amdgpu_pp_ip_block); | 1588 | amdgpu_device_ip_block_add(adev, &amdgpu_pp_ip_block); |
1585 | if (adev->enable_virtual_display) | 1589 | if (adev->enable_virtual_display) |
1586 | amdgpu_ip_block_add(adev, &dce_virtual_ip_block); | 1590 | amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block); |
1587 | #if defined(CONFIG_DRM_AMD_DC) | 1591 | #if defined(CONFIG_DRM_AMD_DC) |
1588 | else if (amdgpu_device_has_dc_support(adev)) | 1592 | else if (amdgpu_device_has_dc_support(adev)) |
1589 | amdgpu_ip_block_add(adev, &dm_ip_block); | 1593 | amdgpu_device_ip_block_add(adev, &dm_ip_block); |
1590 | #endif | 1594 | #endif |
1591 | else | 1595 | else |
1592 | amdgpu_ip_block_add(adev, &dce_v11_0_ip_block); | 1596 | amdgpu_device_ip_block_add(adev, &dce_v11_0_ip_block); |
1593 | amdgpu_ip_block_add(adev, &gfx_v8_1_ip_block); | 1597 | amdgpu_device_ip_block_add(adev, &gfx_v8_1_ip_block); |
1594 | amdgpu_ip_block_add(adev, &sdma_v3_0_ip_block); | 1598 | amdgpu_device_ip_block_add(adev, &sdma_v3_0_ip_block); |
1595 | amdgpu_ip_block_add(adev, &uvd_v6_2_ip_block); | 1599 | amdgpu_device_ip_block_add(adev, &uvd_v6_2_ip_block); |
1596 | amdgpu_ip_block_add(adev, &vce_v3_4_ip_block); | 1600 | amdgpu_device_ip_block_add(adev, &vce_v3_4_ip_block); |
1597 | #if defined(CONFIG_DRM_AMD_ACP) | 1601 | #if defined(CONFIG_DRM_AMD_ACP) |
1598 | amdgpu_ip_block_add(adev, &acp_ip_block); | 1602 | amdgpu_device_ip_block_add(adev, &acp_ip_block); |
1599 | #endif | 1603 | #endif |
1600 | break; | 1604 | break; |
1601 | default: | 1605 | default: |
diff --git a/drivers/gpu/drm/amd/display/TODO b/drivers/gpu/drm/amd/display/TODO index 46464678f2b3..357d59648401 100644 --- a/drivers/gpu/drm/amd/display/TODO +++ b/drivers/gpu/drm/amd/display/TODO | |||
@@ -105,3 +105,6 @@ useless with filtering output. dynamic debug printing might be an option. | |||
105 | 20. Use kernel i2c device to program HDMI retimer. Some boards have an HDMI | 105 | 20. Use kernel i2c device to program HDMI retimer. Some boards have an HDMI |
106 | retimer that we need to program to pass PHY compliance. Currently that's | 106 | retimer that we need to program to pass PHY compliance. Currently that's |
107 | bypassing the i2c device and goes directly to HW. This should be changed. | 107 | bypassing the i2c device and goes directly to HW. This should be changed. |
108 | |||
109 | 21. Remove vector.c from dc/basics. It's used in DDC code which can probably | ||
110 | be simplified enough to no longer need a vector implementation. | ||
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index ccbf10e3bbb6..1ce4c98385e3 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | |||
@@ -431,9 +431,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) | |||
431 | adev->dm.dc = dc_create(&init_data); | 431 | adev->dm.dc = dc_create(&init_data); |
432 | 432 | ||
433 | if (adev->dm.dc) { | 433 | if (adev->dm.dc) { |
434 | DRM_INFO("Display Core initialized!\n"); | 434 | DRM_INFO("Display Core initialized with v%s!\n", DC_VER); |
435 | } else { | 435 | } else { |
436 | DRM_INFO("Display Core failed to initialize!\n"); | 436 | DRM_INFO("Display Core failed to initialize with v%s!\n", DC_VER); |
437 | goto error; | 437 | goto error; |
438 | } | 438 | } |
439 | 439 | ||
@@ -2351,7 +2351,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, | |||
2351 | const struct dm_connector_state *dm_state) | 2351 | const struct dm_connector_state *dm_state) |
2352 | { | 2352 | { |
2353 | struct drm_display_mode *preferred_mode = NULL; | 2353 | struct drm_display_mode *preferred_mode = NULL; |
2354 | const struct drm_connector *drm_connector; | 2354 | struct drm_connector *drm_connector; |
2355 | struct dc_stream_state *stream = NULL; | 2355 | struct dc_stream_state *stream = NULL; |
2356 | struct drm_display_mode mode = *drm_mode; | 2356 | struct drm_display_mode mode = *drm_mode; |
2357 | bool native_mode_found = false; | 2357 | bool native_mode_found = false; |
@@ -2370,11 +2370,13 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, | |||
2370 | 2370 | ||
2371 | if (!aconnector->dc_sink) { | 2371 | if (!aconnector->dc_sink) { |
2372 | /* | 2372 | /* |
2373 | * Exclude MST from creating fake_sink | 2373 | * Create dc_sink when necessary to MST |
2374 | * TODO: need to enable MST into fake_sink feature | 2374 | * Don't apply fake_sink to MST |
2375 | */ | 2375 | */ |
2376 | if (aconnector->mst_port) | 2376 | if (aconnector->mst_port) { |
2377 | goto stream_create_fail; | 2377 | dm_dp_mst_dc_sink_create(drm_connector); |
2378 | goto mst_dc_sink_create_done; | ||
2379 | } | ||
2378 | 2380 | ||
2379 | if (create_fake_sink(aconnector)) | 2381 | if (create_fake_sink(aconnector)) |
2380 | goto stream_create_fail; | 2382 | goto stream_create_fail; |
@@ -2425,6 +2427,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, | |||
2425 | stream_create_fail: | 2427 | stream_create_fail: |
2426 | dm_state_null: | 2428 | dm_state_null: |
2427 | drm_connector_null: | 2429 | drm_connector_null: |
2430 | mst_dc_sink_create_done: | ||
2428 | return stream; | 2431 | return stream; |
2429 | } | 2432 | } |
2430 | 2433 | ||
@@ -2725,8 +2728,7 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector) | |||
2725 | }; | 2728 | }; |
2726 | struct edid *edid; | 2729 | struct edid *edid; |
2727 | 2730 | ||
2728 | if (!aconnector->base.edid_blob_ptr || | 2731 | if (!aconnector->base.edid_blob_ptr) { |
2729 | !aconnector->base.edid_blob_ptr->data) { | ||
2730 | DRM_ERROR("No EDID firmware found on connector: %s ,forcing to OFF!\n", | 2732 | DRM_ERROR("No EDID firmware found on connector: %s ,forcing to OFF!\n", |
2731 | aconnector->base.name); | 2733 | aconnector->base.name); |
2732 | 2734 | ||
@@ -4514,18 +4516,15 @@ static int dm_update_crtcs_state(struct dc *dc, | |||
4514 | __func__, acrtc->base.base.id); | 4516 | __func__, acrtc->base.base.id); |
4515 | break; | 4517 | break; |
4516 | } | 4518 | } |
4517 | } | ||
4518 | 4519 | ||
4519 | if (enable && dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) && | 4520 | if (dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) && |
4520 | dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream)) { | 4521 | dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream)) { |
4521 | 4522 | new_crtc_state->mode_changed = false; | |
4522 | new_crtc_state->mode_changed = false; | 4523 | DRM_DEBUG_DRIVER("Mode change not required, setting mode_changed to %d", |
4523 | 4524 | new_crtc_state->mode_changed); | |
4524 | DRM_DEBUG_DRIVER("Mode change not required, setting mode_changed to %d", | 4525 | } |
4525 | new_crtc_state->mode_changed); | ||
4526 | } | 4526 | } |
4527 | 4527 | ||
4528 | |||
4529 | if (!drm_atomic_crtc_needs_modeset(new_crtc_state)) | 4528 | if (!drm_atomic_crtc_needs_modeset(new_crtc_state)) |
4530 | goto next_crtc; | 4529 | goto next_crtc; |
4531 | 4530 | ||
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 8a1e4f5dbd64..2faa77a7eeda 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | |||
@@ -189,6 +189,8 @@ struct amdgpu_dm_connector { | |||
189 | struct mutex hpd_lock; | 189 | struct mutex hpd_lock; |
190 | 190 | ||
191 | bool fake_enable; | 191 | bool fake_enable; |
192 | |||
193 | bool mst_connected; | ||
192 | }; | 194 | }; |
193 | 195 | ||
194 | #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base) | 196 | #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base) |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c index 707928b88448..f3d87f418d2e 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | |||
@@ -180,6 +180,42 @@ static int dm_connector_update_modes(struct drm_connector *connector, | |||
180 | return drm_add_edid_modes(connector, edid); | 180 | return drm_add_edid_modes(connector, edid); |
181 | } | 181 | } |
182 | 182 | ||
183 | void dm_dp_mst_dc_sink_create(struct drm_connector *connector) | ||
184 | { | ||
185 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); | ||
186 | struct edid *edid; | ||
187 | struct dc_sink *dc_sink; | ||
188 | struct dc_sink_init_data init_params = { | ||
189 | .link = aconnector->dc_link, | ||
190 | .sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST }; | ||
191 | |||
192 | edid = drm_dp_mst_get_edid(connector, &aconnector->mst_port->mst_mgr, aconnector->port); | ||
193 | |||
194 | if (!edid) { | ||
195 | drm_mode_connector_update_edid_property( | ||
196 | &aconnector->base, | ||
197 | NULL); | ||
198 | return; | ||
199 | } | ||
200 | |||
201 | aconnector->edid = edid; | ||
202 | |||
203 | dc_sink = dc_link_add_remote_sink( | ||
204 | aconnector->dc_link, | ||
205 | (uint8_t *)aconnector->edid, | ||
206 | (aconnector->edid->extensions + 1) * EDID_LENGTH, | ||
207 | &init_params); | ||
208 | |||
209 | dc_sink->priv = aconnector; | ||
210 | aconnector->dc_sink = dc_sink; | ||
211 | |||
212 | amdgpu_dm_add_sink_to_freesync_module( | ||
213 | connector, aconnector->edid); | ||
214 | |||
215 | drm_mode_connector_update_edid_property( | ||
216 | &aconnector->base, aconnector->edid); | ||
217 | } | ||
218 | |||
183 | static int dm_dp_mst_get_modes(struct drm_connector *connector) | 219 | static int dm_dp_mst_get_modes(struct drm_connector *connector) |
184 | { | 220 | { |
185 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); | 221 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); |
@@ -306,6 +342,7 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, | |||
306 | drm_mode_connector_set_path_property(connector, pathprop); | 342 | drm_mode_connector_set_path_property(connector, pathprop); |
307 | 343 | ||
308 | drm_connector_list_iter_end(&conn_iter); | 344 | drm_connector_list_iter_end(&conn_iter); |
345 | aconnector->mst_connected = true; | ||
309 | return &aconnector->base; | 346 | return &aconnector->base; |
310 | } | 347 | } |
311 | } | 348 | } |
@@ -358,6 +395,8 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, | |||
358 | */ | 395 | */ |
359 | amdgpu_dm_connector_funcs_reset(connector); | 396 | amdgpu_dm_connector_funcs_reset(connector); |
360 | 397 | ||
398 | aconnector->mst_connected = true; | ||
399 | |||
361 | DRM_INFO("DM_MST: added connector: %p [id: %d] [master: %p]\n", | 400 | DRM_INFO("DM_MST: added connector: %p [id: %d] [master: %p]\n", |
362 | aconnector, connector->base.id, aconnector->mst_port); | 401 | aconnector, connector->base.id, aconnector->mst_port); |
363 | 402 | ||
@@ -389,6 +428,8 @@ static void dm_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, | |||
389 | drm_mode_connector_update_edid_property( | 428 | drm_mode_connector_update_edid_property( |
390 | &aconnector->base, | 429 | &aconnector->base, |
391 | NULL); | 430 | NULL); |
431 | |||
432 | aconnector->mst_connected = false; | ||
392 | } | 433 | } |
393 | 434 | ||
394 | static void dm_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) | 435 | static void dm_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) |
@@ -399,10 +440,18 @@ static void dm_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) | |||
399 | drm_kms_helper_hotplug_event(dev); | 440 | drm_kms_helper_hotplug_event(dev); |
400 | } | 441 | } |
401 | 442 | ||
443 | static void dm_dp_mst_link_status_reset(struct drm_connector *connector) | ||
444 | { | ||
445 | mutex_lock(&connector->dev->mode_config.mutex); | ||
446 | drm_mode_connector_set_link_status_property(connector, DRM_MODE_LINK_STATUS_BAD); | ||
447 | mutex_unlock(&connector->dev->mode_config.mutex); | ||
448 | } | ||
449 | |||
402 | static void dm_dp_mst_register_connector(struct drm_connector *connector) | 450 | static void dm_dp_mst_register_connector(struct drm_connector *connector) |
403 | { | 451 | { |
404 | struct drm_device *dev = connector->dev; | 452 | struct drm_device *dev = connector->dev; |
405 | struct amdgpu_device *adev = dev->dev_private; | 453 | struct amdgpu_device *adev = dev->dev_private; |
454 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); | ||
406 | 455 | ||
407 | if (adev->mode_info.rfbdev) | 456 | if (adev->mode_info.rfbdev) |
408 | drm_fb_helper_add_one_connector(&adev->mode_info.rfbdev->helper, connector); | 457 | drm_fb_helper_add_one_connector(&adev->mode_info.rfbdev->helper, connector); |
@@ -411,6 +460,8 @@ static void dm_dp_mst_register_connector(struct drm_connector *connector) | |||
411 | 460 | ||
412 | drm_connector_register(connector); | 461 | drm_connector_register(connector); |
413 | 462 | ||
463 | if (aconnector->mst_connected) | ||
464 | dm_dp_mst_link_status_reset(connector); | ||
414 | } | 465 | } |
415 | 466 | ||
416 | static const struct drm_dp_mst_topology_cbs dm_mst_cbs = { | 467 | static const struct drm_dp_mst_topology_cbs dm_mst_cbs = { |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h index 2da851b40042..8cf51da26657 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.h | |||
@@ -31,5 +31,6 @@ struct amdgpu_dm_connector; | |||
31 | 31 | ||
32 | void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm, | 32 | void amdgpu_dm_initialize_dp_connector(struct amdgpu_display_manager *dm, |
33 | struct amdgpu_dm_connector *aconnector); | 33 | struct amdgpu_dm_connector *aconnector); |
34 | void dm_dp_mst_dc_sink_create(struct drm_connector *connector); | ||
34 | 35 | ||
35 | #endif | 36 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/Makefile b/drivers/gpu/drm/amd/display/dc/basics/Makefile index 6af8c8a9ad80..bca33bd9a0d2 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/Makefile +++ b/drivers/gpu/drm/amd/display/dc/basics/Makefile | |||
@@ -24,7 +24,7 @@ | |||
24 | # It provides the general basic services required by other DAL | 24 | # It provides the general basic services required by other DAL |
25 | # subcomponents. | 25 | # subcomponents. |
26 | 26 | ||
27 | BASICS = conversion.o fixpt31_32.o fixpt32_32.o grph_object_id.o \ | 27 | BASICS = conversion.o fixpt31_32.o fixpt32_32.o \ |
28 | logger.o log_helpers.o vector.o | 28 | logger.o log_helpers.o vector.o |
29 | 29 | ||
30 | AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS)) | 30 | AMD_DAL_BASICS = $(addprefix $(AMDDALPATH)/dc/basics/,$(BASICS)) |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/conversion.c b/drivers/gpu/drm/amd/display/dc/basics/conversion.c index 23c9a0ec0181..310964915a83 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/conversion.c +++ b/drivers/gpu/drm/amd/display/dc/basics/conversion.c | |||
@@ -46,7 +46,7 @@ uint16_t fixed_point_to_int_frac( | |||
46 | arg)); | 46 | arg)); |
47 | 47 | ||
48 | if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) | 48 | if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor)) |
49 | numerator = (uint16_t)dal_fixed31_32_floor( | 49 | numerator = (uint16_t)dal_fixed31_32_round( |
50 | dal_fixed31_32_mul_int( | 50 | dal_fixed31_32_mul_int( |
51 | arg, | 51 | arg, |
52 | divisor)); | 52 | divisor)); |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c index 26936892c6f5..011a97f82fb6 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | |||
@@ -554,6 +554,22 @@ static inline uint32_t ux_dy( | |||
554 | return result | fractional_part; | 554 | return result | fractional_part; |
555 | } | 555 | } |
556 | 556 | ||
557 | static inline uint32_t clamp_ux_dy( | ||
558 | int64_t value, | ||
559 | uint32_t integer_bits, | ||
560 | uint32_t fractional_bits, | ||
561 | uint32_t min_clamp) | ||
562 | { | ||
563 | uint32_t truncated_val = ux_dy(value, integer_bits, fractional_bits); | ||
564 | |||
565 | if (value >= (1LL << (integer_bits + FIXED31_32_BITS_PER_FRACTIONAL_PART))) | ||
566 | return (1 << (integer_bits + fractional_bits)) - 1; | ||
567 | else if (truncated_val > min_clamp) | ||
568 | return truncated_val; | ||
569 | else | ||
570 | return min_clamp; | ||
571 | } | ||
572 | |||
557 | uint32_t dal_fixed31_32_u2d19( | 573 | uint32_t dal_fixed31_32_u2d19( |
558 | struct fixed31_32 arg) | 574 | struct fixed31_32 arg) |
559 | { | 575 | { |
@@ -565,3 +581,15 @@ uint32_t dal_fixed31_32_u0d19( | |||
565 | { | 581 | { |
566 | return ux_dy(arg.value, 0, 19); | 582 | return ux_dy(arg.value, 0, 19); |
567 | } | 583 | } |
584 | |||
585 | uint32_t dal_fixed31_32_clamp_u0d14( | ||
586 | struct fixed31_32 arg) | ||
587 | { | ||
588 | return clamp_ux_dy(arg.value, 0, 14, 1); | ||
589 | } | ||
590 | |||
591 | uint32_t dal_fixed31_32_clamp_u0d10( | ||
592 | struct fixed31_32 arg) | ||
593 | { | ||
594 | return clamp_ux_dy(arg.value, 0, 10, 1); | ||
595 | } | ||
diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c index 86e6438c5cf3..c00e405b63e8 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser.c | |||
@@ -190,6 +190,7 @@ static struct graphics_object_id bios_parser_get_connector_id( | |||
190 | struct bios_parser *bp = BP_FROM_DCB(dcb); | 190 | struct bios_parser *bp = BP_FROM_DCB(dcb); |
191 | struct graphics_object_id object_id = dal_graphics_object_id_init( | 191 | struct graphics_object_id object_id = dal_graphics_object_id_init( |
192 | 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN); | 192 | 0, ENUM_ID_UNKNOWN, OBJECT_TYPE_UNKNOWN); |
193 | uint16_t id; | ||
193 | 194 | ||
194 | uint32_t connector_table_offset = bp->object_info_tbl_offset | 195 | uint32_t connector_table_offset = bp->object_info_tbl_offset |
195 | + le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset); | 196 | + le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset); |
@@ -197,12 +198,19 @@ static struct graphics_object_id bios_parser_get_connector_id( | |||
197 | ATOM_OBJECT_TABLE *tbl = | 198 | ATOM_OBJECT_TABLE *tbl = |
198 | GET_IMAGE(ATOM_OBJECT_TABLE, connector_table_offset); | 199 | GET_IMAGE(ATOM_OBJECT_TABLE, connector_table_offset); |
199 | 200 | ||
200 | if (tbl && tbl->ucNumberOfObjects > i) { | 201 | if (!tbl) { |
201 | const uint16_t id = le16_to_cpu(tbl->asObjects[i].usObjectID); | 202 | dm_error("Can't get connector table from atom bios.\n"); |
203 | return object_id; | ||
204 | } | ||
202 | 205 | ||
203 | object_id = object_id_from_bios_object_id(id); | 206 | if (tbl->ucNumberOfObjects <= i) { |
207 | dm_error("Can't find connector id %d in connector table of size %d.\n", | ||
208 | i, tbl->ucNumberOfObjects); | ||
209 | return object_id; | ||
204 | } | 210 | } |
205 | 211 | ||
212 | id = le16_to_cpu(tbl->asObjects[i].usObjectID); | ||
213 | object_id = object_id_from_bios_object_id(id); | ||
206 | return object_id; | 214 | return object_id; |
207 | } | 215 | } |
208 | 216 | ||
@@ -2254,6 +2262,52 @@ static enum bp_result get_gpio_i2c_info(struct bios_parser *bp, | |||
2254 | return BP_RESULT_OK; | 2262 | return BP_RESULT_OK; |
2255 | } | 2263 | } |
2256 | 2264 | ||
2265 | static bool dal_graphics_object_id_is_valid(struct graphics_object_id id) | ||
2266 | { | ||
2267 | bool rc = true; | ||
2268 | |||
2269 | switch (id.type) { | ||
2270 | case OBJECT_TYPE_UNKNOWN: | ||
2271 | rc = false; | ||
2272 | break; | ||
2273 | case OBJECT_TYPE_GPU: | ||
2274 | case OBJECT_TYPE_ENGINE: | ||
2275 | /* do NOT check for id.id == 0 */ | ||
2276 | if (id.enum_id == ENUM_ID_UNKNOWN) | ||
2277 | rc = false; | ||
2278 | break; | ||
2279 | default: | ||
2280 | if (id.id == 0 || id.enum_id == ENUM_ID_UNKNOWN) | ||
2281 | rc = false; | ||
2282 | break; | ||
2283 | } | ||
2284 | |||
2285 | return rc; | ||
2286 | } | ||
2287 | |||
2288 | static bool dal_graphics_object_id_is_equal( | ||
2289 | struct graphics_object_id id1, | ||
2290 | struct graphics_object_id id2) | ||
2291 | { | ||
2292 | if (false == dal_graphics_object_id_is_valid(id1)) { | ||
2293 | dm_output_to_console( | ||
2294 | "%s: Warning: comparing invalid object 'id1'!\n", __func__); | ||
2295 | return false; | ||
2296 | } | ||
2297 | |||
2298 | if (false == dal_graphics_object_id_is_valid(id2)) { | ||
2299 | dm_output_to_console( | ||
2300 | "%s: Warning: comparing invalid object 'id2'!\n", __func__); | ||
2301 | return false; | ||
2302 | } | ||
2303 | |||
2304 | if (id1.id == id2.id && id1.enum_id == id2.enum_id | ||
2305 | && id1.type == id2.type) | ||
2306 | return true; | ||
2307 | |||
2308 | return false; | ||
2309 | } | ||
2310 | |||
2257 | static ATOM_OBJECT *get_bios_object(struct bios_parser *bp, | 2311 | static ATOM_OBJECT *get_bios_object(struct bios_parser *bp, |
2258 | struct graphics_object_id id) | 2312 | struct graphics_object_id id) |
2259 | { | 2313 | { |
diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table.c b/drivers/gpu/drm/amd/display/dc/bios/command_table.c index 3f7b2dabc2b0..1aefed8cf98b 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table.c | |||
@@ -387,6 +387,7 @@ static void init_transmitter_control(struct bios_parser *bp) | |||
387 | bp->cmd_tbl.transmitter_control = transmitter_control_v1_6; | 387 | bp->cmd_tbl.transmitter_control = transmitter_control_v1_6; |
388 | break; | 388 | break; |
389 | default: | 389 | default: |
390 | dm_error("Don't have transmitter_control for v%d\n", crev); | ||
390 | bp->cmd_tbl.transmitter_control = NULL; | 391 | bp->cmd_tbl.transmitter_control = NULL; |
391 | break; | 392 | break; |
392 | } | 393 | } |
@@ -910,6 +911,8 @@ static void init_set_pixel_clock(struct bios_parser *bp) | |||
910 | bp->cmd_tbl.set_pixel_clock = set_pixel_clock_v7; | 911 | bp->cmd_tbl.set_pixel_clock = set_pixel_clock_v7; |
911 | break; | 912 | break; |
912 | default: | 913 | default: |
914 | dm_error("Don't have set_pixel_clock for v%d\n", | ||
915 | BIOS_CMD_TABLE_PARA_REVISION(SetPixelClock)); | ||
913 | bp->cmd_tbl.set_pixel_clock = NULL; | 916 | bp->cmd_tbl.set_pixel_clock = NULL; |
914 | break; | 917 | break; |
915 | } | 918 | } |
@@ -1227,6 +1230,8 @@ static void init_enable_spread_spectrum_on_ppll(struct bios_parser *bp) | |||
1227 | enable_spread_spectrum_on_ppll_v3; | 1230 | enable_spread_spectrum_on_ppll_v3; |
1228 | break; | 1231 | break; |
1229 | default: | 1232 | default: |
1233 | dm_error("Don't have enable_spread_spectrum_on_ppll for v%d\n", | ||
1234 | BIOS_CMD_TABLE_PARA_REVISION(EnableSpreadSpectrumOnPPLL)); | ||
1230 | bp->cmd_tbl.enable_spread_spectrum_on_ppll = NULL; | 1235 | bp->cmd_tbl.enable_spread_spectrum_on_ppll = NULL; |
1231 | break; | 1236 | break; |
1232 | } | 1237 | } |
@@ -1422,6 +1427,8 @@ static void init_adjust_display_pll(struct bios_parser *bp) | |||
1422 | bp->cmd_tbl.adjust_display_pll = adjust_display_pll_v3; | 1427 | bp->cmd_tbl.adjust_display_pll = adjust_display_pll_v3; |
1423 | break; | 1428 | break; |
1424 | default: | 1429 | default: |
1430 | dm_error("Don't have adjust_display_pll for v%d\n", | ||
1431 | BIOS_CMD_TABLE_PARA_REVISION(AdjustDisplayPll)); | ||
1425 | bp->cmd_tbl.adjust_display_pll = NULL; | 1432 | bp->cmd_tbl.adjust_display_pll = NULL; |
1426 | break; | 1433 | break; |
1427 | } | 1434 | } |
@@ -1695,6 +1702,8 @@ static void init_set_crtc_timing(struct bios_parser *bp) | |||
1695 | set_crtc_using_dtd_timing_v3; | 1702 | set_crtc_using_dtd_timing_v3; |
1696 | break; | 1703 | break; |
1697 | default: | 1704 | default: |
1705 | dm_error("Don't have set_crtc_timing for dtd v%d\n", | ||
1706 | dtd_version); | ||
1698 | bp->cmd_tbl.set_crtc_timing = NULL; | 1707 | bp->cmd_tbl.set_crtc_timing = NULL; |
1699 | break; | 1708 | break; |
1700 | } | 1709 | } |
@@ -1704,6 +1713,8 @@ static void init_set_crtc_timing(struct bios_parser *bp) | |||
1704 | bp->cmd_tbl.set_crtc_timing = set_crtc_timing_v1; | 1713 | bp->cmd_tbl.set_crtc_timing = set_crtc_timing_v1; |
1705 | break; | 1714 | break; |
1706 | default: | 1715 | default: |
1716 | dm_error("Don't have set_crtc_timing for v%d\n", | ||
1717 | BIOS_CMD_TABLE_PARA_REVISION(SetCRTC_Timing)); | ||
1707 | bp->cmd_tbl.set_crtc_timing = NULL; | 1718 | bp->cmd_tbl.set_crtc_timing = NULL; |
1708 | break; | 1719 | break; |
1709 | } | 1720 | } |
@@ -1890,6 +1901,8 @@ static void init_select_crtc_source(struct bios_parser *bp) | |||
1890 | bp->cmd_tbl.select_crtc_source = select_crtc_source_v3; | 1901 | bp->cmd_tbl.select_crtc_source = select_crtc_source_v3; |
1891 | break; | 1902 | break; |
1892 | default: | 1903 | default: |
1904 | dm_error("Don't select_crtc_source enable_crtc for v%d\n", | ||
1905 | BIOS_CMD_TABLE_PARA_REVISION(SelectCRTC_Source)); | ||
1893 | bp->cmd_tbl.select_crtc_source = NULL; | 1906 | bp->cmd_tbl.select_crtc_source = NULL; |
1894 | break; | 1907 | break; |
1895 | } | 1908 | } |
@@ -1997,6 +2010,8 @@ static void init_enable_crtc(struct bios_parser *bp) | |||
1997 | bp->cmd_tbl.enable_crtc = enable_crtc_v1; | 2010 | bp->cmd_tbl.enable_crtc = enable_crtc_v1; |
1998 | break; | 2011 | break; |
1999 | default: | 2012 | default: |
2013 | dm_error("Don't have enable_crtc for v%d\n", | ||
2014 | BIOS_CMD_TABLE_PARA_REVISION(EnableCRTC)); | ||
2000 | bp->cmd_tbl.enable_crtc = NULL; | 2015 | bp->cmd_tbl.enable_crtc = NULL; |
2001 | break; | 2016 | break; |
2002 | } | 2017 | } |
@@ -2103,6 +2118,8 @@ static void init_program_clock(struct bios_parser *bp) | |||
2103 | bp->cmd_tbl.program_clock = program_clock_v6; | 2118 | bp->cmd_tbl.program_clock = program_clock_v6; |
2104 | break; | 2119 | break; |
2105 | default: | 2120 | default: |
2121 | dm_error("Don't have program_clock for v%d\n", | ||
2122 | BIOS_CMD_TABLE_PARA_REVISION(SetPixelClock)); | ||
2106 | bp->cmd_tbl.program_clock = NULL; | 2123 | bp->cmd_tbl.program_clock = NULL; |
2107 | break; | 2124 | break; |
2108 | } | 2125 | } |
@@ -2324,6 +2341,8 @@ static void init_enable_disp_power_gating( | |||
2324 | enable_disp_power_gating_v2_1; | 2341 | enable_disp_power_gating_v2_1; |
2325 | break; | 2342 | break; |
2326 | default: | 2343 | default: |
2344 | dm_error("Don't enable_disp_power_gating enable_crtc for v%d\n", | ||
2345 | BIOS_CMD_TABLE_PARA_REVISION(EnableDispPowerGating)); | ||
2327 | bp->cmd_tbl.enable_disp_power_gating = NULL; | 2346 | bp->cmd_tbl.enable_disp_power_gating = NULL; |
2328 | break; | 2347 | break; |
2329 | } | 2348 | } |
@@ -2371,6 +2390,8 @@ static void init_set_dce_clock(struct bios_parser *bp) | |||
2371 | bp->cmd_tbl.set_dce_clock = set_dce_clock_v2_1; | 2390 | bp->cmd_tbl.set_dce_clock = set_dce_clock_v2_1; |
2372 | break; | 2391 | break; |
2373 | default: | 2392 | default: |
2393 | dm_error("Don't have set_dce_clock for v%d\n", | ||
2394 | BIOS_CMD_TABLE_PARA_REVISION(SetDCEClock)); | ||
2374 | bp->cmd_tbl.set_dce_clock = NULL; | 2395 | bp->cmd_tbl.set_dce_clock = NULL; |
2375 | break; | 2396 | break; |
2376 | } | 2397 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table2.c b/drivers/gpu/drm/amd/display/dc/bios/command_table2.c index ba68693758a7..946db12388d6 100644 --- a/drivers/gpu/drm/amd/display/dc/bios/command_table2.c +++ b/drivers/gpu/drm/amd/display/dc/bios/command_table2.c | |||
@@ -118,6 +118,7 @@ static void init_dig_encoder_control(struct bios_parser *bp) | |||
118 | bp->cmd_tbl.dig_encoder_control = encoder_control_digx_v1_5; | 118 | bp->cmd_tbl.dig_encoder_control = encoder_control_digx_v1_5; |
119 | break; | 119 | break; |
120 | default: | 120 | default: |
121 | dm_error("Don't have dig_encoder_control for v%d\n", version); | ||
121 | bp->cmd_tbl.dig_encoder_control = NULL; | 122 | bp->cmd_tbl.dig_encoder_control = NULL; |
122 | break; | 123 | break; |
123 | } | 124 | } |
@@ -205,6 +206,7 @@ static void init_transmitter_control(struct bios_parser *bp) | |||
205 | bp->cmd_tbl.transmitter_control = transmitter_control_v1_6; | 206 | bp->cmd_tbl.transmitter_control = transmitter_control_v1_6; |
206 | break; | 207 | break; |
207 | default: | 208 | default: |
209 | dm_error("Don't have transmitter_control for v%d\n", crev); | ||
208 | bp->cmd_tbl.transmitter_control = NULL; | 210 | bp->cmd_tbl.transmitter_control = NULL; |
209 | break; | 211 | break; |
210 | } | 212 | } |
@@ -268,6 +270,8 @@ static void init_set_pixel_clock(struct bios_parser *bp) | |||
268 | bp->cmd_tbl.set_pixel_clock = set_pixel_clock_v7; | 270 | bp->cmd_tbl.set_pixel_clock = set_pixel_clock_v7; |
269 | break; | 271 | break; |
270 | default: | 272 | default: |
273 | dm_error("Don't have set_pixel_clock for v%d\n", | ||
274 | BIOS_CMD_TABLE_PARA_REVISION(setpixelclock)); | ||
271 | bp->cmd_tbl.set_pixel_clock = NULL; | 275 | bp->cmd_tbl.set_pixel_clock = NULL; |
272 | break; | 276 | break; |
273 | } | 277 | } |
@@ -379,6 +383,7 @@ static void init_set_crtc_timing(struct bios_parser *bp) | |||
379 | set_crtc_using_dtd_timing_v3; | 383 | set_crtc_using_dtd_timing_v3; |
380 | break; | 384 | break; |
381 | default: | 385 | default: |
386 | dm_error("Don't have set_crtc_timing for v%d\n", dtd_version); | ||
382 | bp->cmd_tbl.set_crtc_timing = NULL; | 387 | bp->cmd_tbl.set_crtc_timing = NULL; |
383 | break; | 388 | break; |
384 | } | 389 | } |
@@ -498,6 +503,8 @@ static void init_select_crtc_source(struct bios_parser *bp) | |||
498 | bp->cmd_tbl.select_crtc_source = select_crtc_source_v3; | 503 | bp->cmd_tbl.select_crtc_source = select_crtc_source_v3; |
499 | break; | 504 | break; |
500 | default: | 505 | default: |
506 | dm_error("Don't select_crtc_source enable_crtc for v%d\n", | ||
507 | BIOS_CMD_TABLE_PARA_REVISION(selectcrtc_source)); | ||
501 | bp->cmd_tbl.select_crtc_source = NULL; | 508 | bp->cmd_tbl.select_crtc_source = NULL; |
502 | break; | 509 | break; |
503 | } | 510 | } |
@@ -565,6 +572,8 @@ static void init_enable_crtc(struct bios_parser *bp) | |||
565 | bp->cmd_tbl.enable_crtc = enable_crtc_v1; | 572 | bp->cmd_tbl.enable_crtc = enable_crtc_v1; |
566 | break; | 573 | break; |
567 | default: | 574 | default: |
575 | dm_error("Don't have enable_crtc for v%d\n", | ||
576 | BIOS_CMD_TABLE_PARA_REVISION(enablecrtc)); | ||
568 | bp->cmd_tbl.enable_crtc = NULL; | 577 | bp->cmd_tbl.enable_crtc = NULL; |
569 | break; | 578 | break; |
570 | } | 579 | } |
@@ -661,6 +670,8 @@ static void init_enable_disp_power_gating( | |||
661 | enable_disp_power_gating_v2_1; | 670 | enable_disp_power_gating_v2_1; |
662 | break; | 671 | break; |
663 | default: | 672 | default: |
673 | dm_error("Don't enable_disp_power_gating enable_crtc for v%d\n", | ||
674 | BIOS_CMD_TABLE_PARA_REVISION(enabledisppowergating)); | ||
664 | bp->cmd_tbl.enable_disp_power_gating = NULL; | 675 | bp->cmd_tbl.enable_disp_power_gating = NULL; |
665 | break; | 676 | break; |
666 | } | 677 | } |
@@ -710,6 +721,8 @@ static void init_set_dce_clock(struct bios_parser *bp) | |||
710 | bp->cmd_tbl.set_dce_clock = set_dce_clock_v2_1; | 721 | bp->cmd_tbl.set_dce_clock = set_dce_clock_v2_1; |
711 | break; | 722 | break; |
712 | default: | 723 | default: |
724 | dm_error("Don't have set_dce_clock for v%d\n", | ||
725 | BIOS_CMD_TABLE_PARA_REVISION(setdceclock)); | ||
713 | bp->cmd_tbl.set_dce_clock = NULL; | 726 | bp->cmd_tbl.set_dce_clock = NULL; |
714 | break; | 727 | break; |
715 | } | 728 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c index 6347712db834..2e11fac2a63d 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | |||
@@ -29,6 +29,15 @@ | |||
29 | #include "core_types.h" | 29 | #include "core_types.h" |
30 | #include "dal_asic_id.h" | 30 | #include "dal_asic_id.h" |
31 | 31 | ||
32 | /* | ||
33 | * NOTE: | ||
34 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
35 | * | ||
36 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
37 | * ways. Unless there is something clearly wrong with it the code should | ||
38 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
39 | */ | ||
40 | |||
32 | /******************************************************************************* | 41 | /******************************************************************************* |
33 | * Private Functions | 42 | * Private Functions |
34 | ******************************************************************************/ | 43 | ******************************************************************************/ |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c index 626f9cf8aad2..5e2ea12fbb73 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c | |||
@@ -27,6 +27,15 @@ | |||
27 | #include "dcn_calc_auto.h" | 27 | #include "dcn_calc_auto.h" |
28 | #include "dcn_calc_math.h" | 28 | #include "dcn_calc_math.h" |
29 | 29 | ||
30 | /* | ||
31 | * NOTE: | ||
32 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
33 | * | ||
34 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
35 | * ways. Unless there is something clearly wrong with it the code should | ||
36 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
37 | */ | ||
38 | |||
30 | /*REVISION#250*/ | 39 | /*REVISION#250*/ |
31 | void scaler_settings_calculation(struct dcn_bw_internal_vars *v) | 40 | void scaler_settings_calculation(struct dcn_bw_internal_vars *v) |
32 | { | 41 | { |
@@ -773,11 +782,11 @@ void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v) | |||
773 | v->dst_y_after_scaler = 0.0; | 782 | v->dst_y_after_scaler = 0.0; |
774 | } | 783 | } |
775 | v->time_calc = 24.0 / v->projected_dcfclk_deep_sleep; | 784 | v->time_calc = 24.0 / v->projected_dcfclk_deep_sleep; |
776 | v->v_update_offset[k] =dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0); | 785 | v->v_update_offset[k][j] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0); |
777 | v->total_repeater_delay = v->max_inter_dcn_tile_repeaters * (2.0 / (v->required_dispclk[i][j] / (j + 1)) + 3.0 / v->required_dispclk[i][j]); | 786 | v->total_repeater_delay = v->max_inter_dcn_tile_repeaters * (2.0 / (v->required_dispclk[i][j] / (j + 1)) + 3.0 / v->required_dispclk[i][j]); |
778 | v->v_update_width[k] = (14.0 / v->projected_dcfclk_deep_sleep + 12.0 / (v->required_dispclk[i][j] / (j + 1)) + v->total_repeater_delay) * v->pixel_clock[k]; | 787 | v->v_update_width[k][j] = (14.0 / v->projected_dcfclk_deep_sleep + 12.0 / (v->required_dispclk[i][j] / (j + 1)) + v->total_repeater_delay) * v->pixel_clock[k]; |
779 | v->v_ready_offset[k] =dcn_bw_max2(150.0 / (v->required_dispclk[i][j] / (j + 1)), v->total_repeater_delay + 20.0 / v->projected_dcfclk_deep_sleep + 10.0 / (v->required_dispclk[i][j] / (j + 1))) * v->pixel_clock[k]; | 788 | v->v_ready_offset[k][j] = dcn_bw_max2(150.0 / (v->required_dispclk[i][j] / (j + 1)), v->total_repeater_delay + 20.0 / v->projected_dcfclk_deep_sleep + 10.0 / (v->required_dispclk[i][j] / (j + 1))) * v->pixel_clock[k]; |
780 | v->time_setup = (v->v_update_offset[k] + v->v_update_width[k] + v->v_ready_offset[k]) / v->pixel_clock[k]; | 789 | v->time_setup = (v->v_update_offset[k][j] + v->v_update_width[k][j] + v->v_ready_offset[k][j]) / v->pixel_clock[k]; |
781 | v->extra_latency = v->urgent_round_trip_and_out_of_order_latency_per_state[i] + (v->total_number_of_active_dpp[i][j] * v->pixel_chunk_size_in_kbyte + v->total_number_of_dcc_active_dpp[i][j] * v->meta_chunk_size) * 1024.0 / v->return_bw_per_state[i]; | 790 | v->extra_latency = v->urgent_round_trip_and_out_of_order_latency_per_state[i] + (v->total_number_of_active_dpp[i][j] * v->pixel_chunk_size_in_kbyte + v->total_number_of_dcc_active_dpp[i][j] * v->meta_chunk_size) * 1024.0 / v->return_bw_per_state[i]; |
782 | if (v->pte_enable == dcn_bw_yes) { | 791 | if (v->pte_enable == dcn_bw_yes) { |
783 | v->extra_latency = v->extra_latency + v->total_number_of_active_dpp[i][j] * v->pte_chunk_size * 1024.0 / v->return_bw_per_state[i]; | 792 | v->extra_latency = v->extra_latency + v->total_number_of_active_dpp[i][j] * v->pte_chunk_size * 1024.0 / v->return_bw_per_state[i]; |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c index b6abe0f3bb15..7600a4a4abc7 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c | |||
@@ -25,37 +25,44 @@ | |||
25 | 25 | ||
26 | #include "dcn_calc_math.h" | 26 | #include "dcn_calc_math.h" |
27 | 27 | ||
28 | #define isNaN(number) ((number) != (number)) | ||
29 | |||
30 | /* | ||
31 | * NOTE: | ||
32 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
33 | * | ||
34 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
35 | * ways. Unless there is something clearly wrong with it the code should | ||
36 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
37 | */ | ||
38 | |||
28 | float dcn_bw_mod(const float arg1, const float arg2) | 39 | float dcn_bw_mod(const float arg1, const float arg2) |
29 | { | 40 | { |
30 | if (arg1 != arg1) | 41 | if (isNaN(arg1)) |
31 | return arg2; | 42 | return arg2; |
32 | if (arg2 != arg2) | 43 | if (isNaN(arg2)) |
33 | return arg1; | 44 | return arg1; |
34 | return arg1 - arg1 * ((int) (arg1 / arg2)); | 45 | return arg1 - arg1 * ((int) (arg1 / arg2)); |
35 | } | 46 | } |
36 | 47 | ||
37 | float dcn_bw_min2(const float arg1, const float arg2) | 48 | float dcn_bw_min2(const float arg1, const float arg2) |
38 | { | 49 | { |
39 | if (arg1 != arg1) | 50 | if (isNaN(arg1)) |
40 | return arg2; | 51 | return arg2; |
41 | if (arg2 != arg2) | 52 | if (isNaN(arg2)) |
42 | return arg1; | 53 | return arg1; |
43 | return arg1 < arg2 ? arg1 : arg2; | 54 | return arg1 < arg2 ? arg1 : arg2; |
44 | } | 55 | } |
45 | 56 | ||
46 | unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2) | 57 | unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2) |
47 | { | 58 | { |
48 | if (arg1 != arg1) | ||
49 | return arg2; | ||
50 | if (arg2 != arg2) | ||
51 | return arg1; | ||
52 | return arg1 > arg2 ? arg1 : arg2; | 59 | return arg1 > arg2 ? arg1 : arg2; |
53 | } | 60 | } |
54 | float dcn_bw_max2(const float arg1, const float arg2) | 61 | float dcn_bw_max2(const float arg1, const float arg2) |
55 | { | 62 | { |
56 | if (arg1 != arg1) | 63 | if (isNaN(arg1)) |
57 | return arg2; | 64 | return arg2; |
58 | if (arg2 != arg2) | 65 | if (isNaN(arg2)) |
59 | return arg1; | 66 | return arg1; |
60 | return arg1 > arg2 ? arg1 : arg2; | 67 | return arg1 > arg2 ? arg1 : arg2; |
61 | } | 68 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c index a4fbca34bcdf..331891c2c71a 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | |||
@@ -33,6 +33,15 @@ | |||
33 | #include "dcn10/dcn10_resource.h" | 33 | #include "dcn10/dcn10_resource.h" |
34 | #include "dcn_calc_math.h" | 34 | #include "dcn_calc_math.h" |
35 | 35 | ||
36 | /* | ||
37 | * NOTE: | ||
38 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
39 | * | ||
40 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
41 | * ways. Unless there is something clearly wrong with it the code should | ||
42 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
43 | */ | ||
44 | |||
36 | /* Defaults from spreadsheet rev#247 */ | 45 | /* Defaults from spreadsheet rev#247 */ |
37 | const struct dcn_soc_bounding_box dcn10_soc_defaults = { | 46 | const struct dcn_soc_bounding_box dcn10_soc_defaults = { |
38 | /* latencies */ | 47 | /* latencies */ |
@@ -878,6 +887,17 @@ bool dcn_validate_bandwidth( | |||
878 | + pipe->bottom_pipe->plane_res.scl_data.recout.width; | 887 | + pipe->bottom_pipe->plane_res.scl_data.recout.width; |
879 | } | 888 | } |
880 | 889 | ||
890 | if (pipe->plane_state->rotation % 2 == 0) { | ||
891 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value | ||
892 | || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]); | ||
893 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value | ||
894 | || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]); | ||
895 | } else { | ||
896 | ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dal_fixed31_32_one.value | ||
897 | || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]); | ||
898 | ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dal_fixed31_32_one.value | ||
899 | || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]); | ||
900 | } | ||
881 | v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no; | 901 | v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no; |
882 | v->source_pixel_format[input_idx] = tl_pixel_format_to_bw_defs( | 902 | v->source_pixel_format[input_idx] = tl_pixel_format_to_bw_defs( |
883 | pipe->plane_state->format); | 903 | pipe->plane_state->format); |
@@ -888,6 +908,15 @@ bool dcn_validate_bandwidth( | |||
888 | v->override_vta_ps[input_idx] = pipe->plane_res.scl_data.taps.v_taps; | 908 | v->override_vta_ps[input_idx] = pipe->plane_res.scl_data.taps.v_taps; |
889 | v->override_hta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.h_taps_c; | 909 | v->override_hta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.h_taps_c; |
890 | v->override_vta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.v_taps_c; | 910 | v->override_vta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.v_taps_c; |
911 | /* | ||
912 | * Spreadsheet doesn't handle taps_c is one properly, | ||
913 | * need to force Chroma to always be scaled to pass | ||
914 | * bandwidth validation. | ||
915 | */ | ||
916 | if (v->override_hta_pschroma[input_idx] == 1) | ||
917 | v->override_hta_pschroma[input_idx] = 2; | ||
918 | if (v->override_vta_pschroma[input_idx] == 1) | ||
919 | v->override_vta_pschroma[input_idx] = 2; | ||
891 | v->source_scan[input_idx] = (pipe->plane_state->rotation % 2) ? dcn_bw_vert : dcn_bw_hor; | 920 | v->source_scan[input_idx] = (pipe->plane_state->rotation % 2) ? dcn_bw_vert : dcn_bw_hor; |
892 | } | 921 | } |
893 | if (v->is_line_buffer_bpp_fixed == dcn_bw_yes) | 922 | if (v->is_line_buffer_bpp_fixed == dcn_bw_yes) |
@@ -985,9 +1014,9 @@ bool dcn_validate_bandwidth( | |||
985 | if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) | 1014 | if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) |
986 | continue; | 1015 | continue; |
987 | 1016 | ||
988 | pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx]; | 1017 | pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
989 | pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx]; | 1018 | pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
990 | pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx]; | 1019 | pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
991 | pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; | 1020 | pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; |
992 | 1021 | ||
993 | pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; | 1022 | pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; |
@@ -1026,9 +1055,9 @@ bool dcn_validate_bandwidth( | |||
1026 | TIMING_3D_FORMAT_SIDE_BY_SIDE))) { | 1055 | TIMING_3D_FORMAT_SIDE_BY_SIDE))) { |
1027 | if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) { | 1056 | if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) { |
1028 | /* update previously split pipe */ | 1057 | /* update previously split pipe */ |
1029 | hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx]; | 1058 | hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
1030 | hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx]; | 1059 | hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
1031 | hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx]; | 1060 | hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset[input_idx][v->dpp_per_plane[input_idx] == 2 ? 1 : 0]; |
1032 | hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; | 1061 | hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx]; |
1033 | 1062 | ||
1034 | hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; | 1063 | hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total; |
@@ -1556,35 +1585,6 @@ void dcn_bw_sync_calcs_and_dml(struct dc *dc) | |||
1556 | dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one, | 1585 | dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one, |
1557 | dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed, | 1586 | dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed, |
1558 | dc->dcn_ip->dcfclk_cstate_latency); | 1587 | dc->dcn_ip->dcfclk_cstate_latency); |
1559 | dc->dml.soc.vmin.socclk_mhz = dc->dcn_soc->socclk; | ||
1560 | dc->dml.soc.vmid.socclk_mhz = dc->dcn_soc->socclk; | ||
1561 | dc->dml.soc.vnom.socclk_mhz = dc->dcn_soc->socclk; | ||
1562 | dc->dml.soc.vmax.socclk_mhz = dc->dcn_soc->socclk; | ||
1563 | |||
1564 | dc->dml.soc.vmin.dcfclk_mhz = dc->dcn_soc->dcfclkv_min0p65; | ||
1565 | dc->dml.soc.vmid.dcfclk_mhz = dc->dcn_soc->dcfclkv_mid0p72; | ||
1566 | dc->dml.soc.vnom.dcfclk_mhz = dc->dcn_soc->dcfclkv_nom0p8; | ||
1567 | dc->dml.soc.vmax.dcfclk_mhz = dc->dcn_soc->dcfclkv_max0p9; | ||
1568 | |||
1569 | dc->dml.soc.vmin.dispclk_mhz = dc->dcn_soc->max_dispclk_vmin0p65; | ||
1570 | dc->dml.soc.vmid.dispclk_mhz = dc->dcn_soc->max_dispclk_vmid0p72; | ||
1571 | dc->dml.soc.vnom.dispclk_mhz = dc->dcn_soc->max_dispclk_vnom0p8; | ||
1572 | dc->dml.soc.vmax.dispclk_mhz = dc->dcn_soc->max_dispclk_vmax0p9; | ||
1573 | |||
1574 | dc->dml.soc.vmin.dppclk_mhz = dc->dcn_soc->max_dppclk_vmin0p65; | ||
1575 | dc->dml.soc.vmid.dppclk_mhz = dc->dcn_soc->max_dppclk_vmid0p72; | ||
1576 | dc->dml.soc.vnom.dppclk_mhz = dc->dcn_soc->max_dppclk_vnom0p8; | ||
1577 | dc->dml.soc.vmax.dppclk_mhz = dc->dcn_soc->max_dppclk_vmax0p9; | ||
1578 | |||
1579 | dc->dml.soc.vmin.phyclk_mhz = dc->dcn_soc->phyclkv_min0p65; | ||
1580 | dc->dml.soc.vmid.phyclk_mhz = dc->dcn_soc->phyclkv_mid0p72; | ||
1581 | dc->dml.soc.vnom.phyclk_mhz = dc->dcn_soc->phyclkv_nom0p8; | ||
1582 | dc->dml.soc.vmax.phyclk_mhz = dc->dcn_soc->phyclkv_max0p9; | ||
1583 | |||
1584 | dc->dml.soc.vmin.dram_bw_per_chan_gbps = dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65; | ||
1585 | dc->dml.soc.vmid.dram_bw_per_chan_gbps = dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72; | ||
1586 | dc->dml.soc.vnom.dram_bw_per_chan_gbps = dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8; | ||
1587 | dc->dml.soc.vmax.dram_bw_per_chan_gbps = dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9; | ||
1588 | 1588 | ||
1589 | dc->dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time; | 1589 | dc->dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time; |
1590 | dc->dml.soc.sr_enter_plus_exit_time_us = dc->dcn_soc->sr_enter_plus_exit_time; | 1590 | dc->dml.soc.sr_enter_plus_exit_time_us = dc->dcn_soc->sr_enter_plus_exit_time; |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index d1488d5ee028..35e84ed031de 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c | |||
@@ -283,19 +283,17 @@ static bool construct(struct dc *dc, | |||
283 | const struct dc_init_data *init_params) | 283 | const struct dc_init_data *init_params) |
284 | { | 284 | { |
285 | struct dal_logger *logger; | 285 | struct dal_logger *logger; |
286 | struct dc_context *dc_ctx = kzalloc(sizeof(*dc_ctx), GFP_KERNEL); | 286 | struct dc_context *dc_ctx; |
287 | struct bw_calcs_dceip *dc_dceip = kzalloc(sizeof(*dc_dceip), | 287 | struct bw_calcs_dceip *dc_dceip; |
288 | GFP_KERNEL); | 288 | struct bw_calcs_vbios *dc_vbios; |
289 | struct bw_calcs_vbios *dc_vbios = kzalloc(sizeof(*dc_vbios), | ||
290 | GFP_KERNEL); | ||
291 | #ifdef CONFIG_DRM_AMD_DC_DCN1_0 | 289 | #ifdef CONFIG_DRM_AMD_DC_DCN1_0 |
292 | struct dcn_soc_bounding_box *dcn_soc = kzalloc(sizeof(*dcn_soc), | 290 | struct dcn_soc_bounding_box *dcn_soc; |
293 | GFP_KERNEL); | 291 | struct dcn_ip_params *dcn_ip; |
294 | struct dcn_ip_params *dcn_ip = kzalloc(sizeof(*dcn_ip), GFP_KERNEL); | ||
295 | #endif | 292 | #endif |
296 | 293 | ||
297 | enum dce_version dc_version = DCE_VERSION_UNKNOWN; | 294 | enum dce_version dc_version = DCE_VERSION_UNKNOWN; |
298 | 295 | ||
296 | dc_dceip = kzalloc(sizeof(*dc_dceip), GFP_KERNEL); | ||
299 | if (!dc_dceip) { | 297 | if (!dc_dceip) { |
300 | dm_error("%s: failed to create dceip\n", __func__); | 298 | dm_error("%s: failed to create dceip\n", __func__); |
301 | goto fail; | 299 | goto fail; |
@@ -303,6 +301,7 @@ static bool construct(struct dc *dc, | |||
303 | 301 | ||
304 | dc->bw_dceip = dc_dceip; | 302 | dc->bw_dceip = dc_dceip; |
305 | 303 | ||
304 | dc_vbios = kzalloc(sizeof(*dc_vbios), GFP_KERNEL); | ||
306 | if (!dc_vbios) { | 305 | if (!dc_vbios) { |
307 | dm_error("%s: failed to create vbios\n", __func__); | 306 | dm_error("%s: failed to create vbios\n", __func__); |
308 | goto fail; | 307 | goto fail; |
@@ -310,6 +309,7 @@ static bool construct(struct dc *dc, | |||
310 | 309 | ||
311 | dc->bw_vbios = dc_vbios; | 310 | dc->bw_vbios = dc_vbios; |
312 | #ifdef CONFIG_DRM_AMD_DC_DCN1_0 | 311 | #ifdef CONFIG_DRM_AMD_DC_DCN1_0 |
312 | dcn_soc = kzalloc(sizeof(*dcn_soc), GFP_KERNEL); | ||
313 | if (!dcn_soc) { | 313 | if (!dcn_soc) { |
314 | dm_error("%s: failed to create dcn_soc\n", __func__); | 314 | dm_error("%s: failed to create dcn_soc\n", __func__); |
315 | goto fail; | 315 | goto fail; |
@@ -317,6 +317,7 @@ static bool construct(struct dc *dc, | |||
317 | 317 | ||
318 | dc->dcn_soc = dcn_soc; | 318 | dc->dcn_soc = dcn_soc; |
319 | 319 | ||
320 | dcn_ip = kzalloc(sizeof(*dcn_ip), GFP_KERNEL); | ||
320 | if (!dcn_ip) { | 321 | if (!dcn_ip) { |
321 | dm_error("%s: failed to create dcn_ip\n", __func__); | 322 | dm_error("%s: failed to create dcn_ip\n", __func__); |
322 | goto fail; | 323 | goto fail; |
@@ -325,11 +326,18 @@ static bool construct(struct dc *dc, | |||
325 | dc->dcn_ip = dcn_ip; | 326 | dc->dcn_ip = dcn_ip; |
326 | #endif | 327 | #endif |
327 | 328 | ||
329 | dc_ctx = kzalloc(sizeof(*dc_ctx), GFP_KERNEL); | ||
328 | if (!dc_ctx) { | 330 | if (!dc_ctx) { |
329 | dm_error("%s: failed to create ctx\n", __func__); | 331 | dm_error("%s: failed to create ctx\n", __func__); |
330 | goto fail; | 332 | goto fail; |
331 | } | 333 | } |
332 | 334 | ||
335 | dc_ctx->cgs_device = init_params->cgs_device; | ||
336 | dc_ctx->driver_context = init_params->driver; | ||
337 | dc_ctx->dc = dc; | ||
338 | dc_ctx->asic_id = init_params->asic_id; | ||
339 | dc->ctx = dc_ctx; | ||
340 | |||
333 | dc->current_state = dc_create_state(); | 341 | dc->current_state = dc_create_state(); |
334 | 342 | ||
335 | if (!dc->current_state) { | 343 | if (!dc->current_state) { |
@@ -337,11 +345,6 @@ static bool construct(struct dc *dc, | |||
337 | goto fail; | 345 | goto fail; |
338 | } | 346 | } |
339 | 347 | ||
340 | dc_ctx->cgs_device = init_params->cgs_device; | ||
341 | dc_ctx->driver_context = init_params->driver; | ||
342 | dc_ctx->dc = dc; | ||
343 | dc_ctx->asic_id = init_params->asic_id; | ||
344 | |||
345 | /* Create logger */ | 348 | /* Create logger */ |
346 | logger = dal_logger_create(dc_ctx, init_params->log_mask); | 349 | logger = dal_logger_create(dc_ctx, init_params->log_mask); |
347 | 350 | ||
@@ -351,11 +354,10 @@ static bool construct(struct dc *dc, | |||
351 | goto fail; | 354 | goto fail; |
352 | } | 355 | } |
353 | dc_ctx->logger = logger; | 356 | dc_ctx->logger = logger; |
354 | dc->ctx = dc_ctx; | 357 | dc_ctx->dce_environment = init_params->dce_environment; |
355 | dc->ctx->dce_environment = init_params->dce_environment; | ||
356 | 358 | ||
357 | dc_version = resource_parse_asic_id(init_params->asic_id); | 359 | dc_version = resource_parse_asic_id(init_params->asic_id); |
358 | dc->ctx->dce_version = dc_version; | 360 | dc_ctx->dce_version = dc_version; |
359 | 361 | ||
360 | #if defined(CONFIG_DRM_AMD_DC_FBC) | 362 | #if defined(CONFIG_DRM_AMD_DC_FBC) |
361 | dc->ctx->fbc_gpu_addr = init_params->fbc_gpu_addr; | 363 | dc->ctx->fbc_gpu_addr = init_params->fbc_gpu_addr; |
@@ -578,7 +580,7 @@ static void program_timing_sync( | |||
578 | for (j = 0; j < group_size; j++) { | 580 | for (j = 0; j < group_size; j++) { |
579 | struct pipe_ctx *temp; | 581 | struct pipe_ctx *temp; |
580 | 582 | ||
581 | if (!pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg)) { | 583 | if (pipe_set[j]->stream_res.tg->funcs->is_blanked && !pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg)) { |
582 | if (j == 0) | 584 | if (j == 0) |
583 | break; | 585 | break; |
584 | 586 | ||
@@ -591,7 +593,7 @@ static void program_timing_sync( | |||
591 | 593 | ||
592 | /* remove any other unblanked pipes as they have already been synced */ | 594 | /* remove any other unblanked pipes as they have already been synced */ |
593 | for (j = j + 1; j < group_size; j++) { | 595 | for (j = j + 1; j < group_size; j++) { |
594 | if (!pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg)) { | 596 | if (pipe_set[j]->stream_res.tg->funcs->is_blanked && !pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg)) { |
595 | group_size--; | 597 | group_size--; |
596 | pipe_set[j] = pipe_set[group_size]; | 598 | pipe_set[j] = pipe_set[group_size]; |
597 | j--; | 599 | j--; |
@@ -786,6 +788,8 @@ bool dc_post_update_surfaces_to_stream(struct dc *dc) | |||
786 | dc->hwss.disable_plane(dc, &context->res_ctx.pipe_ctx[i]); | 788 | dc->hwss.disable_plane(dc, &context->res_ctx.pipe_ctx[i]); |
787 | } | 789 | } |
788 | 790 | ||
791 | dc->optimized_required = false; | ||
792 | |||
789 | /* 3rd param should be true, temp w/a for RV*/ | 793 | /* 3rd param should be true, temp w/a for RV*/ |
790 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 794 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
791 | dc->hwss.set_bandwidth(dc, context, dc->ctx->dce_version < DCN_VERSION_1_0); | 795 | dc->hwss.set_bandwidth(dc, context, dc->ctx->dce_version < DCN_VERSION_1_0); |
@@ -981,6 +985,11 @@ static enum surface_update_type get_plane_info_update_type(const struct dc_surfa | |||
981 | if (u->plane_info->per_pixel_alpha != u->surface->per_pixel_alpha) | 985 | if (u->plane_info->per_pixel_alpha != u->surface->per_pixel_alpha) |
982 | update_flags->bits.per_pixel_alpha_change = 1; | 986 | update_flags->bits.per_pixel_alpha_change = 1; |
983 | 987 | ||
988 | if (u->plane_info->dcc.enable != u->surface->dcc.enable | ||
989 | || u->plane_info->dcc.grph.independent_64b_blks != u->surface->dcc.grph.independent_64b_blks | ||
990 | || u->plane_info->dcc.grph.meta_pitch != u->surface->dcc.grph.meta_pitch) | ||
991 | update_flags->bits.dcc_change = 1; | ||
992 | |||
984 | if (pixel_format_to_bpp(u->plane_info->format) != | 993 | if (pixel_format_to_bpp(u->plane_info->format) != |
985 | pixel_format_to_bpp(u->surface->format)) | 994 | pixel_format_to_bpp(u->surface->format)) |
986 | /* different bytes per element will require full bandwidth | 995 | /* different bytes per element will require full bandwidth |
@@ -1178,12 +1187,6 @@ static void commit_planes_for_stream(struct dc *dc, | |||
1178 | if (update_type == UPDATE_TYPE_FULL) { | 1187 | if (update_type == UPDATE_TYPE_FULL) { |
1179 | dc->hwss.set_bandwidth(dc, context, false); | 1188 | dc->hwss.set_bandwidth(dc, context, false); |
1180 | context_clock_trace(dc, context); | 1189 | context_clock_trace(dc, context); |
1181 | |||
1182 | for (j = 0; j < dc->res_pool->pipe_count; j++) { | ||
1183 | struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; | ||
1184 | |||
1185 | dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe_ctx); | ||
1186 | } | ||
1187 | } | 1190 | } |
1188 | 1191 | ||
1189 | if (surface_count == 0) { | 1192 | if (surface_count == 0) { |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c index 71993d5983bf..ebc96b720083 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include "timing_generator.h" | 28 | #include "timing_generator.h" |
29 | #include "hw_sequencer.h" | 29 | #include "hw_sequencer.h" |
30 | 30 | ||
31 | #define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0])) | ||
32 | |||
31 | /* used as index in array of black_color_format */ | 33 | /* used as index in array of black_color_format */ |
32 | enum black_color_format { | 34 | enum black_color_format { |
33 | BLACK_COLOR_FORMAT_RGB_FULLRANGE = 0, | 35 | BLACK_COLOR_FORMAT_RGB_FULLRANGE = 0, |
@@ -38,6 +40,15 @@ enum black_color_format { | |||
38 | BLACK_COLOR_FORMAT_DEBUG, | 40 | BLACK_COLOR_FORMAT_DEBUG, |
39 | }; | 41 | }; |
40 | 42 | ||
43 | enum dc_color_space_type { | ||
44 | COLOR_SPACE_RGB_TYPE, | ||
45 | COLOR_SPACE_RGB_LIMITED_TYPE, | ||
46 | COLOR_SPACE_YCBCR601_TYPE, | ||
47 | COLOR_SPACE_YCBCR709_TYPE, | ||
48 | COLOR_SPACE_YCBCR601_LIMITED_TYPE, | ||
49 | COLOR_SPACE_YCBCR709_LIMITED_TYPE | ||
50 | }; | ||
51 | |||
41 | static const struct tg_color black_color_format[] = { | 52 | static const struct tg_color black_color_format[] = { |
42 | /* BlackColorFormat_RGB_FullRange */ | 53 | /* BlackColorFormat_RGB_FullRange */ |
43 | {0, 0, 0}, | 54 | {0, 0, 0}, |
@@ -53,6 +64,140 @@ static const struct tg_color black_color_format[] = { | |||
53 | {0xff, 0xff, 0}, | 64 | {0xff, 0xff, 0}, |
54 | }; | 65 | }; |
55 | 66 | ||
67 | struct out_csc_color_matrix_type { | ||
68 | enum dc_color_space_type color_space_type; | ||
69 | uint16_t regval[12]; | ||
70 | }; | ||
71 | |||
72 | static const struct out_csc_color_matrix_type output_csc_matrix[] = { | ||
73 | { COLOR_SPACE_RGB_TYPE, | ||
74 | { 0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} }, | ||
75 | { COLOR_SPACE_RGB_LIMITED_TYPE, | ||
76 | { 0x1B67, 0, 0, 0x201, 0, 0x1B67, 0, 0x201, 0, 0, 0x1B67, 0x201} }, | ||
77 | { COLOR_SPACE_YCBCR601_TYPE, | ||
78 | { 0xE04, 0xF444, 0xFDB9, 0x1004, 0x831, 0x1016, 0x320, 0x201, 0xFB45, | ||
79 | 0xF6B7, 0xE04, 0x1004} }, | ||
80 | { COLOR_SPACE_YCBCR709_TYPE, | ||
81 | { 0xE04, 0xF345, 0xFEB7, 0x1004, 0x5D3, 0x1399, 0x1FA, | ||
82 | 0x201, 0xFCCA, 0xF533, 0xE04, 0x1004} }, | ||
83 | |||
84 | /* TODO: correct values below */ | ||
85 | { COLOR_SPACE_YCBCR601_LIMITED_TYPE, | ||
86 | { 0xE00, 0xF447, 0xFDB9, 0x1000, 0x991, | ||
87 | 0x12C9, 0x3A6, 0x200, 0xFB47, 0xF6B9, 0xE00, 0x1000} }, | ||
88 | { COLOR_SPACE_YCBCR709_LIMITED_TYPE, | ||
89 | { 0xE00, 0xF349, 0xFEB7, 0x1000, 0x6CE, 0x16E3, | ||
90 | 0x24F, 0x200, 0xFCCB, 0xF535, 0xE00, 0x1000} }, | ||
91 | }; | ||
92 | |||
93 | static bool is_rgb_type( | ||
94 | enum dc_color_space color_space) | ||
95 | { | ||
96 | bool ret = false; | ||
97 | |||
98 | if (color_space == COLOR_SPACE_SRGB || | ||
99 | color_space == COLOR_SPACE_XR_RGB || | ||
100 | color_space == COLOR_SPACE_MSREF_SCRGB || | ||
101 | color_space == COLOR_SPACE_2020_RGB_FULLRANGE || | ||
102 | color_space == COLOR_SPACE_ADOBERGB || | ||
103 | color_space == COLOR_SPACE_DCIP3 || | ||
104 | color_space == COLOR_SPACE_DOLBYVISION) | ||
105 | ret = true; | ||
106 | return ret; | ||
107 | } | ||
108 | |||
109 | static bool is_rgb_limited_type( | ||
110 | enum dc_color_space color_space) | ||
111 | { | ||
112 | bool ret = false; | ||
113 | |||
114 | if (color_space == COLOR_SPACE_SRGB_LIMITED || | ||
115 | color_space == COLOR_SPACE_2020_RGB_LIMITEDRANGE) | ||
116 | ret = true; | ||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | static bool is_ycbcr601_type( | ||
121 | enum dc_color_space color_space) | ||
122 | { | ||
123 | bool ret = false; | ||
124 | |||
125 | if (color_space == COLOR_SPACE_YCBCR601 || | ||
126 | color_space == COLOR_SPACE_XV_YCC_601) | ||
127 | ret = true; | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | static bool is_ycbcr601_limited_type( | ||
132 | enum dc_color_space color_space) | ||
133 | { | ||
134 | bool ret = false; | ||
135 | |||
136 | if (color_space == COLOR_SPACE_YCBCR601_LIMITED) | ||
137 | ret = true; | ||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | static bool is_ycbcr709_type( | ||
142 | enum dc_color_space color_space) | ||
143 | { | ||
144 | bool ret = false; | ||
145 | |||
146 | if (color_space == COLOR_SPACE_YCBCR709 || | ||
147 | color_space == COLOR_SPACE_XV_YCC_709) | ||
148 | ret = true; | ||
149 | return ret; | ||
150 | } | ||
151 | |||
152 | static bool is_ycbcr709_limited_type( | ||
153 | enum dc_color_space color_space) | ||
154 | { | ||
155 | bool ret = false; | ||
156 | |||
157 | if (color_space == COLOR_SPACE_YCBCR709_LIMITED) | ||
158 | ret = true; | ||
159 | return ret; | ||
160 | } | ||
161 | enum dc_color_space_type get_color_space_type(enum dc_color_space color_space) | ||
162 | { | ||
163 | enum dc_color_space_type type = COLOR_SPACE_RGB_TYPE; | ||
164 | |||
165 | if (is_rgb_type(color_space)) | ||
166 | type = COLOR_SPACE_RGB_TYPE; | ||
167 | else if (is_rgb_limited_type(color_space)) | ||
168 | type = COLOR_SPACE_RGB_LIMITED_TYPE; | ||
169 | else if (is_ycbcr601_type(color_space)) | ||
170 | type = COLOR_SPACE_YCBCR601_TYPE; | ||
171 | else if (is_ycbcr709_type(color_space)) | ||
172 | type = COLOR_SPACE_YCBCR709_TYPE; | ||
173 | else if (is_ycbcr601_limited_type(color_space)) | ||
174 | type = COLOR_SPACE_YCBCR601_LIMITED_TYPE; | ||
175 | else if (is_ycbcr709_limited_type(color_space)) | ||
176 | type = COLOR_SPACE_YCBCR709_LIMITED_TYPE; | ||
177 | |||
178 | return type; | ||
179 | } | ||
180 | |||
181 | const uint16_t *find_color_matrix(enum dc_color_space color_space, | ||
182 | uint32_t *array_size) | ||
183 | { | ||
184 | int i; | ||
185 | enum dc_color_space_type type; | ||
186 | const uint16_t *val = NULL; | ||
187 | int arr_size = NUM_ELEMENTS(output_csc_matrix); | ||
188 | |||
189 | type = get_color_space_type(color_space); | ||
190 | for (i = 0; i < arr_size; i++) | ||
191 | if (output_csc_matrix[i].color_space_type == type) { | ||
192 | val = output_csc_matrix[i].regval; | ||
193 | *array_size = 12; | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | return val; | ||
198 | } | ||
199 | |||
200 | |||
56 | void color_space_to_black_color( | 201 | void color_space_to_black_color( |
57 | const struct dc *dc, | 202 | const struct dc *dc, |
58 | enum dc_color_space colorspace, | 203 | enum dc_color_space colorspace, |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 7b0e43c0685c..a37428271573 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c | |||
@@ -938,8 +938,9 @@ static bool construct( | |||
938 | link->link_id = bios->funcs->get_connector_id(bios, init_params->connector_index); | 938 | link->link_id = bios->funcs->get_connector_id(bios, init_params->connector_index); |
939 | 939 | ||
940 | if (link->link_id.type != OBJECT_TYPE_CONNECTOR) { | 940 | if (link->link_id.type != OBJECT_TYPE_CONNECTOR) { |
941 | dm_error("%s: Invalid Connector ObjectID from Adapter Service for connector index:%d!\n", | 941 | dm_error("%s: Invalid Connector ObjectID from Adapter Service for connector index:%d! type %d expected %d\n", |
942 | __func__, init_params->connector_index); | 942 | __func__, init_params->connector_index, |
943 | link->link_id.type, OBJECT_TYPE_CONNECTOR); | ||
943 | goto create_fail; | 944 | goto create_fail; |
944 | } | 945 | } |
945 | 946 | ||
@@ -1271,6 +1272,24 @@ static enum dc_status enable_link_dp( | |||
1271 | return status; | 1272 | return status; |
1272 | } | 1273 | } |
1273 | 1274 | ||
1275 | static enum dc_status enable_link_edp( | ||
1276 | struct dc_state *state, | ||
1277 | struct pipe_ctx *pipe_ctx) | ||
1278 | { | ||
1279 | enum dc_status status; | ||
1280 | struct dc_stream_state *stream = pipe_ctx->stream; | ||
1281 | struct dc_link *link = stream->sink->link; | ||
1282 | |||
1283 | link->dc->hwss.edp_power_control(link, true); | ||
1284 | link->dc->hwss.edp_wait_for_hpd_ready(link, true); | ||
1285 | |||
1286 | status = enable_link_dp(state, pipe_ctx); | ||
1287 | |||
1288 | link->dc->hwss.edp_backlight_control(link, true); | ||
1289 | |||
1290 | return status; | ||
1291 | } | ||
1292 | |||
1274 | static enum dc_status enable_link_dp_mst( | 1293 | static enum dc_status enable_link_dp_mst( |
1275 | struct dc_state *state, | 1294 | struct dc_state *state, |
1276 | struct pipe_ctx *pipe_ctx) | 1295 | struct pipe_ctx *pipe_ctx) |
@@ -1746,9 +1765,11 @@ static enum dc_status enable_link( | |||
1746 | enum dc_status status = DC_ERROR_UNEXPECTED; | 1765 | enum dc_status status = DC_ERROR_UNEXPECTED; |
1747 | switch (pipe_ctx->stream->signal) { | 1766 | switch (pipe_ctx->stream->signal) { |
1748 | case SIGNAL_TYPE_DISPLAY_PORT: | 1767 | case SIGNAL_TYPE_DISPLAY_PORT: |
1749 | case SIGNAL_TYPE_EDP: | ||
1750 | status = enable_link_dp(state, pipe_ctx); | 1768 | status = enable_link_dp(state, pipe_ctx); |
1751 | break; | 1769 | break; |
1770 | case SIGNAL_TYPE_EDP: | ||
1771 | status = enable_link_edp(state, pipe_ctx); | ||
1772 | break; | ||
1752 | case SIGNAL_TYPE_DISPLAY_PORT_MST: | 1773 | case SIGNAL_TYPE_DISPLAY_PORT_MST: |
1753 | status = enable_link_dp_mst(state, pipe_ctx); | 1774 | status = enable_link_dp_mst(state, pipe_ctx); |
1754 | msleep(200); | 1775 | msleep(200); |
@@ -1801,7 +1822,7 @@ static void disable_link(struct dc_link *link, enum signal_type signal) | |||
1801 | link->link_enc->funcs->disable_output(link->link_enc, signal); | 1822 | link->link_enc->funcs->disable_output(link->link_enc, signal); |
1802 | } | 1823 | } |
1803 | 1824 | ||
1804 | bool dp_active_dongle_validate_timing( | 1825 | static bool dp_active_dongle_validate_timing( |
1805 | const struct dc_crtc_timing *timing, | 1826 | const struct dc_crtc_timing *timing, |
1806 | const struct dc_dongle_caps *dongle_caps) | 1827 | const struct dc_dongle_caps *dongle_caps) |
1807 | { | 1828 | { |
@@ -1833,6 +1854,8 @@ bool dp_active_dongle_validate_timing( | |||
1833 | /* Check Color Depth and Pixel Clock */ | 1854 | /* Check Color Depth and Pixel Clock */ |
1834 | if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) | 1855 | if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) |
1835 | required_pix_clk /= 2; | 1856 | required_pix_clk /= 2; |
1857 | else if (timing->pixel_encoding == PIXEL_ENCODING_YCBCR422) | ||
1858 | required_pix_clk = required_pix_clk * 2 / 3; | ||
1836 | 1859 | ||
1837 | switch (timing->display_color_depth) { | 1860 | switch (timing->display_color_depth) { |
1838 | case COLOR_DEPTH_666: | 1861 | case COLOR_DEPTH_666: |
@@ -1907,12 +1930,18 @@ bool dc_link_set_backlight_level(const struct dc_link *link, uint32_t level, | |||
1907 | { | 1930 | { |
1908 | struct dc *core_dc = link->ctx->dc; | 1931 | struct dc *core_dc = link->ctx->dc; |
1909 | struct abm *abm = core_dc->res_pool->abm; | 1932 | struct abm *abm = core_dc->res_pool->abm; |
1933 | struct dmcu *dmcu = core_dc->res_pool->dmcu; | ||
1910 | unsigned int controller_id = 0; | 1934 | unsigned int controller_id = 0; |
1935 | bool use_smooth_brightness = true; | ||
1911 | int i; | 1936 | int i; |
1912 | 1937 | ||
1913 | if ((abm == NULL) || (abm->funcs->set_backlight_level == NULL)) | 1938 | if ((dmcu == NULL) || |
1939 | (abm == NULL) || | ||
1940 | (abm->funcs->set_backlight_level == NULL)) | ||
1914 | return false; | 1941 | return false; |
1915 | 1942 | ||
1943 | use_smooth_brightness = dmcu->funcs->is_dmcu_initialized(dmcu); | ||
1944 | |||
1916 | dm_logger_write(link->ctx->logger, LOG_BACKLIGHT, | 1945 | dm_logger_write(link->ctx->logger, LOG_BACKLIGHT, |
1917 | "New Backlight level: %d (0x%X)\n", level, level); | 1946 | "New Backlight level: %d (0x%X)\n", level, level); |
1918 | 1947 | ||
@@ -1935,7 +1964,8 @@ bool dc_link_set_backlight_level(const struct dc_link *link, uint32_t level, | |||
1935 | abm, | 1964 | abm, |
1936 | level, | 1965 | level, |
1937 | frame_ramp, | 1966 | frame_ramp, |
1938 | controller_id); | 1967 | controller_id, |
1968 | use_smooth_brightness); | ||
1939 | } | 1969 | } |
1940 | 1970 | ||
1941 | return true; | 1971 | return true; |
@@ -1952,144 +1982,6 @@ bool dc_link_set_psr_enable(const struct dc_link *link, bool enable, bool wait) | |||
1952 | return true; | 1982 | return true; |
1953 | } | 1983 | } |
1954 | 1984 | ||
1955 | bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state) | ||
1956 | { | ||
1957 | struct dc *core_dc = link->ctx->dc; | ||
1958 | struct dmcu *dmcu = core_dc->res_pool->dmcu; | ||
1959 | |||
1960 | if (dmcu != NULL && link->psr_enabled) | ||
1961 | dmcu->funcs->get_psr_state(dmcu, psr_state); | ||
1962 | |||
1963 | return true; | ||
1964 | } | ||
1965 | |||
1966 | bool dc_link_setup_psr(struct dc_link *link, | ||
1967 | const struct dc_stream_state *stream, struct psr_config *psr_config, | ||
1968 | struct psr_context *psr_context) | ||
1969 | { | ||
1970 | struct dc *core_dc = link->ctx->dc; | ||
1971 | struct dmcu *dmcu = core_dc->res_pool->dmcu; | ||
1972 | int i; | ||
1973 | |||
1974 | psr_context->controllerId = CONTROLLER_ID_UNDEFINED; | ||
1975 | |||
1976 | if (link != NULL && | ||
1977 | dmcu != NULL) { | ||
1978 | /* updateSinkPsrDpcdConfig*/ | ||
1979 | union dpcd_psr_configuration psr_configuration; | ||
1980 | |||
1981 | memset(&psr_configuration, 0, sizeof(psr_configuration)); | ||
1982 | |||
1983 | psr_configuration.bits.ENABLE = 1; | ||
1984 | psr_configuration.bits.CRC_VERIFICATION = 1; | ||
1985 | psr_configuration.bits.FRAME_CAPTURE_INDICATION = | ||
1986 | psr_config->psr_frame_capture_indication_req; | ||
1987 | |||
1988 | /* Check for PSR v2*/ | ||
1989 | if (psr_config->psr_version == 0x2) { | ||
1990 | /* For PSR v2 selective update. | ||
1991 | * Indicates whether sink should start capturing | ||
1992 | * immediately following active scan line, | ||
1993 | * or starting with the 2nd active scan line. | ||
1994 | */ | ||
1995 | psr_configuration.bits.LINE_CAPTURE_INDICATION = 0; | ||
1996 | /*For PSR v2, determines whether Sink should generate | ||
1997 | * IRQ_HPD when CRC mismatch is detected. | ||
1998 | */ | ||
1999 | psr_configuration.bits.IRQ_HPD_WITH_CRC_ERROR = 1; | ||
2000 | } | ||
2001 | |||
2002 | dm_helpers_dp_write_dpcd( | ||
2003 | link->ctx, | ||
2004 | link, | ||
2005 | 368, | ||
2006 | &psr_configuration.raw, | ||
2007 | sizeof(psr_configuration.raw)); | ||
2008 | |||
2009 | psr_context->channel = link->ddc->ddc_pin->hw_info.ddc_channel; | ||
2010 | psr_context->transmitterId = link->link_enc->transmitter; | ||
2011 | psr_context->engineId = link->link_enc->preferred_engine; | ||
2012 | |||
2013 | for (i = 0; i < MAX_PIPES; i++) { | ||
2014 | if (core_dc->current_state->res_ctx.pipe_ctx[i].stream | ||
2015 | == stream) { | ||
2016 | /* dmcu -1 for all controller id values, | ||
2017 | * therefore +1 here | ||
2018 | */ | ||
2019 | psr_context->controllerId = | ||
2020 | core_dc->current_state->res_ctx. | ||
2021 | pipe_ctx[i].stream_res.tg->inst + 1; | ||
2022 | break; | ||
2023 | } | ||
2024 | } | ||
2025 | |||
2026 | /* Hardcoded for now. Can be Pcie or Uniphy (or Unknown)*/ | ||
2027 | psr_context->phyType = PHY_TYPE_UNIPHY; | ||
2028 | /*PhyId is associated with the transmitter id*/ | ||
2029 | psr_context->smuPhyId = link->link_enc->transmitter; | ||
2030 | |||
2031 | psr_context->crtcTimingVerticalTotal = stream->timing.v_total; | ||
2032 | psr_context->vsyncRateHz = div64_u64(div64_u64((stream-> | ||
2033 | timing.pix_clk_khz * 1000), | ||
2034 | stream->timing.v_total), | ||
2035 | stream->timing.h_total); | ||
2036 | |||
2037 | psr_context->psrSupportedDisplayConfig = true; | ||
2038 | psr_context->psrExitLinkTrainingRequired = | ||
2039 | psr_config->psr_exit_link_training_required; | ||
2040 | psr_context->sdpTransmitLineNumDeadline = | ||
2041 | psr_config->psr_sdp_transmit_line_num_deadline; | ||
2042 | psr_context->psrFrameCaptureIndicationReq = | ||
2043 | psr_config->psr_frame_capture_indication_req; | ||
2044 | |||
2045 | psr_context->skipPsrWaitForPllLock = 0; /* only = 1 in KV */ | ||
2046 | |||
2047 | psr_context->numberOfControllers = | ||
2048 | link->dc->res_pool->res_cap->num_timing_generator; | ||
2049 | |||
2050 | psr_context->rfb_update_auto_en = true; | ||
2051 | |||
2052 | /* 2 frames before enter PSR. */ | ||
2053 | psr_context->timehyst_frames = 2; | ||
2054 | /* half a frame | ||
2055 | * (units in 100 lines, i.e. a value of 1 represents 100 lines) | ||
2056 | */ | ||
2057 | psr_context->hyst_lines = stream->timing.v_total / 2 / 100; | ||
2058 | psr_context->aux_repeats = 10; | ||
2059 | |||
2060 | psr_context->psr_level.u32all = 0; | ||
2061 | |||
2062 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | ||
2063 | /*skip power down the single pipe since it blocks the cstate*/ | ||
2064 | if (ASIC_REV_IS_RAVEN(link->ctx->asic_id.hw_internal_rev)) | ||
2065 | psr_context->psr_level.bits.SKIP_CRTC_DISABLE = true; | ||
2066 | #endif | ||
2067 | |||
2068 | /* SMU will perform additional powerdown sequence. | ||
2069 | * For unsupported ASICs, set psr_level flag to skip PSR | ||
2070 | * static screen notification to SMU. | ||
2071 | * (Always set for DAL2, did not check ASIC) | ||
2072 | */ | ||
2073 | psr_context->psr_level.bits.SKIP_SMU_NOTIFICATION = 1; | ||
2074 | |||
2075 | /* Complete PSR entry before aborting to prevent intermittent | ||
2076 | * freezes on certain eDPs | ||
2077 | */ | ||
2078 | psr_context->psr_level.bits.DISABLE_PSR_ENTRY_ABORT = 1; | ||
2079 | |||
2080 | /* Controls additional delay after remote frame capture before | ||
2081 | * continuing power down, default = 0 | ||
2082 | */ | ||
2083 | psr_context->frame_delay = 0; | ||
2084 | |||
2085 | link->psr_enabled = true; | ||
2086 | dmcu->funcs->setup_psr(dmcu, link, psr_context); | ||
2087 | return true; | ||
2088 | } else | ||
2089 | return false; | ||
2090 | |||
2091 | } | ||
2092 | |||
2093 | const struct dc_link_status *dc_link_get_status(const struct dc_link *link) | 1985 | const struct dc_link_status *dc_link_get_status(const struct dc_link *link) |
2094 | { | 1986 | { |
2095 | return &link->link_status; | 1987 | return &link->link_status; |
@@ -2418,6 +2310,9 @@ void core_link_disable_stream(struct pipe_ctx *pipe_ctx, int option) | |||
2418 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) | 2310 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) |
2419 | deallocate_mst_payload(pipe_ctx); | 2311 | deallocate_mst_payload(pipe_ctx); |
2420 | 2312 | ||
2313 | if (pipe_ctx->stream->signal == SIGNAL_TYPE_EDP) | ||
2314 | core_dc->hwss.edp_backlight_control(pipe_ctx->stream->sink->link, false); | ||
2315 | |||
2421 | core_dc->hwss.disable_stream(pipe_ctx, option); | 2316 | core_dc->hwss.disable_stream(pipe_ctx, option); |
2422 | 2317 | ||
2423 | disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal); | 2318 | disable_link(pipe_ctx->stream->sink->link, pipe_ctx->stream->signal); |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c index 00528b214a9f..61e8c3e02d16 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | |||
@@ -1470,6 +1470,12 @@ void decide_link_settings(struct dc_stream_state *stream, | |||
1470 | return; | 1470 | return; |
1471 | } | 1471 | } |
1472 | 1472 | ||
1473 | /* EDP use the link cap setting */ | ||
1474 | if (stream->sink->sink_signal == SIGNAL_TYPE_EDP) { | ||
1475 | *link_setting = link->verified_link_cap; | ||
1476 | return; | ||
1477 | } | ||
1478 | |||
1473 | /* search for the minimum link setting that: | 1479 | /* search for the minimum link setting that: |
1474 | * 1. is supported according to the link training result | 1480 | * 1. is supported according to the link training result |
1475 | * 2. could support the b/w requested by the timing | 1481 | * 2. could support the b/w requested by the timing |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c index f2902569be2e..2096f2a179f2 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c | |||
@@ -88,15 +88,7 @@ void dp_enable_link_phy( | |||
88 | } | 88 | } |
89 | 89 | ||
90 | if (dc_is_dp_sst_signal(signal)) { | 90 | if (dc_is_dp_sst_signal(signal)) { |
91 | if (signal == SIGNAL_TYPE_EDP) { | 91 | link_enc->funcs->enable_dp_output( |
92 | link->dc->hwss.edp_power_control(link, true); | ||
93 | link_enc->funcs->enable_dp_output( | ||
94 | link_enc, | ||
95 | link_settings, | ||
96 | clock_source); | ||
97 | link->dc->hwss.edp_backlight_control(link, true); | ||
98 | } else | ||
99 | link_enc->funcs->enable_dp_output( | ||
100 | link_enc, | 92 | link_enc, |
101 | link_settings, | 93 | link_settings, |
102 | clock_source); | 94 | clock_source); |
@@ -138,7 +130,6 @@ void dp_disable_link_phy(struct dc_link *link, enum signal_type signal) | |||
138 | dp_receiver_power_ctrl(link, false); | 130 | dp_receiver_power_ctrl(link, false); |
139 | 131 | ||
140 | if (signal == SIGNAL_TYPE_EDP) { | 132 | if (signal == SIGNAL_TYPE_EDP) { |
141 | link->dc->hwss.edp_backlight_control(link, false); | ||
142 | edp_receiver_ready_T9(link); | 133 | edp_receiver_ready_T9(link); |
143 | link->link_enc->funcs->disable_output(link->link_enc, signal); | 134 | link->link_enc->funcs->disable_output(link->link_enc, signal); |
144 | link->dc->hwss.edp_power_control(link, false); | 135 | link->dc->hwss.edp_power_control(link, false); |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index ad28eba017f2..95b8dd0e53c6 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c | |||
@@ -498,26 +498,15 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx) | |||
498 | data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div; | 498 | data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div; |
499 | 499 | ||
500 | /* Handle hsplit */ | 500 | /* Handle hsplit */ |
501 | if (pri_split || sec_split) { | 501 | if (sec_split) { |
502 | /* HMirror XOR Secondary_pipe XOR Rotation_180 */ | 502 | data->viewport.x += data->viewport.width / 2; |
503 | bool right_view = (sec_split != plane_state->horizontal_mirror) != | 503 | data->viewport_c.x += data->viewport_c.width / 2; |
504 | (plane_state->rotation == ROTATION_ANGLE_180); | 504 | /* Ceil offset pipe */ |
505 | 505 | data->viewport.width = (data->viewport.width + 1) / 2; | |
506 | if (plane_state->rotation == ROTATION_ANGLE_90 | 506 | data->viewport_c.width = (data->viewport_c.width + 1) / 2; |
507 | || plane_state->rotation == ROTATION_ANGLE_270) | 507 | } else if (pri_split) { |
508 | /* Secondary_pipe XOR Rotation_270 */ | 508 | data->viewport.width /= 2; |
509 | right_view = (plane_state->rotation == ROTATION_ANGLE_270) != sec_split; | 509 | data->viewport_c.width /= 2; |
510 | |||
511 | if (right_view) { | ||
512 | data->viewport.x += data->viewport.width / 2; | ||
513 | data->viewport_c.x += data->viewport_c.width / 2; | ||
514 | /* Ceil offset pipe */ | ||
515 | data->viewport.width = (data->viewport.width + 1) / 2; | ||
516 | data->viewport_c.width = (data->viewport_c.width + 1) / 2; | ||
517 | } else { | ||
518 | data->viewport.width /= 2; | ||
519 | data->viewport_c.width /= 2; | ||
520 | } | ||
521 | } | 510 | } |
522 | 511 | ||
523 | if (plane_state->rotation == ROTATION_ANGLE_90 || | 512 | if (plane_state->rotation == ROTATION_ANGLE_90 || |
@@ -534,6 +523,11 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip | |||
534 | struct rect surf_src = plane_state->src_rect; | 523 | struct rect surf_src = plane_state->src_rect; |
535 | struct rect surf_clip = plane_state->clip_rect; | 524 | struct rect surf_clip = plane_state->clip_rect; |
536 | int recout_full_x, recout_full_y; | 525 | int recout_full_x, recout_full_y; |
526 | bool pri_split = pipe_ctx->bottom_pipe && | ||
527 | pipe_ctx->bottom_pipe->plane_state == pipe_ctx->plane_state; | ||
528 | bool sec_split = pipe_ctx->top_pipe && | ||
529 | pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state; | ||
530 | bool top_bottom_split = stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM; | ||
537 | 531 | ||
538 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || | 532 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || |
539 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) | 533 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) |
@@ -568,33 +562,43 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip | |||
568 | - pipe_ctx->plane_res.scl_data.recout.y; | 562 | - pipe_ctx->plane_res.scl_data.recout.y; |
569 | 563 | ||
570 | /* Handle h & vsplit */ | 564 | /* Handle h & vsplit */ |
571 | if (pipe_ctx->top_pipe && pipe_ctx->top_pipe->plane_state == | 565 | if (sec_split && top_bottom_split) { |
572 | pipe_ctx->plane_state) { | 566 | pipe_ctx->plane_res.scl_data.recout.y += |
573 | if (stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM) { | 567 | pipe_ctx->plane_res.scl_data.recout.height / 2; |
574 | pipe_ctx->plane_res.scl_data.recout.y += pipe_ctx->plane_res.scl_data.recout.height / 2; | 568 | /* Floor primary pipe, ceil 2ndary pipe */ |
575 | /* Floor primary pipe, ceil 2ndary pipe */ | 569 | pipe_ctx->plane_res.scl_data.recout.height = |
576 | pipe_ctx->plane_res.scl_data.recout.height = (pipe_ctx->plane_res.scl_data.recout.height + 1) / 2; | 570 | (pipe_ctx->plane_res.scl_data.recout.height + 1) / 2; |
571 | } else if (pri_split && top_bottom_split) | ||
572 | pipe_ctx->plane_res.scl_data.recout.height /= 2; | ||
573 | else if (pri_split || sec_split) { | ||
574 | /* HMirror XOR Secondary_pipe XOR Rotation_180 */ | ||
575 | bool right_view = (sec_split != plane_state->horizontal_mirror) != | ||
576 | (plane_state->rotation == ROTATION_ANGLE_180); | ||
577 | |||
578 | if (plane_state->rotation == ROTATION_ANGLE_90 | ||
579 | || plane_state->rotation == ROTATION_ANGLE_270) | ||
580 | /* Secondary_pipe XOR Rotation_270 */ | ||
581 | right_view = (plane_state->rotation == ROTATION_ANGLE_270) != sec_split; | ||
582 | |||
583 | if (right_view) { | ||
584 | pipe_ctx->plane_res.scl_data.recout.x += | ||
585 | pipe_ctx->plane_res.scl_data.recout.width / 2; | ||
586 | /* Ceil offset pipe */ | ||
587 | pipe_ctx->plane_res.scl_data.recout.width = | ||
588 | (pipe_ctx->plane_res.scl_data.recout.width + 1) / 2; | ||
577 | } else { | 589 | } else { |
578 | pipe_ctx->plane_res.scl_data.recout.x += pipe_ctx->plane_res.scl_data.recout.width / 2; | ||
579 | pipe_ctx->plane_res.scl_data.recout.width = (pipe_ctx->plane_res.scl_data.recout.width + 1) / 2; | ||
580 | } | ||
581 | } else if (pipe_ctx->bottom_pipe && | ||
582 | pipe_ctx->bottom_pipe->plane_state == pipe_ctx->plane_state) { | ||
583 | if (stream->view_format == VIEW_3D_FORMAT_TOP_AND_BOTTOM) | ||
584 | pipe_ctx->plane_res.scl_data.recout.height /= 2; | ||
585 | else | ||
586 | pipe_ctx->plane_res.scl_data.recout.width /= 2; | 590 | pipe_ctx->plane_res.scl_data.recout.width /= 2; |
591 | } | ||
587 | } | 592 | } |
588 | |||
589 | /* Unclipped recout offset = stream dst offset + ((surf dst offset - stream surf_src offset) | 593 | /* Unclipped recout offset = stream dst offset + ((surf dst offset - stream surf_src offset) |
590 | * * 1/ stream scaling ratio) - (surf surf_src offset * 1/ full scl | 594 | * * 1/ stream scaling ratio) - (surf surf_src offset * 1/ full scl |
591 | * ratio) | 595 | * ratio) |
592 | */ | 596 | */ |
593 | recout_full_x = stream->dst.x + (plane_state->dst_rect.x - stream->src.x) | 597 | recout_full_x = stream->dst.x + (plane_state->dst_rect.x - stream->src.x) |
594 | * stream->dst.width / stream->src.width - | 598 | * stream->dst.width / stream->src.width - |
595 | surf_src.x * plane_state->dst_rect.width / surf_src.width | 599 | surf_src.x * plane_state->dst_rect.width / surf_src.width |
596 | * stream->dst.width / stream->src.width; | 600 | * stream->dst.width / stream->src.width; |
597 | recout_full_y = stream->dst.y + (plane_state->dst_rect.y - stream->src.y) | 601 | recout_full_y = stream->dst.y + (plane_state->dst_rect.y - stream->src.y) |
598 | * stream->dst.height / stream->src.height - | 602 | * stream->dst.height / stream->src.height - |
599 | surf_src.y * plane_state->dst_rect.height / surf_src.height | 603 | surf_src.y * plane_state->dst_rect.height / surf_src.height |
600 | * stream->dst.height / stream->src.height; | 604 | * stream->dst.height / stream->src.height; |
@@ -650,7 +654,20 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
650 | struct rect src = pipe_ctx->plane_state->src_rect; | 654 | struct rect src = pipe_ctx->plane_state->src_rect; |
651 | int vpc_div = (data->format == PIXEL_FORMAT_420BPP8 | 655 | int vpc_div = (data->format == PIXEL_FORMAT_420BPP8 |
652 | || data->format == PIXEL_FORMAT_420BPP10) ? 2 : 1; | 656 | || data->format == PIXEL_FORMAT_420BPP10) ? 2 : 1; |
657 | bool flip_vert_scan_dir = false, flip_horz_scan_dir = false; | ||
653 | 658 | ||
659 | /* | ||
660 | * Need to calculate the scan direction for viewport to make adjustments | ||
661 | */ | ||
662 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_180) { | ||
663 | flip_vert_scan_dir = true; | ||
664 | flip_horz_scan_dir = true; | ||
665 | } else if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90) | ||
666 | flip_vert_scan_dir = true; | ||
667 | else if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) | ||
668 | flip_horz_scan_dir = true; | ||
669 | if (pipe_ctx->plane_state->horizontal_mirror) | ||
670 | flip_horz_scan_dir = !flip_horz_scan_dir; | ||
654 | 671 | ||
655 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || | 672 | if (pipe_ctx->plane_state->rotation == ROTATION_ANGLE_90 || |
656 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) { | 673 | pipe_ctx->plane_state->rotation == ROTATION_ANGLE_270) { |
@@ -715,7 +732,7 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
715 | } | 732 | } |
716 | 733 | ||
717 | /* Adjust for non-0 viewport offset */ | 734 | /* Adjust for non-0 viewport offset */ |
718 | if (data->viewport.x) { | 735 | if (data->viewport.x && !flip_horz_scan_dir) { |
719 | int int_part; | 736 | int int_part; |
720 | 737 | ||
721 | data->inits.h = dal_fixed31_32_add(data->inits.h, dal_fixed31_32_mul_int( | 738 | data->inits.h = dal_fixed31_32_add(data->inits.h, dal_fixed31_32_mul_int( |
@@ -736,7 +753,7 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
736 | data->inits.h = dal_fixed31_32_add_int(data->inits.h, int_part); | 753 | data->inits.h = dal_fixed31_32_add_int(data->inits.h, int_part); |
737 | } | 754 | } |
738 | 755 | ||
739 | if (data->viewport_c.x) { | 756 | if (data->viewport_c.x && !flip_horz_scan_dir) { |
740 | int int_part; | 757 | int int_part; |
741 | 758 | ||
742 | data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_mul_int( | 759 | data->inits.h_c = dal_fixed31_32_add(data->inits.h_c, dal_fixed31_32_mul_int( |
@@ -757,7 +774,7 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
757 | data->inits.h_c = dal_fixed31_32_add_int(data->inits.h_c, int_part); | 774 | data->inits.h_c = dal_fixed31_32_add_int(data->inits.h_c, int_part); |
758 | } | 775 | } |
759 | 776 | ||
760 | if (data->viewport.y) { | 777 | if (data->viewport.y && !flip_vert_scan_dir) { |
761 | int int_part; | 778 | int int_part; |
762 | 779 | ||
763 | data->inits.v = dal_fixed31_32_add(data->inits.v, dal_fixed31_32_mul_int( | 780 | data->inits.v = dal_fixed31_32_add(data->inits.v, dal_fixed31_32_mul_int( |
@@ -778,7 +795,7 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r | |||
778 | data->inits.v = dal_fixed31_32_add_int(data->inits.v, int_part); | 795 | data->inits.v = dal_fixed31_32_add_int(data->inits.v, int_part); |
779 | } | 796 | } |
780 | 797 | ||
781 | if (data->viewport_c.y) { | 798 | if (data->viewport_c.y && !flip_vert_scan_dir) { |
782 | int int_part; | 799 | int int_part; |
783 | 800 | ||
784 | data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_mul_int( | 801 | data->inits.v_c = dal_fixed31_32_add(data->inits.v_c, dal_fixed31_32_mul_int( |
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index 375fb457e223..261811e0c094 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c | |||
@@ -226,7 +226,7 @@ bool dc_stream_set_cursor_attributes( | |||
226 | if (pipe_ctx->plane_res.dpp != NULL && | 226 | if (pipe_ctx->plane_res.dpp != NULL && |
227 | pipe_ctx->plane_res.dpp->funcs->set_cursor_attributes != NULL) | 227 | pipe_ctx->plane_res.dpp->funcs->set_cursor_attributes != NULL) |
228 | pipe_ctx->plane_res.dpp->funcs->set_cursor_attributes( | 228 | pipe_ctx->plane_res.dpp->funcs->set_cursor_attributes( |
229 | pipe_ctx->plane_res.dpp, attributes); | 229 | pipe_ctx->plane_res.dpp, attributes->color_format); |
230 | } | 230 | } |
231 | 231 | ||
232 | stream->cursor_attributes = *attributes; | 232 | stream->cursor_attributes = *attributes; |
@@ -301,6 +301,8 @@ bool dc_stream_set_cursor_position( | |||
301 | 301 | ||
302 | } | 302 | } |
303 | 303 | ||
304 | stream->cursor_position = *position; | ||
305 | |||
304 | return true; | 306 | return true; |
305 | } | 307 | } |
306 | 308 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index c99ed85ba9a2..e2e3c9df79ea 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "inc/compressor.h" | 38 | #include "inc/compressor.h" |
39 | #include "dml/display_mode_lib.h" | 39 | #include "dml/display_mode_lib.h" |
40 | 40 | ||
41 | #define DC_VER "3.1.20" | 41 | #define DC_VER "3.1.27" |
42 | 42 | ||
43 | #define MAX_SURFACES 3 | 43 | #define MAX_SURFACES 3 |
44 | #define MAX_STREAMS 6 | 44 | #define MAX_STREAMS 6 |
@@ -250,6 +250,8 @@ struct dc { | |||
250 | */ | 250 | */ |
251 | struct dm_pp_display_configuration prev_display_config; | 251 | struct dm_pp_display_configuration prev_display_config; |
252 | 252 | ||
253 | bool optimized_required; | ||
254 | |||
253 | /* FBC compressor */ | 255 | /* FBC compressor */ |
254 | #if defined(CONFIG_DRM_AMD_DC_FBC) | 256 | #if defined(CONFIG_DRM_AMD_DC_FBC) |
255 | struct compressor *fbc_compressor; | 257 | struct compressor *fbc_compressor; |
@@ -340,7 +342,7 @@ struct dc_hdr_static_metadata { | |||
340 | enum dc_transfer_func_type { | 342 | enum dc_transfer_func_type { |
341 | TF_TYPE_PREDEFINED, | 343 | TF_TYPE_PREDEFINED, |
342 | TF_TYPE_DISTRIBUTED_POINTS, | 344 | TF_TYPE_DISTRIBUTED_POINTS, |
343 | TF_TYPE_BYPASS | 345 | TF_TYPE_BYPASS, |
344 | }; | 346 | }; |
345 | 347 | ||
346 | struct dc_transfer_func_distributed_points { | 348 | struct dc_transfer_func_distributed_points { |
@@ -359,6 +361,7 @@ enum dc_transfer_func_predefined { | |||
359 | TRANSFER_FUNCTION_BT709, | 361 | TRANSFER_FUNCTION_BT709, |
360 | TRANSFER_FUNCTION_PQ, | 362 | TRANSFER_FUNCTION_PQ, |
361 | TRANSFER_FUNCTION_LINEAR, | 363 | TRANSFER_FUNCTION_LINEAR, |
364 | TRANSFER_FUNCTION_UNITY, | ||
362 | }; | 365 | }; |
363 | 366 | ||
364 | struct dc_transfer_func { | 367 | struct dc_transfer_func { |
@@ -385,6 +388,7 @@ union surface_update_flags { | |||
385 | 388 | ||
386 | struct { | 389 | struct { |
387 | /* Medium updates */ | 390 | /* Medium updates */ |
391 | uint32_t dcc_change:1; | ||
388 | uint32_t color_space_change:1; | 392 | uint32_t color_space_change:1; |
389 | uint32_t input_tf_change:1; | 393 | uint32_t input_tf_change:1; |
390 | uint32_t horizontal_mirror_change:1; | 394 | uint32_t horizontal_mirror_change:1; |
@@ -436,6 +440,7 @@ struct dc_plane_state { | |||
436 | enum dc_rotation_angle rotation; | 440 | enum dc_rotation_angle rotation; |
437 | enum plane_stereo_format stereo_format; | 441 | enum plane_stereo_format stereo_format; |
438 | 442 | ||
443 | bool is_tiling_rotated; | ||
439 | bool per_pixel_alpha; | 444 | bool per_pixel_alpha; |
440 | bool visible; | 445 | bool visible; |
441 | bool flip_immediate; | 446 | bool flip_immediate; |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h index 587c0bb3d4ac..03029f72dc3f 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h | |||
@@ -579,8 +579,6 @@ enum dc_timing_standard { | |||
579 | TIMING_STANDARD_MAX | 579 | TIMING_STANDARD_MAX |
580 | }; | 580 | }; |
581 | 581 | ||
582 | |||
583 | |||
584 | enum dc_color_depth { | 582 | enum dc_color_depth { |
585 | COLOR_DEPTH_UNDEFINED, | 583 | COLOR_DEPTH_UNDEFINED, |
586 | COLOR_DEPTH_666, | 584 | COLOR_DEPTH_666, |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h index fed0e5ea9625..01c60f11b2bd 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_stream.h +++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h | |||
@@ -86,6 +86,7 @@ struct dc_stream_state { | |||
86 | struct dc_stream_status status; | 86 | struct dc_stream_status status; |
87 | 87 | ||
88 | struct dc_cursor_attributes cursor_attributes; | 88 | struct dc_cursor_attributes cursor_attributes; |
89 | struct dc_cursor_position cursor_position; | ||
89 | 90 | ||
90 | /* from stream struct */ | 91 | /* from stream struct */ |
91 | struct kref refcount; | 92 | struct kref refcount; |
diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h index 9291a60126ad..9faddfae241d 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_types.h +++ b/drivers/gpu/drm/amd/display/dc/dc_types.h | |||
@@ -218,6 +218,7 @@ struct dc_edid_caps { | |||
218 | bool lte_340mcsc_scramble; | 218 | bool lte_340mcsc_scramble; |
219 | 219 | ||
220 | bool edid_hdmi; | 220 | bool edid_hdmi; |
221 | bool hdr_supported; | ||
221 | }; | 222 | }; |
222 | 223 | ||
223 | struct view { | 224 | struct view { |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c index 3fe8e697483f..b48190f54907 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.c | |||
@@ -385,21 +385,12 @@ static bool dce_abm_init_backlight(struct abm *abm) | |||
385 | return true; | 385 | return true; |
386 | } | 386 | } |
387 | 387 | ||
388 | static bool is_dmcu_initialized(struct abm *abm) | ||
389 | { | ||
390 | struct dce_abm *abm_dce = TO_DCE_ABM(abm); | ||
391 | unsigned int dmcu_uc_reset; | ||
392 | |||
393 | REG_GET(DMCU_STATUS, UC_IN_RESET, &dmcu_uc_reset); | ||
394 | |||
395 | return !dmcu_uc_reset; | ||
396 | } | ||
397 | |||
398 | static bool dce_abm_set_backlight_level( | 388 | static bool dce_abm_set_backlight_level( |
399 | struct abm *abm, | 389 | struct abm *abm, |
400 | unsigned int backlight_level, | 390 | unsigned int backlight_level, |
401 | unsigned int frame_ramp, | 391 | unsigned int frame_ramp, |
402 | unsigned int controller_id) | 392 | unsigned int controller_id, |
393 | bool use_smooth_brightness) | ||
403 | { | 394 | { |
404 | struct dce_abm *abm_dce = TO_DCE_ABM(abm); | 395 | struct dce_abm *abm_dce = TO_DCE_ABM(abm); |
405 | 396 | ||
@@ -408,7 +399,7 @@ static bool dce_abm_set_backlight_level( | |||
408 | backlight_level, backlight_level); | 399 | backlight_level, backlight_level); |
409 | 400 | ||
410 | /* If DMCU is in reset state, DMCU is uninitialized */ | 401 | /* If DMCU is in reset state, DMCU is uninitialized */ |
411 | if (is_dmcu_initialized(abm)) | 402 | if (use_smooth_brightness) |
412 | dmcu_set_backlight_level(abm_dce, | 403 | dmcu_set_backlight_level(abm_dce, |
413 | backlight_level, | 404 | backlight_level, |
414 | frame_ramp, | 405 | frame_ramp, |
@@ -425,8 +416,7 @@ static const struct abm_funcs dce_funcs = { | |||
425 | .init_backlight = dce_abm_init_backlight, | 416 | .init_backlight = dce_abm_init_backlight, |
426 | .set_backlight_level = dce_abm_set_backlight_level, | 417 | .set_backlight_level = dce_abm_set_backlight_level, |
427 | .get_current_backlight_8_bit = dce_abm_get_current_backlight_8_bit, | 418 | .get_current_backlight_8_bit = dce_abm_get_current_backlight_8_bit, |
428 | .set_abm_immediate_disable = dce_abm_immediate_disable, | 419 | .set_abm_immediate_disable = dce_abm_immediate_disable |
429 | .is_dmcu_initialized = is_dmcu_initialized | ||
430 | }; | 420 | }; |
431 | 421 | ||
432 | static void dce_abm_construct( | 422 | static void dce_abm_construct( |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.h b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.h index 59e909ec88f2..ff9436966041 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_abm.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_abm.h | |||
@@ -37,8 +37,7 @@ | |||
37 | SR(LVTMA_PWRSEQ_REF_DIV), \ | 37 | SR(LVTMA_PWRSEQ_REF_DIV), \ |
38 | SR(MASTER_COMM_CNTL_REG), \ | 38 | SR(MASTER_COMM_CNTL_REG), \ |
39 | SR(MASTER_COMM_CMD_REG), \ | 39 | SR(MASTER_COMM_CMD_REG), \ |
40 | SR(MASTER_COMM_DATA_REG1), \ | 40 | SR(MASTER_COMM_DATA_REG1) |
41 | SR(DMCU_STATUS) | ||
42 | 41 | ||
43 | #define ABM_DCE110_COMMON_REG_LIST() \ | 42 | #define ABM_DCE110_COMMON_REG_LIST() \ |
44 | ABM_COMMON_REG_LIST_DCE_BASE(), \ | 43 | ABM_COMMON_REG_LIST_DCE_BASE(), \ |
@@ -84,8 +83,7 @@ | |||
84 | ABM_SF(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, mask_sh), \ | 83 | ABM_SF(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, mask_sh), \ |
85 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0, mask_sh), \ | 84 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE0, mask_sh), \ |
86 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE1, mask_sh), \ | 85 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE1, mask_sh), \ |
87 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE2, mask_sh), \ | 86 | ABM_SF(MASTER_COMM_CMD_REG, MASTER_COMM_CMD_REG_BYTE2, mask_sh) |
88 | ABM_SF(DMCU_STATUS, UC_IN_RESET, mask_sh) | ||
89 | 87 | ||
90 | #define ABM_MASK_SH_LIST_DCE110(mask_sh) \ | 88 | #define ABM_MASK_SH_LIST_DCE110(mask_sh) \ |
91 | ABM_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh), \ | 89 | ABM_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh), \ |
@@ -174,7 +172,6 @@ | |||
174 | type MASTER_COMM_CMD_REG_BYTE2; \ | 172 | type MASTER_COMM_CMD_REG_BYTE2; \ |
175 | type BL_PWM_REF_DIV; \ | 173 | type BL_PWM_REF_DIV; \ |
176 | type BL_PWM_EN; \ | 174 | type BL_PWM_EN; \ |
177 | type UC_IN_RESET; \ | ||
178 | type BL_PWM_GRP1_IGNORE_MASTER_LOCK_EN; \ | 175 | type BL_PWM_GRP1_IGNORE_MASTER_LOCK_EN; \ |
179 | type BL_PWM_GRP1_REG_LOCK; \ | 176 | type BL_PWM_GRP1_REG_LOCK; \ |
180 | type BL_PWM_GRP1_REG_UPDATE_PENDING | 177 | type BL_PWM_GRP1_REG_UPDATE_PENDING |
@@ -206,7 +203,6 @@ struct dce_abm_registers { | |||
206 | uint32_t MASTER_COMM_CMD_REG; | 203 | uint32_t MASTER_COMM_CMD_REG; |
207 | uint32_t MASTER_COMM_DATA_REG1; | 204 | uint32_t MASTER_COMM_DATA_REG1; |
208 | uint32_t BIOS_SCRATCH_2; | 205 | uint32_t BIOS_SCRATCH_2; |
209 | uint32_t DMCU_STATUS; | ||
210 | uint32_t BL_PWM_GRP1_REG_LOCK; | 206 | uint32_t BL_PWM_GRP1_REG_LOCK; |
211 | }; | 207 | }; |
212 | 208 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c index 9031d22285ea..9e98a5f39a6d 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include "fixed32_32.h" | 29 | #include "fixed32_32.h" |
30 | #include "bios_parser_interface.h" | 30 | #include "bios_parser_interface.h" |
31 | #include "dc.h" | 31 | #include "dc.h" |
32 | #include "dce_abm.h" | ||
33 | #include "dmcu.h" | 32 | #include "dmcu.h" |
34 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 33 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
35 | #include "dcn_calcs.h" | 34 | #include "dcn_calcs.h" |
@@ -384,7 +383,6 @@ static int dce112_set_clock( | |||
384 | struct bp_set_dce_clock_parameters dce_clk_params; | 383 | struct bp_set_dce_clock_parameters dce_clk_params; |
385 | struct dc_bios *bp = clk->ctx->dc_bios; | 384 | struct dc_bios *bp = clk->ctx->dc_bios; |
386 | struct dc *core_dc = clk->ctx->dc; | 385 | struct dc *core_dc = clk->ctx->dc; |
387 | struct abm *abm = core_dc->res_pool->abm; | ||
388 | struct dmcu *dmcu = core_dc->res_pool->dmcu; | 386 | struct dmcu *dmcu = core_dc->res_pool->dmcu; |
389 | int actual_clock = requested_clk_khz; | 387 | int actual_clock = requested_clk_khz; |
390 | /* Prepare to program display clock*/ | 388 | /* Prepare to program display clock*/ |
@@ -417,7 +415,7 @@ static int dce112_set_clock( | |||
417 | 415 | ||
418 | bp->funcs->set_dce_clock(bp, &dce_clk_params); | 416 | bp->funcs->set_dce_clock(bp, &dce_clk_params); |
419 | 417 | ||
420 | if (abm->funcs->is_dmcu_initialized(abm) && clk_dce->dfs_bypass_disp_clk != actual_clock) | 418 | if (clk_dce->dfs_bypass_disp_clk != actual_clock) |
421 | dmcu->funcs->set_psr_wait_loop(dmcu, | 419 | dmcu->funcs->set_psr_wait_loop(dmcu, |
422 | actual_clock / 1000 / 7); | 420 | actual_clock / 1000 / 7); |
423 | clk_dce->dfs_bypass_disp_clk = actual_clock; | 421 | clk_dce->dfs_bypass_disp_clk = actual_clock; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c index a6de99db0444..f663adb33584 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | |||
@@ -263,15 +263,35 @@ static void dce_dmcu_setup_psr(struct dmcu *dmcu, | |||
263 | REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1); | 263 | REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1); |
264 | } | 264 | } |
265 | 265 | ||
266 | static bool dce_is_dmcu_initialized(struct dmcu *dmcu) | ||
267 | { | ||
268 | struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu); | ||
269 | unsigned int dmcu_uc_reset; | ||
270 | |||
271 | /* microcontroller is not running */ | ||
272 | REG_GET(DMCU_STATUS, UC_IN_RESET, &dmcu_uc_reset); | ||
273 | |||
274 | /* DMCU is not running */ | ||
275 | if (dmcu_uc_reset) | ||
276 | return false; | ||
277 | |||
278 | return true; | ||
279 | } | ||
280 | |||
266 | static void dce_psr_wait_loop( | 281 | static void dce_psr_wait_loop( |
267 | struct dmcu *dmcu, | 282 | struct dmcu *dmcu, |
268 | unsigned int wait_loop_number) | 283 | unsigned int wait_loop_number) |
269 | { | 284 | { |
270 | struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu); | 285 | struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu); |
271 | union dce_dmcu_psr_config_data_wait_loop_reg1 masterCmdData1; | 286 | union dce_dmcu_psr_config_data_wait_loop_reg1 masterCmdData1; |
287 | |||
272 | if (dmcu->cached_wait_loop_number == wait_loop_number) | 288 | if (dmcu->cached_wait_loop_number == wait_loop_number) |
273 | return; | 289 | return; |
274 | 290 | ||
291 | /* DMCU is not running */ | ||
292 | if (!dce_is_dmcu_initialized(dmcu)) | ||
293 | return; | ||
294 | |||
275 | /* waitDMCUReadyForCmd */ | 295 | /* waitDMCUReadyForCmd */ |
276 | REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 1, 10000); | 296 | REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0, 1, 10000); |
277 | 297 | ||
@@ -691,6 +711,14 @@ static void dcn10_get_psr_wait_loop( | |||
691 | return; | 711 | return; |
692 | } | 712 | } |
693 | 713 | ||
714 | static bool dcn10_is_dmcu_initialized(struct dmcu *dmcu) | ||
715 | { | ||
716 | /* microcontroller is not running */ | ||
717 | if (dmcu->dmcu_state != DMCU_RUNNING) | ||
718 | return false; | ||
719 | return true; | ||
720 | } | ||
721 | |||
694 | #endif | 722 | #endif |
695 | 723 | ||
696 | static const struct dmcu_funcs dce_funcs = { | 724 | static const struct dmcu_funcs dce_funcs = { |
@@ -700,7 +728,8 @@ static const struct dmcu_funcs dce_funcs = { | |||
700 | .setup_psr = dce_dmcu_setup_psr, | 728 | .setup_psr = dce_dmcu_setup_psr, |
701 | .get_psr_state = dce_get_dmcu_psr_state, | 729 | .get_psr_state = dce_get_dmcu_psr_state, |
702 | .set_psr_wait_loop = dce_psr_wait_loop, | 730 | .set_psr_wait_loop = dce_psr_wait_loop, |
703 | .get_psr_wait_loop = dce_get_psr_wait_loop | 731 | .get_psr_wait_loop = dce_get_psr_wait_loop, |
732 | .is_dmcu_initialized = dce_is_dmcu_initialized | ||
704 | }; | 733 | }; |
705 | 734 | ||
706 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | 735 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
@@ -711,7 +740,8 @@ static const struct dmcu_funcs dcn10_funcs = { | |||
711 | .setup_psr = dcn10_dmcu_setup_psr, | 740 | .setup_psr = dcn10_dmcu_setup_psr, |
712 | .get_psr_state = dcn10_get_dmcu_psr_state, | 741 | .get_psr_state = dcn10_get_dmcu_psr_state, |
713 | .set_psr_wait_loop = dcn10_psr_wait_loop, | 742 | .set_psr_wait_loop = dcn10_psr_wait_loop, |
714 | .get_psr_wait_loop = dcn10_get_psr_wait_loop | 743 | .get_psr_wait_loop = dcn10_get_psr_wait_loop, |
744 | .is_dmcu_initialized = dcn10_is_dmcu_initialized | ||
715 | }; | 745 | }; |
716 | #endif | 746 | #endif |
717 | 747 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h index 4c25e2dd28f8..1d4546f23135 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h | |||
@@ -62,6 +62,8 @@ | |||
62 | DMCU_ENABLE, mask_sh), \ | 62 | DMCU_ENABLE, mask_sh), \ |
63 | DMCU_SF(DMCU_STATUS, \ | 63 | DMCU_SF(DMCU_STATUS, \ |
64 | UC_IN_STOP_MODE, mask_sh), \ | 64 | UC_IN_STOP_MODE, mask_sh), \ |
65 | DMCU_SF(DMCU_STATUS, \ | ||
66 | UC_IN_RESET, mask_sh), \ | ||
65 | DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ | 67 | DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ |
66 | IRAM_HOST_ACCESS_EN, mask_sh), \ | 68 | IRAM_HOST_ACCESS_EN, mask_sh), \ |
67 | DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ | 69 | DMCU_SF(DMCU_RAM_ACCESS_CTRL, \ |
@@ -98,6 +100,7 @@ | |||
98 | type IRAM_RD_ADDR_AUTO_INC; \ | 100 | type IRAM_RD_ADDR_AUTO_INC; \ |
99 | type DMCU_ENABLE; \ | 101 | type DMCU_ENABLE; \ |
100 | type UC_IN_STOP_MODE; \ | 102 | type UC_IN_STOP_MODE; \ |
103 | type UC_IN_RESET; \ | ||
101 | type MASTER_COMM_CMD_REG_BYTE0; \ | 104 | type MASTER_COMM_CMD_REG_BYTE0; \ |
102 | type MASTER_COMM_INTERRUPT; \ | 105 | type MASTER_COMM_INTERRUPT; \ |
103 | type DPHY_RX_FAST_TRAINING_CAPABLE; \ | 106 | type DPHY_RX_FAST_TRAINING_CAPABLE; \ |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h index 3b0db253ac22..b73db9e78437 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h | |||
@@ -582,7 +582,8 @@ struct dce_hwseq_registers { | |||
582 | type DOMAIN7_PGFSM_PWR_STATUS; \ | 582 | type DOMAIN7_PGFSM_PWR_STATUS; \ |
583 | type DCFCLK_GATE_DIS; \ | 583 | type DCFCLK_GATE_DIS; \ |
584 | type DCHUBBUB_GLOBAL_TIMER_REFDIV; \ | 584 | type DCHUBBUB_GLOBAL_TIMER_REFDIV; \ |
585 | type DENTIST_DPPCLK_WDIVIDER; | 585 | type DENTIST_DPPCLK_WDIVIDER; \ |
586 | type DENTIST_DISPCLK_WDIVIDER; | ||
586 | 587 | ||
587 | struct dce_hwseq_shift { | 588 | struct dce_hwseq_shift { |
588 | HWSEQ_REG_FIELD_LIST(uint8_t) | 589 | HWSEQ_REG_FIELD_LIST(uint8_t) |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c index bad70c6b3aad..a266e3f5e75f 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c | |||
@@ -1072,21 +1072,6 @@ void dce110_link_encoder_disable_output( | |||
1072 | /* disable encoder */ | 1072 | /* disable encoder */ |
1073 | if (dc_is_dp_signal(signal)) | 1073 | if (dc_is_dp_signal(signal)) |
1074 | link_encoder_disable(enc110); | 1074 | link_encoder_disable(enc110); |
1075 | |||
1076 | /* | ||
1077 | * TODO: Power control cause regression, we should implement | ||
1078 | * it properly, for now just comment it. | ||
1079 | */ | ||
1080 | // if (enc110->base.connector.id == CONNECTOR_ID_EDP) { | ||
1081 | // /* power down eDP panel */ | ||
1082 | // link_encoder_edp_wait_for_hpd_ready( | ||
1083 | // enc, | ||
1084 | // enc->connector, | ||
1085 | // false); | ||
1086 | // | ||
1087 | // link_encoder_edp_power_control( | ||
1088 | // enc, false); | ||
1089 | // } | ||
1090 | } | 1075 | } |
1091 | 1076 | ||
1092 | void dce110_link_encoder_dp_set_lane_settings( | 1077 | void dce110_link_encoder_dp_set_lane_settings( |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c index e650bdcd9423..86cdd7b4811f 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | |||
@@ -354,8 +354,8 @@ static bool convert_to_custom_float(struct pwl_result_data *rgb_resulted, | |||
354 | return false; | 354 | return false; |
355 | } | 355 | } |
356 | 356 | ||
357 | if (!convert_to_custom_float_format(arr_points[2].slope, &fmt, | 357 | if (!convert_to_custom_float_format(arr_points[1].slope, &fmt, |
358 | &arr_points[2].custom_float_slope)) { | 358 | &arr_points[1].custom_float_slope)) { |
359 | BREAK_TO_DEBUGGER(); | 359 | BREAK_TO_DEBUGGER(); |
360 | return false; | 360 | return false; |
361 | } | 361 | } |
@@ -870,8 +870,6 @@ void hwss_edp_power_control( | |||
870 | "%s: Skipping Panel Power action: %s\n", | 870 | "%s: Skipping Panel Power action: %s\n", |
871 | __func__, (power_up ? "On":"Off")); | 871 | __func__, (power_up ? "On":"Off")); |
872 | } | 872 | } |
873 | |||
874 | hwss_edp_wait_for_hpd_ready(link, true); | ||
875 | } | 873 | } |
876 | 874 | ||
877 | /*todo: cloned in stream enc, fix*/ | 875 | /*todo: cloned in stream enc, fix*/ |
@@ -972,11 +970,9 @@ void dce110_disable_stream(struct pipe_ctx *pipe_ctx, int option) | |||
972 | } | 970 | } |
973 | 971 | ||
974 | /* blank at encoder level */ | 972 | /* blank at encoder level */ |
975 | if (dc_is_dp_signal(pipe_ctx->stream->signal)) { | 973 | if (dc_is_dp_signal(pipe_ctx->stream->signal)) |
976 | if (pipe_ctx->stream->sink->link->connector_signal == SIGNAL_TYPE_EDP) | ||
977 | hwss_edp_backlight_control(link, false); | ||
978 | pipe_ctx->stream_res.stream_enc->funcs->dp_blank(pipe_ctx->stream_res.stream_enc); | 974 | pipe_ctx->stream_res.stream_enc->funcs->dp_blank(pipe_ctx->stream_res.stream_enc); |
979 | } | 975 | |
980 | link->link_enc->funcs->connect_dig_be_to_fe( | 976 | link->link_enc->funcs->connect_dig_be_to_fe( |
981 | link->link_enc, | 977 | link->link_enc, |
982 | pipe_ctx->stream_res.stream_enc->id, | 978 | pipe_ctx->stream_res.stream_enc->id, |
@@ -988,15 +984,12 @@ void dce110_unblank_stream(struct pipe_ctx *pipe_ctx, | |||
988 | struct dc_link_settings *link_settings) | 984 | struct dc_link_settings *link_settings) |
989 | { | 985 | { |
990 | struct encoder_unblank_param params = { { 0 } }; | 986 | struct encoder_unblank_param params = { { 0 } }; |
991 | struct dc_link *link = pipe_ctx->stream->sink->link; | ||
992 | 987 | ||
993 | /* only 3 items below are used by unblank */ | 988 | /* only 3 items below are used by unblank */ |
994 | params.pixel_clk_khz = | 989 | params.pixel_clk_khz = |
995 | pipe_ctx->stream->timing.pix_clk_khz; | 990 | pipe_ctx->stream->timing.pix_clk_khz; |
996 | params.link_settings.link_rate = link_settings->link_rate; | 991 | params.link_settings.link_rate = link_settings->link_rate; |
997 | pipe_ctx->stream_res.stream_enc->funcs->dp_unblank(pipe_ctx->stream_res.stream_enc, ¶ms); | 992 | pipe_ctx->stream_res.stream_enc->funcs->dp_unblank(pipe_ctx->stream_res.stream_enc, ¶ms); |
998 | if (link->connector_signal == SIGNAL_TYPE_EDP) | ||
999 | hwss_edp_backlight_control(link, true); | ||
1000 | } | 993 | } |
1001 | 994 | ||
1002 | 995 | ||
@@ -1342,10 +1335,8 @@ static void power_down_encoders(struct dc *dc) | |||
1342 | 1335 | ||
1343 | if (!dc->links[i]->wa_flags.dp_keep_receiver_powered) | 1336 | if (!dc->links[i]->wa_flags.dp_keep_receiver_powered) |
1344 | dp_receiver_power_ctrl(dc->links[i], false); | 1337 | dp_receiver_power_ctrl(dc->links[i], false); |
1345 | if (connector_id == CONNECTOR_ID_EDP) { | 1338 | if (connector_id == CONNECTOR_ID_EDP) |
1346 | signal = SIGNAL_TYPE_EDP; | 1339 | signal = SIGNAL_TYPE_EDP; |
1347 | hwss_edp_backlight_control(dc->links[i], false); | ||
1348 | } | ||
1349 | } | 1340 | } |
1350 | 1341 | ||
1351 | dc->links[i]->link_enc->funcs->disable_output( | 1342 | dc->links[i]->link_enc->funcs->disable_output( |
@@ -1698,60 +1689,54 @@ static void apply_min_clocks( | |||
1698 | /* | 1689 | /* |
1699 | * Check if FBC can be enabled | 1690 | * Check if FBC can be enabled |
1700 | */ | 1691 | */ |
1701 | static enum dc_status validate_fbc(struct dc *dc, | 1692 | static bool should_enable_fbc(struct dc *dc, |
1702 | struct dc_state *context) | 1693 | struct dc_state *context) |
1703 | { | 1694 | { |
1704 | struct pipe_ctx *pipe_ctx = | 1695 | struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[0]; |
1705 | &context->res_ctx.pipe_ctx[0]; | ||
1706 | 1696 | ||
1707 | ASSERT(dc->fbc_compressor); | 1697 | ASSERT(dc->fbc_compressor); |
1708 | 1698 | ||
1709 | /* FBC memory should be allocated */ | 1699 | /* FBC memory should be allocated */ |
1710 | if (!dc->ctx->fbc_gpu_addr) | 1700 | if (!dc->ctx->fbc_gpu_addr) |
1711 | return DC_ERROR_UNEXPECTED; | 1701 | return false; |
1712 | 1702 | ||
1713 | /* Only supports single display */ | 1703 | /* Only supports single display */ |
1714 | if (context->stream_count != 1) | 1704 | if (context->stream_count != 1) |
1715 | return DC_ERROR_UNEXPECTED; | 1705 | return false; |
1716 | 1706 | ||
1717 | /* Only supports eDP */ | 1707 | /* Only supports eDP */ |
1718 | if (pipe_ctx->stream->sink->link->connector_signal != SIGNAL_TYPE_EDP) | 1708 | if (pipe_ctx->stream->sink->link->connector_signal != SIGNAL_TYPE_EDP) |
1719 | return DC_ERROR_UNEXPECTED; | 1709 | return false; |
1720 | 1710 | ||
1721 | /* PSR should not be enabled */ | 1711 | /* PSR should not be enabled */ |
1722 | if (pipe_ctx->stream->sink->link->psr_enabled) | 1712 | if (pipe_ctx->stream->sink->link->psr_enabled) |
1723 | return DC_ERROR_UNEXPECTED; | 1713 | return false; |
1724 | 1714 | ||
1725 | /* Nothing to compress */ | 1715 | /* Nothing to compress */ |
1726 | if (!pipe_ctx->plane_state) | 1716 | if (!pipe_ctx->plane_state) |
1727 | return DC_ERROR_UNEXPECTED; | 1717 | return false; |
1728 | 1718 | ||
1729 | /* Only for non-linear tiling */ | 1719 | /* Only for non-linear tiling */ |
1730 | if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL) | 1720 | if (pipe_ctx->plane_state->tiling_info.gfx8.array_mode == DC_ARRAY_LINEAR_GENERAL) |
1731 | return DC_ERROR_UNEXPECTED; | 1721 | return false; |
1732 | 1722 | ||
1733 | return DC_OK; | 1723 | return true; |
1734 | } | 1724 | } |
1735 | 1725 | ||
1736 | /* | 1726 | /* |
1737 | * Enable FBC | 1727 | * Enable FBC |
1738 | */ | 1728 | */ |
1739 | static enum dc_status enable_fbc(struct dc *dc, | 1729 | static void enable_fbc(struct dc *dc, |
1740 | struct dc_state *context) | 1730 | struct dc_state *context) |
1741 | { | 1731 | { |
1742 | enum dc_status status = validate_fbc(dc, context); | 1732 | if (should_enable_fbc(dc, context)) { |
1743 | |||
1744 | if (status == DC_OK) { | ||
1745 | /* Program GRPH COMPRESSED ADDRESS and PITCH */ | 1733 | /* Program GRPH COMPRESSED ADDRESS and PITCH */ |
1746 | struct compr_addr_and_pitch_params params = {0, 0, 0}; | 1734 | struct compr_addr_and_pitch_params params = {0, 0, 0}; |
1747 | struct compressor *compr = dc->fbc_compressor; | 1735 | struct compressor *compr = dc->fbc_compressor; |
1748 | struct pipe_ctx *pipe_ctx = | 1736 | struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[0]; |
1749 | &context->res_ctx.pipe_ctx[0]; | ||
1750 | 1737 | ||
1751 | params.source_view_width = | 1738 | params.source_view_width = pipe_ctx->stream->timing.h_addressable; |
1752 | pipe_ctx->stream->timing.h_addressable; | 1739 | params.source_view_height = pipe_ctx->stream->timing.v_addressable; |
1753 | params.source_view_height = | ||
1754 | pipe_ctx->stream->timing.v_addressable; | ||
1755 | 1740 | ||
1756 | compr->compr_surface_address.quad_part = dc->ctx->fbc_gpu_addr; | 1741 | compr->compr_surface_address.quad_part = dc->ctx->fbc_gpu_addr; |
1757 | 1742 | ||
@@ -1760,7 +1745,6 @@ static enum dc_status enable_fbc(struct dc *dc, | |||
1760 | 1745 | ||
1761 | compr->funcs->enable_fbc(compr, ¶ms); | 1746 | compr->funcs->enable_fbc(compr, ¶ms); |
1762 | } | 1747 | } |
1763 | return status; | ||
1764 | } | 1748 | } |
1765 | #endif | 1749 | #endif |
1766 | 1750 | ||
@@ -2026,8 +2010,7 @@ enum dc_status dce110_apply_ctx_to_hw( | |||
2026 | if (pipe_ctx->stream == pipe_ctx_old->stream) | 2010 | if (pipe_ctx->stream == pipe_ctx_old->stream) |
2027 | continue; | 2011 | continue; |
2028 | 2012 | ||
2029 | if (pipe_ctx->stream && pipe_ctx_old->stream | 2013 | if (pipe_ctx_old->stream && !pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) |
2030 | && !pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) | ||
2031 | continue; | 2014 | continue; |
2032 | 2015 | ||
2033 | if (pipe_ctx->top_pipe) | 2016 | if (pipe_ctx->top_pipe) |
@@ -2063,9 +2046,6 @@ enum dc_status dce110_apply_ctx_to_hw( | |||
2063 | context, | 2046 | context, |
2064 | dc); | 2047 | dc); |
2065 | 2048 | ||
2066 | if (dc->hwss.enable_plane) | ||
2067 | dc->hwss.enable_plane(dc, pipe_ctx, context); | ||
2068 | |||
2069 | if (DC_OK != status) | 2049 | if (DC_OK != status) |
2070 | return status; | 2050 | return status; |
2071 | } | 2051 | } |
@@ -2095,16 +2075,8 @@ static void set_default_colors(struct pipe_ctx *pipe_ctx) | |||
2095 | struct default_adjustment default_adjust = { 0 }; | 2075 | struct default_adjustment default_adjust = { 0 }; |
2096 | 2076 | ||
2097 | default_adjust.force_hw_default = false; | 2077 | default_adjust.force_hw_default = false; |
2098 | if (pipe_ctx->plane_state == NULL) | 2078 | default_adjust.in_color_space = pipe_ctx->plane_state->color_space; |
2099 | default_adjust.in_color_space = COLOR_SPACE_SRGB; | 2079 | default_adjust.out_color_space = pipe_ctx->stream->output_color_space; |
2100 | else | ||
2101 | default_adjust.in_color_space = | ||
2102 | pipe_ctx->plane_state->color_space; | ||
2103 | if (pipe_ctx->stream == NULL) | ||
2104 | default_adjust.out_color_space = COLOR_SPACE_SRGB; | ||
2105 | else | ||
2106 | default_adjust.out_color_space = | ||
2107 | pipe_ctx->stream->output_color_space; | ||
2108 | default_adjust.csc_adjust_type = GRAPHICS_CSC_ADJUST_TYPE_SW; | 2080 | default_adjust.csc_adjust_type = GRAPHICS_CSC_ADJUST_TYPE_SW; |
2109 | default_adjust.surface_pixel_format = pipe_ctx->plane_res.scl_data.format; | 2081 | default_adjust.surface_pixel_format = pipe_ctx->plane_res.scl_data.format; |
2110 | 2082 | ||
@@ -2872,13 +2844,12 @@ static void dce110_apply_ctx_for_surface( | |||
2872 | continue; | 2844 | continue; |
2873 | 2845 | ||
2874 | /* Need to allocate mem before program front end for Fiji */ | 2846 | /* Need to allocate mem before program front end for Fiji */ |
2875 | if (pipe_ctx->plane_res.mi != NULL) | 2847 | pipe_ctx->plane_res.mi->funcs->allocate_mem_input( |
2876 | pipe_ctx->plane_res.mi->funcs->allocate_mem_input( | 2848 | pipe_ctx->plane_res.mi, |
2877 | pipe_ctx->plane_res.mi, | 2849 | pipe_ctx->stream->timing.h_total, |
2878 | pipe_ctx->stream->timing.h_total, | 2850 | pipe_ctx->stream->timing.v_total, |
2879 | pipe_ctx->stream->timing.v_total, | 2851 | pipe_ctx->stream->timing.pix_clk_khz, |
2880 | pipe_ctx->stream->timing.pix_clk_khz, | 2852 | context->stream_count); |
2881 | context->stream_count); | ||
2882 | 2853 | ||
2883 | dce110_program_front_end_for_pipe(dc, pipe_ctx); | 2854 | dce110_program_front_end_for_pipe(dc, pipe_ctx); |
2884 | 2855 | ||
@@ -2985,6 +2956,7 @@ static const struct hw_sequencer_funcs dce110_funcs = { | |||
2985 | .pplib_apply_display_requirements = pplib_apply_display_requirements, | 2956 | .pplib_apply_display_requirements = pplib_apply_display_requirements, |
2986 | .edp_backlight_control = hwss_edp_backlight_control, | 2957 | .edp_backlight_control = hwss_edp_backlight_control, |
2987 | .edp_power_control = hwss_edp_power_control, | 2958 | .edp_power_control = hwss_edp_power_control, |
2959 | .edp_wait_for_hpd_ready = hwss_edp_wait_for_hpd_ready, | ||
2988 | }; | 2960 | }; |
2989 | 2961 | ||
2990 | void dce110_hw_sequencer_construct(struct dc *dc) | 2962 | void dce110_hw_sequencer_construct(struct dc *dc) |
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h index 2dd6ac637572..fc637647f643 100644 --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h | |||
@@ -77,5 +77,9 @@ void hwss_edp_backlight_control( | |||
77 | struct dc_link *link, | 77 | struct dc_link *link, |
78 | bool enable); | 78 | bool enable); |
79 | 79 | ||
80 | void hwss_edp_wait_for_hpd_ready( | ||
81 | struct dc_link *link, | ||
82 | bool power_up); | ||
83 | |||
80 | #endif /* __DC_HWSS_DCE110_H__ */ | 84 | #endif /* __DC_HWSS_DCE110_H__ */ |
81 | 85 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile index 9eac228315b5..5469bdfe19f3 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dcn10/Makefile | |||
@@ -23,7 +23,7 @@ | |||
23 | # Makefile for DCN. | 23 | # Makefile for DCN. |
24 | 24 | ||
25 | DCN10 = dcn10_resource.o dcn10_ipp.o dcn10_hw_sequencer.o \ | 25 | DCN10 = dcn10_resource.o dcn10_ipp.o dcn10_hw_sequencer.o \ |
26 | dcn10_dpp.o dcn10_opp.o dcn10_timing_generator.o \ | 26 | dcn10_dpp.o dcn10_opp.o dcn10_optc.o \ |
27 | dcn10_hubp.o dcn10_mpc.o \ | 27 | dcn10_hubp.o dcn10_mpc.o \ |
28 | dcn10_dpp_dscl.o dcn10_dpp_cm.o dcn10_cm_common.o \ | 28 | dcn10_dpp_dscl.o dcn10_dpp_cm.o dcn10_cm_common.o \ |
29 | dcn10_hubbub.o | 29 | dcn10_hubbub.o |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c index 7f579cb19f4b..53ba3600ee6a 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c | |||
@@ -22,11 +22,12 @@ | |||
22 | * Authors: AMD | 22 | * Authors: AMD |
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | #include "dc.h" | |
26 | #include "reg_helper.h" | 26 | #include "reg_helper.h" |
27 | #include "dcn10_dpp.h" | 27 | #include "dcn10_dpp.h" |
28 | 28 | ||
29 | #include "dcn10_cm_common.h" | 29 | #include "dcn10_cm_common.h" |
30 | #include "custom_float.h" | ||
30 | 31 | ||
31 | #define REG(reg) reg | 32 | #define REG(reg) reg |
32 | 33 | ||
@@ -121,3 +122,294 @@ void cm_helper_program_xfer_func( | |||
121 | } | 122 | } |
122 | 123 | ||
123 | } | 124 | } |
125 | |||
126 | |||
127 | |||
128 | bool cm_helper_convert_to_custom_float( | ||
129 | struct pwl_result_data *rgb_resulted, | ||
130 | struct curve_points *arr_points, | ||
131 | uint32_t hw_points_num, | ||
132 | bool fixpoint) | ||
133 | { | ||
134 | struct custom_float_format fmt; | ||
135 | |||
136 | struct pwl_result_data *rgb = rgb_resulted; | ||
137 | |||
138 | uint32_t i = 0; | ||
139 | |||
140 | fmt.exponenta_bits = 6; | ||
141 | fmt.mantissa_bits = 12; | ||
142 | fmt.sign = false; | ||
143 | |||
144 | if (!convert_to_custom_float_format(arr_points[0].x, &fmt, | ||
145 | &arr_points[0].custom_float_x)) { | ||
146 | BREAK_TO_DEBUGGER(); | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | if (!convert_to_custom_float_format(arr_points[0].offset, &fmt, | ||
151 | &arr_points[0].custom_float_offset)) { | ||
152 | BREAK_TO_DEBUGGER(); | ||
153 | return false; | ||
154 | } | ||
155 | |||
156 | if (!convert_to_custom_float_format(arr_points[0].slope, &fmt, | ||
157 | &arr_points[0].custom_float_slope)) { | ||
158 | BREAK_TO_DEBUGGER(); | ||
159 | return false; | ||
160 | } | ||
161 | |||
162 | fmt.mantissa_bits = 10; | ||
163 | fmt.sign = false; | ||
164 | |||
165 | if (!convert_to_custom_float_format(arr_points[1].x, &fmt, | ||
166 | &arr_points[1].custom_float_x)) { | ||
167 | BREAK_TO_DEBUGGER(); | ||
168 | return false; | ||
169 | } | ||
170 | |||
171 | if (fixpoint == true) | ||
172 | arr_points[1].custom_float_y = dal_fixed31_32_clamp_u0d14(arr_points[1].y); | ||
173 | else if (!convert_to_custom_float_format(arr_points[1].y, &fmt, | ||
174 | &arr_points[1].custom_float_y)) { | ||
175 | BREAK_TO_DEBUGGER(); | ||
176 | return false; | ||
177 | } | ||
178 | |||
179 | if (!convert_to_custom_float_format(arr_points[1].slope, &fmt, | ||
180 | &arr_points[1].custom_float_slope)) { | ||
181 | BREAK_TO_DEBUGGER(); | ||
182 | return false; | ||
183 | } | ||
184 | |||
185 | if (hw_points_num == 0 || rgb_resulted == NULL || fixpoint == true) | ||
186 | return true; | ||
187 | |||
188 | fmt.mantissa_bits = 12; | ||
189 | fmt.sign = true; | ||
190 | |||
191 | while (i != hw_points_num) { | ||
192 | if (!convert_to_custom_float_format(rgb->red, &fmt, | ||
193 | &rgb->red_reg)) { | ||
194 | BREAK_TO_DEBUGGER(); | ||
195 | return false; | ||
196 | } | ||
197 | |||
198 | if (!convert_to_custom_float_format(rgb->green, &fmt, | ||
199 | &rgb->green_reg)) { | ||
200 | BREAK_TO_DEBUGGER(); | ||
201 | return false; | ||
202 | } | ||
203 | |||
204 | if (!convert_to_custom_float_format(rgb->blue, &fmt, | ||
205 | &rgb->blue_reg)) { | ||
206 | BREAK_TO_DEBUGGER(); | ||
207 | return false; | ||
208 | } | ||
209 | |||
210 | if (!convert_to_custom_float_format(rgb->delta_red, &fmt, | ||
211 | &rgb->delta_red_reg)) { | ||
212 | BREAK_TO_DEBUGGER(); | ||
213 | return false; | ||
214 | } | ||
215 | |||
216 | if (!convert_to_custom_float_format(rgb->delta_green, &fmt, | ||
217 | &rgb->delta_green_reg)) { | ||
218 | BREAK_TO_DEBUGGER(); | ||
219 | return false; | ||
220 | } | ||
221 | |||
222 | if (!convert_to_custom_float_format(rgb->delta_blue, &fmt, | ||
223 | &rgb->delta_blue_reg)) { | ||
224 | BREAK_TO_DEBUGGER(); | ||
225 | return false; | ||
226 | } | ||
227 | |||
228 | ++rgb; | ||
229 | ++i; | ||
230 | } | ||
231 | |||
232 | return true; | ||
233 | } | ||
234 | |||
235 | |||
236 | #define MAX_REGIONS_NUMBER 34 | ||
237 | #define MAX_LOW_POINT 25 | ||
238 | #define NUMBER_SEGMENTS 32 | ||
239 | |||
240 | bool cm_helper_translate_curve_to_hw_format( | ||
241 | const struct dc_transfer_func *output_tf, | ||
242 | struct pwl_params *lut_params, bool fixpoint) | ||
243 | { | ||
244 | struct curve_points *arr_points; | ||
245 | struct pwl_result_data *rgb_resulted; | ||
246 | struct pwl_result_data *rgb; | ||
247 | struct pwl_result_data *rgb_plus_1; | ||
248 | struct fixed31_32 y_r; | ||
249 | struct fixed31_32 y_g; | ||
250 | struct fixed31_32 y_b; | ||
251 | struct fixed31_32 y1_min; | ||
252 | struct fixed31_32 y3_max; | ||
253 | |||
254 | int32_t segment_start, segment_end; | ||
255 | int32_t i; | ||
256 | uint32_t j, k, seg_distr[MAX_REGIONS_NUMBER], increment, start_index, hw_points; | ||
257 | |||
258 | if (output_tf == NULL || lut_params == NULL || output_tf->type == TF_TYPE_BYPASS) | ||
259 | return false; | ||
260 | |||
261 | PERF_TRACE(); | ||
262 | |||
263 | arr_points = lut_params->arr_points; | ||
264 | rgb_resulted = lut_params->rgb_resulted; | ||
265 | hw_points = 0; | ||
266 | |||
267 | memset(lut_params, 0, sizeof(struct pwl_params)); | ||
268 | memset(seg_distr, 0, sizeof(seg_distr)); | ||
269 | |||
270 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | ||
271 | /* 32 segments | ||
272 | * segments are from 2^-25 to 2^7 | ||
273 | */ | ||
274 | for (i = 0; i < 32 ; i++) | ||
275 | seg_distr[i] = 3; | ||
276 | |||
277 | segment_start = -25; | ||
278 | segment_end = 7; | ||
279 | } else { | ||
280 | /* 10 segments | ||
281 | * segment is from 2^-10 to 2^0 | ||
282 | * There are less than 256 points, for optimization | ||
283 | */ | ||
284 | seg_distr[0] = 3; | ||
285 | seg_distr[1] = 4; | ||
286 | seg_distr[2] = 4; | ||
287 | seg_distr[3] = 4; | ||
288 | seg_distr[4] = 4; | ||
289 | seg_distr[5] = 4; | ||
290 | seg_distr[6] = 4; | ||
291 | seg_distr[7] = 4; | ||
292 | seg_distr[8] = 5; | ||
293 | seg_distr[9] = 5; | ||
294 | |||
295 | segment_start = -10; | ||
296 | segment_end = 0; | ||
297 | } | ||
298 | |||
299 | for (i = segment_end - segment_start; i < MAX_REGIONS_NUMBER ; i++) | ||
300 | seg_distr[i] = -1; | ||
301 | |||
302 | for (k = 0; k < MAX_REGIONS_NUMBER; k++) { | ||
303 | if (seg_distr[k] != -1) | ||
304 | hw_points += (1 << seg_distr[k]); | ||
305 | } | ||
306 | |||
307 | j = 0; | ||
308 | for (k = 0; k < (segment_end - segment_start); k++) { | ||
309 | increment = NUMBER_SEGMENTS / (1 << seg_distr[k]); | ||
310 | start_index = (segment_start + k + MAX_LOW_POINT) * NUMBER_SEGMENTS; | ||
311 | for (i = start_index; i < start_index + NUMBER_SEGMENTS; i += increment) { | ||
312 | if (j == hw_points - 1) | ||
313 | break; | ||
314 | rgb_resulted[j].red = output_tf->tf_pts.red[i]; | ||
315 | rgb_resulted[j].green = output_tf->tf_pts.green[i]; | ||
316 | rgb_resulted[j].blue = output_tf->tf_pts.blue[i]; | ||
317 | j++; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | /* last point */ | ||
322 | start_index = (segment_end + MAX_LOW_POINT) * NUMBER_SEGMENTS; | ||
323 | rgb_resulted[hw_points - 1].red = output_tf->tf_pts.red[start_index]; | ||
324 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; | ||
325 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; | ||
326 | |||
327 | arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | ||
328 | dal_fixed31_32_from_int(segment_start)); | ||
329 | arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | ||
330 | dal_fixed31_32_from_int(segment_end)); | ||
331 | |||
332 | y_r = rgb_resulted[0].red; | ||
333 | y_g = rgb_resulted[0].green; | ||
334 | y_b = rgb_resulted[0].blue; | ||
335 | |||
336 | y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); | ||
337 | |||
338 | arr_points[0].y = y1_min; | ||
339 | arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); | ||
340 | y_r = rgb_resulted[hw_points - 1].red; | ||
341 | y_g = rgb_resulted[hw_points - 1].green; | ||
342 | y_b = rgb_resulted[hw_points - 1].blue; | ||
343 | |||
344 | /* see comment above, m_arrPoints[1].y should be the Y value for the | ||
345 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) | ||
346 | */ | ||
347 | y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); | ||
348 | |||
349 | arr_points[1].y = y3_max; | ||
350 | |||
351 | arr_points[1].slope = dal_fixed31_32_zero; | ||
352 | |||
353 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | ||
354 | /* for PQ, we want to have a straight line from last HW X point, | ||
355 | * and the slope to be such that we hit 1.0 at 10000 nits. | ||
356 | */ | ||
357 | const struct fixed31_32 end_value = | ||
358 | dal_fixed31_32_from_int(125); | ||
359 | |||
360 | arr_points[1].slope = dal_fixed31_32_div( | ||
361 | dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), | ||
362 | dal_fixed31_32_sub(end_value, arr_points[1].x)); | ||
363 | } | ||
364 | |||
365 | lut_params->hw_points_num = hw_points; | ||
366 | |||
367 | i = 1; | ||
368 | for (k = 0; k < MAX_REGIONS_NUMBER && i < MAX_REGIONS_NUMBER; k++) { | ||
369 | if (seg_distr[k] != -1) { | ||
370 | lut_params->arr_curve_points[k].segments_num = | ||
371 | seg_distr[k]; | ||
372 | lut_params->arr_curve_points[i].offset = | ||
373 | lut_params->arr_curve_points[k].offset + (1 << seg_distr[k]); | ||
374 | } | ||
375 | i++; | ||
376 | } | ||
377 | |||
378 | if (seg_distr[k] != -1) | ||
379 | lut_params->arr_curve_points[k].segments_num = seg_distr[k]; | ||
380 | |||
381 | rgb = rgb_resulted; | ||
382 | rgb_plus_1 = rgb_resulted + 1; | ||
383 | |||
384 | i = 1; | ||
385 | while (i != hw_points + 1) { | ||
386 | if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) | ||
387 | rgb_plus_1->red = rgb->red; | ||
388 | if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) | ||
389 | rgb_plus_1->green = rgb->green; | ||
390 | if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) | ||
391 | rgb_plus_1->blue = rgb->blue; | ||
392 | |||
393 | rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); | ||
394 | rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); | ||
395 | rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); | ||
396 | |||
397 | if (fixpoint == true) { | ||
398 | rgb->delta_red_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_red); | ||
399 | rgb->delta_green_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_green); | ||
400 | rgb->delta_blue_reg = dal_fixed31_32_clamp_u0d10(rgb->delta_blue); | ||
401 | rgb->red_reg = dal_fixed31_32_clamp_u0d14(rgb->red); | ||
402 | rgb->green_reg = dal_fixed31_32_clamp_u0d14(rgb->green); | ||
403 | rgb->blue_reg = dal_fixed31_32_clamp_u0d14(rgb->blue); | ||
404 | } | ||
405 | |||
406 | ++rgb_plus_1; | ||
407 | ++rgb; | ||
408 | ++i; | ||
409 | } | ||
410 | cm_helper_convert_to_custom_float(rgb_resulted, | ||
411 | lut_params->arr_points, | ||
412 | hw_points, fixpoint); | ||
413 | |||
414 | return true; | ||
415 | } | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.h index 64836dcf21f2..64e476b83bcb 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.h | |||
@@ -96,4 +96,14 @@ void cm_helper_program_xfer_func( | |||
96 | const struct pwl_params *params, | 96 | const struct pwl_params *params, |
97 | const struct xfer_func_reg *reg); | 97 | const struct xfer_func_reg *reg); |
98 | 98 | ||
99 | bool cm_helper_convert_to_custom_float( | ||
100 | struct pwl_result_data *rgb_resulted, | ||
101 | struct curve_points *arr_points, | ||
102 | uint32_t hw_points_num, | ||
103 | bool fixpoint); | ||
104 | |||
105 | bool cm_helper_translate_curve_to_hw_format( | ||
106 | const struct dc_transfer_func *output_tf, | ||
107 | struct pwl_params *lut_params, bool fixpoint); | ||
108 | |||
99 | #endif | 109 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c index 8df3945370cf..f2a08b156cf0 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c | |||
@@ -159,11 +159,10 @@ bool dpp_get_optimal_number_of_taps( | |||
159 | scl_data->taps.h_taps = 1; | 159 | scl_data->taps.h_taps = 1; |
160 | if (IDENTITY_RATIO(scl_data->ratios.vert)) | 160 | if (IDENTITY_RATIO(scl_data->ratios.vert)) |
161 | scl_data->taps.v_taps = 1; | 161 | scl_data->taps.v_taps = 1; |
162 | /* | 162 | if (IDENTITY_RATIO(scl_data->ratios.horz_c)) |
163 | * Spreadsheet doesn't handle taps_c is one properly, | 163 | scl_data->taps.h_taps_c = 1; |
164 | * need to force Chroma to always be scaled to pass | 164 | if (IDENTITY_RATIO(scl_data->ratios.vert_c)) |
165 | * bandwidth validation. | 165 | scl_data->taps.v_taps_c = 1; |
166 | */ | ||
167 | } | 166 | } |
168 | 167 | ||
169 | return true; | 168 | return true; |
@@ -386,10 +385,9 @@ void dpp1_cnv_setup ( | |||
386 | 385 | ||
387 | void dpp1_set_cursor_attributes( | 386 | void dpp1_set_cursor_attributes( |
388 | struct dpp *dpp_base, | 387 | struct dpp *dpp_base, |
389 | const struct dc_cursor_attributes *attr) | 388 | enum dc_cursor_color_format color_format) |
390 | { | 389 | { |
391 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); | 390 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); |
392 | enum dc_cursor_color_format color_format = attr->color_format; | ||
393 | 391 | ||
394 | REG_UPDATE_2(CURSOR0_CONTROL, | 392 | REG_UPDATE_2(CURSOR0_CONTROL, |
395 | CUR0_MODE, color_format, | 393 | CUR0_MODE, color_format, |
@@ -402,13 +400,6 @@ void dpp1_set_cursor_attributes( | |||
402 | REG_UPDATE(CURSOR0_COLOR1, | 400 | REG_UPDATE(CURSOR0_COLOR1, |
403 | CUR0_COLOR1, 0xFFFFFFFF); | 401 | CUR0_COLOR1, 0xFFFFFFFF); |
404 | } | 402 | } |
405 | |||
406 | /* TODO: Fixed vs float */ | ||
407 | |||
408 | REG_UPDATE_3(FORMAT_CONTROL, | ||
409 | CNVC_BYPASS, 0, | ||
410 | FORMAT_CONTROL__ALPHA_EN, 1, | ||
411 | FORMAT_EXPANSION_MODE, 0); | ||
412 | } | 403 | } |
413 | 404 | ||
414 | 405 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h index ad71fb50f8a5..f56ee4d08d89 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h | |||
@@ -730,8 +730,9 @@ | |||
730 | type CM_BLNDGAM_RAMA_EXP_REGION33_NUM_SEGMENTS; \ | 730 | type CM_BLNDGAM_RAMA_EXP_REGION33_NUM_SEGMENTS; \ |
731 | type CM_BLNDGAM_LUT_WRITE_EN_MASK; \ | 731 | type CM_BLNDGAM_LUT_WRITE_EN_MASK; \ |
732 | type CM_BLNDGAM_LUT_WRITE_SEL; \ | 732 | type CM_BLNDGAM_LUT_WRITE_SEL; \ |
733 | type CM_BLNDGAM_CONFIG_STATUS; \ | ||
733 | type CM_BLNDGAM_LUT_INDEX; \ | 734 | type CM_BLNDGAM_LUT_INDEX; \ |
734 | type CM_BLNDGAM_LUT_DATA; \ | 735 | type BLNDGAM_MEM_PWR_FORCE; \ |
735 | type CM_3DLUT_MODE; \ | 736 | type CM_3DLUT_MODE; \ |
736 | type CM_3DLUT_SIZE; \ | 737 | type CM_3DLUT_SIZE; \ |
737 | type CM_3DLUT_INDEX; \ | 738 | type CM_3DLUT_INDEX; \ |
@@ -905,6 +906,7 @@ | |||
905 | type CM_SHAPER_RAMA_EXP_REGION33_LUT_OFFSET; \ | 906 | type CM_SHAPER_RAMA_EXP_REGION33_LUT_OFFSET; \ |
906 | type CM_SHAPER_RAMA_EXP_REGION33_NUM_SEGMENTS; \ | 907 | type CM_SHAPER_RAMA_EXP_REGION33_NUM_SEGMENTS; \ |
907 | type CM_SHAPER_LUT_WRITE_EN_MASK; \ | 908 | type CM_SHAPER_LUT_WRITE_EN_MASK; \ |
909 | type CM_SHAPER_CONFIG_STATUS; \ | ||
908 | type CM_SHAPER_LUT_WRITE_SEL; \ | 910 | type CM_SHAPER_LUT_WRITE_SEL; \ |
909 | type CM_SHAPER_LUT_INDEX; \ | 911 | type CM_SHAPER_LUT_INDEX; \ |
910 | type CM_SHAPER_LUT_DATA; \ | 912 | type CM_SHAPER_LUT_DATA; \ |
@@ -1005,258 +1007,255 @@ | |||
1005 | type CM_BYPASS; \ | 1007 | type CM_BYPASS; \ |
1006 | type FORMAT_CONTROL__ALPHA_EN; \ | 1008 | type FORMAT_CONTROL__ALPHA_EN; \ |
1007 | type CUR0_COLOR0; \ | 1009 | type CUR0_COLOR0; \ |
1008 | type CUR0_COLOR1 | 1010 | type CUR0_COLOR1; |
1009 | |||
1010 | |||
1011 | 1011 | ||
1012 | struct dcn_dpp_shift { | 1012 | struct dcn_dpp_shift { |
1013 | TF_REG_FIELD_LIST(uint8_t); | 1013 | TF_REG_FIELD_LIST(uint8_t) |
1014 | }; | 1014 | }; |
1015 | 1015 | ||
1016 | struct dcn_dpp_mask { | 1016 | struct dcn_dpp_mask { |
1017 | TF_REG_FIELD_LIST(uint32_t); | 1017 | TF_REG_FIELD_LIST(uint32_t) |
1018 | }; | 1018 | }; |
1019 | 1019 | ||
1020 | 1020 | #define DPP_COMMON_REG_VARIABLE_LIST \ | |
1021 | 1021 | uint32_t DSCL_EXT_OVERSCAN_LEFT_RIGHT; \ | |
1022 | uint32_t DSCL_EXT_OVERSCAN_TOP_BOTTOM; \ | ||
1023 | uint32_t OTG_H_BLANK; \ | ||
1024 | uint32_t OTG_V_BLANK; \ | ||
1025 | uint32_t SCL_MODE; \ | ||
1026 | uint32_t LB_DATA_FORMAT; \ | ||
1027 | uint32_t LB_MEMORY_CTRL; \ | ||
1028 | uint32_t DSCL_AUTOCAL; \ | ||
1029 | uint32_t SCL_BLACK_OFFSET; \ | ||
1030 | uint32_t SCL_TAP_CONTROL; \ | ||
1031 | uint32_t SCL_COEF_RAM_TAP_SELECT; \ | ||
1032 | uint32_t SCL_COEF_RAM_TAP_DATA; \ | ||
1033 | uint32_t DSCL_2TAP_CONTROL; \ | ||
1034 | uint32_t MPC_SIZE; \ | ||
1035 | uint32_t SCL_HORZ_FILTER_SCALE_RATIO; \ | ||
1036 | uint32_t SCL_VERT_FILTER_SCALE_RATIO; \ | ||
1037 | uint32_t SCL_HORZ_FILTER_SCALE_RATIO_C; \ | ||
1038 | uint32_t SCL_VERT_FILTER_SCALE_RATIO_C; \ | ||
1039 | uint32_t SCL_HORZ_FILTER_INIT; \ | ||
1040 | uint32_t SCL_HORZ_FILTER_INIT_C; \ | ||
1041 | uint32_t SCL_VERT_FILTER_INIT; \ | ||
1042 | uint32_t SCL_VERT_FILTER_INIT_BOT; \ | ||
1043 | uint32_t SCL_VERT_FILTER_INIT_C; \ | ||
1044 | uint32_t SCL_VERT_FILTER_INIT_BOT_C; \ | ||
1045 | uint32_t RECOUT_START; \ | ||
1046 | uint32_t RECOUT_SIZE; \ | ||
1047 | uint32_t CM_GAMUT_REMAP_CONTROL; \ | ||
1048 | uint32_t CM_GAMUT_REMAP_C11_C12; \ | ||
1049 | uint32_t CM_GAMUT_REMAP_C33_C34; \ | ||
1050 | uint32_t CM_COMA_C11_C12; \ | ||
1051 | uint32_t CM_COMA_C33_C34; \ | ||
1052 | uint32_t CM_COMB_C11_C12; \ | ||
1053 | uint32_t CM_COMB_C33_C34; \ | ||
1054 | uint32_t CM_OCSC_CONTROL; \ | ||
1055 | uint32_t CM_OCSC_C11_C12; \ | ||
1056 | uint32_t CM_OCSC_C33_C34; \ | ||
1057 | uint32_t CM_MEM_PWR_CTRL; \ | ||
1058 | uint32_t CM_RGAM_LUT_DATA; \ | ||
1059 | uint32_t CM_RGAM_LUT_WRITE_EN_MASK; \ | ||
1060 | uint32_t CM_RGAM_LUT_INDEX; \ | ||
1061 | uint32_t CM_RGAM_RAMB_START_CNTL_B; \ | ||
1062 | uint32_t CM_RGAM_RAMB_START_CNTL_G; \ | ||
1063 | uint32_t CM_RGAM_RAMB_START_CNTL_R; \ | ||
1064 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_B; \ | ||
1065 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_G; \ | ||
1066 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_R; \ | ||
1067 | uint32_t CM_RGAM_RAMB_END_CNTL1_B; \ | ||
1068 | uint32_t CM_RGAM_RAMB_END_CNTL2_B; \ | ||
1069 | uint32_t CM_RGAM_RAMB_END_CNTL1_G; \ | ||
1070 | uint32_t CM_RGAM_RAMB_END_CNTL2_G; \ | ||
1071 | uint32_t CM_RGAM_RAMB_END_CNTL1_R; \ | ||
1072 | uint32_t CM_RGAM_RAMB_END_CNTL2_R; \ | ||
1073 | uint32_t CM_RGAM_RAMB_REGION_0_1; \ | ||
1074 | uint32_t CM_RGAM_RAMB_REGION_32_33; \ | ||
1075 | uint32_t CM_RGAM_RAMA_START_CNTL_B; \ | ||
1076 | uint32_t CM_RGAM_RAMA_START_CNTL_G; \ | ||
1077 | uint32_t CM_RGAM_RAMA_START_CNTL_R; \ | ||
1078 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_B; \ | ||
1079 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_G; \ | ||
1080 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_R; \ | ||
1081 | uint32_t CM_RGAM_RAMA_END_CNTL1_B; \ | ||
1082 | uint32_t CM_RGAM_RAMA_END_CNTL2_B; \ | ||
1083 | uint32_t CM_RGAM_RAMA_END_CNTL1_G; \ | ||
1084 | uint32_t CM_RGAM_RAMA_END_CNTL2_G; \ | ||
1085 | uint32_t CM_RGAM_RAMA_END_CNTL1_R; \ | ||
1086 | uint32_t CM_RGAM_RAMA_END_CNTL2_R; \ | ||
1087 | uint32_t CM_RGAM_RAMA_REGION_0_1; \ | ||
1088 | uint32_t CM_RGAM_RAMA_REGION_32_33; \ | ||
1089 | uint32_t CM_RGAM_CONTROL; \ | ||
1090 | uint32_t CM_CMOUT_CONTROL; \ | ||
1091 | uint32_t CM_BLNDGAM_LUT_WRITE_EN_MASK; \ | ||
1092 | uint32_t CM_BLNDGAM_CONTROL; \ | ||
1093 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_B; \ | ||
1094 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_G; \ | ||
1095 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_R; \ | ||
1096 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_B; \ | ||
1097 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_G; \ | ||
1098 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_R; \ | ||
1099 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_B; \ | ||
1100 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_B; \ | ||
1101 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_G; \ | ||
1102 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_G; \ | ||
1103 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_R; \ | ||
1104 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_R; \ | ||
1105 | uint32_t CM_BLNDGAM_RAMB_REGION_0_1; \ | ||
1106 | uint32_t CM_BLNDGAM_RAMB_REGION_2_3; \ | ||
1107 | uint32_t CM_BLNDGAM_RAMB_REGION_4_5; \ | ||
1108 | uint32_t CM_BLNDGAM_RAMB_REGION_6_7; \ | ||
1109 | uint32_t CM_BLNDGAM_RAMB_REGION_8_9; \ | ||
1110 | uint32_t CM_BLNDGAM_RAMB_REGION_10_11; \ | ||
1111 | uint32_t CM_BLNDGAM_RAMB_REGION_12_13; \ | ||
1112 | uint32_t CM_BLNDGAM_RAMB_REGION_14_15; \ | ||
1113 | uint32_t CM_BLNDGAM_RAMB_REGION_16_17; \ | ||
1114 | uint32_t CM_BLNDGAM_RAMB_REGION_18_19; \ | ||
1115 | uint32_t CM_BLNDGAM_RAMB_REGION_20_21; \ | ||
1116 | uint32_t CM_BLNDGAM_RAMB_REGION_22_23; \ | ||
1117 | uint32_t CM_BLNDGAM_RAMB_REGION_24_25; \ | ||
1118 | uint32_t CM_BLNDGAM_RAMB_REGION_26_27; \ | ||
1119 | uint32_t CM_BLNDGAM_RAMB_REGION_28_29; \ | ||
1120 | uint32_t CM_BLNDGAM_RAMB_REGION_30_31; \ | ||
1121 | uint32_t CM_BLNDGAM_RAMB_REGION_32_33; \ | ||
1122 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_B; \ | ||
1123 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_G; \ | ||
1124 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_R; \ | ||
1125 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_B; \ | ||
1126 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_G; \ | ||
1127 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_R; \ | ||
1128 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_B; \ | ||
1129 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_B; \ | ||
1130 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_G; \ | ||
1131 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_G; \ | ||
1132 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_R; \ | ||
1133 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_R; \ | ||
1134 | uint32_t CM_BLNDGAM_RAMA_REGION_0_1; \ | ||
1135 | uint32_t CM_BLNDGAM_RAMA_REGION_2_3; \ | ||
1136 | uint32_t CM_BLNDGAM_RAMA_REGION_4_5; \ | ||
1137 | uint32_t CM_BLNDGAM_RAMA_REGION_6_7; \ | ||
1138 | uint32_t CM_BLNDGAM_RAMA_REGION_8_9; \ | ||
1139 | uint32_t CM_BLNDGAM_RAMA_REGION_10_11; \ | ||
1140 | uint32_t CM_BLNDGAM_RAMA_REGION_12_13; \ | ||
1141 | uint32_t CM_BLNDGAM_RAMA_REGION_14_15; \ | ||
1142 | uint32_t CM_BLNDGAM_RAMA_REGION_16_17; \ | ||
1143 | uint32_t CM_BLNDGAM_RAMA_REGION_18_19; \ | ||
1144 | uint32_t CM_BLNDGAM_RAMA_REGION_20_21; \ | ||
1145 | uint32_t CM_BLNDGAM_RAMA_REGION_22_23; \ | ||
1146 | uint32_t CM_BLNDGAM_RAMA_REGION_24_25; \ | ||
1147 | uint32_t CM_BLNDGAM_RAMA_REGION_26_27; \ | ||
1148 | uint32_t CM_BLNDGAM_RAMA_REGION_28_29; \ | ||
1149 | uint32_t CM_BLNDGAM_RAMA_REGION_30_31; \ | ||
1150 | uint32_t CM_BLNDGAM_RAMA_REGION_32_33; \ | ||
1151 | uint32_t CM_BLNDGAM_LUT_INDEX; \ | ||
1152 | uint32_t CM_3DLUT_MODE; \ | ||
1153 | uint32_t CM_3DLUT_INDEX; \ | ||
1154 | uint32_t CM_3DLUT_DATA; \ | ||
1155 | uint32_t CM_3DLUT_DATA_30BIT; \ | ||
1156 | uint32_t CM_3DLUT_READ_WRITE_CONTROL; \ | ||
1157 | uint32_t CM_SHAPER_LUT_WRITE_EN_MASK; \ | ||
1158 | uint32_t CM_SHAPER_CONTROL; \ | ||
1159 | uint32_t CM_SHAPER_RAMB_START_CNTL_B; \ | ||
1160 | uint32_t CM_SHAPER_RAMB_START_CNTL_G; \ | ||
1161 | uint32_t CM_SHAPER_RAMB_START_CNTL_R; \ | ||
1162 | uint32_t CM_SHAPER_RAMB_END_CNTL_B; \ | ||
1163 | uint32_t CM_SHAPER_RAMB_END_CNTL_G; \ | ||
1164 | uint32_t CM_SHAPER_RAMB_END_CNTL_R; \ | ||
1165 | uint32_t CM_SHAPER_RAMB_REGION_0_1; \ | ||
1166 | uint32_t CM_SHAPER_RAMB_REGION_2_3; \ | ||
1167 | uint32_t CM_SHAPER_RAMB_REGION_4_5; \ | ||
1168 | uint32_t CM_SHAPER_RAMB_REGION_6_7; \ | ||
1169 | uint32_t CM_SHAPER_RAMB_REGION_8_9; \ | ||
1170 | uint32_t CM_SHAPER_RAMB_REGION_10_11; \ | ||
1171 | uint32_t CM_SHAPER_RAMB_REGION_12_13; \ | ||
1172 | uint32_t CM_SHAPER_RAMB_REGION_14_15; \ | ||
1173 | uint32_t CM_SHAPER_RAMB_REGION_16_17; \ | ||
1174 | uint32_t CM_SHAPER_RAMB_REGION_18_19; \ | ||
1175 | uint32_t CM_SHAPER_RAMB_REGION_20_21; \ | ||
1176 | uint32_t CM_SHAPER_RAMB_REGION_22_23; \ | ||
1177 | uint32_t CM_SHAPER_RAMB_REGION_24_25; \ | ||
1178 | uint32_t CM_SHAPER_RAMB_REGION_26_27; \ | ||
1179 | uint32_t CM_SHAPER_RAMB_REGION_28_29; \ | ||
1180 | uint32_t CM_SHAPER_RAMB_REGION_30_31; \ | ||
1181 | uint32_t CM_SHAPER_RAMB_REGION_32_33; \ | ||
1182 | uint32_t CM_SHAPER_RAMA_START_CNTL_B; \ | ||
1183 | uint32_t CM_SHAPER_RAMA_START_CNTL_G; \ | ||
1184 | uint32_t CM_SHAPER_RAMA_START_CNTL_R; \ | ||
1185 | uint32_t CM_SHAPER_RAMA_END_CNTL_B; \ | ||
1186 | uint32_t CM_SHAPER_RAMA_END_CNTL_G; \ | ||
1187 | uint32_t CM_SHAPER_RAMA_END_CNTL_R; \ | ||
1188 | uint32_t CM_SHAPER_RAMA_REGION_0_1; \ | ||
1189 | uint32_t CM_SHAPER_RAMA_REGION_2_3; \ | ||
1190 | uint32_t CM_SHAPER_RAMA_REGION_4_5; \ | ||
1191 | uint32_t CM_SHAPER_RAMA_REGION_6_7; \ | ||
1192 | uint32_t CM_SHAPER_RAMA_REGION_8_9; \ | ||
1193 | uint32_t CM_SHAPER_RAMA_REGION_10_11; \ | ||
1194 | uint32_t CM_SHAPER_RAMA_REGION_12_13; \ | ||
1195 | uint32_t CM_SHAPER_RAMA_REGION_14_15; \ | ||
1196 | uint32_t CM_SHAPER_RAMA_REGION_16_17; \ | ||
1197 | uint32_t CM_SHAPER_RAMA_REGION_18_19; \ | ||
1198 | uint32_t CM_SHAPER_RAMA_REGION_20_21; \ | ||
1199 | uint32_t CM_SHAPER_RAMA_REGION_22_23; \ | ||
1200 | uint32_t CM_SHAPER_RAMA_REGION_24_25; \ | ||
1201 | uint32_t CM_SHAPER_RAMA_REGION_26_27; \ | ||
1202 | uint32_t CM_SHAPER_RAMA_REGION_28_29; \ | ||
1203 | uint32_t CM_SHAPER_RAMA_REGION_30_31; \ | ||
1204 | uint32_t CM_SHAPER_RAMA_REGION_32_33; \ | ||
1205 | uint32_t CM_SHAPER_LUT_INDEX; \ | ||
1206 | uint32_t CM_SHAPER_LUT_DATA; \ | ||
1207 | uint32_t CM_ICSC_CONTROL; \ | ||
1208 | uint32_t CM_ICSC_C11_C12; \ | ||
1209 | uint32_t CM_ICSC_C33_C34; \ | ||
1210 | uint32_t CM_BNS_VALUES_R; \ | ||
1211 | uint32_t CM_BNS_VALUES_G; \ | ||
1212 | uint32_t CM_BNS_VALUES_B; \ | ||
1213 | uint32_t CM_DGAM_RAMB_START_CNTL_B; \ | ||
1214 | uint32_t CM_DGAM_RAMB_START_CNTL_G; \ | ||
1215 | uint32_t CM_DGAM_RAMB_START_CNTL_R; \ | ||
1216 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_B; \ | ||
1217 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_G; \ | ||
1218 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_R; \ | ||
1219 | uint32_t CM_DGAM_RAMB_END_CNTL1_B; \ | ||
1220 | uint32_t CM_DGAM_RAMB_END_CNTL2_B; \ | ||
1221 | uint32_t CM_DGAM_RAMB_END_CNTL1_G; \ | ||
1222 | uint32_t CM_DGAM_RAMB_END_CNTL2_G; \ | ||
1223 | uint32_t CM_DGAM_RAMB_END_CNTL1_R; \ | ||
1224 | uint32_t CM_DGAM_RAMB_END_CNTL2_R; \ | ||
1225 | uint32_t CM_DGAM_RAMB_REGION_0_1; \ | ||
1226 | uint32_t CM_DGAM_RAMB_REGION_14_15; \ | ||
1227 | uint32_t CM_DGAM_RAMA_START_CNTL_B; \ | ||
1228 | uint32_t CM_DGAM_RAMA_START_CNTL_G; \ | ||
1229 | uint32_t CM_DGAM_RAMA_START_CNTL_R; \ | ||
1230 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_B; \ | ||
1231 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_G; \ | ||
1232 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_R; \ | ||
1233 | uint32_t CM_DGAM_RAMA_END_CNTL1_B; \ | ||
1234 | uint32_t CM_DGAM_RAMA_END_CNTL2_B; \ | ||
1235 | uint32_t CM_DGAM_RAMA_END_CNTL1_G; \ | ||
1236 | uint32_t CM_DGAM_RAMA_END_CNTL2_G; \ | ||
1237 | uint32_t CM_DGAM_RAMA_END_CNTL1_R; \ | ||
1238 | uint32_t CM_DGAM_RAMA_END_CNTL2_R; \ | ||
1239 | uint32_t CM_DGAM_RAMA_REGION_0_1; \ | ||
1240 | uint32_t CM_DGAM_RAMA_REGION_14_15; \ | ||
1241 | uint32_t CM_DGAM_LUT_WRITE_EN_MASK; \ | ||
1242 | uint32_t CM_DGAM_LUT_INDEX; \ | ||
1243 | uint32_t CM_DGAM_LUT_DATA; \ | ||
1244 | uint32_t CM_CONTROL; \ | ||
1245 | uint32_t CM_DGAM_CONTROL; \ | ||
1246 | uint32_t CM_IGAM_CONTROL; \ | ||
1247 | uint32_t CM_IGAM_LUT_RW_CONTROL; \ | ||
1248 | uint32_t CM_IGAM_LUT_RW_INDEX; \ | ||
1249 | uint32_t CM_IGAM_LUT_SEQ_COLOR; \ | ||
1250 | uint32_t FORMAT_CONTROL; \ | ||
1251 | uint32_t CNVC_SURFACE_PIXEL_FORMAT; \ | ||
1252 | uint32_t CURSOR_CONTROL; \ | ||
1253 | uint32_t CURSOR0_CONTROL; \ | ||
1254 | uint32_t CURSOR0_COLOR0; \ | ||
1255 | uint32_t CURSOR0_COLOR1; | ||
1022 | 1256 | ||
1023 | struct dcn_dpp_registers { | 1257 | struct dcn_dpp_registers { |
1024 | uint32_t DSCL_EXT_OVERSCAN_LEFT_RIGHT; | 1258 | DPP_COMMON_REG_VARIABLE_LIST |
1025 | uint32_t DSCL_EXT_OVERSCAN_TOP_BOTTOM; | ||
1026 | uint32_t OTG_H_BLANK; | ||
1027 | uint32_t OTG_V_BLANK; | ||
1028 | uint32_t SCL_MODE; | ||
1029 | uint32_t LB_DATA_FORMAT; | ||
1030 | uint32_t LB_MEMORY_CTRL; | ||
1031 | uint32_t DSCL_AUTOCAL; | ||
1032 | uint32_t SCL_BLACK_OFFSET; | ||
1033 | uint32_t SCL_TAP_CONTROL; | ||
1034 | uint32_t SCL_COEF_RAM_TAP_SELECT; | ||
1035 | uint32_t SCL_COEF_RAM_TAP_DATA; | ||
1036 | uint32_t DSCL_2TAP_CONTROL; | ||
1037 | uint32_t MPC_SIZE; | ||
1038 | uint32_t SCL_HORZ_FILTER_SCALE_RATIO; | ||
1039 | uint32_t SCL_VERT_FILTER_SCALE_RATIO; | ||
1040 | uint32_t SCL_HORZ_FILTER_SCALE_RATIO_C; | ||
1041 | uint32_t SCL_VERT_FILTER_SCALE_RATIO_C; | ||
1042 | uint32_t SCL_HORZ_FILTER_INIT; | ||
1043 | uint32_t SCL_HORZ_FILTER_INIT_C; | ||
1044 | uint32_t SCL_VERT_FILTER_INIT; | ||
1045 | uint32_t SCL_VERT_FILTER_INIT_BOT; | ||
1046 | uint32_t SCL_VERT_FILTER_INIT_C; | ||
1047 | uint32_t SCL_VERT_FILTER_INIT_BOT_C; | ||
1048 | uint32_t RECOUT_START; | ||
1049 | uint32_t RECOUT_SIZE; | ||
1050 | uint32_t CM_GAMUT_REMAP_CONTROL; | ||
1051 | uint32_t CM_GAMUT_REMAP_C11_C12; | ||
1052 | uint32_t CM_GAMUT_REMAP_C33_C34; | ||
1053 | uint32_t CM_COMA_C11_C12; | ||
1054 | uint32_t CM_COMA_C33_C34; | ||
1055 | uint32_t CM_COMB_C11_C12; | ||
1056 | uint32_t CM_COMB_C33_C34; | ||
1057 | uint32_t CM_OCSC_CONTROL; | ||
1058 | uint32_t CM_OCSC_C11_C12; | ||
1059 | uint32_t CM_OCSC_C33_C34; | ||
1060 | uint32_t CM_MEM_PWR_CTRL; | ||
1061 | uint32_t CM_RGAM_LUT_DATA; | ||
1062 | uint32_t CM_RGAM_LUT_WRITE_EN_MASK; | ||
1063 | uint32_t CM_RGAM_LUT_INDEX; | ||
1064 | uint32_t CM_RGAM_RAMB_START_CNTL_B; | ||
1065 | uint32_t CM_RGAM_RAMB_START_CNTL_G; | ||
1066 | uint32_t CM_RGAM_RAMB_START_CNTL_R; | ||
1067 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_B; | ||
1068 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_G; | ||
1069 | uint32_t CM_RGAM_RAMB_SLOPE_CNTL_R; | ||
1070 | uint32_t CM_RGAM_RAMB_END_CNTL1_B; | ||
1071 | uint32_t CM_RGAM_RAMB_END_CNTL2_B; | ||
1072 | uint32_t CM_RGAM_RAMB_END_CNTL1_G; | ||
1073 | uint32_t CM_RGAM_RAMB_END_CNTL2_G; | ||
1074 | uint32_t CM_RGAM_RAMB_END_CNTL1_R; | ||
1075 | uint32_t CM_RGAM_RAMB_END_CNTL2_R; | ||
1076 | uint32_t CM_RGAM_RAMB_REGION_0_1; | ||
1077 | uint32_t CM_RGAM_RAMB_REGION_32_33; | ||
1078 | uint32_t CM_RGAM_RAMA_START_CNTL_B; | ||
1079 | uint32_t CM_RGAM_RAMA_START_CNTL_G; | ||
1080 | uint32_t CM_RGAM_RAMA_START_CNTL_R; | ||
1081 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_B; | ||
1082 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_G; | ||
1083 | uint32_t CM_RGAM_RAMA_SLOPE_CNTL_R; | ||
1084 | uint32_t CM_RGAM_RAMA_END_CNTL1_B; | ||
1085 | uint32_t CM_RGAM_RAMA_END_CNTL2_B; | ||
1086 | uint32_t CM_RGAM_RAMA_END_CNTL1_G; | ||
1087 | uint32_t CM_RGAM_RAMA_END_CNTL2_G; | ||
1088 | uint32_t CM_RGAM_RAMA_END_CNTL1_R; | ||
1089 | uint32_t CM_RGAM_RAMA_END_CNTL2_R; | ||
1090 | uint32_t CM_RGAM_RAMA_REGION_0_1; | ||
1091 | uint32_t CM_RGAM_RAMA_REGION_32_33; | ||
1092 | uint32_t CM_RGAM_CONTROL; | ||
1093 | uint32_t CM_CMOUT_CONTROL; | ||
1094 | uint32_t CM_BLNDGAM_LUT_WRITE_EN_MASK; | ||
1095 | uint32_t CM_BLNDGAM_CONTROL; | ||
1096 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_B; | ||
1097 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_G; | ||
1098 | uint32_t CM_BLNDGAM_RAMB_START_CNTL_R; | ||
1099 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_B; | ||
1100 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_G; | ||
1101 | uint32_t CM_BLNDGAM_RAMB_SLOPE_CNTL_R; | ||
1102 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_B; | ||
1103 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_B; | ||
1104 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_G; | ||
1105 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_G; | ||
1106 | uint32_t CM_BLNDGAM_RAMB_END_CNTL1_R; | ||
1107 | uint32_t CM_BLNDGAM_RAMB_END_CNTL2_R; | ||
1108 | uint32_t CM_BLNDGAM_RAMB_REGION_0_1; | ||
1109 | uint32_t CM_BLNDGAM_RAMB_REGION_2_3; | ||
1110 | uint32_t CM_BLNDGAM_RAMB_REGION_4_5; | ||
1111 | uint32_t CM_BLNDGAM_RAMB_REGION_6_7; | ||
1112 | uint32_t CM_BLNDGAM_RAMB_REGION_8_9; | ||
1113 | uint32_t CM_BLNDGAM_RAMB_REGION_10_11; | ||
1114 | uint32_t CM_BLNDGAM_RAMB_REGION_12_13; | ||
1115 | uint32_t CM_BLNDGAM_RAMB_REGION_14_15; | ||
1116 | uint32_t CM_BLNDGAM_RAMB_REGION_16_17; | ||
1117 | uint32_t CM_BLNDGAM_RAMB_REGION_18_19; | ||
1118 | uint32_t CM_BLNDGAM_RAMB_REGION_20_21; | ||
1119 | uint32_t CM_BLNDGAM_RAMB_REGION_22_23; | ||
1120 | uint32_t CM_BLNDGAM_RAMB_REGION_24_25; | ||
1121 | uint32_t CM_BLNDGAM_RAMB_REGION_26_27; | ||
1122 | uint32_t CM_BLNDGAM_RAMB_REGION_28_29; | ||
1123 | uint32_t CM_BLNDGAM_RAMB_REGION_30_31; | ||
1124 | uint32_t CM_BLNDGAM_RAMB_REGION_32_33; | ||
1125 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_B; | ||
1126 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_G; | ||
1127 | uint32_t CM_BLNDGAM_RAMA_START_CNTL_R; | ||
1128 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_B; | ||
1129 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_G; | ||
1130 | uint32_t CM_BLNDGAM_RAMA_SLOPE_CNTL_R; | ||
1131 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_B; | ||
1132 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_B; | ||
1133 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_G; | ||
1134 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_G; | ||
1135 | uint32_t CM_BLNDGAM_RAMA_END_CNTL1_R; | ||
1136 | uint32_t CM_BLNDGAM_RAMA_END_CNTL2_R; | ||
1137 | uint32_t CM_BLNDGAM_RAMA_REGION_0_1; | ||
1138 | uint32_t CM_BLNDGAM_RAMA_REGION_2_3; | ||
1139 | uint32_t CM_BLNDGAM_RAMA_REGION_4_5; | ||
1140 | uint32_t CM_BLNDGAM_RAMA_REGION_6_7; | ||
1141 | uint32_t CM_BLNDGAM_RAMA_REGION_8_9; | ||
1142 | uint32_t CM_BLNDGAM_RAMA_REGION_10_11; | ||
1143 | uint32_t CM_BLNDGAM_RAMA_REGION_12_13; | ||
1144 | uint32_t CM_BLNDGAM_RAMA_REGION_14_15; | ||
1145 | uint32_t CM_BLNDGAM_RAMA_REGION_16_17; | ||
1146 | uint32_t CM_BLNDGAM_RAMA_REGION_18_19; | ||
1147 | uint32_t CM_BLNDGAM_RAMA_REGION_20_21; | ||
1148 | uint32_t CM_BLNDGAM_RAMA_REGION_22_23; | ||
1149 | uint32_t CM_BLNDGAM_RAMA_REGION_24_25; | ||
1150 | uint32_t CM_BLNDGAM_RAMA_REGION_26_27; | ||
1151 | uint32_t CM_BLNDGAM_RAMA_REGION_28_29; | ||
1152 | uint32_t CM_BLNDGAM_RAMA_REGION_30_31; | ||
1153 | uint32_t CM_BLNDGAM_RAMA_REGION_32_33; | ||
1154 | uint32_t CM_BLNDGAM_LUT_INDEX; | ||
1155 | uint32_t CM_BLNDGAM_LUT_DATA; | ||
1156 | uint32_t CM_3DLUT_MODE; | ||
1157 | uint32_t CM_3DLUT_INDEX; | ||
1158 | uint32_t CM_3DLUT_DATA; | ||
1159 | uint32_t CM_3DLUT_DATA_30BIT; | ||
1160 | uint32_t CM_3DLUT_READ_WRITE_CONTROL; | ||
1161 | uint32_t CM_SHAPER_LUT_WRITE_EN_MASK; | ||
1162 | uint32_t CM_SHAPER_CONTROL; | ||
1163 | uint32_t CM_SHAPER_RAMB_START_CNTL_B; | ||
1164 | uint32_t CM_SHAPER_RAMB_START_CNTL_G; | ||
1165 | uint32_t CM_SHAPER_RAMB_START_CNTL_R; | ||
1166 | uint32_t CM_SHAPER_RAMB_END_CNTL_B; | ||
1167 | uint32_t CM_SHAPER_RAMB_END_CNTL_G; | ||
1168 | uint32_t CM_SHAPER_RAMB_END_CNTL_R; | ||
1169 | uint32_t CM_SHAPER_RAMB_REGION_0_1; | ||
1170 | uint32_t CM_SHAPER_RAMB_REGION_2_3; | ||
1171 | uint32_t CM_SHAPER_RAMB_REGION_4_5; | ||
1172 | uint32_t CM_SHAPER_RAMB_REGION_6_7; | ||
1173 | uint32_t CM_SHAPER_RAMB_REGION_8_9; | ||
1174 | uint32_t CM_SHAPER_RAMB_REGION_10_11; | ||
1175 | uint32_t CM_SHAPER_RAMB_REGION_12_13; | ||
1176 | uint32_t CM_SHAPER_RAMB_REGION_14_15; | ||
1177 | uint32_t CM_SHAPER_RAMB_REGION_16_17; | ||
1178 | uint32_t CM_SHAPER_RAMB_REGION_18_19; | ||
1179 | uint32_t CM_SHAPER_RAMB_REGION_20_21; | ||
1180 | uint32_t CM_SHAPER_RAMB_REGION_22_23; | ||
1181 | uint32_t CM_SHAPER_RAMB_REGION_24_25; | ||
1182 | uint32_t CM_SHAPER_RAMB_REGION_26_27; | ||
1183 | uint32_t CM_SHAPER_RAMB_REGION_28_29; | ||
1184 | uint32_t CM_SHAPER_RAMB_REGION_30_31; | ||
1185 | uint32_t CM_SHAPER_RAMB_REGION_32_33; | ||
1186 | uint32_t CM_SHAPER_RAMA_START_CNTL_B; | ||
1187 | uint32_t CM_SHAPER_RAMA_START_CNTL_G; | ||
1188 | uint32_t CM_SHAPER_RAMA_START_CNTL_R; | ||
1189 | uint32_t CM_SHAPER_RAMA_END_CNTL_B; | ||
1190 | uint32_t CM_SHAPER_RAMA_END_CNTL_G; | ||
1191 | uint32_t CM_SHAPER_RAMA_END_CNTL_R; | ||
1192 | uint32_t CM_SHAPER_RAMA_REGION_0_1; | ||
1193 | uint32_t CM_SHAPER_RAMA_REGION_2_3; | ||
1194 | uint32_t CM_SHAPER_RAMA_REGION_4_5; | ||
1195 | uint32_t CM_SHAPER_RAMA_REGION_6_7; | ||
1196 | uint32_t CM_SHAPER_RAMA_REGION_8_9; | ||
1197 | uint32_t CM_SHAPER_RAMA_REGION_10_11; | ||
1198 | uint32_t CM_SHAPER_RAMA_REGION_12_13; | ||
1199 | uint32_t CM_SHAPER_RAMA_REGION_14_15; | ||
1200 | uint32_t CM_SHAPER_RAMA_REGION_16_17; | ||
1201 | uint32_t CM_SHAPER_RAMA_REGION_18_19; | ||
1202 | uint32_t CM_SHAPER_RAMA_REGION_20_21; | ||
1203 | uint32_t CM_SHAPER_RAMA_REGION_22_23; | ||
1204 | uint32_t CM_SHAPER_RAMA_REGION_24_25; | ||
1205 | uint32_t CM_SHAPER_RAMA_REGION_26_27; | ||
1206 | uint32_t CM_SHAPER_RAMA_REGION_28_29; | ||
1207 | uint32_t CM_SHAPER_RAMA_REGION_30_31; | ||
1208 | uint32_t CM_SHAPER_RAMA_REGION_32_33; | ||
1209 | uint32_t CM_SHAPER_LUT_INDEX; | ||
1210 | uint32_t CM_SHAPER_LUT_DATA; | ||
1211 | uint32_t CM_ICSC_CONTROL; | ||
1212 | uint32_t CM_ICSC_C11_C12; | ||
1213 | uint32_t CM_ICSC_C33_C34; | ||
1214 | uint32_t CM_BNS_VALUES_R; | ||
1215 | uint32_t CM_BNS_VALUES_G; | ||
1216 | uint32_t CM_BNS_VALUES_B; | ||
1217 | uint32_t CM_DGAM_RAMB_START_CNTL_B; | ||
1218 | uint32_t CM_DGAM_RAMB_START_CNTL_G; | ||
1219 | uint32_t CM_DGAM_RAMB_START_CNTL_R; | ||
1220 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_B; | ||
1221 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_G; | ||
1222 | uint32_t CM_DGAM_RAMB_SLOPE_CNTL_R; | ||
1223 | uint32_t CM_DGAM_RAMB_END_CNTL1_B; | ||
1224 | uint32_t CM_DGAM_RAMB_END_CNTL2_B; | ||
1225 | uint32_t CM_DGAM_RAMB_END_CNTL1_G; | ||
1226 | uint32_t CM_DGAM_RAMB_END_CNTL2_G; | ||
1227 | uint32_t CM_DGAM_RAMB_END_CNTL1_R; | ||
1228 | uint32_t CM_DGAM_RAMB_END_CNTL2_R; | ||
1229 | uint32_t CM_DGAM_RAMB_REGION_0_1; | ||
1230 | uint32_t CM_DGAM_RAMB_REGION_14_15; | ||
1231 | uint32_t CM_DGAM_RAMA_START_CNTL_B; | ||
1232 | uint32_t CM_DGAM_RAMA_START_CNTL_G; | ||
1233 | uint32_t CM_DGAM_RAMA_START_CNTL_R; | ||
1234 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_B; | ||
1235 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_G; | ||
1236 | uint32_t CM_DGAM_RAMA_SLOPE_CNTL_R; | ||
1237 | uint32_t CM_DGAM_RAMA_END_CNTL1_B; | ||
1238 | uint32_t CM_DGAM_RAMA_END_CNTL2_B; | ||
1239 | uint32_t CM_DGAM_RAMA_END_CNTL1_G; | ||
1240 | uint32_t CM_DGAM_RAMA_END_CNTL2_G; | ||
1241 | uint32_t CM_DGAM_RAMA_END_CNTL1_R; | ||
1242 | uint32_t CM_DGAM_RAMA_END_CNTL2_R; | ||
1243 | uint32_t CM_DGAM_RAMA_REGION_0_1; | ||
1244 | uint32_t CM_DGAM_RAMA_REGION_14_15; | ||
1245 | uint32_t CM_DGAM_LUT_WRITE_EN_MASK; | ||
1246 | uint32_t CM_DGAM_LUT_INDEX; | ||
1247 | uint32_t CM_DGAM_LUT_DATA; | ||
1248 | uint32_t CM_CONTROL; | ||
1249 | uint32_t CM_DGAM_CONTROL; | ||
1250 | uint32_t CM_IGAM_CONTROL; | ||
1251 | uint32_t CM_IGAM_LUT_RW_CONTROL; | ||
1252 | uint32_t CM_IGAM_LUT_RW_INDEX; | ||
1253 | uint32_t CM_IGAM_LUT_SEQ_COLOR; | ||
1254 | uint32_t FORMAT_CONTROL; | ||
1255 | uint32_t CNVC_SURFACE_PIXEL_FORMAT; | ||
1256 | uint32_t CURSOR_CONTROL; | ||
1257 | uint32_t CURSOR0_CONTROL; | ||
1258 | uint32_t CURSOR0_COLOR0; | ||
1259 | uint32_t CURSOR0_COLOR1; | ||
1260 | }; | 1259 | }; |
1261 | 1260 | ||
1262 | struct dcn10_dpp { | 1261 | struct dcn10_dpp { |
@@ -1284,6 +1283,10 @@ enum dcn10_input_csc_select { | |||
1284 | INPUT_CSC_SELECT_COMA | 1283 | INPUT_CSC_SELECT_COMA |
1285 | }; | 1284 | }; |
1286 | 1285 | ||
1286 | void dpp1_set_cursor_attributes( | ||
1287 | struct dpp *dpp_base, | ||
1288 | enum dc_cursor_color_format color_format); | ||
1289 | |||
1287 | bool dpp1_dscl_is_lb_conf_valid( | 1290 | bool dpp1_dscl_is_lb_conf_valid( |
1288 | int ceil_vratio, | 1291 | int ceil_vratio, |
1289 | int num_partitions, | 1292 | int num_partitions, |
@@ -1371,7 +1374,7 @@ void dpp1_cm_program_regamma_lutb_settings( | |||
1371 | const struct pwl_params *params); | 1374 | const struct pwl_params *params); |
1372 | void dpp1_cm_set_output_csc_adjustment( | 1375 | void dpp1_cm_set_output_csc_adjustment( |
1373 | struct dpp *dpp_base, | 1376 | struct dpp *dpp_base, |
1374 | const struct out_csc_color_matrix *tbl_entry); | 1377 | const uint16_t *regval); |
1375 | 1378 | ||
1376 | void dpp1_cm_set_output_csc_default( | 1379 | void dpp1_cm_set_output_csc_default( |
1377 | struct dpp *dpp_base, | 1380 | struct dpp *dpp_base, |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_cm.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_cm.c index 4c90043e7b8c..a5b099023652 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_cm.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_cm.c | |||
@@ -49,6 +49,8 @@ | |||
49 | #define FN(reg_name, field_name) \ | 49 | #define FN(reg_name, field_name) \ |
50 | dpp->tf_shift->field_name, dpp->tf_mask->field_name | 50 | dpp->tf_shift->field_name, dpp->tf_mask->field_name |
51 | 51 | ||
52 | #define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0])) | ||
53 | |||
52 | struct dcn10_input_csc_matrix { | 54 | struct dcn10_input_csc_matrix { |
53 | enum dc_color_space color_space; | 55 | enum dc_color_space color_space; |
54 | uint16_t regval[12]; | 56 | uint16_t regval[12]; |
@@ -223,18 +225,18 @@ void dpp1_cm_set_gamut_remap( | |||
223 | 225 | ||
224 | static void dpp1_cm_program_color_matrix( | 226 | static void dpp1_cm_program_color_matrix( |
225 | struct dcn10_dpp *dpp, | 227 | struct dcn10_dpp *dpp, |
226 | const struct out_csc_color_matrix *tbl_entry) | 228 | const uint16_t *regval) |
227 | { | 229 | { |
228 | uint32_t mode; | 230 | uint32_t mode; |
229 | struct color_matrices_reg gam_regs; | 231 | struct color_matrices_reg gam_regs; |
230 | 232 | ||
231 | REG_GET(CM_OCSC_CONTROL, CM_OCSC_MODE, &mode); | 233 | REG_GET(CM_OCSC_CONTROL, CM_OCSC_MODE, &mode); |
232 | 234 | ||
233 | if (tbl_entry == NULL) { | 235 | if (regval == NULL) { |
234 | BREAK_TO_DEBUGGER(); | 236 | BREAK_TO_DEBUGGER(); |
235 | return; | 237 | return; |
236 | } | 238 | } |
237 | 239 | mode = 4; | |
238 | gam_regs.shifts.csc_c11 = dpp->tf_shift->CM_OCSC_C11; | 240 | gam_regs.shifts.csc_c11 = dpp->tf_shift->CM_OCSC_C11; |
239 | gam_regs.masks.csc_c11 = dpp->tf_mask->CM_OCSC_C11; | 241 | gam_regs.masks.csc_c11 = dpp->tf_mask->CM_OCSC_C11; |
240 | gam_regs.shifts.csc_c12 = dpp->tf_shift->CM_OCSC_C12; | 242 | gam_regs.shifts.csc_c12 = dpp->tf_shift->CM_OCSC_C12; |
@@ -247,7 +249,7 @@ static void dpp1_cm_program_color_matrix( | |||
247 | 249 | ||
248 | cm_helper_program_color_matrices( | 250 | cm_helper_program_color_matrices( |
249 | dpp->base.ctx, | 251 | dpp->base.ctx, |
250 | tbl_entry->regval, | 252 | regval, |
251 | &gam_regs); | 253 | &gam_regs); |
252 | 254 | ||
253 | } else { | 255 | } else { |
@@ -257,7 +259,7 @@ static void dpp1_cm_program_color_matrix( | |||
257 | 259 | ||
258 | cm_helper_program_color_matrices( | 260 | cm_helper_program_color_matrices( |
259 | dpp->base.ctx, | 261 | dpp->base.ctx, |
260 | tbl_entry->regval, | 262 | regval, |
261 | &gam_regs); | 263 | &gam_regs); |
262 | } | 264 | } |
263 | } | 265 | } |
@@ -266,24 +268,18 @@ void dpp1_cm_set_output_csc_default( | |||
266 | struct dpp *dpp_base, | 268 | struct dpp *dpp_base, |
267 | enum dc_color_space colorspace) | 269 | enum dc_color_space colorspace) |
268 | { | 270 | { |
269 | |||
270 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); | 271 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); |
271 | struct out_csc_color_matrix tbl_entry; | 272 | const uint16_t *regval = NULL; |
272 | int i, j; | 273 | int arr_size; |
273 | int arr_size = sizeof(output_csc_matrix) / sizeof(struct output_csc_matrix); | ||
274 | uint32_t ocsc_mode = 4; | 274 | uint32_t ocsc_mode = 4; |
275 | 275 | ||
276 | tbl_entry.color_space = colorspace; | 276 | regval = find_color_matrix(colorspace, &arr_size); |
277 | 277 | if (regval == NULL) { | |
278 | for (i = 0; i < arr_size; i++) | 278 | BREAK_TO_DEBUGGER(); |
279 | if (output_csc_matrix[i].color_space == colorspace) { | 279 | return; |
280 | for (j = 0; j < 12; j++) | 280 | } |
281 | tbl_entry.regval[j] = output_csc_matrix[i].regval[j]; | 281 | dpp1_cm_program_color_matrix(dpp, regval); |
282 | break; | ||
283 | } | ||
284 | |||
285 | REG_SET(CM_OCSC_CONTROL, 0, CM_OCSC_MODE, ocsc_mode); | 282 | REG_SET(CM_OCSC_CONTROL, 0, CM_OCSC_MODE, ocsc_mode); |
286 | dpp1_cm_program_color_matrix(dpp, &tbl_entry); | ||
287 | } | 283 | } |
288 | 284 | ||
289 | static void dpp1_cm_get_reg_field( | 285 | static void dpp1_cm_get_reg_field( |
@@ -315,41 +311,12 @@ static void dpp1_cm_get_reg_field( | |||
315 | 311 | ||
316 | void dpp1_cm_set_output_csc_adjustment( | 312 | void dpp1_cm_set_output_csc_adjustment( |
317 | struct dpp *dpp_base, | 313 | struct dpp *dpp_base, |
318 | const struct out_csc_color_matrix *tbl_entry) | 314 | const uint16_t *regval) |
319 | { | 315 | { |
320 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); | 316 | struct dcn10_dpp *dpp = TO_DCN10_DPP(dpp_base); |
321 | //enum csc_color_mode config = CSC_COLOR_MODE_GRAPHICS_OUTPUT_CSC; | ||
322 | uint32_t ocsc_mode = 4; | 317 | uint32_t ocsc_mode = 4; |
323 | 318 | dpp1_cm_program_color_matrix(dpp, regval); | |
324 | /** | ||
325 | *if (tbl_entry != NULL) { | ||
326 | * switch (tbl_entry->color_space) { | ||
327 | * case COLOR_SPACE_SRGB: | ||
328 | * case COLOR_SPACE_2020_RGB_FULLRANGE: | ||
329 | * ocsc_mode = 0; | ||
330 | * break; | ||
331 | * case COLOR_SPACE_SRGB_LIMITED: | ||
332 | * case COLOR_SPACE_2020_RGB_LIMITEDRANGE: | ||
333 | * ocsc_mode = 1; | ||
334 | * break; | ||
335 | * case COLOR_SPACE_YCBCR601: | ||
336 | * case COLOR_SPACE_YCBCR601_LIMITED: | ||
337 | * ocsc_mode = 2; | ||
338 | * break; | ||
339 | * case COLOR_SPACE_YCBCR709: | ||
340 | * case COLOR_SPACE_YCBCR709_LIMITED: | ||
341 | * case COLOR_SPACE_2020_YCBCR: | ||
342 | * ocsc_mode = 3; | ||
343 | * break; | ||
344 | * case COLOR_SPACE_UNKNOWN: | ||
345 | * default: | ||
346 | * break; | ||
347 | * } | ||
348 | *} | ||
349 | */ | ||
350 | |||
351 | REG_SET(CM_OCSC_CONTROL, 0, CM_OCSC_MODE, ocsc_mode); | 319 | REG_SET(CM_OCSC_CONTROL, 0, CM_OCSC_MODE, ocsc_mode); |
352 | dpp1_cm_program_color_matrix(dpp, tbl_entry); | ||
353 | } | 320 | } |
354 | 321 | ||
355 | void dpp1_cm_power_on_regamma_lut(struct dpp *dpp_base, | 322 | void dpp1_cm_power_on_regamma_lut(struct dpp *dpp_base, |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c index 584e82cc5df3..585b33384002 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | |||
@@ -48,9 +48,20 @@ void hubp1_set_blank(struct hubp *hubp, bool blank) | |||
48 | HUBP_TTU_DISABLE, blank_en); | 48 | HUBP_TTU_DISABLE, blank_en); |
49 | 49 | ||
50 | if (blank) { | 50 | if (blank) { |
51 | REG_WAIT(DCHUBP_CNTL, | 51 | uint32_t reg_val = REG_READ(DCHUBP_CNTL); |
52 | HUBP_NO_OUTSTANDING_REQ, 1, | 52 | |
53 | 1, 200); | 53 | if (reg_val) { |
54 | /* init sequence workaround: in case HUBP is | ||
55 | * power gated, this wait would timeout. | ||
56 | * | ||
57 | * we just wrote reg_val to non-0, if it stay 0 | ||
58 | * it means HUBP is gated | ||
59 | */ | ||
60 | REG_WAIT(DCHUBP_CNTL, | ||
61 | HUBP_NO_OUTSTANDING_REQ, 1, | ||
62 | 1, 200); | ||
63 | } | ||
64 | |||
54 | hubp->mpcc_id = 0xf; | 65 | hubp->mpcc_id = 0xf; |
55 | hubp->opp_id = 0xf; | 66 | hubp->opp_id = 0xf; |
56 | } | 67 | } |
@@ -96,10 +107,12 @@ static void hubp1_vready_workaround(struct hubp *hubp, | |||
96 | } | 107 | } |
97 | 108 | ||
98 | void hubp1_program_tiling( | 109 | void hubp1_program_tiling( |
99 | struct dcn10_hubp *hubp1, | 110 | struct hubp *hubp, |
100 | const union dc_tiling_info *info, | 111 | const union dc_tiling_info *info, |
101 | const enum surface_pixel_format pixel_format) | 112 | const enum surface_pixel_format pixel_format) |
102 | { | 113 | { |
114 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
115 | |||
103 | REG_UPDATE_6(DCSURF_ADDR_CONFIG, | 116 | REG_UPDATE_6(DCSURF_ADDR_CONFIG, |
104 | NUM_PIPES, log_2(info->gfx9.num_pipes), | 117 | NUM_PIPES, log_2(info->gfx9.num_pipes), |
105 | NUM_BANKS, log_2(info->gfx9.num_banks), | 118 | NUM_BANKS, log_2(info->gfx9.num_banks), |
@@ -116,13 +129,14 @@ void hubp1_program_tiling( | |||
116 | } | 129 | } |
117 | 130 | ||
118 | void hubp1_program_size_and_rotation( | 131 | void hubp1_program_size_and_rotation( |
119 | struct dcn10_hubp *hubp1, | 132 | struct hubp *hubp, |
120 | enum dc_rotation_angle rotation, | 133 | enum dc_rotation_angle rotation, |
121 | enum surface_pixel_format format, | 134 | enum surface_pixel_format format, |
122 | const union plane_size *plane_size, | 135 | const union plane_size *plane_size, |
123 | struct dc_plane_dcc_param *dcc, | 136 | struct dc_plane_dcc_param *dcc, |
124 | bool horizontal_mirror) | 137 | bool horizontal_mirror) |
125 | { | 138 | { |
139 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
126 | uint32_t pitch, meta_pitch, pitch_c, meta_pitch_c, mirror; | 140 | uint32_t pitch, meta_pitch, pitch_c, meta_pitch_c, mirror; |
127 | 141 | ||
128 | /* Program data and meta surface pitch (calculation from addrlib) | 142 | /* Program data and meta surface pitch (calculation from addrlib) |
@@ -178,9 +192,10 @@ void hubp1_program_size_and_rotation( | |||
178 | } | 192 | } |
179 | 193 | ||
180 | void hubp1_program_pixel_format( | 194 | void hubp1_program_pixel_format( |
181 | struct dcn10_hubp *hubp1, | 195 | struct hubp *hubp, |
182 | enum surface_pixel_format format) | 196 | enum surface_pixel_format format) |
183 | { | 197 | { |
198 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
184 | uint32_t red_bar = 3; | 199 | uint32_t red_bar = 3; |
185 | uint32_t blue_bar = 2; | 200 | uint32_t blue_bar = 2; |
186 | 201 | ||
@@ -424,13 +439,11 @@ void hubp1_program_surface_config( | |||
424 | struct dc_plane_dcc_param *dcc, | 439 | struct dc_plane_dcc_param *dcc, |
425 | bool horizontal_mirror) | 440 | bool horizontal_mirror) |
426 | { | 441 | { |
427 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | ||
428 | |||
429 | hubp1_dcc_control(hubp, dcc->enable, dcc->grph.independent_64b_blks); | 442 | hubp1_dcc_control(hubp, dcc->enable, dcc->grph.independent_64b_blks); |
430 | hubp1_program_tiling(hubp1, tiling_info, format); | 443 | hubp1_program_tiling(hubp, tiling_info, format); |
431 | hubp1_program_size_and_rotation( | 444 | hubp1_program_size_and_rotation( |
432 | hubp1, rotation, format, plane_size, dcc, horizontal_mirror); | 445 | hubp, rotation, format, plane_size, dcc, horizontal_mirror); |
433 | hubp1_program_pixel_format(hubp1, format); | 446 | hubp1_program_pixel_format(hubp, format); |
434 | } | 447 | } |
435 | 448 | ||
436 | void hubp1_program_requestor( | 449 | void hubp1_program_requestor( |
@@ -765,42 +778,7 @@ void hubp1_read_state(struct dcn10_hubp *hubp1, | |||
765 | QoS_LEVEL_HIGH_WM, &s->qos_level_high_wm); | 778 | QoS_LEVEL_HIGH_WM, &s->qos_level_high_wm); |
766 | } | 779 | } |
767 | 780 | ||
768 | enum cursor_pitch { | 781 | enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch) |
769 | CURSOR_PITCH_64_PIXELS = 0, | ||
770 | CURSOR_PITCH_128_PIXELS, | ||
771 | CURSOR_PITCH_256_PIXELS | ||
772 | }; | ||
773 | |||
774 | enum cursor_lines_per_chunk { | ||
775 | CURSOR_LINE_PER_CHUNK_2 = 1, | ||
776 | CURSOR_LINE_PER_CHUNK_4, | ||
777 | CURSOR_LINE_PER_CHUNK_8, | ||
778 | CURSOR_LINE_PER_CHUNK_16 | ||
779 | }; | ||
780 | |||
781 | static bool ippn10_cursor_program_control( | ||
782 | struct dcn10_hubp *hubp1, | ||
783 | bool pixel_data_invert, | ||
784 | enum dc_cursor_color_format color_format) | ||
785 | { | ||
786 | if (REG(CURSOR_SETTINS)) | ||
787 | REG_SET_2(CURSOR_SETTINS, 0, | ||
788 | /* no shift of the cursor HDL schedule */ | ||
789 | CURSOR0_DST_Y_OFFSET, 0, | ||
790 | /* used to shift the cursor chunk request deadline */ | ||
791 | CURSOR0_CHUNK_HDL_ADJUST, 3); | ||
792 | else | ||
793 | REG_SET_2(CURSOR_SETTINGS, 0, | ||
794 | /* no shift of the cursor HDL schedule */ | ||
795 | CURSOR0_DST_Y_OFFSET, 0, | ||
796 | /* used to shift the cursor chunk request deadline */ | ||
797 | CURSOR0_CHUNK_HDL_ADJUST, 3); | ||
798 | |||
799 | return true; | ||
800 | } | ||
801 | |||
802 | static enum cursor_pitch ippn10_get_cursor_pitch( | ||
803 | unsigned int pitch) | ||
804 | { | 782 | { |
805 | enum cursor_pitch hw_pitch; | 783 | enum cursor_pitch hw_pitch; |
806 | 784 | ||
@@ -823,7 +801,7 @@ static enum cursor_pitch ippn10_get_cursor_pitch( | |||
823 | return hw_pitch; | 801 | return hw_pitch; |
824 | } | 802 | } |
825 | 803 | ||
826 | static enum cursor_lines_per_chunk ippn10_get_lines_per_chunk( | 804 | static enum cursor_lines_per_chunk hubp1_get_lines_per_chunk( |
827 | unsigned int cur_width, | 805 | unsigned int cur_width, |
828 | enum dc_cursor_color_format format) | 806 | enum dc_cursor_color_format format) |
829 | { | 807 | { |
@@ -849,8 +827,8 @@ void hubp1_cursor_set_attributes( | |||
849 | const struct dc_cursor_attributes *attr) | 827 | const struct dc_cursor_attributes *attr) |
850 | { | 828 | { |
851 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); | 829 | struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp); |
852 | enum cursor_pitch hw_pitch = ippn10_get_cursor_pitch(attr->pitch); | 830 | enum cursor_pitch hw_pitch = hubp1_get_cursor_pitch(attr->pitch); |
853 | enum cursor_lines_per_chunk lpc = ippn10_get_lines_per_chunk( | 831 | enum cursor_lines_per_chunk lpc = hubp1_get_lines_per_chunk( |
854 | attr->width, attr->color_format); | 832 | attr->width, attr->color_format); |
855 | 833 | ||
856 | hubp->curs_attr = *attr; | 834 | hubp->curs_attr = *attr; |
@@ -863,13 +841,17 @@ void hubp1_cursor_set_attributes( | |||
863 | REG_UPDATE_2(CURSOR_SIZE, | 841 | REG_UPDATE_2(CURSOR_SIZE, |
864 | CURSOR_WIDTH, attr->width, | 842 | CURSOR_WIDTH, attr->width, |
865 | CURSOR_HEIGHT, attr->height); | 843 | CURSOR_HEIGHT, attr->height); |
844 | |||
866 | REG_UPDATE_3(CURSOR_CONTROL, | 845 | REG_UPDATE_3(CURSOR_CONTROL, |
867 | CURSOR_MODE, attr->color_format, | 846 | CURSOR_MODE, attr->color_format, |
868 | CURSOR_PITCH, hw_pitch, | 847 | CURSOR_PITCH, hw_pitch, |
869 | CURSOR_LINES_PER_CHUNK, lpc); | 848 | CURSOR_LINES_PER_CHUNK, lpc); |
870 | ippn10_cursor_program_control(hubp1, | 849 | |
871 | attr->attribute_flags.bits.INVERT_PIXEL_DATA, | 850 | REG_SET_2(CURSOR_SETTINS, 0, |
872 | attr->color_format); | 851 | /* no shift of the cursor HDL schedule */ |
852 | CURSOR0_DST_Y_OFFSET, 0, | ||
853 | /* used to shift the cursor chunk request deadline */ | ||
854 | CURSOR0_CHUNK_HDL_ADJUST, 3); | ||
873 | } | 855 | } |
874 | 856 | ||
875 | void hubp1_cursor_set_position( | 857 | void hubp1_cursor_set_position( |
@@ -909,7 +891,8 @@ void hubp1_cursor_set_position( | |||
909 | cur_en = 0; /* not visible beyond left edge*/ | 891 | cur_en = 0; /* not visible beyond left edge*/ |
910 | 892 | ||
911 | if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0) | 893 | if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0) |
912 | hubp1_cursor_set_attributes(hubp, &hubp->curs_attr); | 894 | hubp->funcs->set_cursor_attributes(hubp, &hubp->curs_attr); |
895 | |||
913 | REG_UPDATE(CURSOR_CONTROL, | 896 | REG_UPDATE(CURSOR_CONTROL, |
914 | CURSOR_ENABLE, cur_en); | 897 | CURSOR_ENABLE, cur_en); |
915 | 898 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h index a7834dd50716..33e91d9c010f 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h | |||
@@ -127,113 +127,110 @@ | |||
127 | SRI(CURSOR_HOT_SPOT, CURSOR, id), \ | 127 | SRI(CURSOR_HOT_SPOT, CURSOR, id), \ |
128 | SRI(CURSOR_DST_OFFSET, CURSOR, id) | 128 | SRI(CURSOR_DST_OFFSET, CURSOR, id) |
129 | 129 | ||
130 | 130 | #define HUBP_COMMON_REG_VARIABLE_LIST \ | |
131 | 131 | uint32_t DCHUBP_CNTL; \ | |
132 | struct dcn_mi_registers { | 132 | uint32_t HUBPREQ_DEBUG_DB; \ |
133 | uint32_t DCHUBP_CNTL; | 133 | uint32_t DCSURF_ADDR_CONFIG; \ |
134 | uint32_t HUBPREQ_DEBUG_DB; | 134 | uint32_t DCSURF_TILING_CONFIG; \ |
135 | uint32_t DCSURF_ADDR_CONFIG; | 135 | uint32_t DCSURF_SURFACE_PITCH; \ |
136 | uint32_t DCSURF_TILING_CONFIG; | 136 | uint32_t DCSURF_SURFACE_PITCH_C; \ |
137 | uint32_t DCSURF_SURFACE_PITCH; | 137 | uint32_t DCSURF_SURFACE_CONFIG; \ |
138 | uint32_t DCSURF_SURFACE_PITCH_C; | 138 | uint32_t DCSURF_FLIP_CONTROL; \ |
139 | uint32_t DCSURF_SURFACE_CONFIG; | 139 | uint32_t DCSURF_PRI_VIEWPORT_DIMENSION; \ |
140 | uint32_t DCSURF_FLIP_CONTROL; | 140 | uint32_t DCSURF_PRI_VIEWPORT_START; \ |
141 | uint32_t DCSURF_PRI_VIEWPORT_DIMENSION; | 141 | uint32_t DCSURF_SEC_VIEWPORT_DIMENSION; \ |
142 | uint32_t DCSURF_PRI_VIEWPORT_START; | 142 | uint32_t DCSURF_SEC_VIEWPORT_START; \ |
143 | uint32_t DCSURF_SEC_VIEWPORT_DIMENSION; | 143 | uint32_t DCSURF_PRI_VIEWPORT_DIMENSION_C; \ |
144 | uint32_t DCSURF_SEC_VIEWPORT_START; | 144 | uint32_t DCSURF_PRI_VIEWPORT_START_C; \ |
145 | uint32_t DCSURF_PRI_VIEWPORT_DIMENSION_C; | 145 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; \ |
146 | uint32_t DCSURF_PRI_VIEWPORT_START_C; | 146 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; \ |
147 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; | 147 | uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS_HIGH; \ |
148 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; | 148 | uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS; \ |
149 | uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS_HIGH; | 149 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH; \ |
150 | uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS; | 150 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS; \ |
151 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH; | 151 | uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS_HIGH; \ |
152 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS; | 152 | uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS; \ |
153 | uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS_HIGH; | 153 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; \ |
154 | uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS; | 154 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; \ |
155 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; | 155 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH_C; \ |
156 | uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; | 156 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_C; \ |
157 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH_C; | 157 | uint32_t DCSURF_SURFACE_INUSE; \ |
158 | uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_C; | 158 | uint32_t DCSURF_SURFACE_INUSE_HIGH; \ |
159 | uint32_t DCSURF_SURFACE_INUSE; | 159 | uint32_t DCSURF_SURFACE_INUSE_C; \ |
160 | uint32_t DCSURF_SURFACE_INUSE_HIGH; | 160 | uint32_t DCSURF_SURFACE_INUSE_HIGH_C; \ |
161 | uint32_t DCSURF_SURFACE_INUSE_C; | 161 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE; \ |
162 | uint32_t DCSURF_SURFACE_INUSE_HIGH_C; | 162 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_HIGH; \ |
163 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE; | 163 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_C; \ |
164 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_HIGH; | 164 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_HIGH_C; \ |
165 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_C; | 165 | uint32_t DCSURF_SURFACE_CONTROL; \ |
166 | uint32_t DCSURF_SURFACE_EARLIEST_INUSE_HIGH_C; | 166 | uint32_t HUBPRET_CONTROL; \ |
167 | uint32_t DCSURF_SURFACE_CONTROL; | 167 | uint32_t DCN_EXPANSION_MODE; \ |
168 | uint32_t HUBPRET_CONTROL; | 168 | uint32_t DCHUBP_REQ_SIZE_CONFIG; \ |
169 | uint32_t DCN_EXPANSION_MODE; | 169 | uint32_t DCHUBP_REQ_SIZE_CONFIG_C; \ |
170 | uint32_t DCHUBP_REQ_SIZE_CONFIG; | 170 | uint32_t BLANK_OFFSET_0; \ |
171 | uint32_t DCHUBP_REQ_SIZE_CONFIG_C; | 171 | uint32_t BLANK_OFFSET_1; \ |
172 | uint32_t BLANK_OFFSET_0; | 172 | uint32_t DST_DIMENSIONS; \ |
173 | uint32_t BLANK_OFFSET_1; | 173 | uint32_t DST_AFTER_SCALER; \ |
174 | uint32_t DST_DIMENSIONS; | 174 | uint32_t PREFETCH_SETTINS; \ |
175 | uint32_t DST_AFTER_SCALER; | 175 | uint32_t PREFETCH_SETTINGS; \ |
176 | uint32_t PREFETCH_SETTINS; | 176 | uint32_t VBLANK_PARAMETERS_0; \ |
177 | uint32_t PREFETCH_SETTINGS; | 177 | uint32_t REF_FREQ_TO_PIX_FREQ; \ |
178 | uint32_t VBLANK_PARAMETERS_0; | 178 | uint32_t VBLANK_PARAMETERS_1; \ |
179 | uint32_t REF_FREQ_TO_PIX_FREQ; | 179 | uint32_t VBLANK_PARAMETERS_3; \ |
180 | uint32_t VBLANK_PARAMETERS_1; | 180 | uint32_t NOM_PARAMETERS_0; \ |
181 | uint32_t VBLANK_PARAMETERS_3; | 181 | uint32_t NOM_PARAMETERS_1; \ |
182 | uint32_t NOM_PARAMETERS_0; | 182 | uint32_t NOM_PARAMETERS_4; \ |
183 | uint32_t NOM_PARAMETERS_1; | 183 | uint32_t NOM_PARAMETERS_5; \ |
184 | uint32_t NOM_PARAMETERS_4; | 184 | uint32_t PER_LINE_DELIVERY_PRE; \ |
185 | uint32_t NOM_PARAMETERS_5; | 185 | uint32_t PER_LINE_DELIVERY; \ |
186 | uint32_t PER_LINE_DELIVERY_PRE; | 186 | uint32_t PREFETCH_SETTINS_C; \ |
187 | uint32_t PER_LINE_DELIVERY; | 187 | uint32_t PREFETCH_SETTINGS_C; \ |
188 | uint32_t PREFETCH_SETTINS_C; | 188 | uint32_t VBLANK_PARAMETERS_2; \ |
189 | uint32_t PREFETCH_SETTINGS_C; | 189 | uint32_t VBLANK_PARAMETERS_4; \ |
190 | uint32_t VBLANK_PARAMETERS_2; | 190 | uint32_t NOM_PARAMETERS_2; \ |
191 | uint32_t VBLANK_PARAMETERS_4; | 191 | uint32_t NOM_PARAMETERS_3; \ |
192 | uint32_t NOM_PARAMETERS_2; | 192 | uint32_t NOM_PARAMETERS_6; \ |
193 | uint32_t NOM_PARAMETERS_3; | 193 | uint32_t NOM_PARAMETERS_7; \ |
194 | uint32_t NOM_PARAMETERS_6; | 194 | uint32_t DCN_TTU_QOS_WM; \ |
195 | uint32_t NOM_PARAMETERS_7; | 195 | uint32_t DCN_GLOBAL_TTU_CNTL; \ |
196 | uint32_t DCN_TTU_QOS_WM; | 196 | uint32_t DCN_SURF0_TTU_CNTL0; \ |
197 | uint32_t DCN_GLOBAL_TTU_CNTL; | 197 | uint32_t DCN_SURF0_TTU_CNTL1; \ |
198 | uint32_t DCN_SURF0_TTU_CNTL0; | 198 | uint32_t DCN_SURF1_TTU_CNTL0; \ |
199 | uint32_t DCN_SURF0_TTU_CNTL1; | 199 | uint32_t DCN_SURF1_TTU_CNTL1; \ |
200 | uint32_t DCN_SURF1_TTU_CNTL0; | 200 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_MSB; \ |
201 | uint32_t DCN_SURF1_TTU_CNTL1; | 201 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LSB; \ |
202 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_MSB; | 202 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_MSB; \ |
203 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LSB; | 203 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_LSB; \ |
204 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_MSB; | 204 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_MSB; \ |
205 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_START_ADDR_LSB; | 205 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_LSB; \ |
206 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_MSB; | 206 | uint32_t DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_MSB; \ |
207 | uint32_t DCN_VM_CONTEXT0_PAGE_TABLE_END_ADDR_LSB; | 207 | uint32_t DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_LSB; \ |
208 | uint32_t DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_MSB; | 208 | uint32_t DCN_VM_MX_L1_TLB_CNTL; \ |
209 | uint32_t DCN_VM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR_LSB; | 209 | uint32_t DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB; \ |
210 | uint32_t DCN_VM_MX_L1_TLB_CNTL; | 210 | uint32_t DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB; \ |
211 | uint32_t DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB; | 211 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR_MSB; \ |
212 | uint32_t DCN_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB; | 212 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR_LSB; \ |
213 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR_MSB; | 213 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_MSB; \ |
214 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR_LSB; | 214 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_LSB; \ |
215 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_MSB; | 215 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR; \ |
216 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR_LSB; | 216 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR; \ |
217 | uint32_t DCN_VM_SYSTEM_APERTURE_LOW_ADDR; | 217 | uint32_t DCHUBBUB_SDPIF_FB_BASE; \ |
218 | uint32_t DCN_VM_SYSTEM_APERTURE_HIGH_ADDR; | 218 | uint32_t DCHUBBUB_SDPIF_FB_OFFSET; \ |
219 | uint32_t DCHUBBUB_SDPIF_FB_BASE; | 219 | uint32_t DCN_VM_FB_LOCATION_TOP; \ |
220 | uint32_t DCHUBBUB_SDPIF_FB_OFFSET; | 220 | uint32_t DCN_VM_FB_LOCATION_BASE; \ |
221 | uint32_t DCN_VM_FB_LOCATION_TOP; | 221 | uint32_t DCN_VM_FB_OFFSET; \ |
222 | uint32_t DCN_VM_FB_LOCATION_BASE; | 222 | uint32_t DCN_VM_AGP_BASE; \ |
223 | uint32_t DCN_VM_FB_OFFSET; | 223 | uint32_t DCN_VM_AGP_BOT; \ |
224 | uint32_t DCN_VM_AGP_BASE; | 224 | uint32_t DCN_VM_AGP_TOP; \ |
225 | uint32_t DCN_VM_AGP_BOT; | 225 | uint32_t CURSOR_SETTINS; \ |
226 | uint32_t DCN_VM_AGP_TOP; | 226 | uint32_t CURSOR_SETTINGS; \ |
227 | uint32_t CURSOR_SETTINS; | 227 | uint32_t CURSOR_SURFACE_ADDRESS_HIGH; \ |
228 | uint32_t CURSOR_SETTINGS; | 228 | uint32_t CURSOR_SURFACE_ADDRESS; \ |
229 | uint32_t CURSOR_SURFACE_ADDRESS_HIGH; | 229 | uint32_t CURSOR_SIZE; \ |
230 | uint32_t CURSOR_SURFACE_ADDRESS; | 230 | uint32_t CURSOR_CONTROL; \ |
231 | uint32_t CURSOR_SIZE; | 231 | uint32_t CURSOR_POSITION; \ |
232 | uint32_t CURSOR_CONTROL; | 232 | uint32_t CURSOR_HOT_SPOT; \ |
233 | uint32_t CURSOR_POSITION; | 233 | uint32_t CURSOR_DST_OFFSET |
234 | uint32_t CURSOR_HOT_SPOT; | ||
235 | uint32_t CURSOR_DST_OFFSET; | ||
236 | }; | ||
237 | 234 | ||
238 | #define HUBP_SF(reg_name, field_name, post_fix)\ | 235 | #define HUBP_SF(reg_name, field_name, post_fix)\ |
239 | .field_name = reg_name ## __ ## field_name ## post_fix | 236 | .field_name = reg_name ## __ ## field_name ## post_fix |
@@ -397,7 +394,6 @@ struct dcn_mi_registers { | |||
397 | HUBP_SF(CURSOR0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \ | 394 | HUBP_SF(CURSOR0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \ |
398 | HUBP_SF(CURSOR0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh) | 395 | HUBP_SF(CURSOR0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh) |
399 | 396 | ||
400 | |||
401 | #define DCN_HUBP_REG_FIELD_LIST(type) \ | 397 | #define DCN_HUBP_REG_FIELD_LIST(type) \ |
402 | type HUBP_BLANK_EN;\ | 398 | type HUBP_BLANK_EN;\ |
403 | type HUBP_TTU_DISABLE;\ | 399 | type HUBP_TTU_DISABLE;\ |
@@ -577,6 +573,10 @@ struct dcn_mi_registers { | |||
577 | type CURSOR_DST_X_OFFSET; \ | 573 | type CURSOR_DST_X_OFFSET; \ |
578 | type OUTPUT_FP | 574 | type OUTPUT_FP |
579 | 575 | ||
576 | struct dcn_mi_registers { | ||
577 | HUBP_COMMON_REG_VARIABLE_LIST; | ||
578 | }; | ||
579 | |||
580 | struct dcn_mi_shift { | 580 | struct dcn_mi_shift { |
581 | DCN_HUBP_REG_FIELD_LIST(uint8_t); | 581 | DCN_HUBP_REG_FIELD_LIST(uint8_t); |
582 | }; | 582 | }; |
@@ -611,11 +611,11 @@ void hubp1_program_requestor( | |||
611 | struct _vcs_dpi_display_rq_regs_st *rq_regs); | 611 | struct _vcs_dpi_display_rq_regs_st *rq_regs); |
612 | 612 | ||
613 | void hubp1_program_pixel_format( | 613 | void hubp1_program_pixel_format( |
614 | struct dcn10_hubp *hubp, | 614 | struct hubp *hubp, |
615 | enum surface_pixel_format format); | 615 | enum surface_pixel_format format); |
616 | 616 | ||
617 | void hubp1_program_size_and_rotation( | 617 | void hubp1_program_size_and_rotation( |
618 | struct dcn10_hubp *hubp, | 618 | struct hubp *hubp, |
619 | enum dc_rotation_angle rotation, | 619 | enum dc_rotation_angle rotation, |
620 | enum surface_pixel_format format, | 620 | enum surface_pixel_format format, |
621 | const union plane_size *plane_size, | 621 | const union plane_size *plane_size, |
@@ -623,7 +623,7 @@ void hubp1_program_size_and_rotation( | |||
623 | bool horizontal_mirror); | 623 | bool horizontal_mirror); |
624 | 624 | ||
625 | void hubp1_program_tiling( | 625 | void hubp1_program_tiling( |
626 | struct dcn10_hubp *hubp, | 626 | struct hubp *hubp, |
627 | const union dc_tiling_info *info, | 627 | const union dc_tiling_info *info, |
628 | const enum surface_pixel_format pixel_format); | 628 | const enum surface_pixel_format pixel_format); |
629 | 629 | ||
@@ -681,4 +681,6 @@ struct dcn_hubp_state { | |||
681 | void hubp1_read_state(struct dcn10_hubp *hubp1, | 681 | void hubp1_read_state(struct dcn10_hubp *hubp1, |
682 | struct dcn_hubp_state *s); | 682 | struct dcn_hubp_state *s); |
683 | 683 | ||
684 | enum cursor_pitch hubp1_get_cursor_pitch(unsigned int pitch); | ||
685 | |||
684 | #endif | 686 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 8e2ddbc2129c..82572863acab 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include "dce/dce_hwseq.h" | 32 | #include "dce/dce_hwseq.h" |
33 | #include "abm.h" | 33 | #include "abm.h" |
34 | #include "dmcu.h" | 34 | #include "dmcu.h" |
35 | #include "dcn10/dcn10_timing_generator.h" | 35 | #include "dcn10_optc.h" |
36 | #include "dcn10/dcn10_dpp.h" | 36 | #include "dcn10/dcn10_dpp.h" |
37 | #include "dcn10/dcn10_mpc.h" | 37 | #include "dcn10/dcn10_mpc.h" |
38 | #include "timing_generator.h" | 38 | #include "timing_generator.h" |
@@ -43,6 +43,7 @@ | |||
43 | #include "custom_float.h" | 43 | #include "custom_float.h" |
44 | #include "dcn10_hubp.h" | 44 | #include "dcn10_hubp.h" |
45 | #include "dcn10_hubbub.h" | 45 | #include "dcn10_hubbub.h" |
46 | #include "dcn10_cm_common.h" | ||
46 | 47 | ||
47 | #define CTX \ | 48 | #define CTX \ |
48 | hws->ctx | 49 | hws->ctx |
@@ -158,7 +159,7 @@ void dcn10_log_hw_state(struct dc *dc) | |||
158 | struct timing_generator *tg = pool->timing_generators[i]; | 159 | struct timing_generator *tg = pool->timing_generators[i]; |
159 | struct dcn_otg_state s = {0}; | 160 | struct dcn_otg_state s = {0}; |
160 | 161 | ||
161 | tgn10_read_otg_state(DCN10TG_FROM_TG(tg), &s); | 162 | optc1_read_otg_state(DCN10TG_FROM_TG(tg), &s); |
162 | 163 | ||
163 | //only print if OTG master is enabled | 164 | //only print if OTG master is enabled |
164 | if ((s.otg_enabled & 1) == 0) | 165 | if ((s.otg_enabled & 1) == 0) |
@@ -425,6 +426,34 @@ static void bios_golden_init(struct dc *dc) | |||
425 | } | 426 | } |
426 | } | 427 | } |
427 | 428 | ||
429 | static void false_optc_underflow_wa( | ||
430 | struct dc *dc, | ||
431 | const struct dc_stream_state *stream, | ||
432 | struct timing_generator *tg) | ||
433 | { | ||
434 | int i; | ||
435 | bool underflow; | ||
436 | |||
437 | if (!dc->hwseq->wa.false_optc_underflow) | ||
438 | return; | ||
439 | |||
440 | underflow = tg->funcs->is_optc_underflow_occurred(tg); | ||
441 | |||
442 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | ||
443 | struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i]; | ||
444 | |||
445 | if (old_pipe_ctx->stream != stream) | ||
446 | continue; | ||
447 | |||
448 | dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, old_pipe_ctx); | ||
449 | } | ||
450 | |||
451 | tg->funcs->set_blank_data_double_buffer(tg, true); | ||
452 | |||
453 | if (tg->funcs->is_optc_underflow_occurred(tg) && !underflow) | ||
454 | tg->funcs->clear_optc_underflow(tg); | ||
455 | } | ||
456 | |||
428 | static enum dc_status dcn10_prog_pixclk_crtc_otg( | 457 | static enum dc_status dcn10_prog_pixclk_crtc_otg( |
429 | struct pipe_ctx *pipe_ctx, | 458 | struct pipe_ctx *pipe_ctx, |
430 | struct dc_state *context, | 459 | struct dc_state *context, |
@@ -433,9 +462,6 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg( | |||
433 | struct dc_stream_state *stream = pipe_ctx->stream; | 462 | struct dc_stream_state *stream = pipe_ctx->stream; |
434 | enum dc_color_space color_space; | 463 | enum dc_color_space color_space; |
435 | struct tg_color black_color = {0}; | 464 | struct tg_color black_color = {0}; |
436 | bool enableStereo = stream->timing.timing_3d_format == TIMING_3D_FORMAT_NONE ? | ||
437 | false:true; | ||
438 | bool rightEyePolarity = stream->timing.flags.RIGHT_EYE_3D_POLARITY; | ||
439 | 465 | ||
440 | /* by upper caller loop, pipe0 is parent pipe and be called first. | 466 | /* by upper caller loop, pipe0 is parent pipe and be called first. |
441 | * back end is set up by for pipe0. Other children pipe share back end | 467 | * back end is set up by for pipe0. Other children pipe share back end |
@@ -470,11 +496,6 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg( | |||
470 | &stream->timing, | 496 | &stream->timing, |
471 | true); | 497 | true); |
472 | 498 | ||
473 | pipe_ctx->stream_res.opp->funcs->opp_set_stereo_polarity( | ||
474 | pipe_ctx->stream_res.opp, | ||
475 | enableStereo, | ||
476 | rightEyePolarity); | ||
477 | |||
478 | #if 0 /* move to after enable_crtc */ | 499 | #if 0 /* move to after enable_crtc */ |
479 | /* TODO: OPP FMT, ABM. etc. should be done here. */ | 500 | /* TODO: OPP FMT, ABM. etc. should be done here. */ |
480 | /* or FPGA now. instance 0 only. TODO: move to opp.c */ | 501 | /* or FPGA now. instance 0 only. TODO: move to opp.c */ |
@@ -489,12 +510,18 @@ static enum dc_status dcn10_prog_pixclk_crtc_otg( | |||
489 | /* program otg blank color */ | 510 | /* program otg blank color */ |
490 | color_space = stream->output_color_space; | 511 | color_space = stream->output_color_space; |
491 | color_space_to_black_color(dc, color_space, &black_color); | 512 | color_space_to_black_color(dc, color_space, &black_color); |
492 | pipe_ctx->stream_res.tg->funcs->set_blank_color( | ||
493 | pipe_ctx->stream_res.tg, | ||
494 | &black_color); | ||
495 | 513 | ||
496 | pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, true); | 514 | if (pipe_ctx->stream_res.tg->funcs->set_blank_color) |
497 | hwss_wait_for_blank_complete(pipe_ctx->stream_res.tg); | 515 | pipe_ctx->stream_res.tg->funcs->set_blank_color( |
516 | pipe_ctx->stream_res.tg, | ||
517 | &black_color); | ||
518 | |||
519 | if (pipe_ctx->stream_res.tg->funcs->is_blanked && | ||
520 | !pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg)) { | ||
521 | pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, true); | ||
522 | hwss_wait_for_blank_complete(pipe_ctx->stream_res.tg); | ||
523 | false_optc_underflow_wa(dc, pipe_ctx->stream, pipe_ctx->stream_res.tg); | ||
524 | } | ||
498 | 525 | ||
499 | /* VTG is within DCHUB command block. DCFCLK is always on */ | 526 | /* VTG is within DCHUB command block. DCFCLK is always on */ |
500 | if (false == pipe_ctx->stream_res.tg->funcs->enable_crtc(pipe_ctx->stream_res.tg)) { | 527 | if (false == pipe_ctx->stream_res.tg->funcs->enable_crtc(pipe_ctx->stream_res.tg)) { |
@@ -573,41 +600,34 @@ static void plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx) | |||
573 | int fe_idx = pipe_ctx->pipe_idx; | 600 | int fe_idx = pipe_ctx->pipe_idx; |
574 | struct hubp *hubp = dc->res_pool->hubps[fe_idx]; | 601 | struct hubp *hubp = dc->res_pool->hubps[fe_idx]; |
575 | struct mpc *mpc = dc->res_pool->mpc; | 602 | struct mpc *mpc = dc->res_pool->mpc; |
576 | int opp_id, z_idx; | 603 | int opp_id; |
577 | int mpcc_id = -1; | 604 | struct mpc_tree *mpc_tree_params; |
605 | struct mpcc *mpcc_to_remove = NULL; | ||
578 | 606 | ||
579 | /* look at tree rather than mi here to know if we already reset */ | 607 | /* look at tree rather than mi here to know if we already reset */ |
580 | for (opp_id = 0; opp_id < dc->res_pool->pipe_count; opp_id++) { | 608 | for (opp_id = 0; opp_id < dc->res_pool->pipe_count; opp_id++) { |
581 | struct output_pixel_processor *opp = dc->res_pool->opps[opp_id]; | 609 | struct output_pixel_processor *opp = dc->res_pool->opps[opp_id]; |
582 | 610 | ||
583 | for (z_idx = 0; z_idx < opp->mpc_tree.num_pipes; z_idx++) { | 611 | mpc_tree_params = &(opp->mpc_tree_params); |
584 | if (opp->mpc_tree.dpp[z_idx] == fe_idx) { | 612 | mpcc_to_remove = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, fe_idx); |
585 | mpcc_id = opp->mpc_tree.mpcc[z_idx]; | 613 | if (mpcc_to_remove != NULL) |
586 | break; | ||
587 | } | ||
588 | } | ||
589 | if (mpcc_id != -1) | ||
590 | break; | 614 | break; |
591 | } | 615 | } |
616 | |||
592 | /*Already reset*/ | 617 | /*Already reset*/ |
593 | if (opp_id == dc->res_pool->pipe_count) | 618 | if (opp_id == dc->res_pool->pipe_count) |
594 | return; | 619 | return; |
595 | 620 | ||
596 | mpc->funcs->remove(mpc, &(dc->res_pool->opps[opp_id]->mpc_tree), | 621 | mpc->funcs->remove_mpcc(mpc, mpc_tree_params, mpcc_to_remove); |
597 | dc->res_pool->opps[opp_id]->inst, fe_idx); | 622 | dc->res_pool->opps[opp_id]->mpcc_disconnect_pending[fe_idx] = true; |
623 | |||
624 | dc->optimized_required = true; | ||
598 | 625 | ||
599 | if (hubp->funcs->hubp_disconnect) | 626 | if (hubp->funcs->hubp_disconnect) |
600 | hubp->funcs->hubp_disconnect(hubp); | 627 | hubp->funcs->hubp_disconnect(hubp); |
601 | 628 | ||
602 | if (dc->debug.sanity_checks) | 629 | if (dc->debug.sanity_checks) |
603 | dcn10_verify_allow_pstate_change_high(dc); | 630 | dcn10_verify_allow_pstate_change_high(dc); |
604 | |||
605 | pipe_ctx->stream = NULL; | ||
606 | memset(&pipe_ctx->stream_res, 0, sizeof(pipe_ctx->stream_res)); | ||
607 | memset(&pipe_ctx->plane_res, 0, sizeof(pipe_ctx->plane_res)); | ||
608 | pipe_ctx->top_pipe = NULL; | ||
609 | pipe_ctx->bottom_pipe = NULL; | ||
610 | pipe_ctx->plane_state = NULL; | ||
611 | } | 631 | } |
612 | 632 | ||
613 | static void plane_atomic_power_down(struct dc *dc, int fe_idx) | 633 | static void plane_atomic_power_down(struct dc *dc, int fe_idx) |
@@ -636,29 +656,30 @@ static void plane_atomic_disable(struct dc *dc, struct pipe_ctx *pipe_ctx) | |||
636 | int fe_idx = pipe_ctx->pipe_idx; | 656 | int fe_idx = pipe_ctx->pipe_idx; |
637 | struct dce_hwseq *hws = dc->hwseq; | 657 | struct dce_hwseq *hws = dc->hwseq; |
638 | struct hubp *hubp = dc->res_pool->hubps[fe_idx]; | 658 | struct hubp *hubp = dc->res_pool->hubps[fe_idx]; |
639 | struct mpc *mpc = dc->res_pool->mpc; | ||
640 | int opp_id = hubp->opp_id; | 659 | int opp_id = hubp->opp_id; |
641 | struct output_pixel_processor *opp; | ||
642 | 660 | ||
643 | if (opp_id != 0xf) { | 661 | dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe_ctx); |
644 | mpc->funcs->wait_for_idle(mpc, hubp->mpcc_id); | ||
645 | opp = dc->res_pool->opps[hubp->opp_id]; | ||
646 | opp->mpcc_disconnect_pending[hubp->mpcc_id] = false; | ||
647 | hubp->funcs->set_blank(hubp, true); | ||
648 | } | ||
649 | 662 | ||
650 | REG_UPDATE(HUBP_CLK_CNTL[fe_idx], | 663 | REG_UPDATE(HUBP_CLK_CNTL[fe_idx], |
651 | HUBP_CLOCK_ENABLE, 0); | 664 | HUBP_CLOCK_ENABLE, 0); |
652 | REG_UPDATE(DPP_CONTROL[fe_idx], | 665 | REG_UPDATE(DPP_CONTROL[fe_idx], |
653 | DPP_CLOCK_ENABLE, 0); | 666 | DPP_CLOCK_ENABLE, 0); |
654 | 667 | ||
655 | if (opp_id != 0xf && dc->res_pool->opps[opp_id]->mpc_tree.num_pipes == 0) | 668 | if (opp_id != 0xf && dc->res_pool->opps[opp_id]->mpc_tree_params.opp_list == NULL) |
656 | REG_UPDATE(OPP_PIPE_CONTROL[opp_id], | 669 | REG_UPDATE(OPP_PIPE_CONTROL[opp_id], |
657 | OPP_PIPE_CLOCK_EN, 0); | 670 | OPP_PIPE_CLOCK_EN, 0); |
658 | 671 | ||
659 | hubp->power_gated = true; | 672 | hubp->power_gated = true; |
673 | dc->optimized_required = false; /* We're powering off, no need to optimize */ | ||
660 | 674 | ||
661 | plane_atomic_power_down(dc, fe_idx); | 675 | plane_atomic_power_down(dc, fe_idx); |
676 | |||
677 | pipe_ctx->stream = NULL; | ||
678 | memset(&pipe_ctx->stream_res, 0, sizeof(pipe_ctx->stream_res)); | ||
679 | memset(&pipe_ctx->plane_res, 0, sizeof(pipe_ctx->plane_res)); | ||
680 | pipe_ctx->top_pipe = NULL; | ||
681 | pipe_ctx->bottom_pipe = NULL; | ||
682 | pipe_ctx->plane_state = NULL; | ||
662 | } | 683 | } |
663 | 684 | ||
664 | static void dcn10_disable_plane(struct dc *dc, struct pipe_ctx *pipe_ctx) | 685 | static void dcn10_disable_plane(struct dc *dc, struct pipe_ctx *pipe_ctx) |
@@ -740,25 +761,27 @@ static void dcn10_init_hw(struct dc *dc) | |||
740 | } | 761 | } |
741 | } | 762 | } |
742 | 763 | ||
764 | /* Reset all MPCC muxes */ | ||
765 | dc->res_pool->mpc->funcs->mpc_init(dc->res_pool->mpc); | ||
766 | |||
743 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | 767 | for (i = 0; i < dc->res_pool->pipe_count; i++) { |
744 | struct timing_generator *tg = dc->res_pool->timing_generators[i]; | 768 | struct timing_generator *tg = dc->res_pool->timing_generators[i]; |
745 | struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; | 769 | struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; |
746 | struct output_pixel_processor *opp = dc->res_pool->opps[i]; | ||
747 | struct mpc_tree_cfg *mpc_tree = &opp->mpc_tree; | ||
748 | struct hubp *hubp = dc->res_pool->hubps[i]; | 770 | struct hubp *hubp = dc->res_pool->hubps[i]; |
749 | 771 | ||
750 | mpc_tree->dpp[0] = i; | ||
751 | mpc_tree->mpcc[0] = i; | ||
752 | mpc_tree->num_pipes = 1; | ||
753 | |||
754 | pipe_ctx->stream_res.tg = tg; | 772 | pipe_ctx->stream_res.tg = tg; |
755 | pipe_ctx->pipe_idx = i; | 773 | pipe_ctx->pipe_idx = i; |
756 | 774 | ||
757 | pipe_ctx->plane_res.hubp = hubp; | 775 | pipe_ctx->plane_res.hubp = hubp; |
758 | hubp->mpcc_id = i; | 776 | hubp->mpcc_id = i; |
759 | hubp->opp_id = dc->res_pool->mpc->funcs->get_opp_id(dc->res_pool->mpc, i); | 777 | hubp->opp_id = 0xf; |
760 | hubp->power_gated = false; | 778 | hubp->power_gated = false; |
761 | 779 | ||
780 | dc->res_pool->opps[i]->mpc_tree_params.opp_id = dc->res_pool->opps[i]->inst; | ||
781 | dc->res_pool->opps[i]->mpc_tree_params.opp_list = NULL; | ||
782 | dc->res_pool->opps[i]->mpcc_disconnect_pending[i] = true; | ||
783 | pipe_ctx->stream_res.opp = dc->res_pool->opps[i]; | ||
784 | |||
762 | plane_atomic_disconnect(dc, pipe_ctx); | 785 | plane_atomic_disconnect(dc, pipe_ctx); |
763 | } | 786 | } |
764 | 787 | ||
@@ -929,280 +952,10 @@ static bool dcn10_set_input_transfer_func(struct pipe_ctx *pipe_ctx, | |||
929 | 952 | ||
930 | return result; | 953 | return result; |
931 | } | 954 | } |
932 | /*modify the method to handle rgb for arr_points*/ | ||
933 | static bool convert_to_custom_float( | ||
934 | struct pwl_result_data *rgb_resulted, | ||
935 | struct curve_points *arr_points, | ||
936 | uint32_t hw_points_num) | ||
937 | { | ||
938 | struct custom_float_format fmt; | ||
939 | |||
940 | struct pwl_result_data *rgb = rgb_resulted; | ||
941 | |||
942 | uint32_t i = 0; | ||
943 | |||
944 | fmt.exponenta_bits = 6; | ||
945 | fmt.mantissa_bits = 12; | ||
946 | fmt.sign = false; | ||
947 | |||
948 | if (!convert_to_custom_float_format(arr_points[0].x, &fmt, | ||
949 | &arr_points[0].custom_float_x)) { | ||
950 | BREAK_TO_DEBUGGER(); | ||
951 | return false; | ||
952 | } | ||
953 | |||
954 | if (!convert_to_custom_float_format(arr_points[0].offset, &fmt, | ||
955 | &arr_points[0].custom_float_offset)) { | ||
956 | BREAK_TO_DEBUGGER(); | ||
957 | return false; | ||
958 | } | ||
959 | |||
960 | if (!convert_to_custom_float_format(arr_points[0].slope, &fmt, | ||
961 | &arr_points[0].custom_float_slope)) { | ||
962 | BREAK_TO_DEBUGGER(); | ||
963 | return false; | ||
964 | } | ||
965 | |||
966 | fmt.mantissa_bits = 10; | ||
967 | fmt.sign = false; | ||
968 | |||
969 | if (!convert_to_custom_float_format(arr_points[1].x, &fmt, | ||
970 | &arr_points[1].custom_float_x)) { | ||
971 | BREAK_TO_DEBUGGER(); | ||
972 | return false; | ||
973 | } | ||
974 | |||
975 | if (!convert_to_custom_float_format(arr_points[1].y, &fmt, | ||
976 | &arr_points[1].custom_float_y)) { | ||
977 | BREAK_TO_DEBUGGER(); | ||
978 | return false; | ||
979 | } | ||
980 | |||
981 | if (!convert_to_custom_float_format(arr_points[1].slope, &fmt, | ||
982 | &arr_points[1].custom_float_slope)) { | ||
983 | BREAK_TO_DEBUGGER(); | ||
984 | return false; | ||
985 | } | ||
986 | 955 | ||
987 | fmt.mantissa_bits = 12; | ||
988 | fmt.sign = true; | ||
989 | 956 | ||
990 | while (i != hw_points_num) { | ||
991 | if (!convert_to_custom_float_format(rgb->red, &fmt, | ||
992 | &rgb->red_reg)) { | ||
993 | BREAK_TO_DEBUGGER(); | ||
994 | return false; | ||
995 | } | ||
996 | |||
997 | if (!convert_to_custom_float_format(rgb->green, &fmt, | ||
998 | &rgb->green_reg)) { | ||
999 | BREAK_TO_DEBUGGER(); | ||
1000 | return false; | ||
1001 | } | ||
1002 | 957 | ||
1003 | if (!convert_to_custom_float_format(rgb->blue, &fmt, | ||
1004 | &rgb->blue_reg)) { | ||
1005 | BREAK_TO_DEBUGGER(); | ||
1006 | return false; | ||
1007 | } | ||
1008 | 958 | ||
1009 | if (!convert_to_custom_float_format(rgb->delta_red, &fmt, | ||
1010 | &rgb->delta_red_reg)) { | ||
1011 | BREAK_TO_DEBUGGER(); | ||
1012 | return false; | ||
1013 | } | ||
1014 | |||
1015 | if (!convert_to_custom_float_format(rgb->delta_green, &fmt, | ||
1016 | &rgb->delta_green_reg)) { | ||
1017 | BREAK_TO_DEBUGGER(); | ||
1018 | return false; | ||
1019 | } | ||
1020 | |||
1021 | if (!convert_to_custom_float_format(rgb->delta_blue, &fmt, | ||
1022 | &rgb->delta_blue_reg)) { | ||
1023 | BREAK_TO_DEBUGGER(); | ||
1024 | return false; | ||
1025 | } | ||
1026 | |||
1027 | ++rgb; | ||
1028 | ++i; | ||
1029 | } | ||
1030 | |||
1031 | return true; | ||
1032 | } | ||
1033 | #define MAX_REGIONS_NUMBER 34 | ||
1034 | #define MAX_LOW_POINT 25 | ||
1035 | #define NUMBER_SEGMENTS 32 | ||
1036 | |||
1037 | static bool | ||
1038 | dcn10_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf, | ||
1039 | struct pwl_params *regamma_params) | ||
1040 | { | ||
1041 | struct curve_points *arr_points; | ||
1042 | struct pwl_result_data *rgb_resulted; | ||
1043 | struct pwl_result_data *rgb; | ||
1044 | struct pwl_result_data *rgb_plus_1; | ||
1045 | struct fixed31_32 y_r; | ||
1046 | struct fixed31_32 y_g; | ||
1047 | struct fixed31_32 y_b; | ||
1048 | struct fixed31_32 y1_min; | ||
1049 | struct fixed31_32 y3_max; | ||
1050 | |||
1051 | int32_t segment_start, segment_end; | ||
1052 | int32_t i; | ||
1053 | uint32_t j, k, seg_distr[MAX_REGIONS_NUMBER], increment, start_index, hw_points; | ||
1054 | |||
1055 | if (output_tf == NULL || regamma_params == NULL || output_tf->type == TF_TYPE_BYPASS) | ||
1056 | return false; | ||
1057 | |||
1058 | PERF_TRACE(); | ||
1059 | |||
1060 | arr_points = regamma_params->arr_points; | ||
1061 | rgb_resulted = regamma_params->rgb_resulted; | ||
1062 | hw_points = 0; | ||
1063 | |||
1064 | memset(regamma_params, 0, sizeof(struct pwl_params)); | ||
1065 | memset(seg_distr, 0, sizeof(seg_distr)); | ||
1066 | |||
1067 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | ||
1068 | /* 32 segments | ||
1069 | * segments are from 2^-25 to 2^7 | ||
1070 | */ | ||
1071 | for (i = 0; i < 32 ; i++) | ||
1072 | seg_distr[i] = 3; | ||
1073 | |||
1074 | segment_start = -25; | ||
1075 | segment_end = 7; | ||
1076 | } else { | ||
1077 | /* 10 segments | ||
1078 | * segment is from 2^-10 to 2^0 | ||
1079 | * There are less than 256 points, for optimization | ||
1080 | */ | ||
1081 | seg_distr[0] = 3; | ||
1082 | seg_distr[1] = 4; | ||
1083 | seg_distr[2] = 4; | ||
1084 | seg_distr[3] = 4; | ||
1085 | seg_distr[4] = 4; | ||
1086 | seg_distr[5] = 4; | ||
1087 | seg_distr[6] = 4; | ||
1088 | seg_distr[7] = 4; | ||
1089 | seg_distr[8] = 5; | ||
1090 | seg_distr[9] = 5; | ||
1091 | |||
1092 | segment_start = -10; | ||
1093 | segment_end = 0; | ||
1094 | } | ||
1095 | |||
1096 | for (i = segment_end - segment_start; i < MAX_REGIONS_NUMBER ; i++) | ||
1097 | seg_distr[i] = -1; | ||
1098 | |||
1099 | for (k = 0; k < MAX_REGIONS_NUMBER; k++) { | ||
1100 | if (seg_distr[k] != -1) | ||
1101 | hw_points += (1 << seg_distr[k]); | ||
1102 | } | ||
1103 | |||
1104 | j = 0; | ||
1105 | for (k = 0; k < (segment_end - segment_start); k++) { | ||
1106 | increment = NUMBER_SEGMENTS / (1 << seg_distr[k]); | ||
1107 | start_index = (segment_start + k + MAX_LOW_POINT) * NUMBER_SEGMENTS; | ||
1108 | for (i = start_index; i < start_index + NUMBER_SEGMENTS; i += increment) { | ||
1109 | if (j == hw_points - 1) | ||
1110 | break; | ||
1111 | rgb_resulted[j].red = output_tf->tf_pts.red[i]; | ||
1112 | rgb_resulted[j].green = output_tf->tf_pts.green[i]; | ||
1113 | rgb_resulted[j].blue = output_tf->tf_pts.blue[i]; | ||
1114 | j++; | ||
1115 | } | ||
1116 | } | ||
1117 | |||
1118 | /* last point */ | ||
1119 | start_index = (segment_end + MAX_LOW_POINT) * NUMBER_SEGMENTS; | ||
1120 | rgb_resulted[hw_points - 1].red = output_tf->tf_pts.red[start_index]; | ||
1121 | rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index]; | ||
1122 | rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index]; | ||
1123 | |||
1124 | arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | ||
1125 | dal_fixed31_32_from_int(segment_start)); | ||
1126 | arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2), | ||
1127 | dal_fixed31_32_from_int(segment_end)); | ||
1128 | |||
1129 | y_r = rgb_resulted[0].red; | ||
1130 | y_g = rgb_resulted[0].green; | ||
1131 | y_b = rgb_resulted[0].blue; | ||
1132 | |||
1133 | y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b)); | ||
1134 | |||
1135 | arr_points[0].y = y1_min; | ||
1136 | arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x); | ||
1137 | y_r = rgb_resulted[hw_points - 1].red; | ||
1138 | y_g = rgb_resulted[hw_points - 1].green; | ||
1139 | y_b = rgb_resulted[hw_points - 1].blue; | ||
1140 | |||
1141 | /* see comment above, m_arrPoints[1].y should be the Y value for the | ||
1142 | * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1) | ||
1143 | */ | ||
1144 | y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b)); | ||
1145 | |||
1146 | arr_points[1].y = y3_max; | ||
1147 | |||
1148 | arr_points[1].slope = dal_fixed31_32_zero; | ||
1149 | |||
1150 | if (output_tf->tf == TRANSFER_FUNCTION_PQ) { | ||
1151 | /* for PQ, we want to have a straight line from last HW X point, | ||
1152 | * and the slope to be such that we hit 1.0 at 10000 nits. | ||
1153 | */ | ||
1154 | const struct fixed31_32 end_value = | ||
1155 | dal_fixed31_32_from_int(125); | ||
1156 | |||
1157 | arr_points[1].slope = dal_fixed31_32_div( | ||
1158 | dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y), | ||
1159 | dal_fixed31_32_sub(end_value, arr_points[1].x)); | ||
1160 | } | ||
1161 | |||
1162 | regamma_params->hw_points_num = hw_points; | ||
1163 | |||
1164 | i = 1; | ||
1165 | for (k = 0; k < MAX_REGIONS_NUMBER && i < MAX_REGIONS_NUMBER; k++) { | ||
1166 | if (seg_distr[k] != -1) { | ||
1167 | regamma_params->arr_curve_points[k].segments_num = | ||
1168 | seg_distr[k]; | ||
1169 | regamma_params->arr_curve_points[i].offset = | ||
1170 | regamma_params->arr_curve_points[k].offset + (1 << seg_distr[k]); | ||
1171 | } | ||
1172 | i++; | ||
1173 | } | ||
1174 | |||
1175 | if (seg_distr[k] != -1) | ||
1176 | regamma_params->arr_curve_points[k].segments_num = seg_distr[k]; | ||
1177 | |||
1178 | rgb = rgb_resulted; | ||
1179 | rgb_plus_1 = rgb_resulted + 1; | ||
1180 | |||
1181 | i = 1; | ||
1182 | |||
1183 | while (i != hw_points + 1) { | ||
1184 | if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red)) | ||
1185 | rgb_plus_1->red = rgb->red; | ||
1186 | if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green)) | ||
1187 | rgb_plus_1->green = rgb->green; | ||
1188 | if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue)) | ||
1189 | rgb_plus_1->blue = rgb->blue; | ||
1190 | |||
1191 | rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red); | ||
1192 | rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green); | ||
1193 | rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue); | ||
1194 | |||
1195 | ++rgb_plus_1; | ||
1196 | ++rgb; | ||
1197 | ++i; | ||
1198 | } | ||
1199 | |||
1200 | convert_to_custom_float(rgb_resulted, arr_points, hw_points); | ||
1201 | |||
1202 | PERF_TRACE(); | ||
1203 | |||
1204 | return true; | ||
1205 | } | ||
1206 | 959 | ||
1207 | static bool | 960 | static bool |
1208 | dcn10_set_output_transfer_func(struct pipe_ctx *pipe_ctx, | 961 | dcn10_set_output_transfer_func(struct pipe_ctx *pipe_ctx, |
@@ -1223,9 +976,9 @@ dcn10_set_output_transfer_func(struct pipe_ctx *pipe_ctx, | |||
1223 | /* dcn10_translate_regamma_to_hw_format takes 750us, only do it when full | 976 | /* dcn10_translate_regamma_to_hw_format takes 750us, only do it when full |
1224 | * update. | 977 | * update. |
1225 | */ | 978 | */ |
1226 | else if (dcn10_translate_regamma_to_hw_format( | 979 | else if (cm_helper_translate_curve_to_hw_format( |
1227 | stream->out_transfer_func, | 980 | stream->out_transfer_func, |
1228 | &dpp->regamma_params)) { | 981 | &dpp->regamma_params, false)) { |
1229 | dpp->funcs->dpp_program_regamma_pwl( | 982 | dpp->funcs->dpp_program_regamma_pwl( |
1230 | dpp, | 983 | dpp, |
1231 | &dpp->regamma_params, OPP_REGAMMA_USER); | 984 | &dpp->regamma_params, OPP_REGAMMA_USER); |
@@ -1579,7 +1332,6 @@ static void dcn10_enable_plane( | |||
1579 | /* make sure OPP_PIPE_CLOCK_EN = 1 */ | 1332 | /* make sure OPP_PIPE_CLOCK_EN = 1 */ |
1580 | REG_UPDATE(OPP_PIPE_CONTROL[pipe_ctx->stream_res.tg->inst], | 1333 | REG_UPDATE(OPP_PIPE_CONTROL[pipe_ctx->stream_res.tg->inst], |
1581 | OPP_PIPE_CLOCK_EN, 1); | 1334 | OPP_PIPE_CLOCK_EN, 1); |
1582 | /*TODO: REG_UPDATE(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, 0x1f);*/ | ||
1583 | 1335 | ||
1584 | /* TODO: enable/disable in dm as per update type. | 1336 | /* TODO: enable/disable in dm as per update type. |
1585 | if (plane_state) { | 1337 | if (plane_state) { |
@@ -1672,60 +1424,15 @@ static void program_csc_matrix(struct pipe_ctx *pipe_ctx, | |||
1672 | enum dc_color_space colorspace, | 1424 | enum dc_color_space colorspace, |
1673 | uint16_t *matrix) | 1425 | uint16_t *matrix) |
1674 | { | 1426 | { |
1675 | int i; | ||
1676 | struct out_csc_color_matrix tbl_entry; | ||
1677 | |||
1678 | if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) { | 1427 | if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) { |
1679 | enum dc_color_space color_space = | ||
1680 | pipe_ctx->stream->output_color_space; | ||
1681 | |||
1682 | //uint16_t matrix[12]; | ||
1683 | for (i = 0; i < 12; i++) | ||
1684 | tbl_entry.regval[i] = pipe_ctx->stream->csc_color_matrix.matrix[i]; | ||
1685 | |||
1686 | tbl_entry.color_space = color_space; | ||
1687 | //tbl_entry.regval = matrix; | ||
1688 | |||
1689 | if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment != NULL) | 1428 | if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment != NULL) |
1690 | pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment(pipe_ctx->plane_res.dpp, &tbl_entry); | 1429 | pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment(pipe_ctx->plane_res.dpp, matrix); |
1691 | } else { | 1430 | } else { |
1692 | if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default != NULL) | 1431 | if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default != NULL) |
1693 | pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default(pipe_ctx->plane_res.dpp, colorspace); | 1432 | pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default(pipe_ctx->plane_res.dpp, colorspace); |
1694 | } | 1433 | } |
1695 | } | 1434 | } |
1696 | 1435 | ||
1697 | static void set_mpc_output_csc(struct dc *dc, | ||
1698 | struct pipe_ctx *pipe_ctx, | ||
1699 | enum dc_color_space colorspace, | ||
1700 | uint16_t *matrix, | ||
1701 | int opp_id) | ||
1702 | { | ||
1703 | struct mpc *mpc = dc->res_pool->mpc; | ||
1704 | int i; | ||
1705 | struct out_csc_color_matrix tbl_entry; | ||
1706 | enum mpc_output_csc_mode ocsc_mode = MPC_OUTPUT_CSC_COEF_A; | ||
1707 | |||
1708 | |||
1709 | if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) { | ||
1710 | //uint16_t matrix[12]; | ||
1711 | for (i = 0; i < 12; i++) | ||
1712 | tbl_entry.regval[i] = matrix[i]; | ||
1713 | tbl_entry.color_space = colorspace; | ||
1714 | |||
1715 | if (mpc->funcs->set_output_csc != NULL) | ||
1716 | mpc->funcs->set_output_csc(mpc, | ||
1717 | opp_id, | ||
1718 | &tbl_entry, | ||
1719 | ocsc_mode); | ||
1720 | } else { | ||
1721 | if (mpc->funcs->set_ocsc_default != NULL) | ||
1722 | mpc->funcs->set_ocsc_default(mpc, | ||
1723 | opp_id, | ||
1724 | colorspace, | ||
1725 | ocsc_mode); | ||
1726 | } | ||
1727 | } | ||
1728 | |||
1729 | static void program_output_csc(struct dc *dc, | 1436 | static void program_output_csc(struct dc *dc, |
1730 | struct pipe_ctx *pipe_ctx, | 1437 | struct pipe_ctx *pipe_ctx, |
1731 | enum dc_color_space colorspace, | 1438 | enum dc_color_space colorspace, |
@@ -1736,13 +1443,6 @@ static void program_output_csc(struct dc *dc, | |||
1736 | program_csc_matrix(pipe_ctx, | 1443 | program_csc_matrix(pipe_ctx, |
1737 | colorspace, | 1444 | colorspace, |
1738 | matrix); | 1445 | matrix); |
1739 | else | ||
1740 | set_mpc_output_csc(dc, | ||
1741 | pipe_ctx, | ||
1742 | colorspace, | ||
1743 | matrix, | ||
1744 | opp_id); | ||
1745 | |||
1746 | } | 1446 | } |
1747 | 1447 | ||
1748 | static bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx) | 1448 | static bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx) |
@@ -1914,35 +1614,73 @@ static void update_dpp(struct dpp *dpp, struct dc_plane_state *plane_state) | |||
1914 | 1614 | ||
1915 | static void update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx) | 1615 | static void update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx) |
1916 | { | 1616 | { |
1917 | struct mpcc_cfg mpcc_cfg = {0}; | ||
1918 | struct hubp *hubp = pipe_ctx->plane_res.hubp; | 1617 | struct hubp *hubp = pipe_ctx->plane_res.hubp; |
1919 | struct pipe_ctx *top_pipe; | 1618 | struct mpcc_blnd_cfg blnd_cfg; |
1920 | bool per_pixel_alpha = | 1619 | bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe; |
1921 | pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe; | 1620 | int mpcc_id; |
1621 | struct mpcc *new_mpcc; | ||
1622 | struct mpc *mpc = dc->res_pool->mpc; | ||
1623 | struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params); | ||
1922 | 1624 | ||
1923 | /* TODO: proper fix once fpga works */ | 1625 | /* TODO: proper fix once fpga works */ |
1924 | 1626 | ||
1925 | mpcc_cfg.dpp_id = hubp->inst; | ||
1926 | mpcc_cfg.opp_id = pipe_ctx->stream_res.opp->inst; | ||
1927 | mpcc_cfg.tree_cfg = &(pipe_ctx->stream_res.opp->mpc_tree); | ||
1928 | for (top_pipe = pipe_ctx->top_pipe; top_pipe; top_pipe = top_pipe->top_pipe) | ||
1929 | mpcc_cfg.z_index++; | ||
1930 | if (dc->debug.surface_visual_confirm) | 1627 | if (dc->debug.surface_visual_confirm) |
1931 | dcn10_get_surface_visual_confirm_color( | 1628 | dcn10_get_surface_visual_confirm_color( |
1932 | pipe_ctx, &mpcc_cfg.black_color); | 1629 | pipe_ctx, &blnd_cfg.black_color); |
1933 | else | 1630 | else |
1934 | color_space_to_black_color( | 1631 | color_space_to_black_color( |
1935 | dc, pipe_ctx->stream->output_color_space, | 1632 | dc, pipe_ctx->stream->output_color_space, |
1936 | &mpcc_cfg.black_color); | 1633 | &blnd_cfg.black_color); |
1937 | mpcc_cfg.per_pixel_alpha = per_pixel_alpha; | 1634 | |
1635 | if (per_pixel_alpha) | ||
1636 | blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA; | ||
1637 | else | ||
1638 | blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA; | ||
1639 | |||
1640 | blnd_cfg.overlap_only = false; | ||
1641 | blnd_cfg.global_alpha = 0xff; | ||
1642 | blnd_cfg.global_gain = 0xff; | ||
1643 | |||
1938 | /* DCN1.0 has output CM before MPC which seems to screw with | 1644 | /* DCN1.0 has output CM before MPC which seems to screw with |
1939 | * pre-multiplied alpha. | 1645 | * pre-multiplied alpha. |
1940 | */ | 1646 | */ |
1941 | mpcc_cfg.pre_multiplied_alpha = is_rgb_cspace( | 1647 | blnd_cfg.pre_multiplied_alpha = is_rgb_cspace( |
1942 | pipe_ctx->stream->output_color_space) | 1648 | pipe_ctx->stream->output_color_space) |
1943 | && per_pixel_alpha; | 1649 | && per_pixel_alpha; |
1944 | hubp->mpcc_id = dc->res_pool->mpc->funcs->add(dc->res_pool->mpc, &mpcc_cfg); | 1650 | |
1945 | hubp->opp_id = mpcc_cfg.opp_id; | 1651 | /* |
1652 | * TODO: remove hack | ||
1653 | * Note: currently there is a bug in init_hw such that | ||
1654 | * on resume from hibernate, BIOS sets up MPCC0, and | ||
1655 | * we do mpcc_remove but the mpcc cannot go to idle | ||
1656 | * after remove. This cause us to pick mpcc1 here, | ||
1657 | * which causes a pstate hang for yet unknown reason. | ||
1658 | */ | ||
1659 | mpcc_id = hubp->inst; | ||
1660 | |||
1661 | /* check if this MPCC is already being used */ | ||
1662 | new_mpcc = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, mpcc_id); | ||
1663 | /* remove MPCC if being used */ | ||
1664 | if (new_mpcc != NULL) | ||
1665 | mpc->funcs->remove_mpcc(mpc, mpc_tree_params, new_mpcc); | ||
1666 | else | ||
1667 | if (dc->debug.sanity_checks) | ||
1668 | mpc->funcs->assert_mpcc_idle_before_connect( | ||
1669 | dc->res_pool->mpc, mpcc_id); | ||
1670 | |||
1671 | /* Call MPC to insert new plane */ | ||
1672 | new_mpcc = mpc->funcs->insert_plane(dc->res_pool->mpc, | ||
1673 | mpc_tree_params, | ||
1674 | &blnd_cfg, | ||
1675 | NULL, | ||
1676 | NULL, | ||
1677 | hubp->inst, | ||
1678 | mpcc_id); | ||
1679 | |||
1680 | ASSERT(new_mpcc != NULL); | ||
1681 | |||
1682 | hubp->opp_id = pipe_ctx->stream_res.opp->inst; | ||
1683 | hubp->mpcc_id = mpcc_id; | ||
1946 | } | 1684 | } |
1947 | 1685 | ||
1948 | static void update_scaler(struct pipe_ctx *pipe_ctx) | 1686 | static void update_scaler(struct pipe_ctx *pipe_ctx) |
@@ -1971,7 +1709,7 @@ static void update_dchubp_dpp( | |||
1971 | union plane_size size = plane_state->plane_size; | 1709 | union plane_size size = plane_state->plane_size; |
1972 | 1710 | ||
1973 | /* depends on DML calculation, DPP clock value may change dynamically */ | 1711 | /* depends on DML calculation, DPP clock value may change dynamically */ |
1974 | if (pipe_ctx->plane_state->update_flags.raw != 0) { | 1712 | if (plane_state->update_flags.bits.full_update) { |
1975 | enable_dppclk( | 1713 | enable_dppclk( |
1976 | dc->hwseq, | 1714 | dc->hwseq, |
1977 | pipe_ctx->pipe_idx, | 1715 | pipe_ctx->pipe_idx, |
@@ -2015,7 +1753,8 @@ static void update_dchubp_dpp( | |||
2015 | } | 1753 | } |
2016 | 1754 | ||
2017 | if (plane_state->update_flags.bits.full_update || | 1755 | if (plane_state->update_flags.bits.full_update || |
2018 | plane_state->update_flags.bits.scaling_change) { | 1756 | plane_state->update_flags.bits.scaling_change || |
1757 | plane_state->update_flags.bits.position_change) { | ||
2019 | hubp->funcs->mem_program_viewport( | 1758 | hubp->funcs->mem_program_viewport( |
2020 | hubp, | 1759 | hubp, |
2021 | &pipe_ctx->plane_res.scl_data.viewport, | 1760 | &pipe_ctx->plane_res.scl_data.viewport, |
@@ -2037,7 +1776,9 @@ static void update_dchubp_dpp( | |||
2037 | plane_state->update_flags.bits.horizontal_mirror_change || | 1776 | plane_state->update_flags.bits.horizontal_mirror_change || |
2038 | plane_state->update_flags.bits.rotation_change || | 1777 | plane_state->update_flags.bits.rotation_change || |
2039 | plane_state->update_flags.bits.swizzle_change || | 1778 | plane_state->update_flags.bits.swizzle_change || |
2040 | plane_state->update_flags.bits.bpp_change) { | 1779 | plane_state->update_flags.bits.dcc_change || |
1780 | plane_state->update_flags.bits.bpp_change || | ||
1781 | plane_state->update_flags.bits.scaling_change) { | ||
2041 | hubp->funcs->hubp_program_surface_config( | 1782 | hubp->funcs->hubp_program_surface_config( |
2042 | hubp, | 1783 | hubp, |
2043 | plane_state->format, | 1784 | plane_state->format, |
@@ -2062,6 +1803,7 @@ static void program_all_pipe_in_tree( | |||
2062 | struct pipe_ctx *pipe_ctx, | 1803 | struct pipe_ctx *pipe_ctx, |
2063 | struct dc_state *context) | 1804 | struct dc_state *context) |
2064 | { | 1805 | { |
1806 | |||
2065 | if (pipe_ctx->top_pipe == NULL) { | 1807 | if (pipe_ctx->top_pipe == NULL) { |
2066 | 1808 | ||
2067 | pipe_ctx->stream_res.tg->dlg_otg_param.vready_offset = pipe_ctx->pipe_dlg_param.vready_offset; | 1809 | pipe_ctx->stream_res.tg->dlg_otg_param.vready_offset = pipe_ctx->pipe_dlg_param.vready_offset; |
@@ -2072,7 +1814,11 @@ static void program_all_pipe_in_tree( | |||
2072 | 1814 | ||
2073 | pipe_ctx->stream_res.tg->funcs->program_global_sync( | 1815 | pipe_ctx->stream_res.tg->funcs->program_global_sync( |
2074 | pipe_ctx->stream_res.tg); | 1816 | pipe_ctx->stream_res.tg); |
2075 | pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, !is_pipe_tree_visible(pipe_ctx)); | 1817 | |
1818 | if (pipe_ctx->stream_res.tg->funcs->set_blank) | ||
1819 | pipe_ctx->stream_res.tg->funcs->set_blank( | ||
1820 | pipe_ctx->stream_res.tg, | ||
1821 | !is_pipe_tree_visible(pipe_ctx)); | ||
2076 | } | 1822 | } |
2077 | 1823 | ||
2078 | if (pipe_ctx->plane_state != NULL) { | 1824 | if (pipe_ctx->plane_state != NULL) { |
@@ -2179,6 +1925,7 @@ static void dcn10_apply_ctx_for_surface( | |||
2179 | { | 1925 | { |
2180 | int i; | 1926 | int i; |
2181 | struct timing_generator *tg; | 1927 | struct timing_generator *tg; |
1928 | struct output_pixel_processor *opp; | ||
2182 | bool removed_pipe[4] = { false }; | 1929 | bool removed_pipe[4] = { false }; |
2183 | unsigned int ref_clk_mhz = dc->res_pool->ref_clock_inKhz/1000; | 1930 | unsigned int ref_clk_mhz = dc->res_pool->ref_clock_inKhz/1000; |
2184 | bool program_water_mark = false; | 1931 | bool program_water_mark = false; |
@@ -2189,6 +1936,8 @@ static void dcn10_apply_ctx_for_surface( | |||
2189 | if (!top_pipe_to_program) | 1936 | if (!top_pipe_to_program) |
2190 | return; | 1937 | return; |
2191 | 1938 | ||
1939 | opp = top_pipe_to_program->stream_res.opp; | ||
1940 | |||
2192 | tg = top_pipe_to_program->stream_res.tg; | 1941 | tg = top_pipe_to_program->stream_res.tg; |
2193 | 1942 | ||
2194 | tg->funcs->lock(tg); | 1943 | tg->funcs->lock(tg); |
@@ -2196,7 +1945,8 @@ static void dcn10_apply_ctx_for_surface( | |||
2196 | if (num_planes == 0) { | 1945 | if (num_planes == 0) { |
2197 | 1946 | ||
2198 | /* OTG blank before remove all front end */ | 1947 | /* OTG blank before remove all front end */ |
2199 | tg->funcs->set_blank(tg, true); | 1948 | if (tg->funcs->set_blank) |
1949 | tg->funcs->set_blank(tg, true); | ||
2200 | } | 1950 | } |
2201 | 1951 | ||
2202 | /* Disconnect unused mpcc */ | 1952 | /* Disconnect unused mpcc */ |
@@ -2236,24 +1986,14 @@ static void dcn10_apply_ctx_for_surface( | |||
2236 | } | 1986 | } |
2237 | } | 1987 | } |
2238 | 1988 | ||
2239 | if (num_planes > 0) { | 1989 | if (num_planes > 0) |
2240 | program_all_pipe_in_tree(dc, top_pipe_to_program, context); | 1990 | program_all_pipe_in_tree(dc, top_pipe_to_program, context); |
2241 | 1991 | ||
2242 | /* TODO: this is a hack w/a for switching from mpo to pipe split */ | ||
2243 | if (stream->cursor_attributes.address.quad_part != 0) { | ||
2244 | struct dc_cursor_position position = { 0 }; | ||
2245 | |||
2246 | dc_stream_set_cursor_position( | ||
2247 | (struct dc_stream_state *)stream, | ||
2248 | &position); | ||
2249 | dc_stream_set_cursor_attributes( | ||
2250 | (struct dc_stream_state *)stream, | ||
2251 | &stream->cursor_attributes); | ||
2252 | } | ||
2253 | } | ||
2254 | |||
2255 | tg->funcs->unlock(tg); | 1992 | tg->funcs->unlock(tg); |
2256 | 1993 | ||
1994 | if (num_planes == 0) | ||
1995 | false_optc_underflow_wa(dc, stream, tg); | ||
1996 | |||
2257 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | 1997 | for (i = 0; i < dc->res_pool->pipe_count; i++) { |
2258 | struct pipe_ctx *old_pipe_ctx = | 1998 | struct pipe_ctx *old_pipe_ctx = |
2259 | &dc->current_state->res_ctx.pipe_ctx[i]; | 1999 | &dc->current_state->res_ctx.pipe_ctx[i]; |
@@ -2264,7 +2004,7 @@ static void dcn10_apply_ctx_for_surface( | |||
2264 | pipe_ctx->plane_state->update_flags.bits.full_update) | 2004 | pipe_ctx->plane_state->update_flags.bits.full_update) |
2265 | program_water_mark = true; | 2005 | program_water_mark = true; |
2266 | 2006 | ||
2267 | if (removed_pipe[i] && num_planes == 0) | 2007 | if (removed_pipe[i]) |
2268 | dcn10_disable_plane(dc, old_pipe_ctx); | 2008 | dcn10_disable_plane(dc, old_pipe_ctx); |
2269 | } | 2009 | } |
2270 | 2010 | ||
@@ -2273,6 +2013,7 @@ static void dcn10_apply_ctx_for_surface( | |||
2273 | /* pstate stuck check after watermark update */ | 2013 | /* pstate stuck check after watermark update */ |
2274 | dcn10_verify_allow_pstate_change_high(dc); | 2014 | dcn10_verify_allow_pstate_change_high(dc); |
2275 | } | 2015 | } |
2016 | |||
2276 | /* watermark is for all pipes */ | 2017 | /* watermark is for all pipes */ |
2277 | hubbub1_program_watermarks(dc->res_pool->hubbub, | 2018 | hubbub1_program_watermarks(dc->res_pool->hubbub, |
2278 | &context->bw.dcn.watermarks, ref_clk_mhz); | 2019 | &context->bw.dcn.watermarks, ref_clk_mhz); |
@@ -2502,10 +2243,10 @@ static void dcn10_setup_stereo(struct pipe_ctx *pipe_ctx, struct dc *dc) | |||
2502 | 2243 | ||
2503 | dcn10_config_stereo_parameters(stream, &flags); | 2244 | dcn10_config_stereo_parameters(stream, &flags); |
2504 | 2245 | ||
2505 | pipe_ctx->stream_res.opp->funcs->opp_set_stereo_polarity( | 2246 | pipe_ctx->stream_res.opp->funcs->opp_program_stereo( |
2506 | pipe_ctx->stream_res.opp, | 2247 | pipe_ctx->stream_res.opp, |
2507 | flags.PROGRAM_STEREO == 1 ? true:false, | 2248 | flags.PROGRAM_STEREO == 1 ? true:false, |
2508 | stream->timing.flags.RIGHT_EYE_3D_POLARITY == 1 ? true:false); | 2249 | &stream->timing); |
2509 | 2250 | ||
2510 | pipe_ctx->stream_res.tg->funcs->program_stereo( | 2251 | pipe_ctx->stream_res.tg->funcs->program_stereo( |
2511 | pipe_ctx->stream_res.tg, | 2252 | pipe_ctx->stream_res.tg, |
@@ -2619,7 +2360,8 @@ static const struct hw_sequencer_funcs dcn10_funcs = { | |||
2619 | .pplib_apply_display_requirements = | 2360 | .pplib_apply_display_requirements = |
2620 | dcn10_pplib_apply_display_requirements, | 2361 | dcn10_pplib_apply_display_requirements, |
2621 | .edp_backlight_control = hwss_edp_backlight_control, | 2362 | .edp_backlight_control = hwss_edp_backlight_control, |
2622 | .edp_power_control = hwss_edp_power_control | 2363 | .edp_power_control = hwss_edp_power_control, |
2364 | .edp_wait_for_hpd_ready = hwss_edp_wait_for_hpd_ready, | ||
2623 | }; | 2365 | }; |
2624 | 2366 | ||
2625 | 2367 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c index b016f4cbd45c..179890b1a8c4 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c | |||
@@ -25,8 +25,6 @@ | |||
25 | 25 | ||
26 | #include "reg_helper.h" | 26 | #include "reg_helper.h" |
27 | #include "dcn10_mpc.h" | 27 | #include "dcn10_mpc.h" |
28 | #include "dc.h" | ||
29 | #include "mem_input.h" | ||
30 | 28 | ||
31 | #define REG(reg)\ | 29 | #define REG(reg)\ |
32 | mpc10->mpc_regs->reg | 30 | mpc10->mpc_regs->reg |
@@ -38,17 +36,13 @@ | |||
38 | #define FN(reg_name, field_name) \ | 36 | #define FN(reg_name, field_name) \ |
39 | mpc10->mpc_shift->field_name, mpc10->mpc_mask->field_name | 37 | mpc10->mpc_shift->field_name, mpc10->mpc_mask->field_name |
40 | 38 | ||
41 | #define MODE_TOP_ONLY 1 | ||
42 | #define MODE_BLEND 3 | ||
43 | #define BLND_PP_ALPHA 0 | ||
44 | #define BLND_GLOBAL_ALPHA 2 | ||
45 | 39 | ||
46 | 40 | void mpc1_set_bg_color(struct mpc *mpc, | |
47 | static void mpc10_set_bg_color( | ||
48 | struct dcn10_mpc *mpc10, | ||
49 | struct tg_color *bg_color, | 41 | struct tg_color *bg_color, |
50 | int id) | 42 | int mpcc_id) |
51 | { | 43 | { |
44 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | ||
45 | |||
52 | /* mpc color is 12 bit. tg_color is 10 bit */ | 46 | /* mpc color is 12 bit. tg_color is 10 bit */ |
53 | /* todo: might want to use 16 bit to represent color and have each | 47 | /* todo: might want to use 16 bit to represent color and have each |
54 | * hw block translate to correct color depth. | 48 | * hw block translate to correct color depth. |
@@ -57,15 +51,47 @@ static void mpc10_set_bg_color( | |||
57 | uint32_t bg_g_y = bg_color->color_g_y << 2; | 51 | uint32_t bg_g_y = bg_color->color_g_y << 2; |
58 | uint32_t bg_b_cb = bg_color->color_b_cb << 2; | 52 | uint32_t bg_b_cb = bg_color->color_b_cb << 2; |
59 | 53 | ||
60 | REG_SET(MPCC_BG_R_CR[id], 0, | 54 | REG_SET(MPCC_BG_R_CR[mpcc_id], 0, |
61 | MPCC_BG_R_CR, bg_r_cr); | 55 | MPCC_BG_R_CR, bg_r_cr); |
62 | REG_SET(MPCC_BG_G_Y[id], 0, | 56 | REG_SET(MPCC_BG_G_Y[mpcc_id], 0, |
63 | MPCC_BG_G_Y, bg_g_y); | 57 | MPCC_BG_G_Y, bg_g_y); |
64 | REG_SET(MPCC_BG_B_CB[id], 0, | 58 | REG_SET(MPCC_BG_B_CB[mpcc_id], 0, |
65 | MPCC_BG_B_CB, bg_b_cb); | 59 | MPCC_BG_B_CB, bg_b_cb); |
66 | } | 60 | } |
67 | 61 | ||
68 | void mpc10_assert_idle_mpcc(struct mpc *mpc, int id) | 62 | static void mpc1_update_blending( |
63 | struct mpc *mpc, | ||
64 | struct mpcc_blnd_cfg *blnd_cfg, | ||
65 | int mpcc_id) | ||
66 | { | ||
67 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | ||
68 | |||
69 | REG_UPDATE_5(MPCC_CONTROL[mpcc_id], | ||
70 | MPCC_ALPHA_BLND_MODE, blnd_cfg->alpha_mode, | ||
71 | MPCC_ALPHA_MULTIPLIED_MODE, blnd_cfg->pre_multiplied_alpha, | ||
72 | MPCC_BLND_ACTIVE_OVERLAP_ONLY, blnd_cfg->overlap_only, | ||
73 | MPCC_GLOBAL_ALPHA, blnd_cfg->global_alpha, | ||
74 | MPCC_GLOBAL_GAIN, blnd_cfg->global_gain); | ||
75 | |||
76 | mpc1_set_bg_color(mpc, &blnd_cfg->black_color, mpcc_id); | ||
77 | } | ||
78 | |||
79 | void mpc1_update_stereo_mix( | ||
80 | struct mpc *mpc, | ||
81 | struct mpcc_sm_cfg *sm_cfg, | ||
82 | int mpcc_id) | ||
83 | { | ||
84 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | ||
85 | |||
86 | REG_UPDATE_6(MPCC_SM_CONTROL[mpcc_id], | ||
87 | MPCC_SM_EN, sm_cfg->enable, | ||
88 | MPCC_SM_MODE, sm_cfg->sm_mode, | ||
89 | MPCC_SM_FRAME_ALT, sm_cfg->frame_alt, | ||
90 | MPCC_SM_FIELD_ALT, sm_cfg->field_alt, | ||
91 | MPCC_SM_FORCE_NEXT_FRAME_POL, sm_cfg->force_next_frame_porlarity, | ||
92 | MPCC_SM_FORCE_NEXT_TOP_POL, sm_cfg->force_next_field_polarity); | ||
93 | } | ||
94 | void mpc1_assert_idle_mpcc(struct mpc *mpc, int id) | ||
69 | { | 95 | { |
70 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 96 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
71 | 97 | ||
@@ -75,39 +101,52 @@ void mpc10_assert_idle_mpcc(struct mpc *mpc, int id) | |||
75 | 1, 100000); | 101 | 1, 100000); |
76 | } | 102 | } |
77 | 103 | ||
78 | static int mpc10_get_idle_mpcc_id(struct dcn10_mpc *mpc10) | 104 | struct mpcc *mpc1_get_mpcc(struct mpc *mpc, int mpcc_id) |
79 | { | 105 | { |
80 | int i; | 106 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
81 | int last_free_mpcc_id = -1; | ||
82 | 107 | ||
83 | for (i = 0; i < mpc10->num_mpcc; i++) { | 108 | ASSERT(mpcc_id < mpc10->num_mpcc); |
84 | uint32_t is_idle = 0; | 109 | return &(mpc->mpcc_array[mpcc_id]); |
110 | } | ||
85 | 111 | ||
86 | if (mpc10->mpcc_in_use_mask & 1 << i) | 112 | struct mpcc *mpc1_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) |
87 | continue; | 113 | { |
114 | struct mpcc *tmp_mpcc = tree->opp_list; | ||
88 | 115 | ||
89 | last_free_mpcc_id = i; | 116 | while (tmp_mpcc != NULL) { |
90 | REG_GET(MPCC_STATUS[i], MPCC_IDLE, &is_idle); | 117 | if (tmp_mpcc->dpp_id == dpp_id) |
91 | if (is_idle) | 118 | return tmp_mpcc; |
92 | return i; | 119 | tmp_mpcc = tmp_mpcc->mpcc_bot; |
93 | } | 120 | } |
121 | return NULL; | ||
122 | } | ||
94 | 123 | ||
95 | /* This assert should never trigger, we have mpcc leak if it does */ | 124 | bool mpc1_is_mpcc_idle(struct mpc *mpc, int mpcc_id) |
96 | ASSERT(last_free_mpcc_id != -1); | 125 | { |
97 | 126 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | |
98 | mpc10_assert_idle_mpcc(&mpc10->base, last_free_mpcc_id); | 127 | unsigned int top_sel; |
99 | return last_free_mpcc_id; | 128 | unsigned int opp_id; |
129 | unsigned int idle; | ||
130 | |||
131 | REG_GET(MPCC_TOP_SEL[mpcc_id], MPCC_TOP_SEL, &top_sel); | ||
132 | REG_GET(MPCC_OPP_ID[mpcc_id], MPCC_OPP_ID, &opp_id); | ||
133 | REG_GET(MPCC_STATUS[mpcc_id], MPCC_IDLE, &idle); | ||
134 | if (top_sel == 0xf && opp_id == 0xf && idle) | ||
135 | return true; | ||
136 | else | ||
137 | return false; | ||
100 | } | 138 | } |
101 | 139 | ||
102 | static void mpc10_assert_mpcc_idle_before_connect(struct dcn10_mpc *mpc10, int id) | 140 | void mpc1_assert_mpcc_idle_before_connect(struct mpc *mpc, int mpcc_id) |
103 | { | 141 | { |
142 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | ||
104 | unsigned int top_sel, mpc_busy, mpc_idle; | 143 | unsigned int top_sel, mpc_busy, mpc_idle; |
105 | 144 | ||
106 | REG_GET(MPCC_TOP_SEL[id], | 145 | REG_GET(MPCC_TOP_SEL[mpcc_id], |
107 | MPCC_TOP_SEL, &top_sel); | 146 | MPCC_TOP_SEL, &top_sel); |
108 | 147 | ||
109 | if (top_sel == 0xf) { | 148 | if (top_sel == 0xf) { |
110 | REG_GET_2(MPCC_STATUS[id], | 149 | REG_GET_2(MPCC_STATUS[mpcc_id], |
111 | MPCC_BUSY, &mpc_busy, | 150 | MPCC_BUSY, &mpc_busy, |
112 | MPCC_IDLE, &mpc_idle); | 151 | MPCC_IDLE, &mpc_idle); |
113 | 152 | ||
@@ -116,241 +155,269 @@ static void mpc10_assert_mpcc_idle_before_connect(struct dcn10_mpc *mpc10, int i | |||
116 | } | 155 | } |
117 | } | 156 | } |
118 | 157 | ||
119 | void mpc10_mpcc_remove( | 158 | /* |
120 | struct mpc *mpc, | 159 | * Insert DPP into MPC tree based on specified blending position. |
121 | struct mpc_tree_cfg *tree_cfg, | 160 | * Only used for planes that are part of blending chain for OPP output |
122 | int opp_id, | 161 | * |
123 | int dpp_id) | 162 | * Parameters: |
124 | { | 163 | * [in/out] mpc - MPC context. |
125 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 164 | * [in/out] tree - MPC tree structure that plane will be added to. |
126 | int mpcc_id, z_idx; | 165 | * [in] blnd_cfg - MPCC blending configuration for the new blending layer. |
127 | 166 | * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer. | |
128 | /* find z_idx for the dpp to be removed */ | 167 | * stereo mix must disable for the very bottom layer of the tree config. |
129 | for (z_idx = 0; z_idx < tree_cfg->num_pipes; z_idx++) | 168 | * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane. |
130 | if (tree_cfg->dpp[z_idx] == dpp_id) | 169 | * [in] dpp_id - DPP instance for the plane to be added. |
131 | break; | 170 | * [in] mpcc_id - The MPCC physical instance to use for blending. |
132 | 171 | * | |
133 | if (z_idx == tree_cfg->num_pipes) { | 172 | * Return: struct mpcc* - MPCC that was added. |
134 | /* In case of resume from S3/S4, remove mpcc from bios left over */ | 173 | */ |
135 | REG_SET(MPCC_OPP_ID[dpp_id], 0, | 174 | struct mpcc *mpc1_insert_plane( |
136 | MPCC_OPP_ID, 0xf); | ||
137 | REG_SET(MPCC_TOP_SEL[dpp_id], 0, | ||
138 | MPCC_TOP_SEL, 0xf); | ||
139 | REG_SET(MPCC_BOT_SEL[dpp_id], 0, | ||
140 | MPCC_BOT_SEL, 0xf); | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | mpcc_id = tree_cfg->mpcc[z_idx]; | ||
145 | |||
146 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, | ||
147 | MPCC_OPP_ID, 0xf); | ||
148 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, | ||
149 | MPCC_TOP_SEL, 0xf); | ||
150 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, | ||
151 | MPCC_BOT_SEL, 0xf); | ||
152 | |||
153 | if (z_idx > 0) { | ||
154 | int top_mpcc_id = tree_cfg->mpcc[z_idx - 1]; | ||
155 | |||
156 | if (z_idx + 1 < tree_cfg->num_pipes) | ||
157 | /* mpcc to be removed is in the middle of the tree */ | ||
158 | REG_SET(MPCC_BOT_SEL[top_mpcc_id], 0, | ||
159 | MPCC_BOT_SEL, tree_cfg->mpcc[z_idx + 1]); | ||
160 | else { | ||
161 | /* mpcc to be removed is at the bottom of the tree */ | ||
162 | REG_SET(MPCC_BOT_SEL[top_mpcc_id], 0, | ||
163 | MPCC_BOT_SEL, 0xf); | ||
164 | REG_UPDATE(MPCC_CONTROL[top_mpcc_id], | ||
165 | MPCC_MODE, MODE_TOP_ONLY); | ||
166 | } | ||
167 | } else if (tree_cfg->num_pipes > 1) | ||
168 | /* mpcc to be removed is at the top of the tree */ | ||
169 | REG_SET(MUX[opp_id], 0, | ||
170 | MPC_OUT_MUX, tree_cfg->mpcc[z_idx + 1]); | ||
171 | else | ||
172 | /* mpcc to be removed is the only one in the tree */ | ||
173 | REG_SET(MUX[opp_id], 0, MPC_OUT_MUX, 0xf); | ||
174 | |||
175 | /* mark this mpcc as not in use */ | ||
176 | mpc10->mpcc_in_use_mask &= ~(1 << mpcc_id); | ||
177 | tree_cfg->num_pipes--; | ||
178 | for (; z_idx < tree_cfg->num_pipes; z_idx++) { | ||
179 | tree_cfg->dpp[z_idx] = tree_cfg->dpp[z_idx + 1]; | ||
180 | tree_cfg->mpcc[z_idx] = tree_cfg->mpcc[z_idx + 1]; | ||
181 | } | ||
182 | tree_cfg->dpp[tree_cfg->num_pipes] = 0xdeadbeef; | ||
183 | tree_cfg->mpcc[tree_cfg->num_pipes] = 0xdeadbeef; | ||
184 | } | ||
185 | |||
186 | static void mpc10_add_to_tree_cfg( | ||
187 | struct mpc *mpc, | 175 | struct mpc *mpc, |
188 | struct mpcc_cfg *cfg, | 176 | struct mpc_tree *tree, |
177 | struct mpcc_blnd_cfg *blnd_cfg, | ||
178 | struct mpcc_sm_cfg *sm_cfg, | ||
179 | struct mpcc *insert_above_mpcc, | ||
180 | int dpp_id, | ||
189 | int mpcc_id) | 181 | int mpcc_id) |
190 | { | 182 | { |
191 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 183 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
192 | int mpcc_mode = MODE_TOP_ONLY; | 184 | struct mpcc *new_mpcc = NULL; |
193 | int position = cfg->z_index; | ||
194 | struct mpc_tree_cfg *tree_cfg = cfg->tree_cfg; | ||
195 | int alpha_blnd_mode = cfg->per_pixel_alpha ? | ||
196 | BLND_PP_ALPHA : BLND_GLOBAL_ALPHA; | ||
197 | int z_idx; | ||
198 | 185 | ||
199 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, | 186 | /* sanity check parameters */ |
200 | MPCC_OPP_ID, cfg->opp_id); | 187 | ASSERT(mpcc_id < mpc10->num_mpcc); |
188 | ASSERT(!(mpc10->mpcc_in_use_mask & 1 << mpcc_id)); | ||
201 | 189 | ||
202 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, | 190 | if (insert_above_mpcc) { |
203 | MPCC_TOP_SEL, cfg->dpp_id); | 191 | /* check insert_above_mpcc exist in tree->opp_list */ |
192 | struct mpcc *temp_mpcc = tree->opp_list; | ||
204 | 193 | ||
205 | if (position == 0) { | 194 | while (temp_mpcc && temp_mpcc->mpcc_bot != insert_above_mpcc) |
206 | /* idle dpp/mpcc is added to the top layer of tree */ | 195 | temp_mpcc = temp_mpcc->mpcc_bot; |
196 | if (temp_mpcc == NULL) | ||
197 | return NULL; | ||
198 | } | ||
207 | 199 | ||
208 | if (tree_cfg->num_pipes > 0) { | 200 | /* Get and update MPCC struct parameters */ |
209 | /* get instance of previous top mpcc */ | 201 | new_mpcc = mpc1_get_mpcc(mpc, mpcc_id); |
210 | int prev_top_mpcc_id = tree_cfg->mpcc[0]; | 202 | new_mpcc->dpp_id = dpp_id; |
211 | 203 | ||
212 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, | 204 | /* program mux and MPCC_MODE */ |
213 | MPCC_BOT_SEL, prev_top_mpcc_id); | 205 | if (insert_above_mpcc) { |
214 | mpcc_mode = MODE_BLEND; | 206 | new_mpcc->mpcc_bot = insert_above_mpcc; |
207 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, MPCC_BOT_SEL, insert_above_mpcc->mpcc_id); | ||
208 | REG_UPDATE(MPCC_CONTROL[mpcc_id], MPCC_MODE, MPCC_BLEND_MODE_TOP_BOT_BLENDING); | ||
209 | } else { | ||
210 | new_mpcc->mpcc_bot = NULL; | ||
211 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, MPCC_BOT_SEL, 0xf); | ||
212 | REG_UPDATE(MPCC_CONTROL[mpcc_id], MPCC_MODE, MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH); | ||
213 | } | ||
214 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, MPCC_TOP_SEL, dpp_id); | ||
215 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, MPCC_OPP_ID, tree->opp_id); | ||
216 | |||
217 | /* update mpc tree mux setting */ | ||
218 | if (tree->opp_list == insert_above_mpcc) { | ||
219 | /* insert the toppest mpcc */ | ||
220 | tree->opp_list = new_mpcc; | ||
221 | REG_UPDATE(MUX[tree->opp_id], MPC_OUT_MUX, mpcc_id); | ||
222 | } else { | ||
223 | /* find insert position */ | ||
224 | struct mpcc *temp_mpcc = tree->opp_list; | ||
225 | |||
226 | while (temp_mpcc && temp_mpcc->mpcc_bot != insert_above_mpcc) | ||
227 | temp_mpcc = temp_mpcc->mpcc_bot; | ||
228 | if (temp_mpcc && temp_mpcc->mpcc_bot == insert_above_mpcc) { | ||
229 | REG_SET(MPCC_BOT_SEL[temp_mpcc->mpcc_id], 0, MPCC_BOT_SEL, mpcc_id); | ||
230 | temp_mpcc->mpcc_bot = new_mpcc; | ||
231 | if (!insert_above_mpcc) | ||
232 | REG_UPDATE(MPCC_CONTROL[temp_mpcc->mpcc_id], | ||
233 | MPCC_MODE, MPCC_BLEND_MODE_TOP_BOT_BLENDING); | ||
215 | } | 234 | } |
235 | } | ||
216 | 236 | ||
217 | /* opp will get new output. from new added mpcc */ | 237 | /* update the blending configuration */ |
218 | REG_SET(MUX[cfg->opp_id], 0, MPC_OUT_MUX, mpcc_id); | 238 | new_mpcc->blnd_cfg = *blnd_cfg; |
219 | 239 | mpc->funcs->update_blending(mpc, &new_mpcc->blnd_cfg, mpcc_id); | |
220 | } else if (position == tree_cfg->num_pipes) { | ||
221 | /* idle dpp/mpcc is added to the bottom layer of tree */ | ||
222 | |||
223 | /* get instance of previous bottom mpcc, set to middle layer */ | ||
224 | int prev_bot_mpcc_id = tree_cfg->mpcc[tree_cfg->num_pipes - 1]; | ||
225 | |||
226 | REG_SET(MPCC_BOT_SEL[prev_bot_mpcc_id], 0, | ||
227 | MPCC_BOT_SEL, mpcc_id); | ||
228 | REG_UPDATE(MPCC_CONTROL[prev_bot_mpcc_id], | ||
229 | MPCC_MODE, MODE_BLEND); | ||
230 | |||
231 | /* mpcc_id become new bottom mpcc*/ | ||
232 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, | ||
233 | MPCC_BOT_SEL, 0xf); | ||
234 | 240 | ||
235 | } else { | 241 | /* update the stereo mix settings, if provided */ |
236 | /* idle dpp/mpcc is added to middle of tree */ | 242 | if (sm_cfg != NULL) { |
237 | int above_mpcc_id = tree_cfg->mpcc[position - 1]; | 243 | new_mpcc->sm_cfg = *sm_cfg; |
238 | int below_mpcc_id = tree_cfg->mpcc[position]; | 244 | mpc1_update_stereo_mix(mpc, sm_cfg, mpcc_id); |
239 | |||
240 | /* mpcc above new mpcc_id has new bottom mux*/ | ||
241 | REG_SET(MPCC_BOT_SEL[above_mpcc_id], 0, | ||
242 | MPCC_BOT_SEL, mpcc_id); | ||
243 | REG_UPDATE(MPCC_CONTROL[above_mpcc_id], | ||
244 | MPCC_MODE, MODE_BLEND); | ||
245 | |||
246 | /* mpcc_id bottom mux is from below mpcc*/ | ||
247 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, | ||
248 | MPCC_BOT_SEL, below_mpcc_id); | ||
249 | mpcc_mode = MODE_BLEND; | ||
250 | } | 245 | } |
251 | 246 | ||
252 | REG_SET_4(MPCC_CONTROL[mpcc_id], 0xffffffff, | 247 | /* mark this mpcc as in use */ |
253 | MPCC_MODE, mpcc_mode, | 248 | mpc10->mpcc_in_use_mask |= 1 << mpcc_id; |
254 | MPCC_ALPHA_BLND_MODE, alpha_blnd_mode, | ||
255 | MPCC_ALPHA_MULTIPLIED_MODE, cfg->pre_multiplied_alpha, | ||
256 | MPCC_BLND_ACTIVE_OVERLAP_ONLY, false); | ||
257 | 249 | ||
258 | /* update mpc_tree_cfg with new mpcc */ | 250 | return new_mpcc; |
259 | for (z_idx = tree_cfg->num_pipes; z_idx > position; z_idx--) { | ||
260 | tree_cfg->dpp[z_idx] = tree_cfg->dpp[z_idx - 1]; | ||
261 | tree_cfg->mpcc[z_idx] = tree_cfg->mpcc[z_idx - 1]; | ||
262 | } | ||
263 | tree_cfg->dpp[position] = cfg->dpp_id; | ||
264 | tree_cfg->mpcc[position] = mpcc_id; | ||
265 | tree_cfg->num_pipes++; | ||
266 | } | 251 | } |
267 | 252 | ||
268 | int mpc10_mpcc_add(struct mpc *mpc, struct mpcc_cfg *cfg) | 253 | /* |
254 | * Remove a specified MPCC from the MPC tree. | ||
255 | * | ||
256 | * Parameters: | ||
257 | * [in/out] mpc - MPC context. | ||
258 | * [in/out] tree - MPC tree structure that plane will be removed from. | ||
259 | * [in/out] mpcc - MPCC to be removed from tree. | ||
260 | * | ||
261 | * Return: void | ||
262 | */ | ||
263 | void mpc1_remove_mpcc( | ||
264 | struct mpc *mpc, | ||
265 | struct mpc_tree *tree, | ||
266 | struct mpcc *mpcc_to_remove) | ||
269 | { | 267 | { |
270 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 268 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
271 | int mpcc_id, z_idx; | 269 | bool found = false; |
272 | 270 | int mpcc_id = mpcc_to_remove->mpcc_id; | |
273 | ASSERT(cfg->z_index < mpc10->num_mpcc); | 271 | |
274 | 272 | if (tree->opp_list == mpcc_to_remove) { | |
275 | /* check in dpp already exists in mpc tree */ | 273 | found = true; |
276 | for (z_idx = 0; z_idx < cfg->tree_cfg->num_pipes; z_idx++) | 274 | /* remove MPCC from top of tree */ |
277 | if (cfg->tree_cfg->dpp[z_idx] == cfg->dpp_id) | 275 | if (mpcc_to_remove->mpcc_bot) { |
278 | break; | 276 | /* set the next MPCC in list to be the top MPCC */ |
279 | if (z_idx == cfg->tree_cfg->num_pipes) { | 277 | tree->opp_list = mpcc_to_remove->mpcc_bot; |
280 | ASSERT(cfg->z_index <= cfg->tree_cfg->num_pipes); | 278 | REG_UPDATE(MUX[tree->opp_id], MPC_OUT_MUX, tree->opp_list->mpcc_id); |
281 | mpcc_id = mpc10_get_idle_mpcc_id(mpc10); | 279 | } else { |
282 | 280 | /* there are no other MPCC is list */ | |
283 | /* | 281 | tree->opp_list = NULL; |
284 | * TODO: remove hack | 282 | REG_UPDATE(MUX[tree->opp_id], MPC_OUT_MUX, 0xf); |
285 | * Note: currently there is a bug in init_hw such that | 283 | } |
286 | * on resume from hibernate, BIOS sets up MPCC0, and | ||
287 | * we do mpcc_remove but the mpcc cannot go to idle | ||
288 | * after remove. This cause us to pick mpcc1 here, | ||
289 | * which causes a pstate hang for yet unknown reason. | ||
290 | */ | ||
291 | mpcc_id = cfg->dpp_id; | ||
292 | /* end hack*/ | ||
293 | |||
294 | ASSERT(!(mpc10->mpcc_in_use_mask & 1 << mpcc_id)); | ||
295 | |||
296 | if (mpc->ctx->dc->debug.sanity_checks) | ||
297 | mpc10_assert_mpcc_idle_before_connect(mpc10, mpcc_id); | ||
298 | } else { | 284 | } else { |
299 | ASSERT(cfg->z_index < cfg->tree_cfg->num_pipes); | 285 | /* find mpcc to remove MPCC list */ |
300 | mpcc_id = cfg->tree_cfg->mpcc[z_idx]; | 286 | struct mpcc *temp_mpcc = tree->opp_list; |
301 | mpc10_mpcc_remove(mpc, cfg->tree_cfg, cfg->opp_id, cfg->dpp_id); | 287 | |
288 | while (temp_mpcc && temp_mpcc->mpcc_bot != mpcc_to_remove) | ||
289 | temp_mpcc = temp_mpcc->mpcc_bot; | ||
290 | |||
291 | if (temp_mpcc && temp_mpcc->mpcc_bot == mpcc_to_remove) { | ||
292 | found = true; | ||
293 | temp_mpcc->mpcc_bot = mpcc_to_remove->mpcc_bot; | ||
294 | if (mpcc_to_remove->mpcc_bot) { | ||
295 | /* remove MPCC in middle of list */ | ||
296 | REG_SET(MPCC_BOT_SEL[temp_mpcc->mpcc_id], 0, | ||
297 | MPCC_BOT_SEL, mpcc_to_remove->mpcc_bot->mpcc_id); | ||
298 | } else { | ||
299 | /* remove MPCC from bottom of list */ | ||
300 | REG_SET(MPCC_BOT_SEL[temp_mpcc->mpcc_id], 0, | ||
301 | MPCC_BOT_SEL, 0xf); | ||
302 | REG_UPDATE(MPCC_CONTROL[temp_mpcc->mpcc_id], | ||
303 | MPCC_MODE, MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH); | ||
304 | } | ||
305 | } | ||
302 | } | 306 | } |
303 | 307 | ||
304 | /* add dpp/mpcc pair to mpc_tree_cfg and update mpcc registers */ | 308 | if (found) { |
305 | mpc10_add_to_tree_cfg(mpc, cfg, mpcc_id); | 309 | /* turn off MPCC mux registers */ |
310 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, MPCC_TOP_SEL, 0xf); | ||
311 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, MPCC_BOT_SEL, 0xf); | ||
312 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, MPCC_OPP_ID, 0xf); | ||
306 | 313 | ||
307 | /* set background color */ | 314 | /* mark this mpcc as not in use */ |
308 | mpc10_set_bg_color(mpc10, &cfg->black_color, mpcc_id); | 315 | mpc10->mpcc_in_use_mask &= ~(1 << mpcc_id); |
309 | 316 | mpcc_to_remove->dpp_id = 0xf; | |
310 | /* mark this mpcc as in use */ | 317 | mpcc_to_remove->mpcc_bot = NULL; |
311 | mpc10->mpcc_in_use_mask |= 1 << mpcc_id; | 318 | } else { |
319 | /* In case of resume from S3/S4, remove mpcc from bios left over */ | ||
320 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, MPCC_TOP_SEL, 0xf); | ||
321 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, MPCC_BOT_SEL, 0xf); | ||
322 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, MPCC_OPP_ID, 0xf); | ||
323 | } | ||
324 | } | ||
312 | 325 | ||
313 | return mpcc_id; | 326 | static void mpc1_init_mpcc(struct mpcc *mpcc, int mpcc_inst) |
327 | { | ||
328 | mpcc->mpcc_id = mpcc_inst; | ||
329 | mpcc->dpp_id = 0xf; | ||
330 | mpcc->mpcc_bot = NULL; | ||
331 | mpcc->blnd_cfg.overlap_only = false; | ||
332 | mpcc->blnd_cfg.global_alpha = 0xff; | ||
333 | mpcc->blnd_cfg.global_gain = 0xff; | ||
334 | mpcc->sm_cfg.enable = false; | ||
314 | } | 335 | } |
315 | 336 | ||
316 | void mpc10_update_blend_mode( | 337 | /* |
317 | struct mpc *mpc, | 338 | * Reset the MPCC HW status by disconnecting all muxes. |
318 | struct mpcc_cfg *cfg) | 339 | * |
340 | * Parameters: | ||
341 | * [in/out] mpc - MPC context. | ||
342 | * | ||
343 | * Return: void | ||
344 | */ | ||
345 | void mpc1_mpc_init(struct mpc *mpc) | ||
319 | { | 346 | { |
320 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 347 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
321 | int mpcc_id, z_idx; | 348 | int mpcc_id; |
322 | int alpha_blnd_mode = cfg->per_pixel_alpha ? | 349 | int opp_id; |
323 | BLND_PP_ALPHA : BLND_GLOBAL_ALPHA; | ||
324 | 350 | ||
325 | /* find z_idx for the dpp that requires blending mode update*/ | 351 | mpc10->mpcc_in_use_mask = 0; |
326 | for (z_idx = 0; z_idx < cfg->tree_cfg->num_pipes; z_idx++) | 352 | for (mpcc_id = 0; mpcc_id < mpc10->num_mpcc; mpcc_id++) { |
327 | if (cfg->tree_cfg->dpp[z_idx] == cfg->dpp_id) | 353 | REG_SET(MPCC_TOP_SEL[mpcc_id], 0, MPCC_TOP_SEL, 0xf); |
328 | break; | 354 | REG_SET(MPCC_BOT_SEL[mpcc_id], 0, MPCC_BOT_SEL, 0xf); |
355 | REG_SET(MPCC_OPP_ID[mpcc_id], 0, MPCC_OPP_ID, 0xf); | ||
329 | 356 | ||
330 | ASSERT(z_idx < cfg->tree_cfg->num_pipes); | 357 | mpc1_init_mpcc(&(mpc->mpcc_array[mpcc_id]), mpcc_id); |
331 | mpcc_id = cfg->tree_cfg->mpcc[z_idx]; | 358 | } |
332 | 359 | ||
333 | REG_UPDATE_2(MPCC_CONTROL[mpcc_id], | 360 | for (opp_id = 0; opp_id < MAX_OPP; opp_id++) { |
334 | MPCC_ALPHA_BLND_MODE, alpha_blnd_mode, | 361 | if (REG(MUX[opp_id])) |
335 | MPCC_ALPHA_MULTIPLIED_MODE, cfg->pre_multiplied_alpha); | 362 | REG_UPDATE(MUX[opp_id], MPC_OUT_MUX, 0xf); |
363 | } | ||
336 | } | 364 | } |
337 | 365 | ||
338 | int mpc10_get_opp_id(struct mpc *mpc, int mpcc_id) | 366 | void mpc1_init_mpcc_list_from_hw( |
367 | struct mpc *mpc, | ||
368 | struct mpc_tree *tree) | ||
339 | { | 369 | { |
340 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); | 370 | struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc); |
341 | int opp_id = 0xF; | 371 | unsigned int opp_id; |
342 | 372 | unsigned int top_sel; | |
343 | REG_GET(MPCC_OPP_ID[mpcc_id], MPCC_OPP_ID, &opp_id); | 373 | unsigned int bot_sel; |
344 | 374 | unsigned int out_mux; | |
345 | return opp_id; | 375 | struct mpcc *mpcc; |
376 | int mpcc_id; | ||
377 | int bot_mpcc_id; | ||
378 | |||
379 | REG_GET(MUX[tree->opp_id], MPC_OUT_MUX, &out_mux); | ||
380 | |||
381 | if (out_mux != 0xf) { | ||
382 | for (mpcc_id = 0; mpcc_id < mpc10->num_mpcc; mpcc_id++) { | ||
383 | REG_GET(MPCC_OPP_ID[mpcc_id], MPCC_OPP_ID, &opp_id); | ||
384 | REG_GET(MPCC_TOP_SEL[mpcc_id], MPCC_TOP_SEL, &top_sel); | ||
385 | REG_GET(MPCC_BOT_SEL[mpcc_id], MPCC_BOT_SEL, &bot_sel); | ||
386 | |||
387 | if (bot_sel == mpcc_id) | ||
388 | bot_sel = 0xf; | ||
389 | |||
390 | if ((opp_id == tree->opp_id) && (top_sel != 0xf)) { | ||
391 | mpcc = mpc1_get_mpcc(mpc, mpcc_id); | ||
392 | mpcc->dpp_id = top_sel; | ||
393 | mpc10->mpcc_in_use_mask |= 1 << mpcc_id; | ||
394 | |||
395 | if (out_mux == mpcc_id) | ||
396 | tree->opp_list = mpcc; | ||
397 | if (bot_sel != 0xf && bot_sel < mpc10->num_mpcc) { | ||
398 | bot_mpcc_id = bot_sel; | ||
399 | REG_GET(MPCC_OPP_ID[bot_mpcc_id], MPCC_OPP_ID, &opp_id); | ||
400 | REG_GET(MPCC_TOP_SEL[bot_mpcc_id], MPCC_TOP_SEL, &top_sel); | ||
401 | if ((opp_id == tree->opp_id) && (top_sel != 0xf)) { | ||
402 | struct mpcc *mpcc_bottom = mpc1_get_mpcc(mpc, bot_mpcc_id); | ||
403 | |||
404 | mpcc->mpcc_bot = mpcc_bottom; | ||
405 | } | ||
406 | } | ||
407 | } | ||
408 | } | ||
409 | } | ||
346 | } | 410 | } |
347 | 411 | ||
348 | const struct mpc_funcs dcn10_mpc_funcs = { | 412 | const struct mpc_funcs dcn10_mpc_funcs = { |
349 | .add = mpc10_mpcc_add, | 413 | .insert_plane = mpc1_insert_plane, |
350 | .remove = mpc10_mpcc_remove, | 414 | .remove_mpcc = mpc1_remove_mpcc, |
351 | .wait_for_idle = mpc10_assert_idle_mpcc, | 415 | .mpc_init = mpc1_mpc_init, |
352 | .update_blend_mode = mpc10_update_blend_mode, | 416 | .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp, |
353 | .get_opp_id = mpc10_get_opp_id, | 417 | .wait_for_idle = mpc1_assert_idle_mpcc, |
418 | .assert_mpcc_idle_before_connect = mpc1_assert_mpcc_idle_before_connect, | ||
419 | .init_mpcc_list_from_hw = mpc1_init_mpcc_list_from_hw, | ||
420 | .update_blending = mpc1_update_blending, | ||
354 | }; | 421 | }; |
355 | 422 | ||
356 | void dcn10_mpc_construct(struct dcn10_mpc *mpc10, | 423 | void dcn10_mpc_construct(struct dcn10_mpc *mpc10, |
@@ -360,6 +427,8 @@ void dcn10_mpc_construct(struct dcn10_mpc *mpc10, | |||
360 | const struct dcn_mpc_mask *mpc_mask, | 427 | const struct dcn_mpc_mask *mpc_mask, |
361 | int num_mpcc) | 428 | int num_mpcc) |
362 | { | 429 | { |
430 | int i; | ||
431 | |||
363 | mpc10->base.ctx = ctx; | 432 | mpc10->base.ctx = ctx; |
364 | 433 | ||
365 | mpc10->base.funcs = &dcn10_mpc_funcs; | 434 | mpc10->base.funcs = &dcn10_mpc_funcs; |
@@ -370,5 +439,8 @@ void dcn10_mpc_construct(struct dcn10_mpc *mpc10, | |||
370 | 439 | ||
371 | mpc10->mpcc_in_use_mask = 0; | 440 | mpc10->mpcc_in_use_mask = 0; |
372 | mpc10->num_mpcc = num_mpcc; | 441 | mpc10->num_mpcc = num_mpcc; |
442 | |||
443 | for (i = 0; i < MAX_MPCC; i++) | ||
444 | mpc1_init_mpcc(&mpc10->base.mpcc_array[i], i); | ||
373 | } | 445 | } |
374 | 446 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.h index e85e1f342266..267a2995ef6e 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.h | |||
@@ -30,9 +30,6 @@ | |||
30 | #define TO_DCN10_MPC(mpc_base) \ | 30 | #define TO_DCN10_MPC(mpc_base) \ |
31 | container_of(mpc_base, struct dcn10_mpc, base) | 31 | container_of(mpc_base, struct dcn10_mpc, base) |
32 | 32 | ||
33 | #define MAX_MPCC 6 | ||
34 | #define MAX_OPP 6 | ||
35 | |||
36 | #define MPC_COMMON_REG_LIST_DCN1_0(inst) \ | 33 | #define MPC_COMMON_REG_LIST_DCN1_0(inst) \ |
37 | SRII(MPCC_TOP_SEL, MPCC, inst),\ | 34 | SRII(MPCC_TOP_SEL, MPCC, inst),\ |
38 | SRII(MPCC_BOT_SEL, MPCC, inst),\ | 35 | SRII(MPCC_BOT_SEL, MPCC, inst),\ |
@@ -42,7 +39,8 @@ | |||
42 | SRII(MPCC_BG_G_Y, MPCC, inst),\ | 39 | SRII(MPCC_BG_G_Y, MPCC, inst),\ |
43 | SRII(MPCC_BG_R_CR, MPCC, inst),\ | 40 | SRII(MPCC_BG_R_CR, MPCC, inst),\ |
44 | SRII(MPCC_BG_B_CB, MPCC, inst),\ | 41 | SRII(MPCC_BG_B_CB, MPCC, inst),\ |
45 | SRII(MPCC_BG_B_CB, MPCC, inst) | 42 | SRII(MPCC_BG_B_CB, MPCC, inst),\ |
43 | SRII(MPCC_SM_CONTROL, MPCC, inst) | ||
46 | 44 | ||
47 | #define MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(inst) \ | 45 | #define MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(inst) \ |
48 | SRII(MUX, MPC_OUT, inst) | 46 | SRII(MUX, MPC_OUT, inst) |
@@ -56,6 +54,7 @@ | |||
56 | uint32_t MPCC_BG_G_Y[MAX_MPCC]; \ | 54 | uint32_t MPCC_BG_G_Y[MAX_MPCC]; \ |
57 | uint32_t MPCC_BG_R_CR[MAX_MPCC]; \ | 55 | uint32_t MPCC_BG_R_CR[MAX_MPCC]; \ |
58 | uint32_t MPCC_BG_B_CB[MAX_MPCC]; \ | 56 | uint32_t MPCC_BG_B_CB[MAX_MPCC]; \ |
57 | uint32_t MPCC_SM_CONTROL[MAX_MPCC]; \ | ||
59 | uint32_t MUX[MAX_OPP]; | 58 | uint32_t MUX[MAX_OPP]; |
60 | 59 | ||
61 | #define MPC_COMMON_MASK_SH_LIST_DCN1_0(mask_sh)\ | 60 | #define MPC_COMMON_MASK_SH_LIST_DCN1_0(mask_sh)\ |
@@ -65,12 +64,20 @@ | |||
65 | SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_BLND_MODE, mask_sh),\ | 64 | SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_BLND_MODE, mask_sh),\ |
66 | SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_MULTIPLIED_MODE, mask_sh),\ | 65 | SF(MPCC0_MPCC_CONTROL, MPCC_ALPHA_MULTIPLIED_MODE, mask_sh),\ |
67 | SF(MPCC0_MPCC_CONTROL, MPCC_BLND_ACTIVE_OVERLAP_ONLY, mask_sh),\ | 66 | SF(MPCC0_MPCC_CONTROL, MPCC_BLND_ACTIVE_OVERLAP_ONLY, mask_sh),\ |
67 | SF(MPCC0_MPCC_CONTROL, MPCC_GLOBAL_ALPHA, mask_sh),\ | ||
68 | SF(MPCC0_MPCC_CONTROL, MPCC_GLOBAL_GAIN, mask_sh),\ | ||
68 | SF(MPCC0_MPCC_STATUS, MPCC_IDLE, mask_sh),\ | 69 | SF(MPCC0_MPCC_STATUS, MPCC_IDLE, mask_sh),\ |
69 | SF(MPCC0_MPCC_STATUS, MPCC_BUSY, mask_sh),\ | 70 | SF(MPCC0_MPCC_STATUS, MPCC_BUSY, mask_sh),\ |
70 | SF(MPCC0_MPCC_OPP_ID, MPCC_OPP_ID, mask_sh),\ | 71 | SF(MPCC0_MPCC_OPP_ID, MPCC_OPP_ID, mask_sh),\ |
71 | SF(MPCC0_MPCC_BG_G_Y, MPCC_BG_G_Y, mask_sh),\ | 72 | SF(MPCC0_MPCC_BG_G_Y, MPCC_BG_G_Y, mask_sh),\ |
72 | SF(MPCC0_MPCC_BG_R_CR, MPCC_BG_R_CR, mask_sh),\ | 73 | SF(MPCC0_MPCC_BG_R_CR, MPCC_BG_R_CR, mask_sh),\ |
73 | SF(MPCC0_MPCC_BG_B_CB, MPCC_BG_B_CB, mask_sh),\ | 74 | SF(MPCC0_MPCC_BG_B_CB, MPCC_BG_B_CB, mask_sh),\ |
75 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_EN, mask_sh),\ | ||
76 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_MODE, mask_sh),\ | ||
77 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FRAME_ALT, mask_sh),\ | ||
78 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FIELD_ALT, mask_sh),\ | ||
79 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FORCE_NEXT_FRAME_POL, mask_sh),\ | ||
80 | SF(MPCC0_MPCC_SM_CONTROL, MPCC_SM_FORCE_NEXT_TOP_POL, mask_sh),\ | ||
74 | SF(MPC_OUT0_MUX, MPC_OUT_MUX, mask_sh) | 81 | SF(MPC_OUT0_MUX, MPC_OUT_MUX, mask_sh) |
75 | 82 | ||
76 | #define MPC_REG_FIELD_LIST(type) \ | 83 | #define MPC_REG_FIELD_LIST(type) \ |
@@ -80,12 +87,20 @@ | |||
80 | type MPCC_ALPHA_BLND_MODE;\ | 87 | type MPCC_ALPHA_BLND_MODE;\ |
81 | type MPCC_ALPHA_MULTIPLIED_MODE;\ | 88 | type MPCC_ALPHA_MULTIPLIED_MODE;\ |
82 | type MPCC_BLND_ACTIVE_OVERLAP_ONLY;\ | 89 | type MPCC_BLND_ACTIVE_OVERLAP_ONLY;\ |
90 | type MPCC_GLOBAL_ALPHA;\ | ||
91 | type MPCC_GLOBAL_GAIN;\ | ||
83 | type MPCC_IDLE;\ | 92 | type MPCC_IDLE;\ |
84 | type MPCC_BUSY;\ | 93 | type MPCC_BUSY;\ |
85 | type MPCC_OPP_ID;\ | 94 | type MPCC_OPP_ID;\ |
86 | type MPCC_BG_G_Y;\ | 95 | type MPCC_BG_G_Y;\ |
87 | type MPCC_BG_R_CR;\ | 96 | type MPCC_BG_R_CR;\ |
88 | type MPCC_BG_B_CB;\ | 97 | type MPCC_BG_B_CB;\ |
98 | type MPCC_SM_EN;\ | ||
99 | type MPCC_SM_MODE;\ | ||
100 | type MPCC_SM_FRAME_ALT;\ | ||
101 | type MPCC_SM_FIELD_ALT;\ | ||
102 | type MPCC_SM_FORCE_NEXT_FRAME_POL;\ | ||
103 | type MPCC_SM_FORCE_NEXT_TOP_POL;\ | ||
89 | type MPC_OUT_MUX; | 104 | type MPC_OUT_MUX; |
90 | 105 | ||
91 | struct dcn_mpc_registers { | 106 | struct dcn_mpc_registers { |
@@ -117,23 +132,55 @@ void dcn10_mpc_construct(struct dcn10_mpc *mpcc10, | |||
117 | const struct dcn_mpc_mask *mpc_mask, | 132 | const struct dcn_mpc_mask *mpc_mask, |
118 | int num_mpcc); | 133 | int num_mpcc); |
119 | 134 | ||
120 | int mpc10_mpcc_add( | 135 | struct mpcc *mpc1_insert_plane( |
121 | struct mpc *mpc, | 136 | struct mpc *mpc, |
122 | struct mpcc_cfg *cfg); | 137 | struct mpc_tree *tree, |
123 | 138 | struct mpcc_blnd_cfg *blnd_cfg, | |
124 | void mpc10_mpcc_remove( | 139 | struct mpcc_sm_cfg *sm_cfg, |
125 | struct mpc *mpc, | 140 | struct mpcc *insert_above_mpcc, |
126 | struct mpc_tree_cfg *tree_cfg, | 141 | int dpp_id, |
127 | int opp_id, | 142 | int mpcc_id); |
128 | int dpp_id); | 143 | |
129 | 144 | void mpc1_remove_mpcc( | |
130 | void mpc10_assert_idle_mpcc( | 145 | struct mpc *mpc, |
131 | struct mpc *mpc, | 146 | struct mpc_tree *tree, |
132 | int id); | 147 | struct mpcc *mpcc); |
133 | 148 | ||
134 | void mpc10_update_blend_mode( | 149 | void mpc1_mpc_init( |
135 | struct mpc *mpc, | 150 | struct mpc *mpc); |
136 | struct mpcc_cfg *cfg); | 151 | |
137 | int mpc10_get_opp_id(struct mpc *mpc, int mpcc_id); | 152 | void mpc1_assert_idle_mpcc( |
153 | struct mpc *mpc, | ||
154 | int id); | ||
155 | |||
156 | void mpc1_set_bg_color( | ||
157 | struct mpc *mpc, | ||
158 | struct tg_color *bg_color, | ||
159 | int id); | ||
160 | |||
161 | void mpc1_update_stereo_mix( | ||
162 | struct mpc *mpc, | ||
163 | struct mpcc_sm_cfg *sm_cfg, | ||
164 | int mpcc_id); | ||
165 | |||
166 | bool mpc1_is_mpcc_idle( | ||
167 | struct mpc *mpc, | ||
168 | int mpcc_id); | ||
169 | |||
170 | void mpc1_assert_mpcc_idle_before_connect( | ||
171 | struct mpc *mpc, | ||
172 | int mpcc_id); | ||
173 | |||
174 | void mpc1_init_mpcc_list_from_hw( | ||
175 | struct mpc *mpc, | ||
176 | struct mpc_tree *tree); | ||
177 | |||
178 | struct mpcc *mpc1_get_mpcc( | ||
179 | struct mpc *mpc, | ||
180 | int mpcc_id); | ||
181 | |||
182 | struct mpcc *mpc1_get_mpcc_for_dpp( | ||
183 | struct mpc_tree *tree, | ||
184 | int dpp_id); | ||
138 | 185 | ||
139 | #endif | 186 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c index 6d6f67b7d30e..f6ba0eef4489 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.c | |||
@@ -296,13 +296,75 @@ void opp1_program_fmt( | |||
296 | return; | 296 | return; |
297 | } | 297 | } |
298 | 298 | ||
299 | void opp1_set_stereo_polarity( | 299 | void opp1_program_stereo( |
300 | struct output_pixel_processor *opp, | 300 | struct output_pixel_processor *opp, |
301 | bool enable, bool rightEyePolarity) | 301 | bool enable, |
302 | const struct dc_crtc_timing *timing) | ||
302 | { | 303 | { |
303 | struct dcn10_opp *oppn10 = TO_DCN10_OPP(opp); | 304 | struct dcn10_opp *oppn10 = TO_DCN10_OPP(opp); |
304 | 305 | ||
305 | REG_UPDATE(FMT_CONTROL, FMT_STEREOSYNC_OVERRIDE, enable); | 306 | uint32_t active_width = timing->h_addressable - timing->h_border_right - timing->h_border_right; |
307 | uint32_t space1_size = timing->v_total - timing->v_addressable; | ||
308 | /* TODO: confirm computation of space2_size */ | ||
309 | uint32_t space2_size = timing->v_total - timing->v_addressable; | ||
310 | |||
311 | if (!enable) { | ||
312 | active_width = 0; | ||
313 | space1_size = 0; | ||
314 | space2_size = 0; | ||
315 | } | ||
316 | |||
317 | /* TODO: for which cases should FMT_STEREOSYNC_OVERRIDE be set? */ | ||
318 | REG_UPDATE(FMT_CONTROL, FMT_STEREOSYNC_OVERRIDE, 0); | ||
319 | |||
320 | REG_UPDATE(OPPBUF_CONTROL, OPPBUF_ACTIVE_WIDTH, active_width); | ||
321 | |||
322 | /* Program OPPBUF_3D_VACT_SPACE1_SIZE and OPPBUF_VACT_SPACE2_SIZE registers | ||
323 | * In 3D progressive frames, Vactive space happens only in between the 2 frames, | ||
324 | * so only need to program OPPBUF_3D_VACT_SPACE1_SIZE | ||
325 | * In 3D alternative frames, left and right frames, top and bottom field. | ||
326 | */ | ||
327 | if (timing->timing_3d_format == TIMING_3D_FORMAT_FRAME_ALTERNATE) | ||
328 | REG_UPDATE(OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE2_SIZE, space2_size); | ||
329 | else | ||
330 | REG_UPDATE(OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE1_SIZE, space1_size); | ||
331 | |||
332 | /* TODO: Is programming of OPPBUF_DUMMY_DATA_R/G/B needed? */ | ||
333 | /* | ||
334 | REG_UPDATE(OPPBUF_3D_PARAMETERS_0, | ||
335 | OPPBUF_DUMMY_DATA_R, data_r); | ||
336 | REG_UPDATE(OPPBUF_3D_PARAMETERS_1, | ||
337 | OPPBUF_DUMMY_DATA_G, data_g); | ||
338 | REG_UPDATE(OPPBUF_3D_PARAMETERS_1, | ||
339 | OPPBUF_DUMMY_DATA_B, _data_b); | ||
340 | */ | ||
341 | } | ||
342 | |||
343 | void opp1_program_oppbuf( | ||
344 | struct output_pixel_processor *opp, | ||
345 | struct oppbuf_params *oppbuf) | ||
346 | { | ||
347 | struct dcn10_opp *oppn10 = TO_DCN10_OPP(opp); | ||
348 | |||
349 | /* Program the oppbuf active width to be the frame width from mpc */ | ||
350 | REG_UPDATE(OPPBUF_CONTROL, OPPBUF_ACTIVE_WIDTH, oppbuf->active_width); | ||
351 | |||
352 | /* Specifies the number of segments in multi-segment mode (DP-MSO operation) | ||
353 | * description "In 1/2/4 segment mode, specifies the horizontal active width in pixels of the display panel. | ||
354 | * In 4 segment split left/right mode, specifies the horizontal 1/2 active width in pixels of the display panel. | ||
355 | * Used to determine segment boundaries in multi-segment mode. Used to determine the width of the vertical active space in 3D frame packed modes. | ||
356 | * OPPBUF_ACTIVE_WIDTH must be integer divisible by the total number of segments." | ||
357 | */ | ||
358 | REG_UPDATE(OPPBUF_CONTROL, OPPBUF_DISPLAY_SEGMENTATION, oppbuf->mso_segmentation); | ||
359 | |||
360 | /* description "Specifies the number of overlap pixels (1-8 overlapping pixels supported), used in multi-segment mode (DP-MSO operation)" */ | ||
361 | REG_UPDATE(OPPBUF_CONTROL, OPPBUF_OVERLAP_PIXEL_NUM, oppbuf->mso_overlap_pixel_num); | ||
362 | |||
363 | /* description "Specifies the number of times a pixel is replicated (0-15 pixel replications supported). | ||
364 | * A value of 0 disables replication. The total number of times a pixel is output is OPPBUF_PIXEL_REPETITION + 1." | ||
365 | */ | ||
366 | REG_UPDATE(OPPBUF_CONTROL, OPPBUF_PIXEL_REPETITION, oppbuf->pixel_repetition); | ||
367 | |||
306 | } | 368 | } |
307 | 369 | ||
308 | /*****************************************/ | 370 | /*****************************************/ |
@@ -319,7 +381,7 @@ static struct opp_funcs dcn10_opp_funcs = { | |||
319 | .opp_set_dyn_expansion = opp1_set_dyn_expansion, | 381 | .opp_set_dyn_expansion = opp1_set_dyn_expansion, |
320 | .opp_program_fmt = opp1_program_fmt, | 382 | .opp_program_fmt = opp1_program_fmt, |
321 | .opp_program_bit_depth_reduction = opp1_program_bit_depth_reduction, | 383 | .opp_program_bit_depth_reduction = opp1_program_bit_depth_reduction, |
322 | .opp_set_stereo_polarity = opp1_set_stereo_polarity, | 384 | .opp_program_stereo = opp1_program_stereo, |
323 | .opp_destroy = opp1_destroy | 385 | .opp_destroy = opp1_destroy |
324 | }; | 386 | }; |
325 | 387 | ||
@@ -330,6 +392,7 @@ void dcn10_opp_construct(struct dcn10_opp *oppn10, | |||
330 | const struct dcn10_opp_shift *opp_shift, | 392 | const struct dcn10_opp_shift *opp_shift, |
331 | const struct dcn10_opp_mask *opp_mask) | 393 | const struct dcn10_opp_mask *opp_mask) |
332 | { | 394 | { |
395 | |||
333 | oppn10->base.ctx = ctx; | 396 | oppn10->base.ctx = ctx; |
334 | oppn10->base.inst = inst; | 397 | oppn10->base.inst = inst; |
335 | oppn10->base.funcs = &dcn10_opp_funcs; | 398 | oppn10->base.funcs = &dcn10_opp_funcs; |
@@ -338,4 +401,3 @@ void dcn10_opp_construct(struct dcn10_opp *oppn10, | |||
338 | oppn10->opp_shift = opp_shift; | 401 | oppn10->opp_shift = opp_shift; |
339 | oppn10->opp_mask = opp_mask; | 402 | oppn10->opp_mask = opp_mask; |
340 | } | 403 | } |
341 | |||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.h index f3c298ec37fb..bc5058af6266 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_opp.h | |||
@@ -41,7 +41,10 @@ | |||
41 | SRI(FMT_DITHER_RAND_B_SEED, FMT, id), \ | 41 | SRI(FMT_DITHER_RAND_B_SEED, FMT, id), \ |
42 | SRI(FMT_CLAMP_CNTL, FMT, id), \ | 42 | SRI(FMT_CLAMP_CNTL, FMT, id), \ |
43 | SRI(FMT_DYNAMIC_EXP_CNTL, FMT, id), \ | 43 | SRI(FMT_DYNAMIC_EXP_CNTL, FMT, id), \ |
44 | SRI(FMT_MAP420_MEMORY_CONTROL, FMT, id) | 44 | SRI(FMT_MAP420_MEMORY_CONTROL, FMT, id), \ |
45 | SRI(OPPBUF_CONTROL, OPPBUF, id),\ | ||
46 | SRI(OPPBUF_3D_PARAMETERS_0, OPPBUF, id), \ | ||
47 | SRI(OPPBUF_3D_PARAMETERS_1, OPPBUF, id) | ||
45 | 48 | ||
46 | #define OPP_REG_LIST_DCN10(id) \ | 49 | #define OPP_REG_LIST_DCN10(id) \ |
47 | OPP_REG_LIST_DCN(id) | 50 | OPP_REG_LIST_DCN(id) |
@@ -54,7 +57,11 @@ | |||
54 | uint32_t FMT_DITHER_RAND_B_SEED; \ | 57 | uint32_t FMT_DITHER_RAND_B_SEED; \ |
55 | uint32_t FMT_CLAMP_CNTL; \ | 58 | uint32_t FMT_CLAMP_CNTL; \ |
56 | uint32_t FMT_DYNAMIC_EXP_CNTL; \ | 59 | uint32_t FMT_DYNAMIC_EXP_CNTL; \ |
57 | uint32_t FMT_MAP420_MEMORY_CONTROL; | 60 | uint32_t FMT_MAP420_MEMORY_CONTROL; \ |
61 | uint32_t OPPBUF_CONTROL; \ | ||
62 | uint32_t OPPBUF_CONTROL1; \ | ||
63 | uint32_t OPPBUF_3D_PARAMETERS_0; \ | ||
64 | uint32_t OPPBUF_3D_PARAMETERS_1 | ||
58 | 65 | ||
59 | #define OPP_MASK_SH_LIST_DCN(mask_sh) \ | 66 | #define OPP_MASK_SH_LIST_DCN(mask_sh) \ |
60 | OPP_SF(FMT0_FMT_BIT_DEPTH_CONTROL, FMT_TRUNCATE_EN, mask_sh), \ | 67 | OPP_SF(FMT0_FMT_BIT_DEPTH_CONTROL, FMT_TRUNCATE_EN, mask_sh), \ |
@@ -78,10 +85,16 @@ | |||
78 | OPP_SF(FMT0_FMT_CLAMP_CNTL, FMT_CLAMP_COLOR_FORMAT, mask_sh), \ | 85 | OPP_SF(FMT0_FMT_CLAMP_CNTL, FMT_CLAMP_COLOR_FORMAT, mask_sh), \ |
79 | OPP_SF(FMT0_FMT_DYNAMIC_EXP_CNTL, FMT_DYNAMIC_EXP_EN, mask_sh), \ | 86 | OPP_SF(FMT0_FMT_DYNAMIC_EXP_CNTL, FMT_DYNAMIC_EXP_EN, mask_sh), \ |
80 | OPP_SF(FMT0_FMT_DYNAMIC_EXP_CNTL, FMT_DYNAMIC_EXP_MODE, mask_sh), \ | 87 | OPP_SF(FMT0_FMT_DYNAMIC_EXP_CNTL, FMT_DYNAMIC_EXP_MODE, mask_sh), \ |
81 | OPP_SF(FMT0_FMT_MAP420_MEMORY_CONTROL, FMT_MAP420MEM_PWR_FORCE, mask_sh) | 88 | OPP_SF(FMT0_FMT_MAP420_MEMORY_CONTROL, FMT_MAP420MEM_PWR_FORCE, mask_sh), \ |
89 | OPP_SF(OPPBUF0_OPPBUF_CONTROL, OPPBUF_ACTIVE_WIDTH, mask_sh),\ | ||
90 | OPP_SF(OPPBUF0_OPPBUF_CONTROL, OPPBUF_PIXEL_REPETITION, mask_sh),\ | ||
91 | OPP_SF(OPPBUF0_OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE1_SIZE, mask_sh), \ | ||
92 | OPP_SF(OPPBUF0_OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE2_SIZE, mask_sh) | ||
82 | 93 | ||
83 | #define OPP_MASK_SH_LIST_DCN10(mask_sh) \ | 94 | #define OPP_MASK_SH_LIST_DCN10(mask_sh) \ |
84 | OPP_MASK_SH_LIST_DCN(mask_sh) | 95 | OPP_MASK_SH_LIST_DCN(mask_sh), \ |
96 | OPP_SF(OPPBUF0_OPPBUF_CONTROL, OPPBUF_DISPLAY_SEGMENTATION, mask_sh),\ | ||
97 | OPP_SF(OPPBUF0_OPPBUF_CONTROL, OPPBUF_OVERLAP_PIXEL_NUM, mask_sh) | ||
85 | 98 | ||
86 | #define OPP_DCN10_REG_FIELD_LIST(type) \ | 99 | #define OPP_DCN10_REG_FIELD_LIST(type) \ |
87 | type FMT_TRUNCATE_EN; \ | 100 | type FMT_TRUNCATE_EN; \ |
@@ -105,18 +118,25 @@ | |||
105 | type FMT_DYNAMIC_EXP_EN; \ | 118 | type FMT_DYNAMIC_EXP_EN; \ |
106 | type FMT_DYNAMIC_EXP_MODE; \ | 119 | type FMT_DYNAMIC_EXP_MODE; \ |
107 | type FMT_MAP420MEM_PWR_FORCE; \ | 120 | type FMT_MAP420MEM_PWR_FORCE; \ |
108 | type FMT_STEREOSYNC_OVERRIDE; | 121 | type FMT_STEREOSYNC_OVERRIDE; \ |
122 | type OPPBUF_ACTIVE_WIDTH;\ | ||
123 | type OPPBUF_PIXEL_REPETITION;\ | ||
124 | type OPPBUF_DISPLAY_SEGMENTATION;\ | ||
125 | type OPPBUF_OVERLAP_PIXEL_NUM;\ | ||
126 | type OPPBUF_NUM_SEGMENT_PADDED_PIXELS; \ | ||
127 | type OPPBUF_3D_VACT_SPACE1_SIZE; \ | ||
128 | type OPPBUF_3D_VACT_SPACE2_SIZE | ||
109 | 129 | ||
110 | struct dcn10_opp_registers { | 130 | struct dcn10_opp_registers { |
111 | OPP_COMMON_REG_VARIABLE_LIST | 131 | OPP_COMMON_REG_VARIABLE_LIST; |
112 | }; | 132 | }; |
113 | 133 | ||
114 | struct dcn10_opp_shift { | 134 | struct dcn10_opp_shift { |
115 | OPP_DCN10_REG_FIELD_LIST(uint8_t) | 135 | OPP_DCN10_REG_FIELD_LIST(uint8_t); |
116 | }; | 136 | }; |
117 | 137 | ||
118 | struct dcn10_opp_mask { | 138 | struct dcn10_opp_mask { |
119 | OPP_DCN10_REG_FIELD_LIST(uint32_t) | 139 | OPP_DCN10_REG_FIELD_LIST(uint32_t); |
120 | }; | 140 | }; |
121 | 141 | ||
122 | struct dcn10_opp { | 142 | struct dcn10_opp { |
@@ -151,9 +171,10 @@ void opp1_program_bit_depth_reduction( | |||
151 | struct output_pixel_processor *opp, | 171 | struct output_pixel_processor *opp, |
152 | const struct bit_depth_reduction_params *params); | 172 | const struct bit_depth_reduction_params *params); |
153 | 173 | ||
154 | void opp1_set_stereo_polarity( | 174 | void opp1_program_stereo( |
155 | struct output_pixel_processor *opp, | 175 | struct output_pixel_processor *opp, |
156 | bool enable, bool rightEyePolarity); | 176 | bool enable, |
177 | const struct dc_crtc_timing *timing); | ||
157 | 178 | ||
158 | void opp1_destroy(struct output_pixel_processor **opp); | 179 | void opp1_destroy(struct output_pixel_processor **opp); |
159 | 180 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_timing_generator.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c index 73ff78f9cae1..4bf64d1b2c60 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_timing_generator.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c | |||
@@ -23,19 +23,20 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | |||
26 | #include "reg_helper.h" | 27 | #include "reg_helper.h" |
27 | #include "dcn10_timing_generator.h" | 28 | #include "dcn10_optc.h" |
28 | #include "dc.h" | 29 | #include "dc.h" |
29 | 30 | ||
30 | #define REG(reg)\ | 31 | #define REG(reg)\ |
31 | tgn10->tg_regs->reg | 32 | optc1->tg_regs->reg |
32 | 33 | ||
33 | #define CTX \ | 34 | #define CTX \ |
34 | tgn10->base.ctx | 35 | optc1->base.ctx |
35 | 36 | ||
36 | #undef FN | 37 | #undef FN |
37 | #define FN(reg_name, field_name) \ | 38 | #define FN(reg_name, field_name) \ |
38 | tgn10->tg_shift->field_name, tgn10->tg_mask->field_name | 39 | optc1->tg_shift->field_name, optc1->tg_mask->field_name |
39 | 40 | ||
40 | #define STATIC_SCREEN_EVENT_MASK_RANGETIMING_DOUBLE_BUFFER_UPDATE_EN 0x100 | 41 | #define STATIC_SCREEN_EVENT_MASK_RANGETIMING_DOUBLE_BUFFER_UPDATE_EN 0x100 |
41 | 42 | ||
@@ -45,8 +46,8 @@ | |||
45 | * This is a workaround for a bug that has existed since R5xx and has not been | 46 | * This is a workaround for a bug that has existed since R5xx and has not been |
46 | * fixed keep Front porch at minimum 2 for Interlaced mode or 1 for progressive. | 47 | * fixed keep Front porch at minimum 2 for Interlaced mode or 1 for progressive. |
47 | */ | 48 | */ |
48 | static void tgn10_apply_front_porch_workaround( | 49 | static void optc1_apply_front_porch_workaround( |
49 | struct timing_generator *tg, | 50 | struct timing_generator *optc, |
50 | struct dc_crtc_timing *timing) | 51 | struct dc_crtc_timing *timing) |
51 | { | 52 | { |
52 | if (timing->flags.INTERLACE == 1) { | 53 | if (timing->flags.INTERLACE == 1) { |
@@ -58,30 +59,30 @@ static void tgn10_apply_front_porch_workaround( | |||
58 | } | 59 | } |
59 | } | 60 | } |
60 | 61 | ||
61 | static void tgn10_program_global_sync( | 62 | void optc1_program_global_sync( |
62 | struct timing_generator *tg) | 63 | struct timing_generator *optc) |
63 | { | 64 | { |
64 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 65 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
65 | 66 | ||
66 | if (tg->dlg_otg_param.vstartup_start == 0) { | 67 | if (optc->dlg_otg_param.vstartup_start == 0) { |
67 | BREAK_TO_DEBUGGER(); | 68 | BREAK_TO_DEBUGGER(); |
68 | return; | 69 | return; |
69 | } | 70 | } |
70 | 71 | ||
71 | REG_SET(OTG_VSTARTUP_PARAM, 0, | 72 | REG_SET(OTG_VSTARTUP_PARAM, 0, |
72 | VSTARTUP_START, tg->dlg_otg_param.vstartup_start); | 73 | VSTARTUP_START, optc->dlg_otg_param.vstartup_start); |
73 | 74 | ||
74 | REG_SET_2(OTG_VUPDATE_PARAM, 0, | 75 | REG_SET_2(OTG_VUPDATE_PARAM, 0, |
75 | VUPDATE_OFFSET, tg->dlg_otg_param.vupdate_offset, | 76 | VUPDATE_OFFSET, optc->dlg_otg_param.vupdate_offset, |
76 | VUPDATE_WIDTH, tg->dlg_otg_param.vupdate_width); | 77 | VUPDATE_WIDTH, optc->dlg_otg_param.vupdate_width); |
77 | 78 | ||
78 | REG_SET(OTG_VREADY_PARAM, 0, | 79 | REG_SET(OTG_VREADY_PARAM, 0, |
79 | VREADY_OFFSET, tg->dlg_otg_param.vready_offset); | 80 | VREADY_OFFSET, optc->dlg_otg_param.vready_offset); |
80 | } | 81 | } |
81 | 82 | ||
82 | static void tgn10_disable_stereo(struct timing_generator *tg) | 83 | static void optc1_disable_stereo(struct timing_generator *optc) |
83 | { | 84 | { |
84 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 85 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
85 | 86 | ||
86 | REG_SET(OTG_STEREO_CONTROL, 0, | 87 | REG_SET(OTG_STEREO_CONTROL, 0, |
87 | OTG_STEREO_EN, 0); | 88 | OTG_STEREO_EN, 0); |
@@ -90,11 +91,6 @@ static void tgn10_disable_stereo(struct timing_generator *tg) | |||
90 | OTG_3D_STRUCTURE_EN, 0, | 91 | OTG_3D_STRUCTURE_EN, 0, |
91 | OTG_3D_STRUCTURE_V_UPDATE_MODE, 0, | 92 | OTG_3D_STRUCTURE_V_UPDATE_MODE, 0, |
92 | OTG_3D_STRUCTURE_STEREO_SEL_OVR, 0); | 93 | OTG_3D_STRUCTURE_STEREO_SEL_OVR, 0); |
93 | |||
94 | REG_UPDATE(OPPBUF_CONTROL, | ||
95 | OPPBUF_ACTIVE_WIDTH, 0); | ||
96 | REG_UPDATE(OPPBUF_3D_PARAMETERS_0, | ||
97 | OPPBUF_3D_VACT_SPACE1_SIZE, 0); | ||
98 | } | 94 | } |
99 | 95 | ||
100 | /** | 96 | /** |
@@ -102,8 +98,8 @@ static void tgn10_disable_stereo(struct timing_generator *tg) | |||
102 | * Program CRTC Timing Registers - OTG_H_*, OTG_V_*, Pixel repetition. | 98 | * Program CRTC Timing Registers - OTG_H_*, OTG_V_*, Pixel repetition. |
103 | * Including SYNC. Call BIOS command table to program Timings. | 99 | * Including SYNC. Call BIOS command table to program Timings. |
104 | */ | 100 | */ |
105 | static void tgn10_program_timing( | 101 | void optc1_program_timing( |
106 | struct timing_generator *tg, | 102 | struct timing_generator *optc, |
107 | const struct dc_crtc_timing *dc_crtc_timing, | 103 | const struct dc_crtc_timing *dc_crtc_timing, |
108 | bool use_vbios) | 104 | bool use_vbios) |
109 | { | 105 | { |
@@ -121,10 +117,10 @@ static void tgn10_program_timing( | |||
121 | uint32_t h_div_2; | 117 | uint32_t h_div_2; |
122 | int32_t vertical_line_start; | 118 | int32_t vertical_line_start; |
123 | 119 | ||
124 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 120 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
125 | 121 | ||
126 | patched_crtc_timing = *dc_crtc_timing; | 122 | patched_crtc_timing = *dc_crtc_timing; |
127 | tgn10_apply_front_porch_workaround(tg, &patched_crtc_timing); | 123 | optc1_apply_front_porch_workaround(optc, &patched_crtc_timing); |
128 | 124 | ||
129 | /* Load horizontal timing */ | 125 | /* Load horizontal timing */ |
130 | 126 | ||
@@ -217,7 +213,7 @@ static void tgn10_program_timing( | |||
217 | /* Use OTG_VERTICAL_INTERRUPT2 replace VUPDATE interrupt, | 213 | /* Use OTG_VERTICAL_INTERRUPT2 replace VUPDATE interrupt, |
218 | * program the reg for interrupt postition. | 214 | * program the reg for interrupt postition. |
219 | */ | 215 | */ |
220 | vertical_line_start = asic_blank_end - tg->dlg_otg_param.vstartup_start + 1; | 216 | vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1; |
221 | if (vertical_line_start < 0) { | 217 | if (vertical_line_start < 0) { |
222 | ASSERT(0); | 218 | ASSERT(0); |
223 | vertical_line_start = 0; | 219 | vertical_line_start = 0; |
@@ -233,26 +229,25 @@ static void tgn10_program_timing( | |||
233 | OTG_V_SYNC_A_POL, v_sync_polarity); | 229 | OTG_V_SYNC_A_POL, v_sync_polarity); |
234 | 230 | ||
235 | v_init = asic_blank_start; | 231 | v_init = asic_blank_start; |
236 | if (tg->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT || | 232 | if (optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT || |
237 | tg->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT_MST || | 233 | optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT_MST || |
238 | tg->dlg_otg_param.signal == SIGNAL_TYPE_EDP) { | 234 | optc->dlg_otg_param.signal == SIGNAL_TYPE_EDP) { |
239 | start_point = 1; | 235 | start_point = 1; |
240 | if (patched_crtc_timing.flags.INTERLACE == 1) | 236 | if (patched_crtc_timing.flags.INTERLACE == 1) |
241 | field_num = 1; | 237 | field_num = 1; |
242 | } | 238 | } |
243 | v_fp2 = 0; | 239 | v_fp2 = 0; |
244 | if (tg->dlg_otg_param.vstartup_start > asic_blank_end) | 240 | if (optc->dlg_otg_param.vstartup_start > asic_blank_end) |
245 | v_fp2 = tg->dlg_otg_param.vstartup_start > asic_blank_end; | 241 | v_fp2 = optc->dlg_otg_param.vstartup_start > asic_blank_end; |
246 | 242 | ||
247 | /* Interlace */ | 243 | /* Interlace */ |
248 | if (patched_crtc_timing.flags.INTERLACE == 1) { | 244 | if (patched_crtc_timing.flags.INTERLACE == 1) { |
249 | REG_UPDATE(OTG_INTERLACE_CONTROL, | 245 | REG_UPDATE(OTG_INTERLACE_CONTROL, |
250 | OTG_INTERLACE_ENABLE, 1); | 246 | OTG_INTERLACE_ENABLE, 1); |
251 | v_init = v_init / 2; | 247 | v_init = v_init / 2; |
252 | if ((tg->dlg_otg_param.vstartup_start/2)*2 > asic_blank_end) | 248 | if ((optc->dlg_otg_param.vstartup_start/2)*2 > asic_blank_end) |
253 | v_fp2 = v_fp2 / 2; | 249 | v_fp2 = v_fp2 / 2; |
254 | } | 250 | } else |
255 | else | ||
256 | REG_UPDATE(OTG_INTERLACE_CONTROL, | 251 | REG_UPDATE(OTG_INTERLACE_CONTROL, |
257 | OTG_INTERLACE_ENABLE, 0); | 252 | OTG_INTERLACE_ENABLE, 0); |
258 | 253 | ||
@@ -270,13 +265,13 @@ static void tgn10_program_timing( | |||
270 | OTG_START_POINT_CNTL, start_point, | 265 | OTG_START_POINT_CNTL, start_point, |
271 | OTG_FIELD_NUMBER_CNTL, field_num); | 266 | OTG_FIELD_NUMBER_CNTL, field_num); |
272 | 267 | ||
273 | tgn10_program_global_sync(tg); | 268 | optc1_program_global_sync(optc); |
274 | 269 | ||
275 | /* TODO | 270 | /* TODO |
276 | * patched_crtc_timing.flags.HORZ_COUNT_BY_TWO == 1 | 271 | * patched_crtc_timing.flags.HORZ_COUNT_BY_TWO == 1 |
277 | * program_horz_count_by_2 | 272 | * program_horz_count_by_2 |
278 | * for DVI 30bpp mode, 0 otherwise | 273 | * for DVI 30bpp mode, 0 otherwise |
279 | * program_horz_count_by_2(tg, &patched_crtc_timing); | 274 | * program_horz_count_by_2(optc, &patched_crtc_timing); |
280 | */ | 275 | */ |
281 | 276 | ||
282 | /* Enable stereo - only when we need to pack 3D frame. Other types | 277 | /* Enable stereo - only when we need to pack 3D frame. Other types |
@@ -290,9 +285,9 @@ static void tgn10_program_timing( | |||
290 | 285 | ||
291 | } | 286 | } |
292 | 287 | ||
293 | static void tgn10_set_blank_data_double_buffer(struct timing_generator *tg, bool enable) | 288 | static void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable) |
294 | { | 289 | { |
295 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 290 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
296 | 291 | ||
297 | uint32_t blank_data_double_buffer_enable = enable ? 1 : 0; | 292 | uint32_t blank_data_double_buffer_enable = enable ? 1 : 0; |
298 | 293 | ||
@@ -304,9 +299,9 @@ static void tgn10_set_blank_data_double_buffer(struct timing_generator *tg, bool | |||
304 | * unblank_crtc | 299 | * unblank_crtc |
305 | * Call ASIC Control Object to UnBlank CRTC. | 300 | * Call ASIC Control Object to UnBlank CRTC. |
306 | */ | 301 | */ |
307 | static void tgn10_unblank_crtc(struct timing_generator *tg) | 302 | static void optc1_unblank_crtc(struct timing_generator *optc) |
308 | { | 303 | { |
309 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 304 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
310 | uint32_t vertical_interrupt_enable = 0; | 305 | uint32_t vertical_interrupt_enable = 0; |
311 | 306 | ||
312 | REG_GET(OTG_VERTICAL_INTERRUPT2_CONTROL, | 307 | REG_GET(OTG_VERTICAL_INTERRUPT2_CONTROL, |
@@ -316,7 +311,7 @@ static void tgn10_unblank_crtc(struct timing_generator *tg) | |||
316 | * this check will be removed. | 311 | * this check will be removed. |
317 | */ | 312 | */ |
318 | if (vertical_interrupt_enable) | 313 | if (vertical_interrupt_enable) |
319 | tgn10_set_blank_data_double_buffer(tg, true); | 314 | optc1_set_blank_data_double_buffer(optc, true); |
320 | 315 | ||
321 | REG_UPDATE_2(OTG_BLANK_CONTROL, | 316 | REG_UPDATE_2(OTG_BLANK_CONTROL, |
322 | OTG_BLANK_DATA_EN, 0, | 317 | OTG_BLANK_DATA_EN, 0, |
@@ -328,36 +323,29 @@ static void tgn10_unblank_crtc(struct timing_generator *tg) | |||
328 | * Call ASIC Control Object to Blank CRTC. | 323 | * Call ASIC Control Object to Blank CRTC. |
329 | */ | 324 | */ |
330 | 325 | ||
331 | static void tgn10_blank_crtc(struct timing_generator *tg) | 326 | static void optc1_blank_crtc(struct timing_generator *optc) |
332 | { | 327 | { |
333 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 328 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
334 | 329 | ||
335 | REG_UPDATE_2(OTG_BLANK_CONTROL, | 330 | REG_UPDATE_2(OTG_BLANK_CONTROL, |
336 | OTG_BLANK_DATA_EN, 1, | 331 | OTG_BLANK_DATA_EN, 1, |
337 | OTG_BLANK_DE_MODE, 0); | 332 | OTG_BLANK_DE_MODE, 0); |
338 | 333 | ||
339 | /* todo: why are we waiting for BLANK_DATA_EN? shouldn't we be waiting | 334 | optc1_set_blank_data_double_buffer(optc, false); |
340 | * for status? | ||
341 | */ | ||
342 | REG_WAIT(OTG_BLANK_CONTROL, | ||
343 | OTG_BLANK_DATA_EN, 1, | ||
344 | 1, 100000); | ||
345 | |||
346 | tgn10_set_blank_data_double_buffer(tg, false); | ||
347 | } | 335 | } |
348 | 336 | ||
349 | static void tgn10_set_blank(struct timing_generator *tg, | 337 | void optc1_set_blank(struct timing_generator *optc, |
350 | bool enable_blanking) | 338 | bool enable_blanking) |
351 | { | 339 | { |
352 | if (enable_blanking) | 340 | if (enable_blanking) |
353 | tgn10_blank_crtc(tg); | 341 | optc1_blank_crtc(optc); |
354 | else | 342 | else |
355 | tgn10_unblank_crtc(tg); | 343 | optc1_unblank_crtc(optc); |
356 | } | 344 | } |
357 | 345 | ||
358 | static bool tgn10_is_blanked(struct timing_generator *tg) | 346 | bool optc1_is_blanked(struct timing_generator *optc) |
359 | { | 347 | { |
360 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 348 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
361 | uint32_t blank_en; | 349 | uint32_t blank_en; |
362 | uint32_t blank_state; | 350 | uint32_t blank_state; |
363 | 351 | ||
@@ -368,9 +356,9 @@ static bool tgn10_is_blanked(struct timing_generator *tg) | |||
368 | return blank_en && blank_state; | 356 | return blank_en && blank_state; |
369 | } | 357 | } |
370 | 358 | ||
371 | static void tgn10_enable_optc_clock(struct timing_generator *tg, bool enable) | 359 | void optc1_enable_optc_clock(struct timing_generator *optc, bool enable) |
372 | { | 360 | { |
373 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 361 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
374 | 362 | ||
375 | if (enable) { | 363 | if (enable) { |
376 | REG_UPDATE_2(OPTC_INPUT_CLOCK_CONTROL, | 364 | REG_UPDATE_2(OPTC_INPUT_CLOCK_CONTROL, |
@@ -403,19 +391,19 @@ static void tgn10_enable_optc_clock(struct timing_generator *tg, bool enable) | |||
403 | * Enable CRTC | 391 | * Enable CRTC |
404 | * Enable CRTC - call ASIC Control Object to enable Timing generator. | 392 | * Enable CRTC - call ASIC Control Object to enable Timing generator. |
405 | */ | 393 | */ |
406 | static bool tgn10_enable_crtc(struct timing_generator *tg) | 394 | static bool optc1_enable_crtc(struct timing_generator *optc) |
407 | { | 395 | { |
408 | /* TODO FPGA wait for answer | 396 | /* TODO FPGA wait for answer |
409 | * OTG_MASTER_UPDATE_MODE != CRTC_MASTER_UPDATE_MODE | 397 | * OTG_MASTER_UPDATE_MODE != CRTC_MASTER_UPDATE_MODE |
410 | * OTG_MASTER_UPDATE_LOCK != CRTC_MASTER_UPDATE_LOCK | 398 | * OTG_MASTER_UPDATE_LOCK != CRTC_MASTER_UPDATE_LOCK |
411 | */ | 399 | */ |
412 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 400 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
413 | 401 | ||
414 | /* opp instance for OTG. For DCN1.0, ODM is remoed. | 402 | /* opp instance for OTG. For DCN1.0, ODM is remoed. |
415 | * OPP and OPTC should 1:1 mapping | 403 | * OPP and OPTC should 1:1 mapping |
416 | */ | 404 | */ |
417 | REG_UPDATE(OPTC_DATA_SOURCE_SELECT, | 405 | REG_UPDATE(OPTC_DATA_SOURCE_SELECT, |
418 | OPTC_SRC_SEL, tg->inst); | 406 | OPTC_SRC_SEL, optc->inst); |
419 | 407 | ||
420 | /* VTG enable first is for HW workaround */ | 408 | /* VTG enable first is for HW workaround */ |
421 | REG_UPDATE(CONTROL, | 409 | REG_UPDATE(CONTROL, |
@@ -430,9 +418,9 @@ static bool tgn10_enable_crtc(struct timing_generator *tg) | |||
430 | } | 418 | } |
431 | 419 | ||
432 | /* disable_crtc - call ASIC Control Object to disable Timing generator. */ | 420 | /* disable_crtc - call ASIC Control Object to disable Timing generator. */ |
433 | static bool tgn10_disable_crtc(struct timing_generator *tg) | 421 | bool optc1_disable_crtc(struct timing_generator *optc) |
434 | { | 422 | { |
435 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 423 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
436 | 424 | ||
437 | /* disable otg request until end of the first line | 425 | /* disable otg request until end of the first line |
438 | * in the vertical blank region | 426 | * in the vertical blank region |
@@ -453,11 +441,11 @@ static bool tgn10_disable_crtc(struct timing_generator *tg) | |||
453 | } | 441 | } |
454 | 442 | ||
455 | 443 | ||
456 | static void tgn10_program_blank_color( | 444 | void optc1_program_blank_color( |
457 | struct timing_generator *tg, | 445 | struct timing_generator *optc, |
458 | const struct tg_color *black_color) | 446 | const struct tg_color *black_color) |
459 | { | 447 | { |
460 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 448 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
461 | 449 | ||
462 | REG_SET_3(OTG_BLACK_COLOR, 0, | 450 | REG_SET_3(OTG_BLACK_COLOR, 0, |
463 | OTG_BLACK_COLOR_B_CB, black_color->color_b_cb, | 451 | OTG_BLACK_COLOR_B_CB, black_color->color_b_cb, |
@@ -465,15 +453,15 @@ static void tgn10_program_blank_color( | |||
465 | OTG_BLACK_COLOR_R_CR, black_color->color_r_cr); | 453 | OTG_BLACK_COLOR_R_CR, black_color->color_r_cr); |
466 | } | 454 | } |
467 | 455 | ||
468 | static bool tgn10_validate_timing( | 456 | bool optc1_validate_timing( |
469 | struct timing_generator *tg, | 457 | struct timing_generator *optc, |
470 | const struct dc_crtc_timing *timing) | 458 | const struct dc_crtc_timing *timing) |
471 | { | 459 | { |
472 | uint32_t interlace_factor; | 460 | uint32_t interlace_factor; |
473 | uint32_t v_blank; | 461 | uint32_t v_blank; |
474 | uint32_t h_blank; | 462 | uint32_t h_blank; |
475 | uint32_t min_v_blank; | 463 | uint32_t min_v_blank; |
476 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 464 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
477 | 465 | ||
478 | ASSERT(timing != NULL); | 466 | ASSERT(timing != NULL); |
479 | 467 | ||
@@ -503,19 +491,19 @@ static bool tgn10_validate_timing( | |||
503 | * needs more than 8192 horizontal and | 491 | * needs more than 8192 horizontal and |
504 | * more than 8192 vertical total pixels) | 492 | * more than 8192 vertical total pixels) |
505 | */ | 493 | */ |
506 | if (timing->h_total > tgn10->max_h_total || | 494 | if (timing->h_total > optc1->max_h_total || |
507 | timing->v_total > tgn10->max_v_total) | 495 | timing->v_total > optc1->max_v_total) |
508 | return false; | 496 | return false; |
509 | 497 | ||
510 | 498 | ||
511 | if (h_blank < tgn10->min_h_blank) | 499 | if (h_blank < optc1->min_h_blank) |
512 | return false; | 500 | return false; |
513 | 501 | ||
514 | if (timing->h_sync_width < tgn10->min_h_sync_width || | 502 | if (timing->h_sync_width < optc1->min_h_sync_width || |
515 | timing->v_sync_width < tgn10->min_v_sync_width) | 503 | timing->v_sync_width < optc1->min_v_sync_width) |
516 | return false; | 504 | return false; |
517 | 505 | ||
518 | min_v_blank = timing->flags.INTERLACE?tgn10->min_v_blank_interlace:tgn10->min_v_blank; | 506 | min_v_blank = timing->flags.INTERLACE?optc1->min_v_blank_interlace:optc1->min_v_blank; |
519 | 507 | ||
520 | if (v_blank < min_v_blank) | 508 | if (v_blank < min_v_blank) |
521 | return false; | 509 | return false; |
@@ -532,15 +520,15 @@ static bool tgn10_validate_timing( | |||
532 | * holds the counter of frames. | 520 | * holds the counter of frames. |
533 | * | 521 | * |
534 | * @param | 522 | * @param |
535 | * struct timing_generator *tg - [in] timing generator which controls the | 523 | * struct timing_generator *optc - [in] timing generator which controls the |
536 | * desired CRTC | 524 | * desired CRTC |
537 | * | 525 | * |
538 | * @return | 526 | * @return |
539 | * Counter of frames, which should equal to number of vblanks. | 527 | * Counter of frames, which should equal to number of vblanks. |
540 | */ | 528 | */ |
541 | static uint32_t tgn10_get_vblank_counter(struct timing_generator *tg) | 529 | uint32_t optc1_get_vblank_counter(struct timing_generator *optc) |
542 | { | 530 | { |
543 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 531 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
544 | uint32_t frame_count; | 532 | uint32_t frame_count; |
545 | 533 | ||
546 | REG_GET(OTG_STATUS_FRAME_COUNT, | 534 | REG_GET(OTG_STATUS_FRAME_COUNT, |
@@ -549,34 +537,34 @@ static uint32_t tgn10_get_vblank_counter(struct timing_generator *tg) | |||
549 | return frame_count; | 537 | return frame_count; |
550 | } | 538 | } |
551 | 539 | ||
552 | static void tgn10_lock(struct timing_generator *tg) | 540 | void optc1_lock(struct timing_generator *optc) |
553 | { | 541 | { |
554 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 542 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
555 | 543 | ||
556 | REG_SET(OTG_GLOBAL_CONTROL0, 0, | 544 | REG_SET(OTG_GLOBAL_CONTROL0, 0, |
557 | OTG_MASTER_UPDATE_LOCK_SEL, tg->inst); | 545 | OTG_MASTER_UPDATE_LOCK_SEL, optc->inst); |
558 | REG_SET(OTG_MASTER_UPDATE_LOCK, 0, | 546 | REG_SET(OTG_MASTER_UPDATE_LOCK, 0, |
559 | OTG_MASTER_UPDATE_LOCK, 1); | 547 | OTG_MASTER_UPDATE_LOCK, 1); |
560 | 548 | ||
561 | /* Should be fast, status does not update on maximus */ | 549 | /* Should be fast, status does not update on maximus */ |
562 | if (tg->ctx->dce_environment != DCE_ENV_FPGA_MAXIMUS) | 550 | if (optc->ctx->dce_environment != DCE_ENV_FPGA_MAXIMUS) |
563 | REG_WAIT(OTG_MASTER_UPDATE_LOCK, | 551 | REG_WAIT(OTG_MASTER_UPDATE_LOCK, |
564 | UPDATE_LOCK_STATUS, 1, | 552 | UPDATE_LOCK_STATUS, 1, |
565 | 1, 10); | 553 | 1, 10); |
566 | } | 554 | } |
567 | 555 | ||
568 | static void tgn10_unlock(struct timing_generator *tg) | 556 | void optc1_unlock(struct timing_generator *optc) |
569 | { | 557 | { |
570 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 558 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
571 | 559 | ||
572 | REG_SET(OTG_MASTER_UPDATE_LOCK, 0, | 560 | REG_SET(OTG_MASTER_UPDATE_LOCK, 0, |
573 | OTG_MASTER_UPDATE_LOCK, 0); | 561 | OTG_MASTER_UPDATE_LOCK, 0); |
574 | } | 562 | } |
575 | 563 | ||
576 | static void tgn10_get_position(struct timing_generator *tg, | 564 | void optc1_get_position(struct timing_generator *optc, |
577 | struct crtc_position *position) | 565 | struct crtc_position *position) |
578 | { | 566 | { |
579 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 567 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
580 | 568 | ||
581 | REG_GET_2(OTG_STATUS_POSITION, | 569 | REG_GET_2(OTG_STATUS_POSITION, |
582 | OTG_HORZ_COUNT, &position->horizontal_count, | 570 | OTG_HORZ_COUNT, &position->horizontal_count, |
@@ -586,12 +574,12 @@ static void tgn10_get_position(struct timing_generator *tg, | |||
586 | OTG_VERT_COUNT_NOM, &position->nominal_vcount); | 574 | OTG_VERT_COUNT_NOM, &position->nominal_vcount); |
587 | } | 575 | } |
588 | 576 | ||
589 | static bool tgn10_is_counter_moving(struct timing_generator *tg) | 577 | bool optc1_is_counter_moving(struct timing_generator *optc) |
590 | { | 578 | { |
591 | struct crtc_position position1, position2; | 579 | struct crtc_position position1, position2; |
592 | 580 | ||
593 | tg->funcs->get_position(tg, &position1); | 581 | optc->funcs->get_position(optc, &position1); |
594 | tg->funcs->get_position(tg, &position2); | 582 | optc->funcs->get_position(optc, &position2); |
595 | 583 | ||
596 | if (position1.horizontal_count == position2.horizontal_count && | 584 | if (position1.horizontal_count == position2.horizontal_count && |
597 | position1.vertical_count == position2.vertical_count) | 585 | position1.vertical_count == position2.vertical_count) |
@@ -600,10 +588,10 @@ static bool tgn10_is_counter_moving(struct timing_generator *tg) | |||
600 | return true; | 588 | return true; |
601 | } | 589 | } |
602 | 590 | ||
603 | static bool tgn10_did_triggered_reset_occur( | 591 | bool optc1_did_triggered_reset_occur( |
604 | struct timing_generator *tg) | 592 | struct timing_generator *optc) |
605 | { | 593 | { |
606 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 594 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
607 | uint32_t occurred_force, occurred_vsync; | 595 | uint32_t occurred_force, occurred_vsync; |
608 | 596 | ||
609 | REG_GET(OTG_FORCE_COUNT_NOW_CNTL, | 597 | REG_GET(OTG_FORCE_COUNT_NOW_CNTL, |
@@ -615,9 +603,9 @@ static bool tgn10_did_triggered_reset_occur( | |||
615 | return occurred_vsync != 0 || occurred_force != 0; | 603 | return occurred_vsync != 0 || occurred_force != 0; |
616 | } | 604 | } |
617 | 605 | ||
618 | static void tgn10_disable_reset_trigger(struct timing_generator *tg) | 606 | void optc1_disable_reset_trigger(struct timing_generator *optc) |
619 | { | 607 | { |
620 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 608 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
621 | 609 | ||
622 | REG_WRITE(OTG_TRIGA_CNTL, 0); | 610 | REG_WRITE(OTG_TRIGA_CNTL, 0); |
623 | 611 | ||
@@ -628,9 +616,9 @@ static void tgn10_disable_reset_trigger(struct timing_generator *tg) | |||
628 | OTG_FORCE_VSYNC_NEXT_LINE_CLEAR, 1); | 616 | OTG_FORCE_VSYNC_NEXT_LINE_CLEAR, 1); |
629 | } | 617 | } |
630 | 618 | ||
631 | static void tgn10_enable_reset_trigger(struct timing_generator *tg, int source_tg_inst) | 619 | void optc1_enable_reset_trigger(struct timing_generator *optc, int source_tg_inst) |
632 | { | 620 | { |
633 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 621 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
634 | uint32_t falling_edge; | 622 | uint32_t falling_edge; |
635 | 623 | ||
636 | REG_GET(OTG_V_SYNC_A_CNTL, | 624 | REG_GET(OTG_V_SYNC_A_CNTL, |
@@ -662,12 +650,12 @@ static void tgn10_enable_reset_trigger(struct timing_generator *tg, int source_t | |||
662 | OTG_FORCE_COUNT_NOW_MODE, 2); | 650 | OTG_FORCE_COUNT_NOW_MODE, 2); |
663 | } | 651 | } |
664 | 652 | ||
665 | void tgn10_enable_crtc_reset( | 653 | void optc1_enable_crtc_reset( |
666 | struct timing_generator *tg, | 654 | struct timing_generator *optc, |
667 | int source_tg_inst, | 655 | int source_tg_inst, |
668 | struct crtc_trigger_info *crtc_tp) | 656 | struct crtc_trigger_info *crtc_tp) |
669 | { | 657 | { |
670 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 658 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
671 | uint32_t falling_edge = 0; | 659 | uint32_t falling_edge = 0; |
672 | uint32_t rising_edge = 0; | 660 | uint32_t rising_edge = 0; |
673 | 661 | ||
@@ -707,10 +695,10 @@ void tgn10_enable_crtc_reset( | |||
707 | } | 695 | } |
708 | } | 696 | } |
709 | 697 | ||
710 | static void tgn10_wait_for_state(struct timing_generator *tg, | 698 | void optc1_wait_for_state(struct timing_generator *optc, |
711 | enum crtc_state state) | 699 | enum crtc_state state) |
712 | { | 700 | { |
713 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 701 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
714 | 702 | ||
715 | switch (state) { | 703 | switch (state) { |
716 | case CRTC_STATE_VBLANK: | 704 | case CRTC_STATE_VBLANK: |
@@ -730,8 +718,8 @@ static void tgn10_wait_for_state(struct timing_generator *tg, | |||
730 | } | 718 | } |
731 | } | 719 | } |
732 | 720 | ||
733 | static void tgn10_set_early_control( | 721 | void optc1_set_early_control( |
734 | struct timing_generator *tg, | 722 | struct timing_generator *optc, |
735 | uint32_t early_cntl) | 723 | uint32_t early_cntl) |
736 | { | 724 | { |
737 | /* asic design change, do not need this control | 725 | /* asic design change, do not need this control |
@@ -740,11 +728,11 @@ static void tgn10_set_early_control( | |||
740 | } | 728 | } |
741 | 729 | ||
742 | 730 | ||
743 | static void tgn10_set_static_screen_control( | 731 | void optc1_set_static_screen_control( |
744 | struct timing_generator *tg, | 732 | struct timing_generator *optc, |
745 | uint32_t value) | 733 | uint32_t value) |
746 | { | 734 | { |
747 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 735 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
748 | 736 | ||
749 | /* Bit 8 is no longer applicable in RV for PSR case, | 737 | /* Bit 8 is no longer applicable in RV for PSR case, |
750 | * set bit 8 to 0 if given | 738 | * set bit 8 to 0 if given |
@@ -769,11 +757,11 @@ static void tgn10_set_static_screen_control( | |||
769 | * | 757 | * |
770 | ***************************************************************************** | 758 | ***************************************************************************** |
771 | */ | 759 | */ |
772 | static void tgn10_set_drr( | 760 | void optc1_set_drr( |
773 | struct timing_generator *tg, | 761 | struct timing_generator *optc, |
774 | const struct drr_params *params) | 762 | const struct drr_params *params) |
775 | { | 763 | { |
776 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 764 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
777 | 765 | ||
778 | if (params != NULL && | 766 | if (params != NULL && |
779 | params->vertical_total_max > 0 && | 767 | params->vertical_total_max > 0 && |
@@ -806,15 +794,15 @@ static void tgn10_set_drr( | |||
806 | } | 794 | } |
807 | } | 795 | } |
808 | 796 | ||
809 | static void tgn10_set_test_pattern( | 797 | static void optc1_set_test_pattern( |
810 | struct timing_generator *tg, | 798 | struct timing_generator *optc, |
811 | /* TODO: replace 'controller_dp_test_pattern' by 'test_pattern_mode' | 799 | /* TODO: replace 'controller_dp_test_pattern' by 'test_pattern_mode' |
812 | * because this is not DP-specific (which is probably somewhere in DP | 800 | * because this is not DP-specific (which is probably somewhere in DP |
813 | * encoder) */ | 801 | * encoder) */ |
814 | enum controller_dp_test_pattern test_pattern, | 802 | enum controller_dp_test_pattern test_pattern, |
815 | enum dc_color_depth color_depth) | 803 | enum dc_color_depth color_depth) |
816 | { | 804 | { |
817 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 805 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
818 | enum test_pattern_color_format bit_depth; | 806 | enum test_pattern_color_format bit_depth; |
819 | enum test_pattern_dyn_range dyn_range; | 807 | enum test_pattern_dyn_range dyn_range; |
820 | enum test_pattern_mode mode; | 808 | enum test_pattern_mode mode; |
@@ -1065,35 +1053,30 @@ static void tgn10_set_test_pattern( | |||
1065 | } | 1053 | } |
1066 | } | 1054 | } |
1067 | 1055 | ||
1068 | static void tgn10_get_crtc_scanoutpos( | 1056 | void optc1_get_crtc_scanoutpos( |
1069 | struct timing_generator *tg, | 1057 | struct timing_generator *optc, |
1070 | uint32_t *v_blank_start, | 1058 | uint32_t *v_blank_start, |
1071 | uint32_t *v_blank_end, | 1059 | uint32_t *v_blank_end, |
1072 | uint32_t *h_position, | 1060 | uint32_t *h_position, |
1073 | uint32_t *v_position) | 1061 | uint32_t *v_position) |
1074 | { | 1062 | { |
1075 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 1063 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1076 | struct crtc_position position; | 1064 | struct crtc_position position; |
1077 | 1065 | ||
1078 | REG_GET_2(OTG_V_BLANK_START_END, | 1066 | REG_GET_2(OTG_V_BLANK_START_END, |
1079 | OTG_V_BLANK_START, v_blank_start, | 1067 | OTG_V_BLANK_START, v_blank_start, |
1080 | OTG_V_BLANK_END, v_blank_end); | 1068 | OTG_V_BLANK_END, v_blank_end); |
1081 | 1069 | ||
1082 | tgn10_get_position(tg, &position); | 1070 | optc1_get_position(optc, &position); |
1083 | 1071 | ||
1084 | *h_position = position.horizontal_count; | 1072 | *h_position = position.horizontal_count; |
1085 | *v_position = position.vertical_count; | 1073 | *v_position = position.vertical_count; |
1086 | } | 1074 | } |
1087 | 1075 | ||
1088 | 1076 | static void optc1_enable_stereo(struct timing_generator *optc, | |
1089 | |||
1090 | static void tgn10_enable_stereo(struct timing_generator *tg, | ||
1091 | const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags) | 1077 | const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags) |
1092 | { | 1078 | { |
1093 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 1079 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1094 | |||
1095 | uint32_t active_width = timing->h_addressable; | ||
1096 | uint32_t space1_size = timing->v_total - timing->v_addressable; | ||
1097 | 1080 | ||
1098 | if (flags) { | 1081 | if (flags) { |
1099 | uint32_t stereo_en; | 1082 | uint32_t stereo_en; |
@@ -1121,29 +1104,23 @@ static void tgn10_enable_stereo(struct timing_generator *tg, | |||
1121 | OTG_3D_STRUCTURE_STEREO_SEL_OVR, flags->FRAME_PACKED); | 1104 | OTG_3D_STRUCTURE_STEREO_SEL_OVR, flags->FRAME_PACKED); |
1122 | 1105 | ||
1123 | } | 1106 | } |
1124 | |||
1125 | REG_UPDATE(OPPBUF_CONTROL, | ||
1126 | OPPBUF_ACTIVE_WIDTH, active_width); | ||
1127 | |||
1128 | REG_UPDATE(OPPBUF_3D_PARAMETERS_0, | ||
1129 | OPPBUF_3D_VACT_SPACE1_SIZE, space1_size); | ||
1130 | } | 1107 | } |
1131 | 1108 | ||
1132 | static void tgn10_program_stereo(struct timing_generator *tg, | 1109 | void optc1_program_stereo(struct timing_generator *optc, |
1133 | const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags) | 1110 | const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags) |
1134 | { | 1111 | { |
1135 | if (flags->PROGRAM_STEREO) | 1112 | if (flags->PROGRAM_STEREO) |
1136 | tgn10_enable_stereo(tg, timing, flags); | 1113 | optc1_enable_stereo(optc, timing, flags); |
1137 | else | 1114 | else |
1138 | tgn10_disable_stereo(tg); | 1115 | optc1_disable_stereo(optc); |
1139 | } | 1116 | } |
1140 | 1117 | ||
1141 | 1118 | ||
1142 | static bool tgn10_is_stereo_left_eye(struct timing_generator *tg) | 1119 | bool optc1_is_stereo_left_eye(struct timing_generator *optc) |
1143 | { | 1120 | { |
1144 | bool ret = false; | 1121 | bool ret = false; |
1145 | uint32_t left_eye = 0; | 1122 | uint32_t left_eye = 0; |
1146 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 1123 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1147 | 1124 | ||
1148 | REG_GET(OTG_STEREO_STATUS, | 1125 | REG_GET(OTG_STEREO_STATUS, |
1149 | OTG_STEREO_CURRENT_EYE, &left_eye); | 1126 | OTG_STEREO_CURRENT_EYE, &left_eye); |
@@ -1155,7 +1132,7 @@ static bool tgn10_is_stereo_left_eye(struct timing_generator *tg) | |||
1155 | return ret; | 1132 | return ret; |
1156 | } | 1133 | } |
1157 | 1134 | ||
1158 | void tgn10_read_otg_state(struct dcn10_timing_generator *tgn10, | 1135 | void optc1_read_otg_state(struct optc *optc1, |
1159 | struct dcn_otg_state *s) | 1136 | struct dcn_otg_state *s) |
1160 | { | 1137 | { |
1161 | REG_GET(OTG_CONTROL, | 1138 | REG_GET(OTG_CONTROL, |
@@ -1199,17 +1176,22 @@ void tgn10_read_otg_state(struct dcn10_timing_generator *tgn10, | |||
1199 | OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status); | 1176 | OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status); |
1200 | } | 1177 | } |
1201 | 1178 | ||
1202 | static void tgn10_tg_init(struct timing_generator *tg) | 1179 | static void optc1_clear_optc_underflow(struct timing_generator *optc) |
1203 | { | 1180 | { |
1204 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 1181 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1205 | 1182 | ||
1206 | tgn10_set_blank_data_double_buffer(tg, true); | ||
1207 | REG_UPDATE(OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, 1); | 1183 | REG_UPDATE(OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, 1); |
1208 | } | 1184 | } |
1209 | 1185 | ||
1210 | static bool tgn10_is_tg_enabled(struct timing_generator *tg) | 1186 | static void optc1_tg_init(struct timing_generator *optc) |
1187 | { | ||
1188 | optc1_set_blank_data_double_buffer(optc, true); | ||
1189 | optc1_clear_optc_underflow(optc); | ||
1190 | } | ||
1191 | |||
1192 | static bool optc1_is_tg_enabled(struct timing_generator *optc) | ||
1211 | { | 1193 | { |
1212 | struct dcn10_timing_generator *tgn10 = DCN10TG_FROM_TG(tg); | 1194 | struct optc *optc1 = DCN10TG_FROM_TG(optc); |
1213 | uint32_t otg_enabled = 0; | 1195 | uint32_t otg_enabled = 0; |
1214 | 1196 | ||
1215 | REG_GET(OTG_CONTROL, OTG_MASTER_EN, &otg_enabled); | 1197 | REG_GET(OTG_CONTROL, OTG_MASTER_EN, &otg_enabled); |
@@ -1217,50 +1199,65 @@ static bool tgn10_is_tg_enabled(struct timing_generator *tg) | |||
1217 | return (otg_enabled != 0); | 1199 | return (otg_enabled != 0); |
1218 | 1200 | ||
1219 | } | 1201 | } |
1202 | |||
1203 | static bool optc1_is_optc_underflow_occurred(struct timing_generator *optc) | ||
1204 | { | ||
1205 | struct optc *optc1 = DCN10TG_FROM_TG(optc); | ||
1206 | uint32_t underflow_occurred = 0; | ||
1207 | |||
1208 | REG_GET(OPTC_INPUT_GLOBAL_CONTROL, | ||
1209 | OPTC_UNDERFLOW_OCCURRED_STATUS, | ||
1210 | &underflow_occurred); | ||
1211 | |||
1212 | return (underflow_occurred == 1); | ||
1213 | } | ||
1214 | |||
1220 | static const struct timing_generator_funcs dcn10_tg_funcs = { | 1215 | static const struct timing_generator_funcs dcn10_tg_funcs = { |
1221 | .validate_timing = tgn10_validate_timing, | 1216 | .validate_timing = optc1_validate_timing, |
1222 | .program_timing = tgn10_program_timing, | 1217 | .program_timing = optc1_program_timing, |
1223 | .program_global_sync = tgn10_program_global_sync, | 1218 | .program_global_sync = optc1_program_global_sync, |
1224 | .enable_crtc = tgn10_enable_crtc, | 1219 | .enable_crtc = optc1_enable_crtc, |
1225 | .disable_crtc = tgn10_disable_crtc, | 1220 | .disable_crtc = optc1_disable_crtc, |
1226 | /* used by enable_timing_synchronization. Not need for FPGA */ | 1221 | /* used by enable_timing_synchronization. Not need for FPGA */ |
1227 | .is_counter_moving = tgn10_is_counter_moving, | 1222 | .is_counter_moving = optc1_is_counter_moving, |
1228 | .get_position = tgn10_get_position, | 1223 | .get_position = optc1_get_position, |
1229 | .get_frame_count = tgn10_get_vblank_counter, | 1224 | .get_frame_count = optc1_get_vblank_counter, |
1230 | .get_scanoutpos = tgn10_get_crtc_scanoutpos, | 1225 | .get_scanoutpos = optc1_get_crtc_scanoutpos, |
1231 | .set_early_control = tgn10_set_early_control, | 1226 | .set_early_control = optc1_set_early_control, |
1232 | /* used by enable_timing_synchronization. Not need for FPGA */ | 1227 | /* used by enable_timing_synchronization. Not need for FPGA */ |
1233 | .wait_for_state = tgn10_wait_for_state, | 1228 | .wait_for_state = optc1_wait_for_state, |
1234 | .set_blank = tgn10_set_blank, | 1229 | .set_blank = optc1_set_blank, |
1235 | .is_blanked = tgn10_is_blanked, | 1230 | .is_blanked = optc1_is_blanked, |
1236 | .set_blank_color = tgn10_program_blank_color, | 1231 | .set_blank_color = optc1_program_blank_color, |
1237 | .did_triggered_reset_occur = tgn10_did_triggered_reset_occur, | 1232 | .did_triggered_reset_occur = optc1_did_triggered_reset_occur, |
1238 | .enable_reset_trigger = tgn10_enable_reset_trigger, | 1233 | .enable_reset_trigger = optc1_enable_reset_trigger, |
1239 | .enable_crtc_reset = tgn10_enable_crtc_reset, | 1234 | .enable_crtc_reset = optc1_enable_crtc_reset, |
1240 | .disable_reset_trigger = tgn10_disable_reset_trigger, | 1235 | .disable_reset_trigger = optc1_disable_reset_trigger, |
1241 | .lock = tgn10_lock, | 1236 | .lock = optc1_lock, |
1242 | .unlock = tgn10_unlock, | 1237 | .unlock = optc1_unlock, |
1243 | .enable_optc_clock = tgn10_enable_optc_clock, | 1238 | .enable_optc_clock = optc1_enable_optc_clock, |
1244 | .set_drr = tgn10_set_drr, | 1239 | .set_drr = optc1_set_drr, |
1245 | .set_static_screen_control = tgn10_set_static_screen_control, | 1240 | .set_static_screen_control = optc1_set_static_screen_control, |
1246 | .set_test_pattern = tgn10_set_test_pattern, | 1241 | .set_test_pattern = optc1_set_test_pattern, |
1247 | .program_stereo = tgn10_program_stereo, | 1242 | .program_stereo = optc1_program_stereo, |
1248 | .is_stereo_left_eye = tgn10_is_stereo_left_eye, | 1243 | .is_stereo_left_eye = optc1_is_stereo_left_eye, |
1249 | .set_blank_data_double_buffer = tgn10_set_blank_data_double_buffer, | 1244 | .set_blank_data_double_buffer = optc1_set_blank_data_double_buffer, |
1250 | .tg_init = tgn10_tg_init, | 1245 | .tg_init = optc1_tg_init, |
1251 | .is_tg_enabled = tgn10_is_tg_enabled, | 1246 | .is_tg_enabled = optc1_is_tg_enabled, |
1247 | .is_optc_underflow_occurred = optc1_is_optc_underflow_occurred, | ||
1248 | .clear_optc_underflow = optc1_clear_optc_underflow, | ||
1252 | }; | 1249 | }; |
1253 | 1250 | ||
1254 | void dcn10_timing_generator_init(struct dcn10_timing_generator *tgn10) | 1251 | void dcn10_timing_generator_init(struct optc *optc1) |
1255 | { | 1252 | { |
1256 | tgn10->base.funcs = &dcn10_tg_funcs; | 1253 | optc1->base.funcs = &dcn10_tg_funcs; |
1257 | 1254 | ||
1258 | tgn10->max_h_total = tgn10->tg_mask->OTG_H_TOTAL + 1; | 1255 | optc1->max_h_total = optc1->tg_mask->OTG_H_TOTAL + 1; |
1259 | tgn10->max_v_total = tgn10->tg_mask->OTG_V_TOTAL + 1; | 1256 | optc1->max_v_total = optc1->tg_mask->OTG_V_TOTAL + 1; |
1260 | 1257 | ||
1261 | tgn10->min_h_blank = 32; | 1258 | optc1->min_h_blank = 32; |
1262 | tgn10->min_v_blank = 3; | 1259 | optc1->min_v_blank = 3; |
1263 | tgn10->min_v_blank_interlace = 5; | 1260 | optc1->min_v_blank_interlace = 5; |
1264 | tgn10->min_h_sync_width = 8; | 1261 | optc1->min_h_sync_width = 8; |
1265 | tgn10->min_v_sync_width = 1; | 1262 | optc1->min_v_sync_width = 1; |
1266 | } | 1263 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_timing_generator.h b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h index bb1cbfdc3554..a3c7c2012f05 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_timing_generator.h +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "timing_generator.h" | 29 | #include "timing_generator.h" |
30 | 30 | ||
31 | #define DCN10TG_FROM_TG(tg)\ | 31 | #define DCN10TG_FROM_TG(tg)\ |
32 | container_of(tg, struct dcn10_timing_generator, base) | 32 | container_of(tg, struct optc, base) |
33 | 33 | ||
34 | #define TG_COMMON_REG_LIST_DCN(inst) \ | 34 | #define TG_COMMON_REG_LIST_DCN(inst) \ |
35 | SRI(OTG_VSTARTUP_PARAM, OTG, inst),\ | 35 | SRI(OTG_VSTARTUP_PARAM, OTG, inst),\ |
@@ -70,8 +70,6 @@ | |||
70 | SRI(OPTC_INPUT_CLOCK_CONTROL, ODM, inst),\ | 70 | SRI(OPTC_INPUT_CLOCK_CONTROL, ODM, inst),\ |
71 | SRI(OPTC_DATA_SOURCE_SELECT, ODM, inst),\ | 71 | SRI(OPTC_DATA_SOURCE_SELECT, ODM, inst),\ |
72 | SRI(OPTC_INPUT_GLOBAL_CONTROL, ODM, inst),\ | 72 | SRI(OPTC_INPUT_GLOBAL_CONTROL, ODM, inst),\ |
73 | SRI(OPPBUF_CONTROL, OPPBUF, inst),\ | ||
74 | SRI(OPPBUF_3D_PARAMETERS_0, OPPBUF, inst),\ | ||
75 | SRI(CONTROL, VTG, inst),\ | 73 | SRI(CONTROL, VTG, inst),\ |
76 | SRI(OTG_VERT_SYNC_CONTROL, OTG, inst),\ | 74 | SRI(OTG_VERT_SYNC_CONTROL, OTG, inst),\ |
77 | SRI(OTG_MASTER_UPDATE_MODE, OTG, inst),\ | 75 | SRI(OTG_MASTER_UPDATE_MODE, OTG, inst),\ |
@@ -84,7 +82,7 @@ | |||
84 | SRI(OTG_TEST_PATTERN_COLOR, OTG, inst) | 82 | SRI(OTG_TEST_PATTERN_COLOR, OTG, inst) |
85 | 83 | ||
86 | 84 | ||
87 | struct dcn_tg_registers { | 85 | struct dcn_optc_registers { |
88 | uint32_t OTG_VERT_SYNC_CONTROL; | 86 | uint32_t OTG_VERT_SYNC_CONTROL; |
89 | uint32_t OTG_MASTER_UPDATE_MODE; | 87 | uint32_t OTG_MASTER_UPDATE_MODE; |
90 | uint32_t OTG_GSL_CONTROL; | 88 | uint32_t OTG_GSL_CONTROL; |
@@ -129,9 +127,11 @@ struct dcn_tg_registers { | |||
129 | uint32_t OPTC_INPUT_CLOCK_CONTROL; | 127 | uint32_t OPTC_INPUT_CLOCK_CONTROL; |
130 | uint32_t OPTC_DATA_SOURCE_SELECT; | 128 | uint32_t OPTC_DATA_SOURCE_SELECT; |
131 | uint32_t OPTC_INPUT_GLOBAL_CONTROL; | 129 | uint32_t OPTC_INPUT_GLOBAL_CONTROL; |
132 | uint32_t OPPBUF_CONTROL; | ||
133 | uint32_t OPPBUF_3D_PARAMETERS_0; | ||
134 | uint32_t CONTROL; | 130 | uint32_t CONTROL; |
131 | uint32_t OTG_GSL_WINDOW_X; | ||
132 | uint32_t OTG_GSL_WINDOW_Y; | ||
133 | uint32_t OTG_VUPDATE_KEEPOUT; | ||
134 | uint32_t OTG_DSC_START_POSITION; | ||
135 | }; | 135 | }; |
136 | 136 | ||
137 | #define TG_COMMON_MASK_SH_LIST_DCN(mask_sh)\ | 137 | #define TG_COMMON_MASK_SH_LIST_DCN(mask_sh)\ |
@@ -211,8 +211,6 @@ struct dcn_tg_registers { | |||
211 | SF(ODM0_OPTC_INPUT_CLOCK_CONTROL, OPTC_INPUT_CLK_GATE_DIS, mask_sh),\ | 211 | SF(ODM0_OPTC_INPUT_CLOCK_CONTROL, OPTC_INPUT_CLK_GATE_DIS, mask_sh),\ |
212 | SF(ODM0_OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_OCCURRED_STATUS, mask_sh),\ | 212 | SF(ODM0_OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_OCCURRED_STATUS, mask_sh),\ |
213 | SF(ODM0_OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, mask_sh),\ | 213 | SF(ODM0_OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, mask_sh),\ |
214 | SF(OPPBUF0_OPPBUF_CONTROL, OPPBUF_ACTIVE_WIDTH, mask_sh),\ | ||
215 | SF(OPPBUF0_OPPBUF_3D_PARAMETERS_0, OPPBUF_3D_VACT_SPACE1_SIZE, mask_sh),\ | ||
216 | SF(VTG0_CONTROL, VTG0_ENABLE, mask_sh),\ | 214 | SF(VTG0_CONTROL, VTG0_ENABLE, mask_sh),\ |
217 | SF(VTG0_CONTROL, VTG0_FP2, mask_sh),\ | 215 | SF(VTG0_CONTROL, VTG0_FP2, mask_sh),\ |
218 | SF(VTG0_CONTROL, VTG0_VCOUNT_INIT, mask_sh),\ | 216 | SF(VTG0_CONTROL, VTG0_VCOUNT_INIT, mask_sh),\ |
@@ -332,8 +330,6 @@ struct dcn_tg_registers { | |||
332 | type OPTC_SEG0_SRC_SEL;\ | 330 | type OPTC_SEG0_SRC_SEL;\ |
333 | type OPTC_UNDERFLOW_OCCURRED_STATUS;\ | 331 | type OPTC_UNDERFLOW_OCCURRED_STATUS;\ |
334 | type OPTC_UNDERFLOW_CLEAR;\ | 332 | type OPTC_UNDERFLOW_CLEAR;\ |
335 | type OPPBUF_ACTIVE_WIDTH;\ | ||
336 | type OPPBUF_3D_VACT_SPACE1_SIZE;\ | ||
337 | type VTG0_ENABLE;\ | 333 | type VTG0_ENABLE;\ |
338 | type VTG0_FP2;\ | 334 | type VTG0_FP2;\ |
339 | type VTG0_VCOUNT_INIT;\ | 335 | type VTG0_VCOUNT_INIT;\ |
@@ -346,22 +342,35 @@ struct dcn_tg_registers { | |||
346 | type OTG_GSL2_EN;\ | 342 | type OTG_GSL2_EN;\ |
347 | type OTG_GSL_MASTER_EN;\ | 343 | type OTG_GSL_MASTER_EN;\ |
348 | type OTG_GSL_FORCE_DELAY;\ | 344 | type OTG_GSL_FORCE_DELAY;\ |
349 | type OTG_GSL_CHECK_ALL_FIELDS; | 345 | type OTG_GSL_CHECK_ALL_FIELDS;\ |
346 | type OTG_GSL_WINDOW_START_X;\ | ||
347 | type OTG_GSL_WINDOW_END_X;\ | ||
348 | type OTG_GSL_WINDOW_START_Y;\ | ||
349 | type OTG_GSL_WINDOW_END_Y;\ | ||
350 | type OTG_RANGE_TIMING_DBUF_UPDATE_MODE;\ | ||
351 | type OTG_GSL_MASTER_MODE;\ | ||
352 | type OTG_MASTER_UPDATE_LOCK_GSL_EN;\ | ||
353 | type MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_START_OFFSET;\ | ||
354 | type MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_END_OFFSET;\ | ||
355 | type OTG_DSC_START_POSITION_X;\ | ||
356 | type OTG_DSC_START_POSITION_LINE_NUM;\ | ||
357 | type OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN; | ||
350 | 358 | ||
351 | struct dcn_tg_shift { | 359 | |
360 | struct dcn_optc_shift { | ||
352 | TG_REG_FIELD_LIST(uint8_t) | 361 | TG_REG_FIELD_LIST(uint8_t) |
353 | }; | 362 | }; |
354 | 363 | ||
355 | struct dcn_tg_mask { | 364 | struct dcn_optc_mask { |
356 | TG_REG_FIELD_LIST(uint32_t) | 365 | TG_REG_FIELD_LIST(uint32_t) |
357 | }; | 366 | }; |
358 | 367 | ||
359 | struct dcn10_timing_generator { | 368 | struct optc { |
360 | struct timing_generator base; | 369 | struct timing_generator base; |
361 | 370 | ||
362 | const struct dcn_tg_registers *tg_regs; | 371 | const struct dcn_optc_registers *tg_regs; |
363 | const struct dcn_tg_shift *tg_shift; | 372 | const struct dcn_optc_shift *tg_shift; |
364 | const struct dcn_tg_mask *tg_mask; | 373 | const struct dcn_optc_mask *tg_mask; |
365 | 374 | ||
366 | enum controller_id controller_id; | 375 | enum controller_id controller_id; |
367 | 376 | ||
@@ -376,7 +385,7 @@ struct dcn10_timing_generator { | |||
376 | uint32_t min_v_blank_interlace; | 385 | uint32_t min_v_blank_interlace; |
377 | }; | 386 | }; |
378 | 387 | ||
379 | void dcn10_timing_generator_init(struct dcn10_timing_generator *tg); | 388 | void dcn10_timing_generator_init(struct optc *optc); |
380 | 389 | ||
381 | struct dcn_otg_state { | 390 | struct dcn_otg_state { |
382 | uint32_t v_blank_start; | 391 | uint32_t v_blank_start; |
@@ -397,7 +406,77 @@ struct dcn_otg_state { | |||
397 | uint32_t otg_enabled; | 406 | uint32_t otg_enabled; |
398 | }; | 407 | }; |
399 | 408 | ||
400 | void tgn10_read_otg_state(struct dcn10_timing_generator *tgn10, | 409 | void optc1_read_otg_state(struct optc *optc1, |
401 | struct dcn_otg_state *s); | 410 | struct dcn_otg_state *s); |
402 | 411 | ||
412 | bool optc1_validate_timing( | ||
413 | struct timing_generator *optc, | ||
414 | const struct dc_crtc_timing *timing); | ||
415 | |||
416 | void optc1_program_timing( | ||
417 | struct timing_generator *optc, | ||
418 | const struct dc_crtc_timing *dc_crtc_timing, | ||
419 | bool use_vbios); | ||
420 | |||
421 | void optc1_program_global_sync( | ||
422 | struct timing_generator *optc); | ||
423 | |||
424 | bool optc1_disable_crtc(struct timing_generator *optc); | ||
425 | |||
426 | bool optc1_is_counter_moving(struct timing_generator *optc); | ||
427 | |||
428 | void optc1_get_position(struct timing_generator *optc, | ||
429 | struct crtc_position *position); | ||
430 | |||
431 | uint32_t optc1_get_vblank_counter(struct timing_generator *optc); | ||
432 | |||
433 | void optc1_get_crtc_scanoutpos( | ||
434 | struct timing_generator *optc, | ||
435 | uint32_t *v_blank_start, | ||
436 | uint32_t *v_blank_end, | ||
437 | uint32_t *h_position, | ||
438 | uint32_t *v_position); | ||
439 | |||
440 | void optc1_set_early_control( | ||
441 | struct timing_generator *optc, | ||
442 | uint32_t early_cntl); | ||
443 | |||
444 | void optc1_wait_for_state(struct timing_generator *optc, | ||
445 | enum crtc_state state); | ||
446 | |||
447 | void optc1_set_blank(struct timing_generator *optc, | ||
448 | bool enable_blanking); | ||
449 | |||
450 | bool optc1_is_blanked(struct timing_generator *optc); | ||
451 | |||
452 | void optc1_program_blank_color( | ||
453 | struct timing_generator *optc, | ||
454 | const struct tg_color *black_color); | ||
455 | |||
456 | bool optc1_did_triggered_reset_occur( | ||
457 | struct timing_generator *optc); | ||
458 | |||
459 | void optc1_enable_reset_trigger(struct timing_generator *optc, int source_tg_inst); | ||
460 | |||
461 | void optc1_disable_reset_trigger(struct timing_generator *optc); | ||
462 | |||
463 | void optc1_lock(struct timing_generator *optc); | ||
464 | |||
465 | void optc1_unlock(struct timing_generator *optc); | ||
466 | |||
467 | void optc1_enable_optc_clock(struct timing_generator *optc, bool enable); | ||
468 | |||
469 | void optc1_set_drr( | ||
470 | struct timing_generator *optc, | ||
471 | const struct drr_params *params); | ||
472 | |||
473 | void optc1_set_static_screen_control( | ||
474 | struct timing_generator *optc, | ||
475 | uint32_t value); | ||
476 | |||
477 | void optc1_program_stereo(struct timing_generator *optc, | ||
478 | const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags); | ||
479 | |||
480 | bool optc1_is_stereo_left_eye(struct timing_generator *optc); | ||
481 | |||
403 | #endif /* __DC_TIMING_GENERATOR_DCN10_H__ */ | 482 | #endif /* __DC_TIMING_GENERATOR_DCN10_H__ */ |
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c index 10cce51d31d2..44825e2c9ebb 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "dcn10/dcn10_mpc.h" | 34 | #include "dcn10/dcn10_mpc.h" |
35 | #include "irq/dcn10/irq_service_dcn10.h" | 35 | #include "irq/dcn10/irq_service_dcn10.h" |
36 | #include "dcn10/dcn10_dpp.h" | 36 | #include "dcn10/dcn10_dpp.h" |
37 | #include "dcn10/dcn10_timing_generator.h" | 37 | #include "dcn10_optc.h" |
38 | #include "dcn10/dcn10_hw_sequencer.h" | 38 | #include "dcn10/dcn10_hw_sequencer.h" |
39 | #include "dce110/dce110_hw_sequencer.h" | 39 | #include "dce110/dce110_hw_sequencer.h" |
40 | #include "dcn10/dcn10_opp.h" | 40 | #include "dcn10/dcn10_opp.h" |
@@ -348,18 +348,18 @@ static const struct dcn_mpc_mask mpc_mask = { | |||
348 | #define tg_regs(id)\ | 348 | #define tg_regs(id)\ |
349 | [id] = {TG_COMMON_REG_LIST_DCN1_0(id)} | 349 | [id] = {TG_COMMON_REG_LIST_DCN1_0(id)} |
350 | 350 | ||
351 | static const struct dcn_tg_registers tg_regs[] = { | 351 | static const struct dcn_optc_registers tg_regs[] = { |
352 | tg_regs(0), | 352 | tg_regs(0), |
353 | tg_regs(1), | 353 | tg_regs(1), |
354 | tg_regs(2), | 354 | tg_regs(2), |
355 | tg_regs(3), | 355 | tg_regs(3), |
356 | }; | 356 | }; |
357 | 357 | ||
358 | static const struct dcn_tg_shift tg_shift = { | 358 | static const struct dcn_optc_shift tg_shift = { |
359 | TG_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT) | 359 | TG_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT) |
360 | }; | 360 | }; |
361 | 361 | ||
362 | static const struct dcn_tg_mask tg_mask = { | 362 | static const struct dcn_optc_mask tg_mask = { |
363 | TG_COMMON_MASK_SH_LIST_DCN1_0(_MASK) | 363 | TG_COMMON_MASK_SH_LIST_DCN1_0(_MASK) |
364 | }; | 364 | }; |
365 | 365 | ||
@@ -553,8 +553,8 @@ static struct timing_generator *dcn10_timing_generator_create( | |||
553 | struct dc_context *ctx, | 553 | struct dc_context *ctx, |
554 | uint32_t instance) | 554 | uint32_t instance) |
555 | { | 555 | { |
556 | struct dcn10_timing_generator *tgn10 = | 556 | struct optc *tgn10 = |
557 | kzalloc(sizeof(struct dcn10_timing_generator), GFP_KERNEL); | 557 | kzalloc(sizeof(struct optc), GFP_KERNEL); |
558 | 558 | ||
559 | if (!tgn10) | 559 | if (!tgn10) |
560 | return NULL; | 560 | return NULL; |
@@ -678,6 +678,7 @@ static struct dce_hwseq *dcn10_hwseq_create( | |||
678 | hws->shifts = &hwseq_shift; | 678 | hws->shifts = &hwseq_shift; |
679 | hws->masks = &hwseq_mask; | 679 | hws->masks = &hwseq_mask; |
680 | hws->wa.DEGVIDCN10_253 = true; | 680 | hws->wa.DEGVIDCN10_253 = true; |
681 | hws->wa.false_optc_underflow = true; | ||
681 | } | 682 | } |
682 | return hws; | 683 | return hws; |
683 | } | 684 | } |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c index 4c31fa54af39..c109b2c34c8f 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_lib.c | |||
@@ -35,35 +35,6 @@ static void set_soc_bounding_box(struct _vcs_dpi_soc_bounding_box_st *soc, enum | |||
35 | soc->writeback_latency_us = 12.0; | 35 | soc->writeback_latency_us = 12.0; |
36 | soc->ideal_dram_bw_after_urgent_percent = 80.0; | 36 | soc->ideal_dram_bw_after_urgent_percent = 80.0; |
37 | soc->max_request_size_bytes = 256; | 37 | soc->max_request_size_bytes = 256; |
38 | |||
39 | soc->vmin.dcfclk_mhz = 300.0; | ||
40 | soc->vmin.dispclk_mhz = 608.0; | ||
41 | soc->vmin.dppclk_mhz = 435.0; | ||
42 | soc->vmin.dram_bw_per_chan_gbps = 12.8; | ||
43 | soc->vmin.phyclk_mhz = 540.0; | ||
44 | soc->vmin.socclk_mhz = 208.0; | ||
45 | |||
46 | soc->vmid.dcfclk_mhz = 600.0; | ||
47 | soc->vmid.dispclk_mhz = 661.0; | ||
48 | soc->vmid.dppclk_mhz = 661.0; | ||
49 | soc->vmid.dram_bw_per_chan_gbps = 12.8; | ||
50 | soc->vmid.phyclk_mhz = 540.0; | ||
51 | soc->vmid.socclk_mhz = 208.0; | ||
52 | |||
53 | soc->vnom.dcfclk_mhz = 600.0; | ||
54 | soc->vnom.dispclk_mhz = 661.0; | ||
55 | soc->vnom.dppclk_mhz = 661.0; | ||
56 | soc->vnom.dram_bw_per_chan_gbps = 38.4; | ||
57 | soc->vnom.phyclk_mhz = 810; | ||
58 | soc->vnom.socclk_mhz = 208.0; | ||
59 | |||
60 | soc->vmax.dcfclk_mhz = 600.0; | ||
61 | soc->vmax.dispclk_mhz = 1086.0; | ||
62 | soc->vmax.dppclk_mhz = 661.0; | ||
63 | soc->vmax.dram_bw_per_chan_gbps = 38.4; | ||
64 | soc->vmax.phyclk_mhz = 810.0; | ||
65 | soc->vmax.socclk_mhz = 208.0; | ||
66 | |||
67 | soc->downspread_percent = 0.5; | 38 | soc->downspread_percent = 0.5; |
68 | soc->dram_page_open_time_ns = 50.0; | 39 | soc->dram_page_open_time_ns = 50.0; |
69 | soc->dram_rw_turnaround_time_ns = 17.5; | 40 | soc->dram_rw_turnaround_time_ns = 17.5; |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h b/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h index 2d9d6298f0d3..aeebd8bee628 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h | |||
@@ -79,10 +79,6 @@ struct _vcs_dpi_soc_bounding_box_st { | |||
79 | double writeback_latency_us; | 79 | double writeback_latency_us; |
80 | double ideal_dram_bw_after_urgent_percent; | 80 | double ideal_dram_bw_after_urgent_percent; |
81 | unsigned int max_request_size_bytes; | 81 | unsigned int max_request_size_bytes; |
82 | struct _vcs_dpi_voltage_scaling_st vmin; | ||
83 | struct _vcs_dpi_voltage_scaling_st vmid; | ||
84 | struct _vcs_dpi_voltage_scaling_st vnom; | ||
85 | struct _vcs_dpi_voltage_scaling_st vmax; | ||
86 | double downspread_percent; | 82 | double downspread_percent; |
87 | double dram_page_open_time_ns; | 83 | double dram_page_open_time_ns; |
88 | double dram_rw_turnaround_time_ns; | 84 | double dram_rw_turnaround_time_ns; |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c index 1f337ecfeab0..260e113fcc02 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c +++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c | |||
@@ -28,6 +28,15 @@ | |||
28 | 28 | ||
29 | #include "dml_inline_defs.h" | 29 | #include "dml_inline_defs.h" |
30 | 30 | ||
31 | /* | ||
32 | * NOTE: | ||
33 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
34 | * | ||
35 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
36 | * ways. Unless there is something clearly wrong with it the code should | ||
37 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
38 | */ | ||
39 | |||
31 | #define BPP_INVALID 0 | 40 | #define BPP_INVALID 0 |
32 | #define BPP_BLENDED_PIPE 0xffffffff | 41 | #define BPP_BLENDED_PIPE 0xffffffff |
33 | static const unsigned int NumberOfStates = DC__VOLTAGE_STATES; | 42 | static const unsigned int NumberOfStates = DC__VOLTAGE_STATES; |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c b/drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c index 8ba962df42e6..325dd2b757d6 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c +++ b/drivers/gpu/drm/amd/display/dc/dml/display_rq_dlg_calc.c | |||
@@ -27,6 +27,15 @@ | |||
27 | #include "display_mode_vba.h" | 27 | #include "display_mode_vba.h" |
28 | #include "display_rq_dlg_calc.h" | 28 | #include "display_rq_dlg_calc.h" |
29 | 29 | ||
30 | /* | ||
31 | * NOTE: | ||
32 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
33 | * | ||
34 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
35 | * ways. Unless there is something clearly wrong with it the code should | ||
36 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
37 | */ | ||
38 | |||
30 | static void calculate_ttu_cursor(struct display_mode_lib *mode_lib, | 39 | static void calculate_ttu_cursor(struct display_mode_lib *mode_lib, |
31 | double *refcyc_per_req_delivery_pre_cur, | 40 | double *refcyc_per_req_delivery_pre_cur, |
32 | double *refcyc_per_req_delivery_cur, | 41 | double *refcyc_per_req_delivery_cur, |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c b/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c index 1e4b1e383401..c2037daa8e66 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dml1_display_rq_dlg_calc.c | |||
@@ -28,6 +28,15 @@ | |||
28 | 28 | ||
29 | #include "dml_inline_defs.h" | 29 | #include "dml_inline_defs.h" |
30 | 30 | ||
31 | /* | ||
32 | * NOTE: | ||
33 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
34 | * | ||
35 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
36 | * ways. Unless there is something clearly wrong with it the code should | ||
37 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
38 | */ | ||
39 | |||
31 | static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma) | 40 | static unsigned int get_bytes_per_element(enum source_format_class source_format, bool is_chroma) |
32 | { | 41 | { |
33 | unsigned int ret_val = 0; | 42 | unsigned int ret_val = 0; |
diff --git a/drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c b/drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c index bc7d8c707221..324239c77958 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c +++ b/drivers/gpu/drm/amd/display/dc/dml/soc_bounding_box.c | |||
@@ -27,6 +27,16 @@ | |||
27 | #include "dc_features.h" | 27 | #include "dc_features.h" |
28 | 28 | ||
29 | #include "dml_inline_defs.h" | 29 | #include "dml_inline_defs.h" |
30 | |||
31 | /* | ||
32 | * NOTE: | ||
33 | * This file is gcc-parseable HW gospel, coming straight from HW engineers. | ||
34 | * | ||
35 | * It doesn't adhere to Linux kernel style and sometimes will do things in odd | ||
36 | * ways. Unless there is something clearly wrong with it the code should | ||
37 | * remain as-is as it provides us with a guarantee from HW that it is correct. | ||
38 | */ | ||
39 | |||
30 | void dml_socbb_set_latencies(soc_bounding_box_st *to_box, soc_bounding_box_st *from_box) | 40 | void dml_socbb_set_latencies(soc_bounding_box_st *to_box, soc_bounding_box_st *from_box) |
31 | { | 41 | { |
32 | to_box->dram_clock_change_latency_us = from_box->dram_clock_change_latency_us; | 42 | to_box->dram_clock_change_latency_us = from_box->dram_clock_change_latency_us; |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index d680b565af6f..d6971054ec07 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h | |||
@@ -212,7 +212,6 @@ struct pipe_ctx { | |||
212 | struct _vcs_dpi_display_rq_regs_st rq_regs; | 212 | struct _vcs_dpi_display_rq_regs_st rq_regs; |
213 | struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param; | 213 | struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param; |
214 | #endif | 214 | #endif |
215 | struct dwbc *dwbc; | ||
216 | }; | 215 | }; |
217 | 216 | ||
218 | struct resource_context { | 217 | struct resource_context { |
@@ -241,6 +240,7 @@ struct dce_bw_output { | |||
241 | 240 | ||
242 | struct dcn_bw_clocks { | 241 | struct dcn_bw_clocks { |
243 | int dispclk_khz; | 242 | int dispclk_khz; |
243 | int dppclk_khz; | ||
244 | bool dppclk_div; | 244 | bool dppclk_div; |
245 | int dcfclk_khz; | 245 | int dcfclk_khz; |
246 | int dcfclk_deep_sleep_khz; | 246 | int dcfclk_deep_sleep_khz; |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h b/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h index 1e231f6de732..132d18d4b293 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h +++ b/drivers/gpu/drm/amd/display/dc/inc/dcn_calcs.h | |||
@@ -349,10 +349,10 @@ struct dcn_bw_internal_vars { | |||
349 | float dst_x_after_scaler; | 349 | float dst_x_after_scaler; |
350 | float dst_y_after_scaler; | 350 | float dst_y_after_scaler; |
351 | float time_calc; | 351 | float time_calc; |
352 | float v_update_offset[number_of_planes_minus_one + 1]; | 352 | float v_update_offset[number_of_planes_minus_one + 1][2]; |
353 | float total_repeater_delay; | 353 | float total_repeater_delay; |
354 | float v_update_width[number_of_planes_minus_one + 1]; | 354 | float v_update_width[number_of_planes_minus_one + 1][2]; |
355 | float v_ready_offset[number_of_planes_minus_one + 1]; | 355 | float v_ready_offset[number_of_planes_minus_one + 1][2]; |
356 | float time_setup; | 356 | float time_setup; |
357 | float extra_latency; | 357 | float extra_latency; |
358 | float maximum_vstartup; | 358 | float maximum_vstartup; |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/abm.h b/drivers/gpu/drm/amd/display/dc/inc/hw/abm.h index 48217ecfabd4..a83a48494613 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/abm.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/abm.h | |||
@@ -50,9 +50,9 @@ struct abm_funcs { | |||
50 | bool (*set_backlight_level)(struct abm *abm, | 50 | bool (*set_backlight_level)(struct abm *abm, |
51 | unsigned int backlight_level, | 51 | unsigned int backlight_level, |
52 | unsigned int frame_ramp, | 52 | unsigned int frame_ramp, |
53 | unsigned int controller_id); | 53 | unsigned int controller_id, |
54 | bool use_smooth_brightness); | ||
54 | unsigned int (*get_current_backlight_8_bit)(struct abm *abm); | 55 | unsigned int (*get_current_backlight_8_bit)(struct abm *abm); |
55 | bool (*is_dmcu_initialized)(struct abm *abm); | ||
56 | }; | 56 | }; |
57 | 57 | ||
58 | #endif | 58 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h index b59712b41b81..ce206355461b 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h | |||
@@ -63,6 +63,7 @@ struct dmcu_funcs { | |||
63 | unsigned int wait_loop_number); | 63 | unsigned int wait_loop_number); |
64 | void (*get_psr_wait_loop)(struct dmcu *dmcu, | 64 | void (*get_psr_wait_loop)(struct dmcu *dmcu, |
65 | unsigned int *psr_wait_loop_number); | 65 | unsigned int *psr_wait_loop_number); |
66 | bool (*is_dmcu_initialized)(struct dmcu *dmcu); | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | #endif | 69 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h index ccb4896975c2..25edbde6163e 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h | |||
@@ -68,7 +68,7 @@ struct dpp_funcs { | |||
68 | 68 | ||
69 | void (*dpp_set_csc_adjustment)( | 69 | void (*dpp_set_csc_adjustment)( |
70 | struct dpp *dpp, | 70 | struct dpp *dpp, |
71 | const struct out_csc_color_matrix *tbl_entry); | 71 | const uint16_t *regval); |
72 | 72 | ||
73 | void (*dpp_power_on_regamma_lut)( | 73 | void (*dpp_power_on_regamma_lut)( |
74 | struct dpp *dpp, | 74 | struct dpp *dpp, |
@@ -122,7 +122,7 @@ struct dpp_funcs { | |||
122 | 122 | ||
123 | void (*set_cursor_attributes)( | 123 | void (*set_cursor_attributes)( |
124 | struct dpp *dpp_base, | 124 | struct dpp *dpp_base, |
125 | const struct dc_cursor_attributes *attr); | 125 | enum dc_cursor_color_format color_format); |
126 | 126 | ||
127 | void (*set_cursor_position)( | 127 | void (*set_cursor_position)( |
128 | struct dpp *dpp_base, | 128 | struct dpp *dpp_base, |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h index 49b12f602e79..b7c7e70022e4 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hubp.h | |||
@@ -28,6 +28,20 @@ | |||
28 | 28 | ||
29 | #include "mem_input.h" | 29 | #include "mem_input.h" |
30 | 30 | ||
31 | |||
32 | enum cursor_pitch { | ||
33 | CURSOR_PITCH_64_PIXELS = 0, | ||
34 | CURSOR_PITCH_128_PIXELS, | ||
35 | CURSOR_PITCH_256_PIXELS | ||
36 | }; | ||
37 | |||
38 | enum cursor_lines_per_chunk { | ||
39 | CURSOR_LINE_PER_CHUNK_2 = 1, | ||
40 | CURSOR_LINE_PER_CHUNK_4, | ||
41 | CURSOR_LINE_PER_CHUNK_8, | ||
42 | CURSOR_LINE_PER_CHUNK_16 | ||
43 | }; | ||
44 | |||
31 | struct hubp { | 45 | struct hubp { |
32 | struct hubp_funcs *funcs; | 46 | struct hubp_funcs *funcs; |
33 | struct dc_context *ctx; | 47 | struct dc_context *ctx; |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h b/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h index ddc56700109b..e3f0b4056318 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h | |||
@@ -126,36 +126,12 @@ struct default_adjustment { | |||
126 | bool force_hw_default; | 126 | bool force_hw_default; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | struct out_csc_color_matrix { | ||
130 | enum dc_color_space color_space; | ||
131 | uint16_t regval[12]; | ||
132 | }; | ||
133 | 129 | ||
134 | struct output_csc_matrix { | 130 | struct out_csc_color_matrix { |
135 | enum dc_color_space color_space; | 131 | enum dc_color_space color_space; |
136 | uint16_t regval[12]; | 132 | uint16_t regval[12]; |
137 | }; | 133 | }; |
138 | 134 | ||
139 | static const struct output_csc_matrix output_csc_matrix[] = { | ||
140 | { COLOR_SPACE_SRGB, | ||
141 | { 0x2000, 0, 0, 0, 0, 0x2000, 0, 0, 0, 0, 0x2000, 0} }, | ||
142 | { COLOR_SPACE_SRGB_LIMITED, | ||
143 | { 0x1B67, 0, 0, 0x201, 0, 0x1B67, 0, 0x201, 0, 0, 0x1B67, 0x201} }, | ||
144 | { COLOR_SPACE_YCBCR601, | ||
145 | { 0xE04, 0xF444, 0xFDB9, 0x1004, 0x831, 0x1016, 0x320, 0x201, 0xFB45, | ||
146 | 0xF6B7, 0xE04, 0x1004} }, | ||
147 | { COLOR_SPACE_YCBCR709, | ||
148 | { 0xE04, 0xF345, 0xFEB7, 0x1004, 0x5D3, 0x1399, 0x1FA, | ||
149 | 0x201, 0xFCCA, 0xF533, 0xE04, 0x1004} }, | ||
150 | |||
151 | /* TODO: correct values below */ | ||
152 | { COLOR_SPACE_YCBCR601_LIMITED, | ||
153 | { 0xE00, 0xF447, 0xFDB9, 0x1000, 0x991, | ||
154 | 0x12C9, 0x3A6, 0x200, 0xFB47, 0xF6B9, 0xE00, 0x1000} }, | ||
155 | { COLOR_SPACE_YCBCR709_LIMITED, | ||
156 | { 0xE00, 0xF349, 0xFEB7, 0x1000, 0x6CE, 0x16E3, | ||
157 | 0x24F, 0x200, 0xFCCB, 0xF535, 0xE00, 0x1000} }, | ||
158 | }; | ||
159 | 135 | ||
160 | enum opp_regamma { | 136 | enum opp_regamma { |
161 | OPP_REGAMMA_BYPASS = 0, | 137 | OPP_REGAMMA_BYPASS = 0, |
@@ -178,4 +154,41 @@ struct dc_bias_and_scale { | |||
178 | uint16_t bias_blue; | 154 | uint16_t bias_blue; |
179 | }; | 155 | }; |
180 | 156 | ||
157 | enum test_pattern_dyn_range { | ||
158 | TEST_PATTERN_DYN_RANGE_VESA = 0, | ||
159 | TEST_PATTERN_DYN_RANGE_CEA | ||
160 | }; | ||
161 | |||
162 | enum test_pattern_mode { | ||
163 | TEST_PATTERN_MODE_COLORSQUARES_RGB = 0, | ||
164 | TEST_PATTERN_MODE_COLORSQUARES_YCBCR601, | ||
165 | TEST_PATTERN_MODE_COLORSQUARES_YCBCR709, | ||
166 | TEST_PATTERN_MODE_VERTICALBARS, | ||
167 | TEST_PATTERN_MODE_HORIZONTALBARS, | ||
168 | TEST_PATTERN_MODE_SINGLERAMP_RGB, | ||
169 | TEST_PATTERN_MODE_DUALRAMP_RGB | ||
170 | }; | ||
171 | |||
172 | enum test_pattern_color_format { | ||
173 | TEST_PATTERN_COLOR_FORMAT_BPC_6 = 0, | ||
174 | TEST_PATTERN_COLOR_FORMAT_BPC_8, | ||
175 | TEST_PATTERN_COLOR_FORMAT_BPC_10, | ||
176 | TEST_PATTERN_COLOR_FORMAT_BPC_12 | ||
177 | }; | ||
178 | |||
179 | enum controller_dp_test_pattern { | ||
180 | CONTROLLER_DP_TEST_PATTERN_D102 = 0, | ||
181 | CONTROLLER_DP_TEST_PATTERN_SYMBOLERROR, | ||
182 | CONTROLLER_DP_TEST_PATTERN_PRBS7, | ||
183 | CONTROLLER_DP_TEST_PATTERN_COLORSQUARES, | ||
184 | CONTROLLER_DP_TEST_PATTERN_VERTICALBARS, | ||
185 | CONTROLLER_DP_TEST_PATTERN_HORIZONTALBARS, | ||
186 | CONTROLLER_DP_TEST_PATTERN_COLORRAMP, | ||
187 | CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, | ||
188 | CONTROLLER_DP_TEST_PATTERN_RESERVED_8, | ||
189 | CONTROLLER_DP_TEST_PATTERN_RESERVED_9, | ||
190 | CONTROLLER_DP_TEST_PATTERN_RESERVED_A, | ||
191 | CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA | ||
192 | }; | ||
193 | |||
181 | #endif /* __DAL_HW_SHARED_H__ */ | 194 | #endif /* __DAL_HW_SHARED_H__ */ |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h index 72ea33526a5c..23a8d5e53a89 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/mpc.h | |||
@@ -26,7 +26,10 @@ | |||
26 | #define __DC_MPCC_H__ | 26 | #define __DC_MPCC_H__ |
27 | 27 | ||
28 | #include "dc_hw_types.h" | 28 | #include "dc_hw_types.h" |
29 | #include "opp.h" | 29 | #include "hw_shared.h" |
30 | |||
31 | #define MAX_MPCC 6 | ||
32 | #define MAX_OPP 6 | ||
30 | 33 | ||
31 | enum mpc_output_csc_mode { | 34 | enum mpc_output_csc_mode { |
32 | MPC_OUTPUT_CSC_DISABLE = 0, | 35 | MPC_OUTPUT_CSC_DISABLE = 0, |
@@ -34,45 +37,151 @@ enum mpc_output_csc_mode { | |||
34 | MPC_OUTPUT_CSC_COEF_B | 37 | MPC_OUTPUT_CSC_COEF_B |
35 | }; | 38 | }; |
36 | 39 | ||
37 | struct mpcc_cfg { | ||
38 | int dpp_id; | ||
39 | int opp_id; | ||
40 | struct mpc_tree_cfg *tree_cfg; | ||
41 | unsigned int z_index; | ||
42 | 40 | ||
43 | struct tg_color black_color; | 41 | enum mpcc_blend_mode { |
44 | bool per_pixel_alpha; | 42 | MPCC_BLEND_MODE_BYPASS, |
45 | bool pre_multiplied_alpha; | 43 | MPCC_BLEND_MODE_TOP_LAYER_PASSTHROUGH, |
44 | MPCC_BLEND_MODE_TOP_LAYER_ONLY, | ||
45 | MPCC_BLEND_MODE_TOP_BOT_BLENDING | ||
46 | }; | ||
47 | |||
48 | enum mpcc_alpha_blend_mode { | ||
49 | MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA, | ||
50 | MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN, | ||
51 | MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * MPCC blending configuration | ||
56 | */ | ||
57 | struct mpcc_blnd_cfg { | ||
58 | struct tg_color black_color; /* background color */ | ||
59 | enum mpcc_alpha_blend_mode alpha_mode; /* alpha blend mode */ | ||
60 | bool pre_multiplied_alpha; /* alpha pre-multiplied mode flag */ | ||
61 | int global_gain; | ||
62 | int global_alpha; | ||
63 | bool overlap_only; | ||
64 | |||
65 | }; | ||
66 | |||
67 | struct mpcc_sm_cfg { | ||
68 | bool enable; | ||
69 | /* 0-single plane,2-row subsampling,4-column subsampling,6-checkboard subsampling */ | ||
70 | int sm_mode; | ||
71 | /* 0- disable frame alternate, 1- enable frame alternate */ | ||
72 | bool frame_alt; | ||
73 | /* 0- disable field alternate, 1- enable field alternate */ | ||
74 | bool field_alt; | ||
75 | /* 0-no force,2-force frame polarity from top,3-force frame polarity from bottom */ | ||
76 | int force_next_frame_porlarity; | ||
77 | /* 0-no force,2-force field polarity from top,3-force field polarity from bottom */ | ||
78 | int force_next_field_polarity; | ||
79 | }; | ||
80 | |||
81 | /* | ||
82 | * MPCC connection and blending configuration for a single MPCC instance. | ||
83 | * This struct is used as a node in an MPC tree. | ||
84 | */ | ||
85 | struct mpcc { | ||
86 | int mpcc_id; /* MPCC physical instance */ | ||
87 | int dpp_id; /* DPP input to this MPCC */ | ||
88 | struct mpcc *mpcc_bot; /* pointer to bottom layer MPCC. NULL when not connected */ | ||
89 | struct mpcc_blnd_cfg blnd_cfg; /* The blending configuration for this MPCC */ | ||
90 | struct mpcc_sm_cfg sm_cfg; /* stereo mix setting for this MPCC */ | ||
91 | }; | ||
92 | |||
93 | /* | ||
94 | * MPC tree represents all MPCC connections for a pipe. | ||
95 | */ | ||
96 | struct mpc_tree { | ||
97 | int opp_id; /* The OPP instance that owns this MPC tree */ | ||
98 | struct mpcc *opp_list; /* The top MPCC layer of the MPC tree that outputs to OPP endpoint */ | ||
46 | }; | 99 | }; |
47 | 100 | ||
48 | struct mpc { | 101 | struct mpc { |
49 | const struct mpc_funcs *funcs; | 102 | const struct mpc_funcs *funcs; |
50 | struct dc_context *ctx; | 103 | struct dc_context *ctx; |
104 | |||
105 | struct mpcc mpcc_array[MAX_MPCC]; | ||
51 | }; | 106 | }; |
52 | 107 | ||
53 | struct mpc_funcs { | 108 | struct mpc_funcs { |
54 | int (*add)(struct mpc *mpc, struct mpcc_cfg *cfg); | 109 | /* |
110 | * Insert DPP into MPC tree based on specified blending position. | ||
111 | * Only used for planes that are part of blending chain for OPP output | ||
112 | * | ||
113 | * Parameters: | ||
114 | * [in/out] mpc - MPC context. | ||
115 | * [in/out] tree - MPC tree structure that plane will be added to. | ||
116 | * [in] blnd_cfg - MPCC blending configuration for the new blending layer. | ||
117 | * [in] sm_cfg - MPCC stereo mix configuration for the new blending layer. | ||
118 | * stereo mix must disable for the very bottom layer of the tree config. | ||
119 | * [in] insert_above_mpcc - Insert new plane above this MPCC. If NULL, insert as bottom plane. | ||
120 | * [in] dpp_id - DPP instance for the plane to be added. | ||
121 | * [in] mpcc_id - The MPCC physical instance to use for blending. | ||
122 | * | ||
123 | * Return: struct mpcc* - MPCC that was added. | ||
124 | */ | ||
125 | struct mpcc* (*insert_plane)( | ||
126 | struct mpc *mpc, | ||
127 | struct mpc_tree *tree, | ||
128 | struct mpcc_blnd_cfg *blnd_cfg, | ||
129 | struct mpcc_sm_cfg *sm_cfg, | ||
130 | struct mpcc *insert_above_mpcc, | ||
131 | int dpp_id, | ||
132 | int mpcc_id); | ||
55 | 133 | ||
56 | void (*remove)(struct mpc *mpc, | 134 | /* |
57 | struct mpc_tree_cfg *tree_cfg, | 135 | * Remove a specified MPCC from the MPC tree. |
58 | int opp_id, | 136 | * |
59 | int mpcc_inst); | 137 | * Parameters: |
138 | * [in/out] mpc - MPC context. | ||
139 | * [in/out] tree - MPC tree structure that plane will be removed from. | ||
140 | * [in/out] mpcc - MPCC to be removed from tree. | ||
141 | * | ||
142 | * Return: void | ||
143 | */ | ||
144 | void (*remove_mpcc)( | ||
145 | struct mpc *mpc, | ||
146 | struct mpc_tree *tree, | ||
147 | struct mpcc *mpcc); | ||
60 | 148 | ||
61 | void (*wait_for_idle)(struct mpc *mpc, int id); | 149 | /* |
150 | * Reset the MPCC HW status by disconnecting all muxes. | ||
151 | * | ||
152 | * Parameters: | ||
153 | * [in/out] mpc - MPC context. | ||
154 | * | ||
155 | * Return: void | ||
156 | */ | ||
157 | void (*mpc_init)(struct mpc *mpc); | ||
62 | 158 | ||
63 | void (*update_blend_mode)(struct mpc *mpc, struct mpcc_cfg *cfg); | 159 | /* |
160 | * Update the blending configuration for a specified MPCC. | ||
161 | * | ||
162 | * Parameters: | ||
163 | * [in/out] mpc - MPC context. | ||
164 | * [in] blnd_cfg - MPCC blending configuration. | ||
165 | * [in] mpcc_id - The MPCC physical instance. | ||
166 | * | ||
167 | * Return: void | ||
168 | */ | ||
169 | void (*update_blending)( | ||
170 | struct mpc *mpc, | ||
171 | struct mpcc_blnd_cfg *blnd_cfg, | ||
172 | int mpcc_id); | ||
64 | 173 | ||
65 | int (*get_opp_id)(struct mpc *mpc, int mpcc_id); | 174 | struct mpcc* (*get_mpcc_for_dpp)( |
175 | struct mpc_tree *tree, | ||
176 | int dpp_id); | ||
177 | |||
178 | void (*wait_for_idle)(struct mpc *mpc, int id); | ||
66 | 179 | ||
67 | void (*set_output_csc)(struct mpc *mpc, | 180 | void (*assert_mpcc_idle_before_connect)(struct mpc *mpc, int mpcc_id); |
68 | int opp_id, | ||
69 | const struct out_csc_color_matrix *tbl_entry, | ||
70 | enum mpc_output_csc_mode ocsc_mode); | ||
71 | 181 | ||
72 | void (*set_ocsc_default)(struct mpc *mpc, | 182 | void (*init_mpcc_list_from_hw)( |
73 | int opp_id, | 183 | struct mpc *mpc, |
74 | enum dc_color_space color_space, | 184 | struct mpc_tree *tree); |
75 | enum mpc_output_csc_mode ocsc_mode); | ||
76 | 185 | ||
77 | }; | 186 | }; |
78 | 187 | ||
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/opp.h b/drivers/gpu/drm/amd/display/dc/inc/hw/opp.h index 579d1059a3d4..ab8fb77f1ae5 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/opp.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/opp.h | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "hw_shared.h" | 29 | #include "hw_shared.h" |
30 | #include "dc_hw_types.h" | 30 | #include "dc_hw_types.h" |
31 | #include "transform.h" | 31 | #include "transform.h" |
32 | #include "mpc.h" | ||
32 | 33 | ||
33 | struct fixed31_32; | 34 | struct fixed31_32; |
34 | 35 | ||
@@ -204,7 +205,7 @@ struct output_pixel_processor { | |||
204 | struct dc_context *ctx; | 205 | struct dc_context *ctx; |
205 | uint32_t inst; | 206 | uint32_t inst; |
206 | struct pwl_params regamma_params; | 207 | struct pwl_params regamma_params; |
207 | struct mpc_tree_cfg mpc_tree; | 208 | struct mpc_tree mpc_tree_params; |
208 | bool mpcc_disconnect_pending[MAX_PIPES]; | 209 | bool mpcc_disconnect_pending[MAX_PIPES]; |
209 | const struct opp_funcs *funcs; | 210 | const struct opp_funcs *funcs; |
210 | }; | 211 | }; |
@@ -248,6 +249,21 @@ enum ovl_csc_adjust_item { | |||
248 | OVERLAY_COLOR_TEMPERATURE | 249 | OVERLAY_COLOR_TEMPERATURE |
249 | }; | 250 | }; |
250 | 251 | ||
252 | enum oppbuf_display_segmentation { | ||
253 | OPPBUF_DISPLAY_SEGMENTATION_1_SEGMENT = 0, | ||
254 | OPPBUF_DISPLAY_SEGMENTATION_2_SEGMENT = 1, | ||
255 | OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT = 2, | ||
256 | OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_LEFT = 3, | ||
257 | OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_RIGHT = 4 | ||
258 | }; | ||
259 | |||
260 | struct oppbuf_params { | ||
261 | uint32_t active_width; | ||
262 | enum oppbuf_display_segmentation mso_segmentation; | ||
263 | uint32_t mso_overlap_pixel_num; | ||
264 | uint32_t pixel_repetition; | ||
265 | }; | ||
266 | |||
251 | struct opp_funcs { | 267 | struct opp_funcs { |
252 | 268 | ||
253 | 269 | ||
@@ -276,26 +292,11 @@ struct opp_funcs { | |||
276 | 292 | ||
277 | void (*opp_destroy)(struct output_pixel_processor **opp); | 293 | void (*opp_destroy)(struct output_pixel_processor **opp); |
278 | 294 | ||
279 | void (*opp_set_stereo_polarity)( | 295 | void (*opp_program_stereo)( |
280 | struct output_pixel_processor *opp, | ||
281 | bool enable, | ||
282 | bool rightEyePolarity); | ||
283 | |||
284 | void (*opp_set_test_pattern)( | ||
285 | struct output_pixel_processor *opp, | ||
286 | bool enable); | ||
287 | |||
288 | void (*opp_dpg_blank_enable)( | ||
289 | struct output_pixel_processor *opp, | ||
290 | bool enable, | ||
291 | const struct tg_color *color, | ||
292 | int width, | ||
293 | int height); | ||
294 | |||
295 | void (*opp_convert_pti)( | ||
296 | struct output_pixel_processor *opp, | 296 | struct output_pixel_processor *opp, |
297 | bool enable, | 297 | bool enable, |
298 | bool polarity); | 298 | const struct dc_crtc_timing *timing); |
299 | |||
299 | }; | 300 | }; |
300 | 301 | ||
301 | #endif | 302 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h b/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h index 860259913d78..ec312f1a3e55 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/timing_generator.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #ifndef __DAL_TIMING_GENERATOR_TYPES_H__ | 26 | #ifndef __DAL_TIMING_GENERATOR_TYPES_H__ |
27 | #define __DAL_TIMING_GENERATOR_TYPES_H__ | 27 | #define __DAL_TIMING_GENERATOR_TYPES_H__ |
28 | 28 | ||
29 | #include "hw_shared.h" | ||
30 | |||
29 | struct dc_bios; | 31 | struct dc_bios; |
30 | 32 | ||
31 | /* Contains CRTC vertical/horizontal pixel counters */ | 33 | /* Contains CRTC vertical/horizontal pixel counters */ |
@@ -40,6 +42,19 @@ struct dcp_gsl_params { | |||
40 | int gsl_master; | 42 | int gsl_master; |
41 | }; | 43 | }; |
42 | 44 | ||
45 | struct gsl_params { | ||
46 | int gsl0_en; | ||
47 | int gsl1_en; | ||
48 | int gsl2_en; | ||
49 | int gsl_master_en; | ||
50 | int gsl_master_mode; | ||
51 | int master_update_lock_gsl_en; | ||
52 | int gsl_window_start_x; | ||
53 | int gsl_window_end_x; | ||
54 | int gsl_window_start_y; | ||
55 | int gsl_window_end_y; | ||
56 | }; | ||
57 | |||
43 | /* define the structure of Dynamic Refresh Mode */ | 58 | /* define the structure of Dynamic Refresh Mode */ |
44 | struct drr_params { | 59 | struct drr_params { |
45 | uint32_t vertical_total_min; | 60 | uint32_t vertical_total_min; |
@@ -50,43 +65,6 @@ struct drr_params { | |||
50 | #define LEFT_EYE_3D_PRIMARY_SURFACE 1 | 65 | #define LEFT_EYE_3D_PRIMARY_SURFACE 1 |
51 | #define RIGHT_EYE_3D_PRIMARY_SURFACE 0 | 66 | #define RIGHT_EYE_3D_PRIMARY_SURFACE 0 |
52 | 67 | ||
53 | enum test_pattern_dyn_range { | ||
54 | TEST_PATTERN_DYN_RANGE_VESA = 0, | ||
55 | TEST_PATTERN_DYN_RANGE_CEA | ||
56 | }; | ||
57 | |||
58 | enum test_pattern_mode { | ||
59 | TEST_PATTERN_MODE_COLORSQUARES_RGB = 0, | ||
60 | TEST_PATTERN_MODE_COLORSQUARES_YCBCR601, | ||
61 | TEST_PATTERN_MODE_COLORSQUARES_YCBCR709, | ||
62 | TEST_PATTERN_MODE_VERTICALBARS, | ||
63 | TEST_PATTERN_MODE_HORIZONTALBARS, | ||
64 | TEST_PATTERN_MODE_SINGLERAMP_RGB, | ||
65 | TEST_PATTERN_MODE_DUALRAMP_RGB | ||
66 | }; | ||
67 | |||
68 | enum test_pattern_color_format { | ||
69 | TEST_PATTERN_COLOR_FORMAT_BPC_6 = 0, | ||
70 | TEST_PATTERN_COLOR_FORMAT_BPC_8, | ||
71 | TEST_PATTERN_COLOR_FORMAT_BPC_10, | ||
72 | TEST_PATTERN_COLOR_FORMAT_BPC_12 | ||
73 | }; | ||
74 | |||
75 | enum controller_dp_test_pattern { | ||
76 | CONTROLLER_DP_TEST_PATTERN_D102 = 0, | ||
77 | CONTROLLER_DP_TEST_PATTERN_SYMBOLERROR, | ||
78 | CONTROLLER_DP_TEST_PATTERN_PRBS7, | ||
79 | CONTROLLER_DP_TEST_PATTERN_COLORSQUARES, | ||
80 | CONTROLLER_DP_TEST_PATTERN_VERTICALBARS, | ||
81 | CONTROLLER_DP_TEST_PATTERN_HORIZONTALBARS, | ||
82 | CONTROLLER_DP_TEST_PATTERN_COLORRAMP, | ||
83 | CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, | ||
84 | CONTROLLER_DP_TEST_PATTERN_RESERVED_8, | ||
85 | CONTROLLER_DP_TEST_PATTERN_RESERVED_9, | ||
86 | CONTROLLER_DP_TEST_PATTERN_RESERVED_A, | ||
87 | CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA | ||
88 | }; | ||
89 | |||
90 | enum crtc_state { | 68 | enum crtc_state { |
91 | CRTC_STATE_VBLANK = 0, | 69 | CRTC_STATE_VBLANK = 0, |
92 | CRTC_STATE_VACTIVE | 70 | CRTC_STATE_VACTIVE |
@@ -100,6 +78,12 @@ struct _dlg_otg_param { | |||
100 | enum signal_type signal; | 78 | enum signal_type signal; |
101 | }; | 79 | }; |
102 | 80 | ||
81 | struct vupdate_keepout_params { | ||
82 | int start_offset; | ||
83 | int end_offset; | ||
84 | int enable; | ||
85 | }; | ||
86 | |||
103 | struct crtc_stereo_flags { | 87 | struct crtc_stereo_flags { |
104 | uint8_t PROGRAM_STEREO : 1; | 88 | uint8_t PROGRAM_STEREO : 1; |
105 | uint8_t PROGRAM_POLARITY : 1; | 89 | uint8_t PROGRAM_POLARITY : 1; |
@@ -187,6 +171,8 @@ struct timing_generator_funcs { | |||
187 | 171 | ||
188 | void (*tg_init)(struct timing_generator *tg); | 172 | void (*tg_init)(struct timing_generator *tg); |
189 | bool (*is_tg_enabled)(struct timing_generator *tg); | 173 | bool (*is_tg_enabled)(struct timing_generator *tg); |
174 | bool (*is_optc_underflow_occurred)(struct timing_generator *tg); | ||
175 | void (*clear_optc_underflow)(struct timing_generator *tg); | ||
190 | }; | 176 | }; |
191 | 177 | ||
192 | #endif | 178 | #endif |
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h index 5dc4ecf618ff..4c0aa56f7bae 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "dc_types.h" | 28 | #include "dc_types.h" |
29 | #include "clock_source.h" | 29 | #include "clock_source.h" |
30 | #include "inc/hw/timing_generator.h" | 30 | #include "inc/hw/timing_generator.h" |
31 | #include "inc/hw/opp.h" | ||
31 | #include "inc/hw/link_encoder.h" | 32 | #include "inc/hw/link_encoder.h" |
32 | #include "core_status.h" | 33 | #include "core_status.h" |
33 | 34 | ||
@@ -40,6 +41,7 @@ enum pipe_gating_control { | |||
40 | struct dce_hwseq_wa { | 41 | struct dce_hwseq_wa { |
41 | bool blnd_crtc_trigger; | 42 | bool blnd_crtc_trigger; |
42 | bool DEGVIDCN10_253; | 43 | bool DEGVIDCN10_253; |
44 | bool false_optc_underflow; | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | struct hwseq_wa_state { | 47 | struct hwseq_wa_state { |
@@ -137,10 +139,6 @@ struct hw_sequencer_funcs { | |||
137 | 139 | ||
138 | void (*disable_plane)(struct dc *dc, struct pipe_ctx *pipe_ctx); | 140 | void (*disable_plane)(struct dc *dc, struct pipe_ctx *pipe_ctx); |
139 | 141 | ||
140 | void (*enable_plane)(struct dc *dc, | ||
141 | struct pipe_ctx *pipe, | ||
142 | struct dc_state *context); | ||
143 | |||
144 | void (*update_info_frame)(struct pipe_ctx *pipe_ctx); | 142 | void (*update_info_frame)(struct pipe_ctx *pipe_ctx); |
145 | 143 | ||
146 | void (*enable_stream)(struct pipe_ctx *pipe_ctx); | 144 | void (*enable_stream)(struct pipe_ctx *pipe_ctx); |
@@ -198,6 +196,7 @@ struct hw_sequencer_funcs { | |||
198 | void (*edp_backlight_control)( | 196 | void (*edp_backlight_control)( |
199 | struct dc_link *link, | 197 | struct dc_link *link, |
200 | bool enable); | 198 | bool enable); |
199 | void (*edp_wait_for_hpd_ready)(struct dc_link *link, bool power_up); | ||
201 | 200 | ||
202 | }; | 201 | }; |
203 | 202 | ||
@@ -209,4 +208,8 @@ void color_space_to_black_color( | |||
209 | bool hwss_wait_for_blank_complete( | 208 | bool hwss_wait_for_blank_complete( |
210 | struct timing_generator *tg); | 209 | struct timing_generator *tg); |
211 | 210 | ||
211 | const uint16_t *find_color_matrix( | ||
212 | enum dc_color_space color_space, | ||
213 | uint32_t *array_size); | ||
214 | |||
212 | #endif /* __DC_HW_SEQUENCER_H__ */ | 215 | #endif /* __DC_HW_SEQUENCER_H__ */ |
diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h index a87c0329541f..1fcbc99e63b5 100644 --- a/drivers/gpu/drm/amd/display/dc/os_types.h +++ b/drivers/gpu/drm/amd/display/dc/os_types.h | |||
@@ -26,8 +26,6 @@ | |||
26 | #ifndef _OS_TYPES_H_ | 26 | #ifndef _OS_TYPES_H_ |
27 | #define _OS_TYPES_H_ | 27 | #define _OS_TYPES_H_ |
28 | 28 | ||
29 | #if defined __KERNEL__ | ||
30 | |||
31 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
32 | #include <linux/types.h> | 30 | #include <linux/types.h> |
33 | #include <drm/drmP.h> | 31 | #include <drm/drmP.h> |
@@ -46,14 +44,12 @@ | |||
46 | #undef WRITE | 44 | #undef WRITE |
47 | #undef FRAME_SIZE | 45 | #undef FRAME_SIZE |
48 | 46 | ||
49 | #define dm_output_to_console(fmt, ...) DRM_INFO(fmt, ##__VA_ARGS__) | 47 | #define dm_output_to_console(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__) |
50 | 48 | ||
51 | #define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__) | 49 | #define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__) |
52 | 50 | ||
53 | #define dm_debug(fmt, ...) DRM_DEBUG_KMS(fmt, ##__VA_ARGS__) | 51 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) |
54 | 52 | #include <asm/fpu/api.h> | |
55 | #define dm_vlog(fmt, args) vprintk(fmt, args) | ||
56 | |||
57 | #endif | 53 | #endif |
58 | 54 | ||
59 | /* | 55 | /* |
@@ -89,8 +85,4 @@ | |||
89 | BREAK_TO_DEBUGGER(); \ | 85 | BREAK_TO_DEBUGGER(); \ |
90 | } while (0) | 86 | } while (0) |
91 | 87 | ||
92 | #if defined(CONFIG_DRM_AMD_DC_DCN1_0) | ||
93 | #include <asm/fpu/api.h> | ||
94 | #endif | ||
95 | |||
96 | #endif /* _OS_TYPES_H_ */ | 88 | #endif /* _OS_TYPES_H_ */ |
diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h b/drivers/gpu/drm/amd/display/include/fixed31_32.h index 3248f699daf2..4badaedbaadd 100644 --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h | |||
@@ -463,4 +463,11 @@ uint32_t dal_fixed31_32_u2d19( | |||
463 | uint32_t dal_fixed31_32_u0d19( | 463 | uint32_t dal_fixed31_32_u0d19( |
464 | struct fixed31_32 arg); | 464 | struct fixed31_32 arg); |
465 | 465 | ||
466 | |||
467 | uint32_t dal_fixed31_32_clamp_u0d14( | ||
468 | struct fixed31_32 arg); | ||
469 | |||
470 | uint32_t dal_fixed31_32_clamp_u0d10( | ||
471 | struct fixed31_32 arg); | ||
472 | |||
466 | #endif | 473 | #endif |
diff --git a/drivers/gpu/drm/amd/display/include/grph_object_id.h b/drivers/gpu/drm/amd/display/include/grph_object_id.h index 03a7a9ca95ea..c4197432eb7c 100644 --- a/drivers/gpu/drm/amd/display/include/grph_object_id.h +++ b/drivers/gpu/drm/amd/display/include/grph_object_id.h | |||
@@ -233,10 +233,6 @@ static inline struct graphics_object_id dal_graphics_object_id_init( | |||
233 | return result; | 233 | return result; |
234 | } | 234 | } |
235 | 235 | ||
236 | bool dal_graphics_object_id_is_equal( | ||
237 | struct graphics_object_id id1, | ||
238 | struct graphics_object_id id2); | ||
239 | |||
240 | /* Based on internal data members memory layout */ | 236 | /* Based on internal data members memory layout */ |
241 | static inline uint32_t dal_graphics_object_id_to_uint( | 237 | static inline uint32_t dal_graphics_object_id_to_uint( |
242 | struct graphics_object_id id) | 238 | struct graphics_object_id id) |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_default.h b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_default.h index 663d3af35baf..5bf84c6d0ec3 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_default.h +++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_default.h | |||
@@ -436,7 +436,6 @@ | |||
436 | #define mmTA_CNTL_DEFAULT 0x8004d850 | 436 | #define mmTA_CNTL_DEFAULT 0x8004d850 |
437 | #define mmTA_CNTL_AUX_DEFAULT 0x00000000 | 437 | #define mmTA_CNTL_AUX_DEFAULT 0x00000000 |
438 | #define mmTA_RESERVED_010C_DEFAULT 0x00000000 | 438 | #define mmTA_RESERVED_010C_DEFAULT 0x00000000 |
439 | #define mmTA_GRAD_ADJ_DEFAULT 0x40000040 | ||
440 | #define mmTA_STATUS_DEFAULT 0x00000000 | 439 | #define mmTA_STATUS_DEFAULT 0x00000000 |
441 | #define mmTA_SCRATCH_DEFAULT 0x00000000 | 440 | #define mmTA_SCRATCH_DEFAULT 0x00000000 |
442 | 441 | ||
@@ -1700,7 +1699,6 @@ | |||
1700 | #define mmDB_STENCIL_WRITE_BASE_DEFAULT 0x00000000 | 1699 | #define mmDB_STENCIL_WRITE_BASE_DEFAULT 0x00000000 |
1701 | #define mmDB_STENCIL_WRITE_BASE_HI_DEFAULT 0x00000000 | 1700 | #define mmDB_STENCIL_WRITE_BASE_HI_DEFAULT 0x00000000 |
1702 | #define mmDB_DFSM_CONTROL_DEFAULT 0x00000000 | 1701 | #define mmDB_DFSM_CONTROL_DEFAULT 0x00000000 |
1703 | #define mmDB_RENDER_FILTER_DEFAULT 0x00000000 | ||
1704 | #define mmDB_Z_INFO2_DEFAULT 0x00000000 | 1702 | #define mmDB_Z_INFO2_DEFAULT 0x00000000 |
1705 | #define mmDB_STENCIL_INFO2_DEFAULT 0x00000000 | 1703 | #define mmDB_STENCIL_INFO2_DEFAULT 0x00000000 |
1706 | #define mmTA_BC_BASE_ADDR_DEFAULT 0x00000000 | 1704 | #define mmTA_BC_BASE_ADDR_DEFAULT 0x00000000 |
@@ -1806,8 +1804,6 @@ | |||
1806 | #define mmPA_SC_RIGHT_VERT_GRID_DEFAULT 0x00000000 | 1804 | #define mmPA_SC_RIGHT_VERT_GRID_DEFAULT 0x00000000 |
1807 | #define mmPA_SC_LEFT_VERT_GRID_DEFAULT 0x00000000 | 1805 | #define mmPA_SC_LEFT_VERT_GRID_DEFAULT 0x00000000 |
1808 | #define mmPA_SC_HORIZ_GRID_DEFAULT 0x00000000 | 1806 | #define mmPA_SC_HORIZ_GRID_DEFAULT 0x00000000 |
1809 | #define mmPA_SC_FOV_WINDOW_LR_DEFAULT 0x00000000 | ||
1810 | #define mmPA_SC_FOV_WINDOW_TB_DEFAULT 0x00000000 | ||
1811 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_DEFAULT 0x00000000 | 1807 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_DEFAULT 0x00000000 |
1812 | #define mmCB_BLEND_RED_DEFAULT 0x00000000 | 1808 | #define mmCB_BLEND_RED_DEFAULT 0x00000000 |
1813 | #define mmCB_BLEND_GREEN_DEFAULT 0x00000000 | 1809 | #define mmCB_BLEND_GREEN_DEFAULT 0x00000000 |
@@ -2072,7 +2068,6 @@ | |||
2072 | #define mmVGT_EVENT_INITIATOR_DEFAULT 0x00000000 | 2068 | #define mmVGT_EVENT_INITIATOR_DEFAULT 0x00000000 |
2073 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_DEFAULT 0x00000000 | 2069 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_DEFAULT 0x00000000 |
2074 | #define mmVGT_DRAW_PAYLOAD_CNTL_DEFAULT 0x00000000 | 2070 | #define mmVGT_DRAW_PAYLOAD_CNTL_DEFAULT 0x00000000 |
2075 | #define mmVGT_INDEX_PAYLOAD_CNTL_DEFAULT 0x00000000 | ||
2076 | #define mmVGT_INSTANCE_STEP_RATE_0_DEFAULT 0x00000000 | 2071 | #define mmVGT_INSTANCE_STEP_RATE_0_DEFAULT 0x00000000 |
2077 | #define mmVGT_INSTANCE_STEP_RATE_1_DEFAULT 0x00000000 | 2072 | #define mmVGT_INSTANCE_STEP_RATE_1_DEFAULT 0x00000000 |
2078 | #define mmVGT_ESGS_RING_ITEMSIZE_DEFAULT 0x00000000 | 2073 | #define mmVGT_ESGS_RING_ITEMSIZE_DEFAULT 0x00000000 |
@@ -2490,7 +2485,6 @@ | |||
2490 | #define mmWD_INDEX_BUF_BASE_DEFAULT 0x00000000 | 2485 | #define mmWD_INDEX_BUF_BASE_DEFAULT 0x00000000 |
2491 | #define mmWD_INDEX_BUF_BASE_HI_DEFAULT 0x00000000 | 2486 | #define mmWD_INDEX_BUF_BASE_HI_DEFAULT 0x00000000 |
2492 | #define mmIA_MULTI_VGT_PARAM_DEFAULT 0x006000ff | 2487 | #define mmIA_MULTI_VGT_PARAM_DEFAULT 0x006000ff |
2493 | #define mmVGT_OBJECT_ID_DEFAULT 0x00000000 | ||
2494 | #define mmVGT_INSTANCE_BASE_ID_DEFAULT 0x00000000 | 2488 | #define mmVGT_INSTANCE_BASE_ID_DEFAULT 0x00000000 |
2495 | #define mmPA_SU_LINE_STIPPLE_VALUE_DEFAULT 0x00000000 | 2489 | #define mmPA_SU_LINE_STIPPLE_VALUE_DEFAULT 0x00000000 |
2496 | #define mmPA_SC_LINE_STIPPLE_STATE_DEFAULT 0x00000000 | 2490 | #define mmPA_SC_LINE_STIPPLE_STATE_DEFAULT 0x00000000 |
@@ -2534,7 +2528,6 @@ | |||
2534 | #define mmSQC_WRITEBACK_DEFAULT 0x00000000 | 2528 | #define mmSQC_WRITEBACK_DEFAULT 0x00000000 |
2535 | #define mmTA_CS_BC_BASE_ADDR_DEFAULT 0x00000000 | 2529 | #define mmTA_CS_BC_BASE_ADDR_DEFAULT 0x00000000 |
2536 | #define mmTA_CS_BC_BASE_ADDR_HI_DEFAULT 0x00000000 | 2530 | #define mmTA_CS_BC_BASE_ADDR_HI_DEFAULT 0x00000000 |
2537 | #define mmTA_GRAD_ADJ_UCONFIG_DEFAULT 0x40000040 | ||
2538 | #define mmDB_OCCLUSION_COUNT0_LOW_DEFAULT 0x00000000 | 2531 | #define mmDB_OCCLUSION_COUNT0_LOW_DEFAULT 0x00000000 |
2539 | #define mmDB_OCCLUSION_COUNT0_HI_DEFAULT 0x00000000 | 2532 | #define mmDB_OCCLUSION_COUNT0_HI_DEFAULT 0x00000000 |
2540 | #define mmDB_OCCLUSION_COUNT1_LOW_DEFAULT 0x00000000 | 2533 | #define mmDB_OCCLUSION_COUNT1_LOW_DEFAULT 0x00000000 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h index e6d6171aa8b9..4ce090db7ef7 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_offset.h | |||
@@ -841,8 +841,6 @@ | |||
841 | #define mmTA_CNTL_AUX_BASE_IDX 0 | 841 | #define mmTA_CNTL_AUX_BASE_IDX 0 |
842 | #define mmTA_RESERVED_010C 0x0543 | 842 | #define mmTA_RESERVED_010C 0x0543 |
843 | #define mmTA_RESERVED_010C_BASE_IDX 0 | 843 | #define mmTA_RESERVED_010C_BASE_IDX 0 |
844 | #define mmTA_GRAD_ADJ 0x0544 | ||
845 | #define mmTA_GRAD_ADJ_BASE_IDX 0 | ||
846 | #define mmTA_STATUS 0x0548 | 844 | #define mmTA_STATUS 0x0548 |
847 | #define mmTA_STATUS_BASE_IDX 0 | 845 | #define mmTA_STATUS_BASE_IDX 0 |
848 | #define mmTA_SCRATCH 0x0564 | 846 | #define mmTA_SCRATCH 0x0564 |
@@ -3330,8 +3328,6 @@ | |||
3330 | #define mmDB_STENCIL_WRITE_BASE_HI_BASE_IDX 1 | 3328 | #define mmDB_STENCIL_WRITE_BASE_HI_BASE_IDX 1 |
3331 | #define mmDB_DFSM_CONTROL 0x0018 | 3329 | #define mmDB_DFSM_CONTROL 0x0018 |
3332 | #define mmDB_DFSM_CONTROL_BASE_IDX 1 | 3330 | #define mmDB_DFSM_CONTROL_BASE_IDX 1 |
3333 | #define mmDB_RENDER_FILTER 0x0019 | ||
3334 | #define mmDB_RENDER_FILTER_BASE_IDX 1 | ||
3335 | #define mmDB_Z_INFO2 0x001a | 3331 | #define mmDB_Z_INFO2 0x001a |
3336 | #define mmDB_Z_INFO2_BASE_IDX 1 | 3332 | #define mmDB_Z_INFO2_BASE_IDX 1 |
3337 | #define mmDB_STENCIL_INFO2 0x001b | 3333 | #define mmDB_STENCIL_INFO2 0x001b |
@@ -3542,10 +3538,6 @@ | |||
3542 | #define mmPA_SC_LEFT_VERT_GRID_BASE_IDX 1 | 3538 | #define mmPA_SC_LEFT_VERT_GRID_BASE_IDX 1 |
3543 | #define mmPA_SC_HORIZ_GRID 0x00ea | 3539 | #define mmPA_SC_HORIZ_GRID 0x00ea |
3544 | #define mmPA_SC_HORIZ_GRID_BASE_IDX 1 | 3540 | #define mmPA_SC_HORIZ_GRID_BASE_IDX 1 |
3545 | #define mmPA_SC_FOV_WINDOW_LR 0x00eb | ||
3546 | #define mmPA_SC_FOV_WINDOW_LR_BASE_IDX 1 | ||
3547 | #define mmPA_SC_FOV_WINDOW_TB 0x00ec | ||
3548 | #define mmPA_SC_FOV_WINDOW_TB_BASE_IDX 1 | ||
3549 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX 0x0103 | 3541 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX 0x0103 |
3550 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_BASE_IDX 1 | 3542 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_BASE_IDX 1 |
3551 | #define mmCB_BLEND_RED 0x0105 | 3543 | #define mmCB_BLEND_RED 0x0105 |
@@ -4074,8 +4066,6 @@ | |||
4074 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_BASE_IDX 1 | 4066 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_BASE_IDX 1 |
4075 | #define mmVGT_DRAW_PAYLOAD_CNTL 0x02a6 | 4067 | #define mmVGT_DRAW_PAYLOAD_CNTL 0x02a6 |
4076 | #define mmVGT_DRAW_PAYLOAD_CNTL_BASE_IDX 1 | 4068 | #define mmVGT_DRAW_PAYLOAD_CNTL_BASE_IDX 1 |
4077 | #define mmVGT_INDEX_PAYLOAD_CNTL 0x02a7 | ||
4078 | #define mmVGT_INDEX_PAYLOAD_CNTL_BASE_IDX 1 | ||
4079 | #define mmVGT_INSTANCE_STEP_RATE_0 0x02a8 | 4069 | #define mmVGT_INSTANCE_STEP_RATE_0 0x02a8 |
4080 | #define mmVGT_INSTANCE_STEP_RATE_0_BASE_IDX 1 | 4070 | #define mmVGT_INSTANCE_STEP_RATE_0_BASE_IDX 1 |
4081 | #define mmVGT_INSTANCE_STEP_RATE_1 0x02a9 | 4071 | #define mmVGT_INSTANCE_STEP_RATE_1 0x02a9 |
@@ -4908,8 +4898,6 @@ | |||
4908 | #define mmWD_INDEX_BUF_BASE_HI_BASE_IDX 1 | 4898 | #define mmWD_INDEX_BUF_BASE_HI_BASE_IDX 1 |
4909 | #define mmIA_MULTI_VGT_PARAM 0x2258 | 4899 | #define mmIA_MULTI_VGT_PARAM 0x2258 |
4910 | #define mmIA_MULTI_VGT_PARAM_BASE_IDX 1 | 4900 | #define mmIA_MULTI_VGT_PARAM_BASE_IDX 1 |
4911 | #define mmVGT_OBJECT_ID 0x2259 | ||
4912 | #define mmVGT_OBJECT_ID_BASE_IDX 1 | ||
4913 | #define mmVGT_INSTANCE_BASE_ID 0x225a | 4901 | #define mmVGT_INSTANCE_BASE_ID 0x225a |
4914 | #define mmVGT_INSTANCE_BASE_ID_BASE_IDX 1 | 4902 | #define mmVGT_INSTANCE_BASE_ID_BASE_IDX 1 |
4915 | #define mmPA_SU_LINE_STIPPLE_VALUE 0x2280 | 4903 | #define mmPA_SU_LINE_STIPPLE_VALUE 0x2280 |
@@ -4996,8 +4984,6 @@ | |||
4996 | #define mmTA_CS_BC_BASE_ADDR_BASE_IDX 1 | 4984 | #define mmTA_CS_BC_BASE_ADDR_BASE_IDX 1 |
4997 | #define mmTA_CS_BC_BASE_ADDR_HI 0x2381 | 4985 | #define mmTA_CS_BC_BASE_ADDR_HI 0x2381 |
4998 | #define mmTA_CS_BC_BASE_ADDR_HI_BASE_IDX 1 | 4986 | #define mmTA_CS_BC_BASE_ADDR_HI_BASE_IDX 1 |
4999 | #define mmTA_GRAD_ADJ_UCONFIG 0x2382 | ||
5000 | #define mmTA_GRAD_ADJ_UCONFIG_BASE_IDX 1 | ||
5001 | #define mmDB_OCCLUSION_COUNT0_LOW 0x23c0 | 4987 | #define mmDB_OCCLUSION_COUNT0_LOW 0x23c0 |
5002 | #define mmDB_OCCLUSION_COUNT0_LOW_BASE_IDX 1 | 4988 | #define mmDB_OCCLUSION_COUNT0_LOW_BASE_IDX 1 |
5003 | #define mmDB_OCCLUSION_COUNT0_HI 0x23c1 | 4989 | #define mmDB_OCCLUSION_COUNT0_HI 0x23c1 |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h index 5c5e9b445432..2e1214be67a2 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h +++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_0_sh_mask.h | |||
@@ -4576,15 +4576,6 @@ | |||
4576 | //TA_RESERVED_010C | 4576 | //TA_RESERVED_010C |
4577 | #define TA_RESERVED_010C__Unused__SHIFT 0x0 | 4577 | #define TA_RESERVED_010C__Unused__SHIFT 0x0 |
4578 | #define TA_RESERVED_010C__Unused_MASK 0xFFFFFFFFL | 4578 | #define TA_RESERVED_010C__Unused_MASK 0xFFFFFFFFL |
4579 | //TA_GRAD_ADJ | ||
4580 | #define TA_GRAD_ADJ__GRAD_ADJ_0__SHIFT 0x0 | ||
4581 | #define TA_GRAD_ADJ__GRAD_ADJ_1__SHIFT 0x8 | ||
4582 | #define TA_GRAD_ADJ__GRAD_ADJ_2__SHIFT 0x10 | ||
4583 | #define TA_GRAD_ADJ__GRAD_ADJ_3__SHIFT 0x18 | ||
4584 | #define TA_GRAD_ADJ__GRAD_ADJ_0_MASK 0x000000FFL | ||
4585 | #define TA_GRAD_ADJ__GRAD_ADJ_1_MASK 0x0000FF00L | ||
4586 | #define TA_GRAD_ADJ__GRAD_ADJ_2_MASK 0x00FF0000L | ||
4587 | #define TA_GRAD_ADJ__GRAD_ADJ_3_MASK 0xFF000000L | ||
4588 | //TA_STATUS | 4579 | //TA_STATUS |
4589 | #define TA_STATUS__FG_PFIFO_EMPTYB__SHIFT 0xc | 4580 | #define TA_STATUS__FG_PFIFO_EMPTYB__SHIFT 0xc |
4590 | #define TA_STATUS__FG_LFIFO_EMPTYB__SHIFT 0xd | 4581 | #define TA_STATUS__FG_LFIFO_EMPTYB__SHIFT 0xd |
@@ -14459,9 +14450,6 @@ | |||
14459 | #define DB_DFSM_CONTROL__PUNCHOUT_MODE_MASK 0x00000003L | 14450 | #define DB_DFSM_CONTROL__PUNCHOUT_MODE_MASK 0x00000003L |
14460 | #define DB_DFSM_CONTROL__POPS_DRAIN_PS_ON_OVERLAP_MASK 0x00000004L | 14451 | #define DB_DFSM_CONTROL__POPS_DRAIN_PS_ON_OVERLAP_MASK 0x00000004L |
14461 | #define DB_DFSM_CONTROL__DISALLOW_OVERFLOW_MASK 0x00000008L | 14452 | #define DB_DFSM_CONTROL__DISALLOW_OVERFLOW_MASK 0x00000008L |
14462 | //DB_RENDER_FILTER | ||
14463 | #define DB_RENDER_FILTER__PS_INVOKE_MASK__SHIFT 0x0 | ||
14464 | #define DB_RENDER_FILTER__PS_INVOKE_MASK_MASK 0x0000FFFFL | ||
14465 | //DB_Z_INFO2 | 14453 | //DB_Z_INFO2 |
14466 | #define DB_Z_INFO2__EPITCH__SHIFT 0x0 | 14454 | #define DB_Z_INFO2__EPITCH__SHIFT 0x0 |
14467 | #define DB_Z_INFO2__EPITCH_MASK 0x0000FFFFL | 14455 | #define DB_Z_INFO2__EPITCH_MASK 0x0000FFFFL |
@@ -14959,11 +14947,9 @@ | |||
14959 | #define PA_SC_TILE_STEERING_OVERRIDE__ENABLE__SHIFT 0x0 | 14947 | #define PA_SC_TILE_STEERING_OVERRIDE__ENABLE__SHIFT 0x0 |
14960 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_SE__SHIFT 0x1 | 14948 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_SE__SHIFT 0x1 |
14961 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_RB_PER_SE__SHIFT 0x5 | 14949 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_RB_PER_SE__SHIFT 0x5 |
14962 | #define PA_SC_TILE_STEERING_OVERRIDE__DISABLE_SRBSL_DB_OPTIMIZED_PACKING__SHIFT 0x8 | ||
14963 | #define PA_SC_TILE_STEERING_OVERRIDE__ENABLE_MASK 0x00000001L | 14950 | #define PA_SC_TILE_STEERING_OVERRIDE__ENABLE_MASK 0x00000001L |
14964 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_SE_MASK 0x00000006L | 14951 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_SE_MASK 0x00000006L |
14965 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_RB_PER_SE_MASK 0x00000060L | 14952 | #define PA_SC_TILE_STEERING_OVERRIDE__NUM_RB_PER_SE_MASK 0x00000060L |
14966 | #define PA_SC_TILE_STEERING_OVERRIDE__DISABLE_SRBSL_DB_OPTIMIZED_PACKING_MASK 0x00000100L | ||
14967 | //CP_PERFMON_CNTX_CNTL | 14953 | //CP_PERFMON_CNTX_CNTL |
14968 | #define CP_PERFMON_CNTX_CNTL__PERFMON_ENABLE__SHIFT 0x1f | 14954 | #define CP_PERFMON_CNTX_CNTL__PERFMON_ENABLE__SHIFT 0x1f |
14969 | #define CP_PERFMON_CNTX_CNTL__PERFMON_ENABLE_MASK 0x80000000L | 14955 | #define CP_PERFMON_CNTX_CNTL__PERFMON_ENABLE_MASK 0x80000000L |
@@ -15003,20 +14989,6 @@ | |||
15003 | #define PA_SC_HORIZ_GRID__TOP_HALF_MASK 0x0000FF00L | 14989 | #define PA_SC_HORIZ_GRID__TOP_HALF_MASK 0x0000FF00L |
15004 | #define PA_SC_HORIZ_GRID__BOT_HALF_MASK 0x00FF0000L | 14990 | #define PA_SC_HORIZ_GRID__BOT_HALF_MASK 0x00FF0000L |
15005 | #define PA_SC_HORIZ_GRID__BOT_QTR_MASK 0xFF000000L | 14991 | #define PA_SC_HORIZ_GRID__BOT_QTR_MASK 0xFF000000L |
15006 | //PA_SC_FOV_WINDOW_LR | ||
15007 | #define PA_SC_FOV_WINDOW_LR__LEFT_EYE_FOV_LEFT__SHIFT 0x0 | ||
15008 | #define PA_SC_FOV_WINDOW_LR__LEFT_EYE_FOV_RIGHT__SHIFT 0x8 | ||
15009 | #define PA_SC_FOV_WINDOW_LR__RIGHT_EYE_FOV_LEFT__SHIFT 0x10 | ||
15010 | #define PA_SC_FOV_WINDOW_LR__RIGHT_EYE_FOV_RIGHT__SHIFT 0x18 | ||
15011 | #define PA_SC_FOV_WINDOW_LR__LEFT_EYE_FOV_LEFT_MASK 0x000000FFL | ||
15012 | #define PA_SC_FOV_WINDOW_LR__LEFT_EYE_FOV_RIGHT_MASK 0x0000FF00L | ||
15013 | #define PA_SC_FOV_WINDOW_LR__RIGHT_EYE_FOV_LEFT_MASK 0x00FF0000L | ||
15014 | #define PA_SC_FOV_WINDOW_LR__RIGHT_EYE_FOV_RIGHT_MASK 0xFF000000L | ||
15015 | //PA_SC_FOV_WINDOW_TB | ||
15016 | #define PA_SC_FOV_WINDOW_TB__FOV_TOP__SHIFT 0x0 | ||
15017 | #define PA_SC_FOV_WINDOW_TB__FOV_BOT__SHIFT 0x8 | ||
15018 | #define PA_SC_FOV_WINDOW_TB__FOV_TOP_MASK 0x000000FFL | ||
15019 | #define PA_SC_FOV_WINDOW_TB__FOV_BOT_MASK 0x0000FF00L | ||
15020 | //VGT_MULTI_PRIM_IB_RESET_INDX | 14992 | //VGT_MULTI_PRIM_IB_RESET_INDX |
15021 | #define VGT_MULTI_PRIM_IB_RESET_INDX__RESET_INDX__SHIFT 0x0 | 14993 | #define VGT_MULTI_PRIM_IB_RESET_INDX__RESET_INDX__SHIFT 0x0 |
15022 | #define VGT_MULTI_PRIM_IB_RESET_INDX__RESET_INDX_MASK 0xFFFFFFFFL | 14994 | #define VGT_MULTI_PRIM_IB_RESET_INDX__RESET_INDX_MASK 0xFFFFFFFFL |
@@ -17010,13 +16982,11 @@ | |||
17010 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__LINE_FILTER_DISABLE__SHIFT 0x2 | 16982 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__LINE_FILTER_DISABLE__SHIFT 0x2 |
17011 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__POINT_FILTER_DISABLE__SHIFT 0x3 | 16983 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__POINT_FILTER_DISABLE__SHIFT 0x3 |
17012 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__RECTANGLE_FILTER_DISABLE__SHIFT 0x4 | 16984 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__RECTANGLE_FILTER_DISABLE__SHIFT 0x4 |
17013 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__SRBSL_ENABLE__SHIFT 0x5 | ||
17014 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__SMALL_PRIM_FILTER_ENABLE_MASK 0x00000001L | 16985 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__SMALL_PRIM_FILTER_ENABLE_MASK 0x00000001L |
17015 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__TRIANGLE_FILTER_DISABLE_MASK 0x00000002L | 16986 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__TRIANGLE_FILTER_DISABLE_MASK 0x00000002L |
17016 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__LINE_FILTER_DISABLE_MASK 0x00000004L | 16987 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__LINE_FILTER_DISABLE_MASK 0x00000004L |
17017 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__POINT_FILTER_DISABLE_MASK 0x00000008L | 16988 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__POINT_FILTER_DISABLE_MASK 0x00000008L |
17018 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__RECTANGLE_FILTER_DISABLE_MASK 0x00000010L | 16989 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__RECTANGLE_FILTER_DISABLE_MASK 0x00000010L |
17019 | #define PA_SU_SMALL_PRIM_FILTER_CNTL__SRBSL_ENABLE_MASK 0x00000020L | ||
17020 | //PA_CL_OBJPRIM_ID_CNTL | 16990 | //PA_CL_OBJPRIM_ID_CNTL |
17021 | #define PA_CL_OBJPRIM_ID_CNTL__OBJ_ID_SEL__SHIFT 0x0 | 16991 | #define PA_CL_OBJPRIM_ID_CNTL__OBJ_ID_SEL__SHIFT 0x0 |
17022 | #define PA_CL_OBJPRIM_ID_CNTL__ADD_PIPED_PRIM_ID__SHIFT 0x1 | 16992 | #define PA_CL_OBJPRIM_ID_CNTL__ADD_PIPED_PRIM_ID__SHIFT 0x1 |
@@ -17345,9 +17315,6 @@ | |||
17345 | #define VGT_DRAW_PAYLOAD_CNTL__EN_REG_RT_INDEX_MASK 0x00000002L | 17315 | #define VGT_DRAW_PAYLOAD_CNTL__EN_REG_RT_INDEX_MASK 0x00000002L |
17346 | #define VGT_DRAW_PAYLOAD_CNTL__EN_PIPELINE_PRIMID_MASK 0x00000004L | 17316 | #define VGT_DRAW_PAYLOAD_CNTL__EN_PIPELINE_PRIMID_MASK 0x00000004L |
17347 | #define VGT_DRAW_PAYLOAD_CNTL__OBJECT_ID_INST_EN_MASK 0x00000008L | 17317 | #define VGT_DRAW_PAYLOAD_CNTL__OBJECT_ID_INST_EN_MASK 0x00000008L |
17348 | //VGT_INDEX_PAYLOAD_CNTL | ||
17349 | #define VGT_INDEX_PAYLOAD_CNTL__COMPOUND_INDEX_EN__SHIFT 0x0 | ||
17350 | #define VGT_INDEX_PAYLOAD_CNTL__COMPOUND_INDEX_EN_MASK 0x00000001L | ||
17351 | //VGT_INSTANCE_STEP_RATE_0 | 17318 | //VGT_INSTANCE_STEP_RATE_0 |
17352 | #define VGT_INSTANCE_STEP_RATE_0__STEP_RATE__SHIFT 0x0 | 17319 | #define VGT_INSTANCE_STEP_RATE_0__STEP_RATE__SHIFT 0x0 |
17353 | #define VGT_INSTANCE_STEP_RATE_0__STEP_RATE_MASK 0xFFFFFFFFL | 17320 | #define VGT_INSTANCE_STEP_RATE_0__STEP_RATE_MASK 0xFFFFFFFFL |
@@ -19849,9 +19816,6 @@ | |||
19849 | #define IA_MULTI_VGT_PARAM__EN_INST_OPT_BASIC_MASK 0x00200000L | 19816 | #define IA_MULTI_VGT_PARAM__EN_INST_OPT_BASIC_MASK 0x00200000L |
19850 | #define IA_MULTI_VGT_PARAM__EN_INST_OPT_ADV_MASK 0x00400000L | 19817 | #define IA_MULTI_VGT_PARAM__EN_INST_OPT_ADV_MASK 0x00400000L |
19851 | #define IA_MULTI_VGT_PARAM__HW_USE_ONLY_MASK 0x00800000L | 19818 | #define IA_MULTI_VGT_PARAM__HW_USE_ONLY_MASK 0x00800000L |
19852 | //VGT_OBJECT_ID | ||
19853 | #define VGT_OBJECT_ID__REG_OBJ_ID__SHIFT 0x0 | ||
19854 | #define VGT_OBJECT_ID__REG_OBJ_ID_MASK 0xFFFFFFFFL | ||
19855 | //VGT_INSTANCE_BASE_ID | 19819 | //VGT_INSTANCE_BASE_ID |
19856 | #define VGT_INSTANCE_BASE_ID__INSTANCE_BASE_ID__SHIFT 0x0 | 19820 | #define VGT_INSTANCE_BASE_ID__INSTANCE_BASE_ID__SHIFT 0x0 |
19857 | #define VGT_INSTANCE_BASE_ID__INSTANCE_BASE_ID_MASK 0xFFFFFFFFL | 19821 | #define VGT_INSTANCE_BASE_ID__INSTANCE_BASE_ID_MASK 0xFFFFFFFFL |
@@ -20067,15 +20031,6 @@ | |||
20067 | //TA_CS_BC_BASE_ADDR_HI | 20031 | //TA_CS_BC_BASE_ADDR_HI |
20068 | #define TA_CS_BC_BASE_ADDR_HI__ADDRESS__SHIFT 0x0 | 20032 | #define TA_CS_BC_BASE_ADDR_HI__ADDRESS__SHIFT 0x0 |
20069 | #define TA_CS_BC_BASE_ADDR_HI__ADDRESS_MASK 0x000000FFL | 20033 | #define TA_CS_BC_BASE_ADDR_HI__ADDRESS_MASK 0x000000FFL |
20070 | //TA_GRAD_ADJ_UCONFIG | ||
20071 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_0__SHIFT 0x0 | ||
20072 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_1__SHIFT 0x8 | ||
20073 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_2__SHIFT 0x10 | ||
20074 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_3__SHIFT 0x18 | ||
20075 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_0_MASK 0x000000FFL | ||
20076 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_1_MASK 0x0000FF00L | ||
20077 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_2_MASK 0x00FF0000L | ||
20078 | #define TA_GRAD_ADJ_UCONFIG__GRAD_ADJ_3_MASK 0xFF000000L | ||
20079 | //DB_OCCLUSION_COUNT0_LOW | 20034 | //DB_OCCLUSION_COUNT0_LOW |
20080 | #define DB_OCCLUSION_COUNT0_LOW__COUNT_LOW__SHIFT 0x0 | 20035 | #define DB_OCCLUSION_COUNT0_LOW__COUNT_LOW__SHIFT 0x0 |
20081 | #define DB_OCCLUSION_COUNT0_LOW__COUNT_LOW_MASK 0xFFFFFFFFL | 20036 | #define DB_OCCLUSION_COUNT0_LOW__COUNT_LOW_MASK 0xFFFFFFFFL |
diff --git a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_1_offset.h b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_1_offset.h index db7ef5ede0e5..030e0020902b 100644 --- a/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_1_offset.h +++ b/drivers/gpu/drm/amd/include/asic_reg/gc/gc_9_1_offset.h | |||
@@ -815,8 +815,6 @@ | |||
815 | #define mmTA_CNTL_AUX_BASE_IDX 0 | 815 | #define mmTA_CNTL_AUX_BASE_IDX 0 |
816 | #define mmTA_RESERVED_010C 0x0543 | 816 | #define mmTA_RESERVED_010C 0x0543 |
817 | #define mmTA_RESERVED_010C_BASE_IDX 0 | 817 | #define mmTA_RESERVED_010C_BASE_IDX 0 |
818 | #define mmTA_GRAD_ADJ 0x0544 | ||
819 | #define mmTA_GRAD_ADJ_BASE_IDX 0 | ||
820 | #define mmTA_STATUS 0x0548 | 818 | #define mmTA_STATUS 0x0548 |
821 | #define mmTA_STATUS_BASE_IDX 0 | 819 | #define mmTA_STATUS_BASE_IDX 0 |
822 | #define mmTA_SCRATCH 0x0564 | 820 | #define mmTA_SCRATCH 0x0564 |
@@ -3617,8 +3615,6 @@ | |||
3617 | #define mmDB_STENCIL_WRITE_BASE_HI_BASE_IDX 1 | 3615 | #define mmDB_STENCIL_WRITE_BASE_HI_BASE_IDX 1 |
3618 | #define mmDB_DFSM_CONTROL 0x0018 | 3616 | #define mmDB_DFSM_CONTROL 0x0018 |
3619 | #define mmDB_DFSM_CONTROL_BASE_IDX 1 | 3617 | #define mmDB_DFSM_CONTROL_BASE_IDX 1 |
3620 | #define mmDB_RENDER_FILTER 0x0019 | ||
3621 | #define mmDB_RENDER_FILTER_BASE_IDX 1 | ||
3622 | #define mmDB_Z_INFO2 0x001a | 3618 | #define mmDB_Z_INFO2 0x001a |
3623 | #define mmDB_Z_INFO2_BASE_IDX 1 | 3619 | #define mmDB_Z_INFO2_BASE_IDX 1 |
3624 | #define mmDB_STENCIL_INFO2 0x001b | 3620 | #define mmDB_STENCIL_INFO2 0x001b |
@@ -3829,10 +3825,6 @@ | |||
3829 | #define mmPA_SC_LEFT_VERT_GRID_BASE_IDX 1 | 3825 | #define mmPA_SC_LEFT_VERT_GRID_BASE_IDX 1 |
3830 | #define mmPA_SC_HORIZ_GRID 0x00ea | 3826 | #define mmPA_SC_HORIZ_GRID 0x00ea |
3831 | #define mmPA_SC_HORIZ_GRID_BASE_IDX 1 | 3827 | #define mmPA_SC_HORIZ_GRID_BASE_IDX 1 |
3832 | #define mmPA_SC_FOV_WINDOW_LR 0x00eb | ||
3833 | #define mmPA_SC_FOV_WINDOW_LR_BASE_IDX 1 | ||
3834 | #define mmPA_SC_FOV_WINDOW_TB 0x00ec | ||
3835 | #define mmPA_SC_FOV_WINDOW_TB_BASE_IDX 1 | ||
3836 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX 0x0103 | 3828 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX 0x0103 |
3837 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_BASE_IDX 1 | 3829 | #define mmVGT_MULTI_PRIM_IB_RESET_INDX_BASE_IDX 1 |
3838 | #define mmCB_BLEND_RED 0x0105 | 3830 | #define mmCB_BLEND_RED 0x0105 |
@@ -4361,8 +4353,6 @@ | |||
4361 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_BASE_IDX 1 | 4353 | #define mmVGT_GS_MAX_PRIMS_PER_SUBGROUP_BASE_IDX 1 |
4362 | #define mmVGT_DRAW_PAYLOAD_CNTL 0x02a6 | 4354 | #define mmVGT_DRAW_PAYLOAD_CNTL 0x02a6 |
4363 | #define mmVGT_DRAW_PAYLOAD_CNTL_BASE_IDX 1 | 4355 | #define mmVGT_DRAW_PAYLOAD_CNTL_BASE_IDX 1 |
4364 | #define mmVGT_INDEX_PAYLOAD_CNTL 0x02a7 | ||
4365 | #define mmVGT_INDEX_PAYLOAD_CNTL_BASE_IDX 1 | ||
4366 | #define mmVGT_INSTANCE_STEP_RATE_0 0x02a8 | 4356 | #define mmVGT_INSTANCE_STEP_RATE_0 0x02a8 |
4367 | #define mmVGT_INSTANCE_STEP_RATE_0_BASE_IDX 1 | 4357 | #define mmVGT_INSTANCE_STEP_RATE_0_BASE_IDX 1 |
4368 | #define mmVGT_INSTANCE_STEP_RATE_1 0x02a9 | 4358 | #define mmVGT_INSTANCE_STEP_RATE_1 0x02a9 |
@@ -5195,8 +5185,6 @@ | |||
5195 | #define mmWD_INDEX_BUF_BASE_HI_BASE_IDX 1 | 5185 | #define mmWD_INDEX_BUF_BASE_HI_BASE_IDX 1 |
5196 | #define mmIA_MULTI_VGT_PARAM 0x2258 | 5186 | #define mmIA_MULTI_VGT_PARAM 0x2258 |
5197 | #define mmIA_MULTI_VGT_PARAM_BASE_IDX 1 | 5187 | #define mmIA_MULTI_VGT_PARAM_BASE_IDX 1 |
5198 | #define mmVGT_OBJECT_ID 0x2259 | ||
5199 | #define mmVGT_OBJECT_ID_BASE_IDX 1 | ||
5200 | #define mmVGT_INSTANCE_BASE_ID 0x225a | 5188 | #define mmVGT_INSTANCE_BASE_ID 0x225a |
5201 | #define mmVGT_INSTANCE_BASE_ID_BASE_IDX 1 | 5189 | #define mmVGT_INSTANCE_BASE_ID_BASE_IDX 1 |
5202 | #define mmPA_SU_LINE_STIPPLE_VALUE 0x2280 | 5190 | #define mmPA_SU_LINE_STIPPLE_VALUE 0x2280 |
@@ -5283,8 +5271,6 @@ | |||
5283 | #define mmTA_CS_BC_BASE_ADDR_BASE_IDX 1 | 5271 | #define mmTA_CS_BC_BASE_ADDR_BASE_IDX 1 |
5284 | #define mmTA_CS_BC_BASE_ADDR_HI 0x2381 | 5272 | #define mmTA_CS_BC_BASE_ADDR_HI 0x2381 |
5285 | #define mmTA_CS_BC_BASE_ADDR_HI_BASE_IDX 1 | 5273 | #define mmTA_CS_BC_BASE_ADDR_HI_BASE_IDX 1 |
5286 | #define mmTA_GRAD_ADJ_UCONFIG 0x2382 | ||
5287 | #define mmTA_GRAD_ADJ_UCONFIG_BASE_IDX 1 | ||
5288 | #define mmDB_OCCLUSION_COUNT0_LOW 0x23c0 | 5274 | #define mmDB_OCCLUSION_COUNT0_LOW 0x23c0 |
5289 | #define mmDB_OCCLUSION_COUNT0_LOW_BASE_IDX 1 | 5275 | #define mmDB_OCCLUSION_COUNT0_LOW_BASE_IDX 1 |
5290 | #define mmDB_OCCLUSION_COUNT0_HI 0x23c1 | 5276 | #define mmDB_OCCLUSION_COUNT0_HI 0x23c1 |
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index 9d3bdada79d5..fa9d1615a2cc 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c | |||
@@ -389,20 +389,12 @@ static int pp_dpm_force_performance_level(void *handle, | |||
389 | if (level == hwmgr->dpm_level) | 389 | if (level == hwmgr->dpm_level) |
390 | return 0; | 390 | return 0; |
391 | 391 | ||
392 | if (hwmgr->hwmgr_func->force_dpm_level == NULL) { | ||
393 | pr_info("%s was not implemented.\n", __func__); | ||
394 | return 0; | ||
395 | } | ||
396 | |||
397 | mutex_lock(&pp_handle->pp_lock); | 392 | mutex_lock(&pp_handle->pp_lock); |
398 | pp_dpm_en_umd_pstate(hwmgr, &level); | 393 | pp_dpm_en_umd_pstate(hwmgr, &level); |
399 | hwmgr->request_dpm_level = level; | 394 | hwmgr->request_dpm_level = level; |
400 | hwmgr_handle_task(pp_handle, AMD_PP_TASK_READJUST_POWER_STATE, NULL, NULL); | 395 | hwmgr_handle_task(pp_handle, AMD_PP_TASK_READJUST_POWER_STATE, NULL, NULL); |
401 | ret = hwmgr->hwmgr_func->force_dpm_level(hwmgr, level); | ||
402 | if (!ret) | ||
403 | hwmgr->dpm_level = hwmgr->request_dpm_level; | ||
404 | |||
405 | mutex_unlock(&pp_handle->pp_lock); | 396 | mutex_unlock(&pp_handle->pp_lock); |
397 | |||
406 | return 0; | 398 | return 0; |
407 | } | 399 | } |
408 | 400 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c index ad1f6b57884b..b314d09d41af 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | |||
@@ -728,9 +728,6 @@ static int cz_update_sclk_limit(struct pp_hwmgr *hwmgr) | |||
728 | 728 | ||
729 | if (clock < stable_pstate_sclk) | 729 | if (clock < stable_pstate_sclk) |
730 | clock = stable_pstate_sclk; | 730 | clock = stable_pstate_sclk; |
731 | } else { | ||
732 | if (clock < hwmgr->gfx_arbiter.sclk) | ||
733 | clock = hwmgr->gfx_arbiter.sclk; | ||
734 | } | 731 | } |
735 | 732 | ||
736 | if (cz_hwmgr->sclk_dpm.soft_min_clk != clock) { | 733 | if (cz_hwmgr->sclk_dpm.soft_min_clk != clock) { |
@@ -1085,14 +1082,8 @@ static int cz_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
1085 | uint32_t num_of_active_displays = 0; | 1082 | uint32_t num_of_active_displays = 0; |
1086 | struct cgs_display_info info = {0}; | 1083 | struct cgs_display_info info = {0}; |
1087 | 1084 | ||
1088 | cz_ps->evclk = hwmgr->vce_arbiter.evclk; | ||
1089 | cz_ps->ecclk = hwmgr->vce_arbiter.ecclk; | ||
1090 | |||
1091 | cz_ps->need_dfs_bypass = true; | 1085 | cz_ps->need_dfs_bypass = true; |
1092 | 1086 | ||
1093 | cz_hwmgr->video_start = (hwmgr->uvd_arbiter.vclk != 0 || hwmgr->uvd_arbiter.dclk != 0 || | ||
1094 | hwmgr->vce_arbiter.evclk != 0 || hwmgr->vce_arbiter.ecclk != 0); | ||
1095 | |||
1096 | cz_hwmgr->battery_state = (PP_StateUILabel_Battery == prequest_ps->classification.ui_label); | 1087 | cz_hwmgr->battery_state = (PP_StateUILabel_Battery == prequest_ps->classification.ui_label); |
1097 | 1088 | ||
1098 | clocks.memoryClock = hwmgr->display_config.min_mem_set_clock != 0 ? | 1089 | clocks.memoryClock = hwmgr->display_config.min_mem_set_clock != 0 ? |
@@ -1105,9 +1096,6 @@ static int cz_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
1105 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_StablePState)) | 1096 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_StablePState)) |
1106 | clocks.memoryClock = hwmgr->dyn_state.max_clock_voltage_on_ac.mclk; | 1097 | clocks.memoryClock = hwmgr->dyn_state.max_clock_voltage_on_ac.mclk; |
1107 | 1098 | ||
1108 | if (clocks.memoryClock < hwmgr->gfx_arbiter.mclk) | ||
1109 | clocks.memoryClock = hwmgr->gfx_arbiter.mclk; | ||
1110 | |||
1111 | force_high = (clocks.memoryClock > cz_hwmgr->sys_info.nbp_memory_clock[CZ_NUM_NBPMEMORYCLOCK - 1]) | 1099 | force_high = (clocks.memoryClock > cz_hwmgr->sys_info.nbp_memory_clock[CZ_NUM_NBPMEMORYCLOCK - 1]) |
1112 | || (num_of_active_displays >= 3); | 1100 | || (num_of_active_displays >= 3); |
1113 | 1101 | ||
@@ -1339,22 +1327,13 @@ int cz_dpm_update_vce_dpm(struct pp_hwmgr *hwmgr) | |||
1339 | cz_hwmgr->vce_dpm.hard_min_clk, | 1327 | cz_hwmgr->vce_dpm.hard_min_clk, |
1340 | PPSMC_MSG_SetEclkHardMin)); | 1328 | PPSMC_MSG_SetEclkHardMin)); |
1341 | } else { | 1329 | } else { |
1342 | /*Program HardMin based on the vce_arbiter.ecclk */ | 1330 | |
1343 | if (hwmgr->vce_arbiter.ecclk == 0) { | 1331 | smum_send_msg_to_smc_with_parameter(hwmgr, |
1344 | smum_send_msg_to_smc_with_parameter(hwmgr, | 1332 | PPSMC_MSG_SetEclkHardMin, 0); |
1345 | PPSMC_MSG_SetEclkHardMin, 0); | ||
1346 | /* disable ECLK DPM 0. Otherwise VCE could hang if | 1333 | /* disable ECLK DPM 0. Otherwise VCE could hang if |
1347 | * switching SCLK from DPM 0 to 6/7 */ | 1334 | * switching SCLK from DPM 0 to 6/7 */ |
1348 | smum_send_msg_to_smc_with_parameter(hwmgr, | 1335 | smum_send_msg_to_smc_with_parameter(hwmgr, |
1349 | PPSMC_MSG_SetEclkSoftMin, 1); | 1336 | PPSMC_MSG_SetEclkSoftMin, 1); |
1350 | } else { | ||
1351 | cz_hwmgr->vce_dpm.hard_min_clk = hwmgr->vce_arbiter.ecclk; | ||
1352 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
1353 | PPSMC_MSG_SetEclkHardMin, | ||
1354 | cz_get_eclk_level(hwmgr, | ||
1355 | cz_hwmgr->vce_dpm.hard_min_clk, | ||
1356 | PPSMC_MSG_SetEclkHardMin)); | ||
1357 | } | ||
1358 | } | 1337 | } |
1359 | return 0; | 1338 | return 0; |
1360 | } | 1339 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c index 623cff90233d..2b0c53fe4c8d 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | |||
@@ -112,26 +112,29 @@ int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level | |||
112 | 112 | ||
113 | PHM_FUNC_CHECK(hwmgr); | 113 | PHM_FUNC_CHECK(hwmgr); |
114 | 114 | ||
115 | if (hwmgr->hwmgr_func->force_dpm_level != NULL) { | 115 | if (hwmgr->hwmgr_func->force_dpm_level != NULL) |
116 | ret = hwmgr->hwmgr_func->force_dpm_level(hwmgr, level); | 116 | ret = hwmgr->hwmgr_func->force_dpm_level(hwmgr, level); |
117 | if (ret) | ||
118 | return ret; | ||
119 | |||
120 | if (hwmgr->hwmgr_func->set_power_profile_state) { | ||
121 | if (hwmgr->current_power_profile == AMD_PP_GFX_PROFILE) | ||
122 | ret = hwmgr->hwmgr_func->set_power_profile_state( | ||
123 | hwmgr, | ||
124 | &hwmgr->gfx_power_profile); | ||
125 | else if (hwmgr->current_power_profile == AMD_PP_COMPUTE_PROFILE) | ||
126 | ret = hwmgr->hwmgr_func->set_power_profile_state( | ||
127 | hwmgr, | ||
128 | &hwmgr->compute_power_profile); | ||
129 | } | ||
130 | } | ||
131 | 117 | ||
132 | return ret; | 118 | return ret; |
133 | } | 119 | } |
134 | 120 | ||
121 | int phm_reset_power_profile_state(struct pp_hwmgr *hwmgr) | ||
122 | { | ||
123 | int ret = 0; | ||
124 | |||
125 | if (hwmgr->hwmgr_func->set_power_profile_state) { | ||
126 | if (hwmgr->current_power_profile == AMD_PP_GFX_PROFILE) | ||
127 | ret = hwmgr->hwmgr_func->set_power_profile_state( | ||
128 | hwmgr, | ||
129 | &hwmgr->gfx_power_profile); | ||
130 | else if (hwmgr->current_power_profile == AMD_PP_COMPUTE_PROFILE) | ||
131 | ret = hwmgr->hwmgr_func->set_power_profile_state( | ||
132 | hwmgr, | ||
133 | &hwmgr->compute_power_profile); | ||
134 | } | ||
135 | return ret; | ||
136 | } | ||
137 | |||
135 | int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | 138 | int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, |
136 | struct pp_power_state *adjusted_ps, | 139 | struct pp_power_state *adjusted_ps, |
137 | const struct pp_power_state *current_ps) | 140 | const struct pp_power_state *current_ps) |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c index ce59e0e67cb2..0229f774f7a9 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | |||
@@ -149,6 +149,7 @@ int hwmgr_early_init(struct pp_instance *handle) | |||
149 | hwmgr->power_source = PP_PowerSource_AC; | 149 | hwmgr->power_source = PP_PowerSource_AC; |
150 | hwmgr->pp_table_version = PP_TABLE_V1; | 150 | hwmgr->pp_table_version = PP_TABLE_V1; |
151 | hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; | 151 | hwmgr->dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; |
152 | hwmgr->request_dpm_level = AMD_DPM_FORCED_LEVEL_AUTO; | ||
152 | hwmgr_init_default_caps(hwmgr); | 153 | hwmgr_init_default_caps(hwmgr); |
153 | hwmgr_set_user_specify_caps(hwmgr); | 154 | hwmgr_set_user_specify_caps(hwmgr); |
154 | hwmgr->fan_ctrl_is_in_default_mode = true; | 155 | hwmgr->fan_ctrl_is_in_default_mode = true; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c index ffa44bbb218e..95ab772e0c3e 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | |||
@@ -244,6 +244,10 @@ int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr, bool skip, | |||
244 | } | 244 | } |
245 | 245 | ||
246 | phm_notify_smc_display_config_after_ps_adjustment(hwmgr); | 246 | phm_notify_smc_display_config_after_ps_adjustment(hwmgr); |
247 | if (!phm_force_dpm_levels(hwmgr, hwmgr->request_dpm_level)) | ||
248 | hwmgr->dpm_level = hwmgr->request_dpm_level; | ||
249 | |||
250 | phm_reset_power_profile_state(hwmgr); | ||
247 | 251 | ||
248 | return 0; | 252 | return 0; |
249 | } | 253 | } |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c index 3e0b267c74a8..569073e3a5a1 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | |||
@@ -159,7 +159,6 @@ static int rv_construct_boot_state(struct pp_hwmgr *hwmgr) | |||
159 | 159 | ||
160 | static int rv_set_clock_limit(struct pp_hwmgr *hwmgr, const void *input) | 160 | static int rv_set_clock_limit(struct pp_hwmgr *hwmgr, const void *input) |
161 | { | 161 | { |
162 | struct rv_hwmgr *rv_data = (struct rv_hwmgr *)(hwmgr->backend); | ||
163 | struct PP_Clocks clocks = {0}; | 162 | struct PP_Clocks clocks = {0}; |
164 | struct pp_display_clock_request clock_req; | 163 | struct pp_display_clock_request clock_req; |
165 | 164 | ||
@@ -170,39 +169,6 @@ static int rv_set_clock_limit(struct pp_hwmgr *hwmgr, const void *input) | |||
170 | PP_ASSERT_WITH_CODE(!rv_display_clock_voltage_request(hwmgr, &clock_req), | 169 | PP_ASSERT_WITH_CODE(!rv_display_clock_voltage_request(hwmgr, &clock_req), |
171 | "Attempt to set DCF Clock Failed!", return -EINVAL); | 170 | "Attempt to set DCF Clock Failed!", return -EINVAL); |
172 | 171 | ||
173 | if (((hwmgr->uvd_arbiter.vclk_soft_min / 100) != rv_data->vclk_soft_min) || | ||
174 | ((hwmgr->uvd_arbiter.dclk_soft_min / 100) != rv_data->dclk_soft_min)) { | ||
175 | rv_data->vclk_soft_min = hwmgr->uvd_arbiter.vclk_soft_min / 100; | ||
176 | rv_data->dclk_soft_min = hwmgr->uvd_arbiter.dclk_soft_min / 100; | ||
177 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
178 | PPSMC_MSG_SetSoftMinVcn, | ||
179 | (rv_data->vclk_soft_min << 16) | rv_data->vclk_soft_min); | ||
180 | } | ||
181 | |||
182 | if((hwmgr->gfx_arbiter.sclk_hard_min != 0) && | ||
183 | ((hwmgr->gfx_arbiter.sclk_hard_min / 100) != rv_data->soc_actual_hard_min_freq)) { | ||
184 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
185 | PPSMC_MSG_SetHardMinSocclkByFreq, | ||
186 | hwmgr->gfx_arbiter.sclk_hard_min / 100); | ||
187 | rv_read_arg_from_smc(hwmgr, &rv_data->soc_actual_hard_min_freq); | ||
188 | } | ||
189 | |||
190 | if ((hwmgr->gfx_arbiter.gfxclk != 0) && | ||
191 | (rv_data->gfx_actual_soft_min_freq != (hwmgr->gfx_arbiter.gfxclk))) { | ||
192 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
193 | PPSMC_MSG_SetMinVideoGfxclkFreq, | ||
194 | hwmgr->gfx_arbiter.gfxclk / 100); | ||
195 | rv_read_arg_from_smc(hwmgr, &rv_data->gfx_actual_soft_min_freq); | ||
196 | } | ||
197 | |||
198 | if ((hwmgr->gfx_arbiter.fclk != 0) && | ||
199 | (rv_data->fabric_actual_soft_min_freq != (hwmgr->gfx_arbiter.fclk / 100))) { | ||
200 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
201 | PPSMC_MSG_SetMinVideoFclkFreq, | ||
202 | hwmgr->gfx_arbiter.fclk / 100); | ||
203 | rv_read_arg_from_smc(hwmgr, &rv_data->fabric_actual_soft_min_freq); | ||
204 | } | ||
205 | |||
206 | return 0; | 172 | return 0; |
207 | } | 173 | } |
208 | 174 | ||
@@ -518,17 +484,161 @@ static int rv_hwmgr_backend_fini(struct pp_hwmgr *hwmgr) | |||
518 | static int rv_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | 484 | static int rv_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, |
519 | enum amd_dpm_forced_level level) | 485 | enum amd_dpm_forced_level level) |
520 | { | 486 | { |
487 | if (hwmgr->smu_version < 0x1E3700) { | ||
488 | pr_info("smu firmware version too old, can not set dpm level\n"); | ||
489 | return 0; | ||
490 | } | ||
491 | |||
492 | switch (level) { | ||
493 | case AMD_DPM_FORCED_LEVEL_HIGH: | ||
494 | case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: | ||
495 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
496 | PPSMC_MSG_SetHardMinGfxClk, | ||
497 | RAVEN_UMD_PSTATE_PEAK_GFXCLK); | ||
498 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
499 | PPSMC_MSG_SetHardMinFclkByFreq, | ||
500 | RAVEN_UMD_PSTATE_PEAK_FCLK); | ||
501 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
502 | PPSMC_MSG_SetHardMinSocclkByFreq, | ||
503 | RAVEN_UMD_PSTATE_PEAK_SOCCLK); | ||
504 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
505 | PPSMC_MSG_SetHardMinVcn, | ||
506 | RAVEN_UMD_PSTATE_VCE); | ||
507 | |||
508 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
509 | PPSMC_MSG_SetSoftMaxGfxClk, | ||
510 | RAVEN_UMD_PSTATE_PEAK_GFXCLK); | ||
511 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
512 | PPSMC_MSG_SetSoftMaxFclkByFreq, | ||
513 | RAVEN_UMD_PSTATE_PEAK_FCLK); | ||
514 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
515 | PPSMC_MSG_SetSoftMaxSocclkByFreq, | ||
516 | RAVEN_UMD_PSTATE_PEAK_SOCCLK); | ||
517 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
518 | PPSMC_MSG_SetSoftMaxVcn, | ||
519 | RAVEN_UMD_PSTATE_VCE); | ||
520 | break; | ||
521 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: | ||
522 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
523 | PPSMC_MSG_SetHardMinGfxClk, | ||
524 | RAVEN_UMD_PSTATE_MIN_GFXCLK); | ||
525 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
526 | PPSMC_MSG_SetSoftMaxGfxClk, | ||
527 | RAVEN_UMD_PSTATE_MIN_GFXCLK); | ||
528 | break; | ||
529 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK: | ||
530 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
531 | PPSMC_MSG_SetHardMinFclkByFreq, | ||
532 | RAVEN_UMD_PSTATE_MIN_FCLK); | ||
533 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
534 | PPSMC_MSG_SetSoftMaxFclkByFreq, | ||
535 | RAVEN_UMD_PSTATE_MIN_FCLK); | ||
536 | break; | ||
537 | case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: | ||
538 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
539 | PPSMC_MSG_SetHardMinGfxClk, | ||
540 | RAVEN_UMD_PSTATE_GFXCLK); | ||
541 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
542 | PPSMC_MSG_SetHardMinFclkByFreq, | ||
543 | RAVEN_UMD_PSTATE_FCLK); | ||
544 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
545 | PPSMC_MSG_SetHardMinSocclkByFreq, | ||
546 | RAVEN_UMD_PSTATE_SOCCLK); | ||
547 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
548 | PPSMC_MSG_SetHardMinVcn, | ||
549 | RAVEN_UMD_PSTATE_VCE); | ||
550 | |||
551 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
552 | PPSMC_MSG_SetSoftMaxGfxClk, | ||
553 | RAVEN_UMD_PSTATE_GFXCLK); | ||
554 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
555 | PPSMC_MSG_SetSoftMaxFclkByFreq, | ||
556 | RAVEN_UMD_PSTATE_FCLK); | ||
557 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
558 | PPSMC_MSG_SetSoftMaxSocclkByFreq, | ||
559 | RAVEN_UMD_PSTATE_SOCCLK); | ||
560 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
561 | PPSMC_MSG_SetSoftMaxVcn, | ||
562 | RAVEN_UMD_PSTATE_VCE); | ||
563 | break; | ||
564 | case AMD_DPM_FORCED_LEVEL_AUTO: | ||
565 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
566 | PPSMC_MSG_SetHardMinGfxClk, | ||
567 | RAVEN_UMD_PSTATE_MIN_GFXCLK); | ||
568 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
569 | PPSMC_MSG_SetHardMinFclkByFreq, | ||
570 | RAVEN_UMD_PSTATE_MIN_FCLK); | ||
571 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
572 | PPSMC_MSG_SetHardMinSocclkByFreq, | ||
573 | RAVEN_UMD_PSTATE_MIN_SOCCLK); | ||
574 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
575 | PPSMC_MSG_SetHardMinVcn, | ||
576 | RAVEN_UMD_PSTATE_MIN_VCE); | ||
577 | |||
578 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
579 | PPSMC_MSG_SetSoftMaxGfxClk, | ||
580 | RAVEN_UMD_PSTATE_PEAK_GFXCLK); | ||
581 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
582 | PPSMC_MSG_SetSoftMaxFclkByFreq, | ||
583 | RAVEN_UMD_PSTATE_PEAK_FCLK); | ||
584 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
585 | PPSMC_MSG_SetSoftMaxSocclkByFreq, | ||
586 | RAVEN_UMD_PSTATE_PEAK_SOCCLK); | ||
587 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
588 | PPSMC_MSG_SetSoftMaxVcn, | ||
589 | RAVEN_UMD_PSTATE_VCE); | ||
590 | break; | ||
591 | case AMD_DPM_FORCED_LEVEL_LOW: | ||
592 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
593 | PPSMC_MSG_SetHardMinGfxClk, | ||
594 | RAVEN_UMD_PSTATE_MIN_GFXCLK); | ||
595 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
596 | PPSMC_MSG_SetSoftMaxGfxClk, | ||
597 | RAVEN_UMD_PSTATE_MIN_GFXCLK); | ||
598 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
599 | PPSMC_MSG_SetHardMinFclkByFreq, | ||
600 | RAVEN_UMD_PSTATE_MIN_FCLK); | ||
601 | smum_send_msg_to_smc_with_parameter(hwmgr, | ||
602 | PPSMC_MSG_SetSoftMaxFclkByFreq, | ||
603 | RAVEN_UMD_PSTATE_MIN_FCLK); | ||
604 | break; | ||
605 | case AMD_DPM_FORCED_LEVEL_MANUAL: | ||
606 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: | ||
607 | default: | ||
608 | break; | ||
609 | } | ||
521 | return 0; | 610 | return 0; |
522 | } | 611 | } |
523 | 612 | ||
524 | static uint32_t rv_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low) | 613 | static uint32_t rv_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low) |
525 | { | 614 | { |
526 | return 0; | 615 | struct rv_hwmgr *data; |
616 | |||
617 | if (hwmgr == NULL) | ||
618 | return -EINVAL; | ||
619 | |||
620 | data = (struct rv_hwmgr *)(hwmgr->backend); | ||
621 | |||
622 | if (low) | ||
623 | return data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk; | ||
624 | else | ||
625 | return data->clock_vol_info.vdd_dep_on_fclk->entries[ | ||
626 | data->clock_vol_info.vdd_dep_on_fclk->count - 1].clk; | ||
527 | } | 627 | } |
528 | 628 | ||
529 | static uint32_t rv_dpm_get_sclk(struct pp_hwmgr *hwmgr, bool low) | 629 | static uint32_t rv_dpm_get_sclk(struct pp_hwmgr *hwmgr, bool low) |
530 | { | 630 | { |
531 | return 0; | 631 | struct rv_hwmgr *data; |
632 | |||
633 | if (hwmgr == NULL) | ||
634 | return -EINVAL; | ||
635 | |||
636 | data = (struct rv_hwmgr *)(hwmgr->backend); | ||
637 | |||
638 | if (low) | ||
639 | return data->gfx_min_freq_limit; | ||
640 | else | ||
641 | return data->gfx_max_freq_limit; | ||
532 | } | 642 | } |
533 | 643 | ||
534 | static int rv_dpm_patch_boot_state(struct pp_hwmgr *hwmgr, | 644 | static int rv_dpm_patch_boot_state(struct pp_hwmgr *hwmgr, |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.h index 9dc503055394..c3bc311dc59f 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.h | |||
@@ -304,4 +304,19 @@ struct pp_hwmgr; | |||
304 | 304 | ||
305 | int rv_init_function_pointers(struct pp_hwmgr *hwmgr); | 305 | int rv_init_function_pointers(struct pp_hwmgr *hwmgr); |
306 | 306 | ||
307 | /* UMD PState Raven Msg Parameters in MHz */ | ||
308 | #define RAVEN_UMD_PSTATE_GFXCLK 700 | ||
309 | #define RAVEN_UMD_PSTATE_SOCCLK 626 | ||
310 | #define RAVEN_UMD_PSTATE_FCLK 933 | ||
311 | #define RAVEN_UMD_PSTATE_VCE 0x03C00320 | ||
312 | |||
313 | #define RAVEN_UMD_PSTATE_PEAK_GFXCLK 1100 | ||
314 | #define RAVEN_UMD_PSTATE_PEAK_SOCCLK 757 | ||
315 | #define RAVEN_UMD_PSTATE_PEAK_FCLK 1200 | ||
316 | |||
317 | #define RAVEN_UMD_PSTATE_MIN_GFXCLK 200 | ||
318 | #define RAVEN_UMD_PSTATE_MIN_FCLK 400 | ||
319 | #define RAVEN_UMD_PSTATE_MIN_SOCCLK 200 | ||
320 | #define RAVEN_UMD_PSTATE_MIN_VCE 0x0190012C | ||
321 | |||
307 | #endif | 322 | #endif |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c index 8edb0c4c3876..40adc855c416 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | |||
@@ -2722,9 +2722,6 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
2722 | } | 2722 | } |
2723 | } | 2723 | } |
2724 | 2724 | ||
2725 | smu7_ps->vce_clks.evclk = hwmgr->vce_arbiter.evclk; | ||
2726 | smu7_ps->vce_clks.ecclk = hwmgr->vce_arbiter.ecclk; | ||
2727 | |||
2728 | cgs_get_active_displays_info(hwmgr->device, &info); | 2725 | cgs_get_active_displays_info(hwmgr->device, &info); |
2729 | 2726 | ||
2730 | minimum_clocks.engineClock = hwmgr->display_config.min_core_set_clock; | 2727 | minimum_clocks.engineClock = hwmgr->display_config.min_core_set_clock; |
@@ -2754,38 +2751,6 @@ static int smu7_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
2754 | minimum_clocks.memoryClock = stable_pstate_mclk; | 2751 | minimum_clocks.memoryClock = stable_pstate_mclk; |
2755 | } | 2752 | } |
2756 | 2753 | ||
2757 | if (minimum_clocks.engineClock < hwmgr->gfx_arbiter.sclk) | ||
2758 | minimum_clocks.engineClock = hwmgr->gfx_arbiter.sclk; | ||
2759 | |||
2760 | if (minimum_clocks.memoryClock < hwmgr->gfx_arbiter.mclk) | ||
2761 | minimum_clocks.memoryClock = hwmgr->gfx_arbiter.mclk; | ||
2762 | |||
2763 | smu7_ps->sclk_threshold = hwmgr->gfx_arbiter.sclk_threshold; | ||
2764 | |||
2765 | if (0 != hwmgr->gfx_arbiter.sclk_over_drive) { | ||
2766 | PP_ASSERT_WITH_CODE((hwmgr->gfx_arbiter.sclk_over_drive <= | ||
2767 | hwmgr->platform_descriptor.overdriveLimit.engineClock), | ||
2768 | "Overdrive sclk exceeds limit", | ||
2769 | hwmgr->gfx_arbiter.sclk_over_drive = | ||
2770 | hwmgr->platform_descriptor.overdriveLimit.engineClock); | ||
2771 | |||
2772 | if (hwmgr->gfx_arbiter.sclk_over_drive >= hwmgr->gfx_arbiter.sclk) | ||
2773 | smu7_ps->performance_levels[1].engine_clock = | ||
2774 | hwmgr->gfx_arbiter.sclk_over_drive; | ||
2775 | } | ||
2776 | |||
2777 | if (0 != hwmgr->gfx_arbiter.mclk_over_drive) { | ||
2778 | PP_ASSERT_WITH_CODE((hwmgr->gfx_arbiter.mclk_over_drive <= | ||
2779 | hwmgr->platform_descriptor.overdriveLimit.memoryClock), | ||
2780 | "Overdrive mclk exceeds limit", | ||
2781 | hwmgr->gfx_arbiter.mclk_over_drive = | ||
2782 | hwmgr->platform_descriptor.overdriveLimit.memoryClock); | ||
2783 | |||
2784 | if (hwmgr->gfx_arbiter.mclk_over_drive >= hwmgr->gfx_arbiter.mclk) | ||
2785 | smu7_ps->performance_levels[1].memory_clock = | ||
2786 | hwmgr->gfx_arbiter.mclk_over_drive; | ||
2787 | } | ||
2788 | |||
2789 | disable_mclk_switching_for_frame_lock = phm_cap_enabled( | 2754 | disable_mclk_switching_for_frame_lock = phm_cap_enabled( |
2790 | hwmgr->platform_descriptor.platformCaps, | 2755 | hwmgr->platform_descriptor.platformCaps, |
2791 | PHM_PlatformCaps_DisableMclkSwitchingForFrameLock); | 2756 | PHM_PlatformCaps_DisableMclkSwitchingForFrameLock); |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index 07d256d136ad..2d55dabc77d4 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | |||
@@ -426,9 +426,9 @@ static void vega10_init_dpm_defaults(struct pp_hwmgr *hwmgr) | |||
426 | data->smu_features[GNLD_VR0HOT].supported = true; | 426 | data->smu_features[GNLD_VR0HOT].supported = true; |
427 | 427 | ||
428 | smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetSmuVersion); | 428 | smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetSmuVersion); |
429 | vega10_read_arg_from_smc(hwmgr, &(data->smu_version)); | 429 | vega10_read_arg_from_smc(hwmgr, &(hwmgr->smu_version)); |
430 | /* ACG firmware has major version 5 */ | 430 | /* ACG firmware has major version 5 */ |
431 | if ((data->smu_version & 0xff000000) == 0x5000000) | 431 | if ((hwmgr->smu_version & 0xff000000) == 0x5000000) |
432 | data->smu_features[GNLD_ACG].supported = true; | 432 | data->smu_features[GNLD_ACG].supported = true; |
433 | 433 | ||
434 | if (data->registry_data.didt_support) | 434 | if (data->registry_data.didt_support) |
@@ -2879,8 +2879,8 @@ static int vega10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) | |||
2879 | "DPM is already running right , skipping re-enablement!", | 2879 | "DPM is already running right , skipping re-enablement!", |
2880 | return 0); | 2880 | return 0); |
2881 | 2881 | ||
2882 | if ((data->smu_version == 0x001c2c00) || | 2882 | if ((hwmgr->smu_version == 0x001c2c00) || |
2883 | (data->smu_version == 0x001c2d00)) { | 2883 | (hwmgr->smu_version == 0x001c2d00)) { |
2884 | tmp_result = smum_send_msg_to_smc_with_parameter(hwmgr, | 2884 | tmp_result = smum_send_msg_to_smc_with_parameter(hwmgr, |
2885 | PPSMC_MSG_UpdatePkgPwrPidAlpha, 1); | 2885 | PPSMC_MSG_UpdatePkgPwrPidAlpha, 1); |
2886 | PP_ASSERT_WITH_CODE(!tmp_result, | 2886 | PP_ASSERT_WITH_CODE(!tmp_result, |
@@ -3124,9 +3124,6 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
3124 | } | 3124 | } |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | vega10_ps->vce_clks.evclk = hwmgr->vce_arbiter.evclk; | ||
3128 | vega10_ps->vce_clks.ecclk = hwmgr->vce_arbiter.ecclk; | ||
3129 | |||
3130 | cgs_get_active_displays_info(hwmgr->device, &info); | 3127 | cgs_get_active_displays_info(hwmgr->device, &info); |
3131 | 3128 | ||
3132 | /* result = PHM_CheckVBlankTime(hwmgr, &vblankTooShort);*/ | 3129 | /* result = PHM_CheckVBlankTime(hwmgr, &vblankTooShort);*/ |
@@ -3165,38 +3162,6 @@ static int vega10_apply_state_adjust_rules(struct pp_hwmgr *hwmgr, | |||
3165 | minimum_clocks.memoryClock = stable_pstate_mclk; | 3162 | minimum_clocks.memoryClock = stable_pstate_mclk; |
3166 | } | 3163 | } |
3167 | 3164 | ||
3168 | if (minimum_clocks.engineClock < hwmgr->gfx_arbiter.sclk) | ||
3169 | minimum_clocks.engineClock = hwmgr->gfx_arbiter.sclk; | ||
3170 | |||
3171 | if (minimum_clocks.memoryClock < hwmgr->gfx_arbiter.mclk) | ||
3172 | minimum_clocks.memoryClock = hwmgr->gfx_arbiter.mclk; | ||
3173 | |||
3174 | vega10_ps->sclk_threshold = hwmgr->gfx_arbiter.sclk_threshold; | ||
3175 | |||
3176 | if (hwmgr->gfx_arbiter.sclk_over_drive) { | ||
3177 | PP_ASSERT_WITH_CODE((hwmgr->gfx_arbiter.sclk_over_drive <= | ||
3178 | hwmgr->platform_descriptor.overdriveLimit.engineClock), | ||
3179 | "Overdrive sclk exceeds limit", | ||
3180 | hwmgr->gfx_arbiter.sclk_over_drive = | ||
3181 | hwmgr->platform_descriptor.overdriveLimit.engineClock); | ||
3182 | |||
3183 | if (hwmgr->gfx_arbiter.sclk_over_drive >= hwmgr->gfx_arbiter.sclk) | ||
3184 | vega10_ps->performance_levels[1].gfx_clock = | ||
3185 | hwmgr->gfx_arbiter.sclk_over_drive; | ||
3186 | } | ||
3187 | |||
3188 | if (hwmgr->gfx_arbiter.mclk_over_drive) { | ||
3189 | PP_ASSERT_WITH_CODE((hwmgr->gfx_arbiter.mclk_over_drive <= | ||
3190 | hwmgr->platform_descriptor.overdriveLimit.memoryClock), | ||
3191 | "Overdrive mclk exceeds limit", | ||
3192 | hwmgr->gfx_arbiter.mclk_over_drive = | ||
3193 | hwmgr->platform_descriptor.overdriveLimit.memoryClock); | ||
3194 | |||
3195 | if (hwmgr->gfx_arbiter.mclk_over_drive >= hwmgr->gfx_arbiter.mclk) | ||
3196 | vega10_ps->performance_levels[1].mem_clock = | ||
3197 | hwmgr->gfx_arbiter.mclk_over_drive; | ||
3198 | } | ||
3199 | |||
3200 | disable_mclk_switching_for_frame_lock = phm_cap_enabled( | 3165 | disable_mclk_switching_for_frame_lock = phm_cap_enabled( |
3201 | hwmgr->platform_descriptor.platformCaps, | 3166 | hwmgr->platform_descriptor.platformCaps, |
3202 | PHM_PlatformCaps_DisableMclkSwitchingForFrameLock); | 3167 | PHM_PlatformCaps_DisableMclkSwitchingForFrameLock); |
@@ -3819,10 +3784,7 @@ static int vega10_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
3819 | uint32_t low_sclk_interrupt_threshold = 0; | 3784 | uint32_t low_sclk_interrupt_threshold = 0; |
3820 | 3785 | ||
3821 | if (PP_CAP(PHM_PlatformCaps_SclkThrottleLowNotification) && | 3786 | if (PP_CAP(PHM_PlatformCaps_SclkThrottleLowNotification) && |
3822 | (hwmgr->gfx_arbiter.sclk_threshold != | 3787 | (data->low_sclk_interrupt_threshold != 0)) { |
3823 | data->low_sclk_interrupt_threshold)) { | ||
3824 | data->low_sclk_interrupt_threshold = | ||
3825 | hwmgr->gfx_arbiter.sclk_threshold; | ||
3826 | low_sclk_interrupt_threshold = | 3788 | low_sclk_interrupt_threshold = |
3827 | data->low_sclk_interrupt_threshold; | 3789 | data->low_sclk_interrupt_threshold; |
3828 | 3790 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h index 8f7358cc3327..e8507ff8dbb3 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.h | |||
@@ -387,7 +387,6 @@ struct vega10_hwmgr { | |||
387 | struct vega10_smc_state_table smc_state_table; | 387 | struct vega10_smc_state_table smc_state_table; |
388 | 388 | ||
389 | uint32_t config_telemetry; | 389 | uint32_t config_telemetry; |
390 | uint32_t smu_version; | ||
391 | uint32_t acg_loop_state; | 390 | uint32_t acg_loop_state; |
392 | uint32_t mem_channels; | 391 | uint32_t mem_channels; |
393 | }; | 392 | }; |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h index 57a0467b7267..5716b937a6ad 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hardwaremanager.h | |||
@@ -437,5 +437,6 @@ extern int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr, | |||
437 | 437 | ||
438 | extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); | 438 | extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); |
439 | extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr); | 439 | extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr); |
440 | extern int phm_reset_power_profile_state(struct pp_hwmgr *hwmgr); | ||
440 | #endif /* _HARDWARE_MANAGER_H_ */ | 441 | #endif /* _HARDWARE_MANAGER_H_ */ |
441 | 442 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h index 004a40e88bde..565fe0832f41 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | |||
@@ -105,36 +105,6 @@ struct phm_set_power_state_input { | |||
105 | const struct pp_hw_power_state *pnew_state; | 105 | const struct pp_hw_power_state *pnew_state; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | struct phm_acp_arbiter { | ||
109 | uint32_t acpclk; | ||
110 | }; | ||
111 | |||
112 | struct phm_uvd_arbiter { | ||
113 | uint32_t vclk; | ||
114 | uint32_t dclk; | ||
115 | uint32_t vclk_ceiling; | ||
116 | uint32_t dclk_ceiling; | ||
117 | uint32_t vclk_soft_min; | ||
118 | uint32_t dclk_soft_min; | ||
119 | }; | ||
120 | |||
121 | struct phm_vce_arbiter { | ||
122 | uint32_t evclk; | ||
123 | uint32_t ecclk; | ||
124 | }; | ||
125 | |||
126 | struct phm_gfx_arbiter { | ||
127 | uint32_t sclk; | ||
128 | uint32_t sclk_hard_min; | ||
129 | uint32_t mclk; | ||
130 | uint32_t sclk_over_drive; | ||
131 | uint32_t mclk_over_drive; | ||
132 | uint32_t sclk_threshold; | ||
133 | uint32_t num_cus; | ||
134 | uint32_t gfxclk; | ||
135 | uint32_t fclk; | ||
136 | }; | ||
137 | |||
138 | struct phm_clock_array { | 108 | struct phm_clock_array { |
139 | uint32_t count; | 109 | uint32_t count; |
140 | uint32_t values[1]; | 110 | uint32_t values[1]; |
@@ -722,6 +692,7 @@ enum PP_TABLE_VERSION { | |||
722 | struct pp_hwmgr { | 692 | struct pp_hwmgr { |
723 | uint32_t chip_family; | 693 | uint32_t chip_family; |
724 | uint32_t chip_id; | 694 | uint32_t chip_id; |
695 | uint32_t smu_version; | ||
725 | 696 | ||
726 | uint32_t pp_table_version; | 697 | uint32_t pp_table_version; |
727 | void *device; | 698 | void *device; |
@@ -737,10 +708,6 @@ struct pp_hwmgr { | |||
737 | enum amd_dpm_forced_level dpm_level; | 708 | enum amd_dpm_forced_level dpm_level; |
738 | enum amd_dpm_forced_level saved_dpm_level; | 709 | enum amd_dpm_forced_level saved_dpm_level; |
739 | enum amd_dpm_forced_level request_dpm_level; | 710 | enum amd_dpm_forced_level request_dpm_level; |
740 | struct phm_gfx_arbiter gfx_arbiter; | ||
741 | struct phm_acp_arbiter acp_arbiter; | ||
742 | struct phm_uvd_arbiter uvd_arbiter; | ||
743 | struct phm_vce_arbiter vce_arbiter; | ||
744 | uint32_t usec_timeout; | 711 | uint32_t usec_timeout; |
745 | void *pptable; | 712 | void *pptable; |
746 | struct phm_platform_descriptor platform_descriptor; | 713 | struct phm_platform_descriptor platform_descriptor; |
diff --git a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h index 2b3497135bbd..f15f4df9d0a9 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h +++ b/drivers/gpu/drm/amd/powerplay/inc/rv_ppsmc.h | |||
@@ -75,7 +75,12 @@ | |||
75 | #define PPSMC_MSG_GetMinGfxclkFrequency 0x2C | 75 | #define PPSMC_MSG_GetMinGfxclkFrequency 0x2C |
76 | #define PPSMC_MSG_GetMaxGfxclkFrequency 0x2D | 76 | #define PPSMC_MSG_GetMaxGfxclkFrequency 0x2D |
77 | #define PPSMC_MSG_SoftReset 0x2E | 77 | #define PPSMC_MSG_SoftReset 0x2E |
78 | #define PPSMC_Message_Count 0x2F | 78 | #define PPSMC_MSG_SetSoftMaxGfxClk 0x30 |
79 | #define PPSMC_MSG_SetHardMinGfxClk 0x31 | ||
80 | #define PPSMC_MSG_SetSoftMaxSocclkByFreq 0x32 | ||
81 | #define PPSMC_MSG_SetSoftMaxFclkByFreq 0x33 | ||
82 | #define PPSMC_MSG_SetSoftMaxVcn 0x34 | ||
83 | #define PPSMC_Message_Count 0x35 | ||
79 | 84 | ||
80 | 85 | ||
81 | typedef uint16_t PPSMC_Result; | 86 | typedef uint16_t PPSMC_Result; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c index c36f00ef46f3..0b4a55660de4 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | |||
@@ -2218,10 +2218,7 @@ static int ci_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
2218 | 2218 | ||
2219 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 2219 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
2220 | PHM_PlatformCaps_SclkThrottleLowNotification) | 2220 | PHM_PlatformCaps_SclkThrottleLowNotification) |
2221 | && (hwmgr->gfx_arbiter.sclk_threshold != | 2221 | && (data->low_sclk_interrupt_threshold != 0)) { |
2222 | data->low_sclk_interrupt_threshold)) { | ||
2223 | data->low_sclk_interrupt_threshold = | ||
2224 | hwmgr->gfx_arbiter.sclk_threshold; | ||
2225 | low_sclk_interrupt_threshold = | 2222 | low_sclk_interrupt_threshold = |
2226 | data->low_sclk_interrupt_threshold; | 2223 | data->low_sclk_interrupt_threshold; |
2227 | 2224 | ||
@@ -2319,6 +2316,7 @@ static int ci_load_smc_ucode(struct pp_hwmgr *hwmgr) | |||
2319 | cgs_get_firmware_info(hwmgr->device, CGS_UCODE_ID_SMU, &info); | 2316 | cgs_get_firmware_info(hwmgr->device, CGS_UCODE_ID_SMU, &info); |
2320 | 2317 | ||
2321 | hwmgr->is_kicker = info.is_kicker; | 2318 | hwmgr->is_kicker = info.is_kicker; |
2319 | hwmgr->smu_version = info.version; | ||
2322 | byte_count = info.image_size; | 2320 | byte_count = info.image_size; |
2323 | src = (uint8_t *)info.kptr; | 2321 | src = (uint8_t *)info.kptr; |
2324 | start_addr = info.ucode_start_address; | 2322 | start_addr = info.ucode_start_address; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c index f572beff197f..085d81c8b332 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | |||
@@ -2385,10 +2385,7 @@ static int fiji_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
2385 | 2385 | ||
2386 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 2386 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
2387 | PHM_PlatformCaps_SclkThrottleLowNotification) | 2387 | PHM_PlatformCaps_SclkThrottleLowNotification) |
2388 | && (hwmgr->gfx_arbiter.sclk_threshold != | 2388 | && (data->low_sclk_interrupt_threshold != 0)) { |
2389 | data->low_sclk_interrupt_threshold)) { | ||
2390 | data->low_sclk_interrupt_threshold = | ||
2391 | hwmgr->gfx_arbiter.sclk_threshold; | ||
2392 | low_sclk_interrupt_threshold = | 2389 | low_sclk_interrupt_threshold = |
2393 | data->low_sclk_interrupt_threshold; | 2390 | data->low_sclk_interrupt_threshold; |
2394 | 2391 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c index d62078681cae..125312691f75 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | |||
@@ -204,7 +204,7 @@ static int iceland_smu_upload_firmware_image(struct pp_hwmgr *hwmgr) | |||
204 | pr_err("[ powerplay ] SMC address is beyond the SMC RAM area\n"); | 204 | pr_err("[ powerplay ] SMC address is beyond the SMC RAM area\n"); |
205 | return -EINVAL; | 205 | return -EINVAL; |
206 | } | 206 | } |
207 | 207 | hwmgr->smu_version = info.version; | |
208 | /* wait for smc boot up */ | 208 | /* wait for smc boot up */ |
209 | PHM_WAIT_INDIRECT_FIELD_UNEQUAL(hwmgr, SMC_IND, | 209 | PHM_WAIT_INDIRECT_FIELD_UNEQUAL(hwmgr, SMC_IND, |
210 | RCU_UC_EVENTS, boot_seq_done, 0); | 210 | RCU_UC_EVENTS, boot_seq_done, 0); |
@@ -2202,10 +2202,7 @@ static int iceland_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
2202 | 2202 | ||
2203 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 2203 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
2204 | PHM_PlatformCaps_SclkThrottleLowNotification) | 2204 | PHM_PlatformCaps_SclkThrottleLowNotification) |
2205 | && (hwmgr->gfx_arbiter.sclk_threshold != | 2205 | && (data->low_sclk_interrupt_threshold != 0)) { |
2206 | data->low_sclk_interrupt_threshold)) { | ||
2207 | data->low_sclk_interrupt_threshold = | ||
2208 | hwmgr->gfx_arbiter.sclk_threshold; | ||
2209 | low_sclk_interrupt_threshold = | 2206 | low_sclk_interrupt_threshold = |
2210 | data->low_sclk_interrupt_threshold; | 2207 | data->low_sclk_interrupt_threshold; |
2211 | 2208 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c index bd6be7793ca7..cdb47657b567 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c | |||
@@ -2369,10 +2369,7 @@ static int polaris10_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
2369 | 2369 | ||
2370 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 2370 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
2371 | PHM_PlatformCaps_SclkThrottleLowNotification) | 2371 | PHM_PlatformCaps_SclkThrottleLowNotification) |
2372 | && (hwmgr->gfx_arbiter.sclk_threshold != | 2372 | && (data->low_sclk_interrupt_threshold != 0)) { |
2373 | data->low_sclk_interrupt_threshold)) { | ||
2374 | data->low_sclk_interrupt_threshold = | ||
2375 | hwmgr->gfx_arbiter.sclk_threshold; | ||
2376 | low_sclk_interrupt_threshold = | 2373 | low_sclk_interrupt_threshold = |
2377 | data->low_sclk_interrupt_threshold; | 2374 | data->low_sclk_interrupt_threshold; |
2378 | 2375 | ||
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c index b98ade676d12..2d662b44af54 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c | |||
@@ -305,6 +305,14 @@ static int rv_smu_fini(struct pp_hwmgr *hwmgr) | |||
305 | 305 | ||
306 | static int rv_start_smu(struct pp_hwmgr *hwmgr) | 306 | static int rv_start_smu(struct pp_hwmgr *hwmgr) |
307 | { | 307 | { |
308 | struct cgs_firmware_info info = {0}; | ||
309 | |||
310 | smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetSmuVersion); | ||
311 | rv_read_arg_from_smc(hwmgr, &hwmgr->smu_version); | ||
312 | info.version = hwmgr->smu_version >> 8; | ||
313 | |||
314 | cgs_get_firmware_info(hwmgr->device, CGS_UCODE_ID_SMU, &info); | ||
315 | |||
308 | if (rv_verify_smc_interface(hwmgr)) | 316 | if (rv_verify_smc_interface(hwmgr)) |
309 | return -EINVAL; | 317 | return -EINVAL; |
310 | if (rv_smc_enable_sdma(hwmgr)) | 318 | if (rv_smc_enable_sdma(hwmgr)) |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 7f5359a97ef2..cb95e882b98f 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | |||
@@ -535,7 +535,7 @@ int smu7_upload_smu_firmware_image(struct pp_hwmgr *hwmgr) | |||
535 | smu7_convert_fw_type_to_cgs(UCODE_ID_SMU_SK), &info); | 535 | smu7_convert_fw_type_to_cgs(UCODE_ID_SMU_SK), &info); |
536 | 536 | ||
537 | hwmgr->is_kicker = info.is_kicker; | 537 | hwmgr->is_kicker = info.is_kicker; |
538 | 538 | hwmgr->smu_version = info.version; | |
539 | result = smu7_upload_smc_firmware_data(hwmgr, info.image_size, (uint32_t *)info.kptr, SMU7_SMC_SIZE); | 539 | result = smu7_upload_smc_firmware_data(hwmgr, info.image_size, (uint32_t *)info.kptr, SMU7_SMC_SIZE); |
540 | 540 | ||
541 | return result; | 541 | return result; |
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c index 81b8790c0d22..79e5c05571bc 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c | |||
@@ -2654,10 +2654,7 @@ static int tonga_update_sclk_threshold(struct pp_hwmgr *hwmgr) | |||
2654 | 2654 | ||
2655 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, | 2655 | if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, |
2656 | PHM_PlatformCaps_SclkThrottleLowNotification) | 2656 | PHM_PlatformCaps_SclkThrottleLowNotification) |
2657 | && (hwmgr->gfx_arbiter.sclk_threshold != | 2657 | && (data->low_sclk_interrupt_threshold != 0)) { |
2658 | data->low_sclk_interrupt_threshold)) { | ||
2659 | data->low_sclk_interrupt_threshold = | ||
2660 | hwmgr->gfx_arbiter.sclk_threshold; | ||
2661 | low_sclk_interrupt_threshold = | 2658 | low_sclk_interrupt_threshold = |
2662 | data->low_sclk_interrupt_threshold; | 2659 | data->low_sclk_interrupt_threshold; |
2663 | 2660 | ||
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h b/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h deleted file mode 100644 index b42a78922505..000000000000 --- a/drivers/gpu/drm/amd/scheduler/gpu_sched_trace.h +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #if !defined(_GPU_SCHED_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) | ||
25 | #define _GPU_SCHED_TRACE_H_ | ||
26 | |||
27 | #include <linux/stringify.h> | ||
28 | #include <linux/types.h> | ||
29 | #include <linux/tracepoint.h> | ||
30 | |||
31 | #include <drm/drmP.h> | ||
32 | |||
33 | #undef TRACE_SYSTEM | ||
34 | #define TRACE_SYSTEM gpu_sched | ||
35 | #define TRACE_INCLUDE_FILE gpu_sched_trace | ||
36 | |||
37 | TRACE_EVENT(amd_sched_job, | ||
38 | TP_PROTO(struct amd_sched_job *sched_job, struct amd_sched_entity *entity), | ||
39 | TP_ARGS(sched_job, entity), | ||
40 | TP_STRUCT__entry( | ||
41 | __field(struct amd_sched_entity *, entity) | ||
42 | __field(struct dma_fence *, fence) | ||
43 | __field(const char *, name) | ||
44 | __field(uint64_t, id) | ||
45 | __field(u32, job_count) | ||
46 | __field(int, hw_job_count) | ||
47 | ), | ||
48 | |||
49 | TP_fast_assign( | ||
50 | __entry->entity = entity; | ||
51 | __entry->id = sched_job->id; | ||
52 | __entry->fence = &sched_job->s_fence->finished; | ||
53 | __entry->name = sched_job->sched->name; | ||
54 | __entry->job_count = spsc_queue_count(&entity->job_queue); | ||
55 | __entry->hw_job_count = atomic_read( | ||
56 | &sched_job->sched->hw_rq_count); | ||
57 | ), | ||
58 | TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d", | ||
59 | __entry->entity, __entry->id, | ||
60 | __entry->fence, __entry->name, | ||
61 | __entry->job_count, __entry->hw_job_count) | ||
62 | ); | ||
63 | |||
64 | TRACE_EVENT(amd_sched_process_job, | ||
65 | TP_PROTO(struct amd_sched_fence *fence), | ||
66 | TP_ARGS(fence), | ||
67 | TP_STRUCT__entry( | ||
68 | __field(struct dma_fence *, fence) | ||
69 | ), | ||
70 | |||
71 | TP_fast_assign( | ||
72 | __entry->fence = &fence->finished; | ||
73 | ), | ||
74 | TP_printk("fence=%p signaled", __entry->fence) | ||
75 | ); | ||
76 | |||
77 | #endif | ||
78 | |||
79 | /* This part must be outside protection */ | ||
80 | #undef TRACE_INCLUDE_PATH | ||
81 | #define TRACE_INCLUDE_PATH . | ||
82 | #include <trace/define_trace.h> | ||
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h deleted file mode 100644 index b590fcc2786a..000000000000 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +++ /dev/null | |||
@@ -1,186 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2015 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef _GPU_SCHEDULER_H_ | ||
25 | #define _GPU_SCHEDULER_H_ | ||
26 | |||
27 | #include <linux/kfifo.h> | ||
28 | #include <linux/dma-fence.h> | ||
29 | #include "spsc_queue.h" | ||
30 | |||
31 | struct amd_gpu_scheduler; | ||
32 | struct amd_sched_rq; | ||
33 | |||
34 | enum amd_sched_priority { | ||
35 | AMD_SCHED_PRIORITY_MIN, | ||
36 | AMD_SCHED_PRIORITY_LOW = AMD_SCHED_PRIORITY_MIN, | ||
37 | AMD_SCHED_PRIORITY_NORMAL, | ||
38 | AMD_SCHED_PRIORITY_HIGH_SW, | ||
39 | AMD_SCHED_PRIORITY_HIGH_HW, | ||
40 | AMD_SCHED_PRIORITY_KERNEL, | ||
41 | AMD_SCHED_PRIORITY_MAX, | ||
42 | AMD_SCHED_PRIORITY_INVALID = -1, | ||
43 | AMD_SCHED_PRIORITY_UNSET = -2 | ||
44 | }; | ||
45 | |||
46 | |||
47 | /** | ||
48 | * A scheduler entity is a wrapper around a job queue or a group | ||
49 | * of other entities. Entities take turns emitting jobs from their | ||
50 | * job queues to corresponding hardware ring based on scheduling | ||
51 | * policy. | ||
52 | */ | ||
53 | struct amd_sched_entity { | ||
54 | struct list_head list; | ||
55 | struct amd_sched_rq *rq; | ||
56 | spinlock_t rq_lock; | ||
57 | struct amd_gpu_scheduler *sched; | ||
58 | |||
59 | spinlock_t queue_lock; | ||
60 | struct spsc_queue job_queue; | ||
61 | |||
62 | atomic_t fence_seq; | ||
63 | uint64_t fence_context; | ||
64 | |||
65 | struct dma_fence *dependency; | ||
66 | struct dma_fence_cb cb; | ||
67 | atomic_t *guilty; /* points to ctx's guilty */ | ||
68 | }; | ||
69 | |||
70 | /** | ||
71 | * Run queue is a set of entities scheduling command submissions for | ||
72 | * one specific ring. It implements the scheduling policy that selects | ||
73 | * the next entity to emit commands from. | ||
74 | */ | ||
75 | struct amd_sched_rq { | ||
76 | spinlock_t lock; | ||
77 | struct list_head entities; | ||
78 | struct amd_sched_entity *current_entity; | ||
79 | }; | ||
80 | |||
81 | struct amd_sched_fence { | ||
82 | struct dma_fence scheduled; | ||
83 | struct dma_fence finished; | ||
84 | struct dma_fence_cb cb; | ||
85 | struct dma_fence *parent; | ||
86 | struct amd_gpu_scheduler *sched; | ||
87 | spinlock_t lock; | ||
88 | void *owner; | ||
89 | }; | ||
90 | |||
91 | struct amd_sched_job { | ||
92 | struct spsc_node queue_node; | ||
93 | struct amd_gpu_scheduler *sched; | ||
94 | struct amd_sched_fence *s_fence; | ||
95 | struct dma_fence_cb finish_cb; | ||
96 | struct work_struct finish_work; | ||
97 | struct list_head node; | ||
98 | struct delayed_work work_tdr; | ||
99 | uint64_t id; | ||
100 | atomic_t karma; | ||
101 | enum amd_sched_priority s_priority; | ||
102 | }; | ||
103 | |||
104 | extern const struct dma_fence_ops amd_sched_fence_ops_scheduled; | ||
105 | extern const struct dma_fence_ops amd_sched_fence_ops_finished; | ||
106 | static inline struct amd_sched_fence *to_amd_sched_fence(struct dma_fence *f) | ||
107 | { | ||
108 | if (f->ops == &amd_sched_fence_ops_scheduled) | ||
109 | return container_of(f, struct amd_sched_fence, scheduled); | ||
110 | |||
111 | if (f->ops == &amd_sched_fence_ops_finished) | ||
112 | return container_of(f, struct amd_sched_fence, finished); | ||
113 | |||
114 | return NULL; | ||
115 | } | ||
116 | |||
117 | static inline bool amd_sched_invalidate_job(struct amd_sched_job *s_job, int threshold) | ||
118 | { | ||
119 | return (s_job && atomic_inc_return(&s_job->karma) > threshold); | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * Define the backend operations called by the scheduler, | ||
124 | * these functions should be implemented in driver side | ||
125 | */ | ||
126 | struct amd_sched_backend_ops { | ||
127 | struct dma_fence *(*dependency)(struct amd_sched_job *sched_job, | ||
128 | struct amd_sched_entity *s_entity); | ||
129 | struct dma_fence *(*run_job)(struct amd_sched_job *sched_job); | ||
130 | void (*timedout_job)(struct amd_sched_job *sched_job); | ||
131 | void (*free_job)(struct amd_sched_job *sched_job); | ||
132 | }; | ||
133 | |||
134 | /** | ||
135 | * One scheduler is implemented for each hardware ring | ||
136 | */ | ||
137 | struct amd_gpu_scheduler { | ||
138 | const struct amd_sched_backend_ops *ops; | ||
139 | uint32_t hw_submission_limit; | ||
140 | long timeout; | ||
141 | const char *name; | ||
142 | struct amd_sched_rq sched_rq[AMD_SCHED_PRIORITY_MAX]; | ||
143 | wait_queue_head_t wake_up_worker; | ||
144 | wait_queue_head_t job_scheduled; | ||
145 | atomic_t hw_rq_count; | ||
146 | atomic64_t job_id_count; | ||
147 | struct task_struct *thread; | ||
148 | struct list_head ring_mirror_list; | ||
149 | spinlock_t job_list_lock; | ||
150 | int hang_limit; | ||
151 | }; | ||
152 | |||
153 | int amd_sched_init(struct amd_gpu_scheduler *sched, | ||
154 | const struct amd_sched_backend_ops *ops, | ||
155 | uint32_t hw_submission, unsigned hang_limit, long timeout, const char *name); | ||
156 | void amd_sched_fini(struct amd_gpu_scheduler *sched); | ||
157 | |||
158 | int amd_sched_entity_init(struct amd_gpu_scheduler *sched, | ||
159 | struct amd_sched_entity *entity, | ||
160 | struct amd_sched_rq *rq, | ||
161 | uint32_t jobs, atomic_t* guilty); | ||
162 | void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, | ||
163 | struct amd_sched_entity *entity); | ||
164 | void amd_sched_entity_push_job(struct amd_sched_job *sched_job, | ||
165 | struct amd_sched_entity *entity); | ||
166 | void amd_sched_entity_set_rq(struct amd_sched_entity *entity, | ||
167 | struct amd_sched_rq *rq); | ||
168 | |||
169 | int amd_sched_fence_slab_init(void); | ||
170 | void amd_sched_fence_slab_fini(void); | ||
171 | |||
172 | struct amd_sched_fence *amd_sched_fence_create( | ||
173 | struct amd_sched_entity *s_entity, void *owner); | ||
174 | void amd_sched_fence_scheduled(struct amd_sched_fence *fence); | ||
175 | void amd_sched_fence_finished(struct amd_sched_fence *fence); | ||
176 | int amd_sched_job_init(struct amd_sched_job *job, | ||
177 | struct amd_gpu_scheduler *sched, | ||
178 | struct amd_sched_entity *entity, | ||
179 | void *owner); | ||
180 | void amd_sched_hw_job_reset(struct amd_gpu_scheduler *sched, struct amd_sched_job *job); | ||
181 | void amd_sched_job_recovery(struct amd_gpu_scheduler *sched); | ||
182 | bool amd_sched_dependency_optimized(struct dma_fence* fence, | ||
183 | struct amd_sched_entity *entity); | ||
184 | void amd_sched_job_kickout(struct amd_sched_job *s_job); | ||
185 | |||
186 | #endif | ||
diff --git a/drivers/gpu/drm/amd/scheduler/spsc_queue.h b/drivers/gpu/drm/amd/scheduler/spsc_queue.h deleted file mode 100644 index 5902f35ce759..000000000000 --- a/drivers/gpu/drm/amd/scheduler/spsc_queue.h +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | * OTHER DEALINGS IN THE SOFTWARE. | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef AMD_SCHEDULER_SPSC_QUEUE_H_ | ||
25 | #define AMD_SCHEDULER_SPSC_QUEUE_H_ | ||
26 | |||
27 | #include <linux/atomic.h> | ||
28 | |||
29 | /** SPSC lockless queue */ | ||
30 | |||
31 | struct spsc_node { | ||
32 | |||
33 | /* Stores spsc_node* */ | ||
34 | struct spsc_node *next; | ||
35 | }; | ||
36 | |||
37 | struct spsc_queue { | ||
38 | |||
39 | struct spsc_node *head; | ||
40 | |||
41 | /* atomic pointer to struct spsc_node* */ | ||
42 | atomic_long_t tail; | ||
43 | |||
44 | atomic_t job_count; | ||
45 | }; | ||
46 | |||
47 | static inline void spsc_queue_init(struct spsc_queue *queue) | ||
48 | { | ||
49 | queue->head = NULL; | ||
50 | atomic_long_set(&queue->tail, (long)&queue->head); | ||
51 | atomic_set(&queue->job_count, 0); | ||
52 | } | ||
53 | |||
54 | static inline struct spsc_node *spsc_queue_peek(struct spsc_queue *queue) | ||
55 | { | ||
56 | return queue->head; | ||
57 | } | ||
58 | |||
59 | static inline int spsc_queue_count(struct spsc_queue *queue) | ||
60 | { | ||
61 | return atomic_read(&queue->job_count); | ||
62 | } | ||
63 | |||
64 | static inline bool spsc_queue_push(struct spsc_queue *queue, struct spsc_node *node) | ||
65 | { | ||
66 | struct spsc_node **tail; | ||
67 | |||
68 | node->next = NULL; | ||
69 | |||
70 | preempt_disable(); | ||
71 | |||
72 | tail = (struct spsc_node **)atomic_long_xchg(&queue->tail, (long)&node->next); | ||
73 | WRITE_ONCE(*tail, node); | ||
74 | atomic_inc(&queue->job_count); | ||
75 | |||
76 | /* | ||
77 | * In case of first element verify new node will be visible to the consumer | ||
78 | * thread when we ping the kernel thread that there is new work to do. | ||
79 | */ | ||
80 | smp_wmb(); | ||
81 | |||
82 | preempt_enable(); | ||
83 | |||
84 | return tail == &queue->head; | ||
85 | } | ||
86 | |||
87 | |||
88 | static inline struct spsc_node *spsc_queue_pop(struct spsc_queue *queue) | ||
89 | { | ||
90 | struct spsc_node *next, *node; | ||
91 | |||
92 | /* Verify reading from memory and not the cache */ | ||
93 | smp_rmb(); | ||
94 | |||
95 | node = READ_ONCE(queue->head); | ||
96 | |||
97 | if (!node) | ||
98 | return NULL; | ||
99 | |||
100 | next = READ_ONCE(node->next); | ||
101 | WRITE_ONCE(queue->head, next); | ||
102 | |||
103 | if (unlikely(!next)) { | ||
104 | /* slowpath for the last element in the queue */ | ||
105 | |||
106 | if (atomic_long_cmpxchg(&queue->tail, | ||
107 | (long)&node->next, (long) &queue->head) != (long)&node->next) { | ||
108 | /* Updating tail failed wait for new next to appear */ | ||
109 | do { | ||
110 | smp_rmb(); | ||
111 | } while (unlikely(!(queue->head = READ_ONCE(node->next)))); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | atomic_dec(&queue->job_count); | ||
116 | return node; | ||
117 | } | ||
118 | |||
119 | |||
120 | |||
121 | #endif /* AMD_SCHEDULER_SPSC_QUEUE_H_ */ | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 949bf6b3feab..6b6fb2080ac3 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c | |||
@@ -1226,7 +1226,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
1226 | if (ret) | 1226 | if (ret) |
1227 | goto out; | 1227 | goto out; |
1228 | 1228 | ||
1229 | ret = ttm_bo_move_ttm(bo, intr, no_wait_gpu, new_reg); | 1229 | ret = ttm_bo_move_ttm(bo, &ctx, new_reg); |
1230 | out: | 1230 | out: |
1231 | ttm_bo_mem_put(bo, &tmp_reg); | 1231 | ttm_bo_mem_put(bo, &tmp_reg); |
1232 | return ret; | 1232 | return ret; |
@@ -1255,7 +1255,7 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, | |||
1255 | if (ret) | 1255 | if (ret) |
1256 | return ret; | 1256 | return ret; |
1257 | 1257 | ||
1258 | ret = ttm_bo_move_ttm(bo, intr, no_wait_gpu, &tmp_reg); | 1258 | ret = ttm_bo_move_ttm(bo, &ctx, &tmp_reg); |
1259 | if (ret) | 1259 | if (ret) |
1260 | goto out; | 1260 | goto out; |
1261 | 1261 | ||
@@ -1380,8 +1380,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, | |||
1380 | /* Fallback to software copy. */ | 1380 | /* Fallback to software copy. */ |
1381 | ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); | 1381 | ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); |
1382 | if (ret == 0) | 1382 | if (ret == 0) |
1383 | ret = ttm_bo_move_memcpy(bo, ctx->interruptible, | 1383 | ret = ttm_bo_move_memcpy(bo, ctx, new_reg); |
1384 | ctx->no_wait_gpu, new_reg); | ||
1385 | 1384 | ||
1386 | out: | 1385 | out: |
1387 | if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) { | 1386 | if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) { |
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index d866f329e7d8..78ce118d9157 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c | |||
@@ -357,8 +357,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict, | |||
357 | qxl_move_null(bo, new_mem); | 357 | qxl_move_null(bo, new_mem); |
358 | return 0; | 358 | return 0; |
359 | } | 359 | } |
360 | return ttm_bo_move_memcpy(bo, ctx->interruptible, ctx->no_wait_gpu, | 360 | return ttm_bo_move_memcpy(bo, ctx, new_mem); |
361 | new_mem); | ||
362 | } | 361 | } |
363 | 362 | ||
364 | static void qxl_bo_move_notify(struct ttm_buffer_object *bo, | 363 | static void qxl_bo_move_notify(struct ttm_buffer_object *bo, |
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index a6511918f632..d3045a371a55 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c | |||
@@ -1627,8 +1627,6 @@ static const u32 godavari_golden_registers[] = | |||
1627 | 1627 | ||
1628 | static void cik_init_golden_registers(struct radeon_device *rdev) | 1628 | static void cik_init_golden_registers(struct radeon_device *rdev) |
1629 | { | 1629 | { |
1630 | /* Some of the registers might be dependent on GRBM_GFX_INDEX */ | ||
1631 | mutex_lock(&rdev->grbm_idx_mutex); | ||
1632 | switch (rdev->family) { | 1630 | switch (rdev->family) { |
1633 | case CHIP_BONAIRE: | 1631 | case CHIP_BONAIRE: |
1634 | radeon_program_register_sequence(rdev, | 1632 | radeon_program_register_sequence(rdev, |
@@ -1703,7 +1701,6 @@ static void cik_init_golden_registers(struct radeon_device *rdev) | |||
1703 | default: | 1701 | default: |
1704 | break; | 1702 | break; |
1705 | } | 1703 | } |
1706 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
1707 | } | 1704 | } |
1708 | 1705 | ||
1709 | /** | 1706 | /** |
@@ -3120,7 +3117,6 @@ static void cik_setup_rb(struct radeon_device *rdev, | |||
3120 | u32 disabled_rbs = 0; | 3117 | u32 disabled_rbs = 0; |
3121 | u32 enabled_rbs = 0; | 3118 | u32 enabled_rbs = 0; |
3122 | 3119 | ||
3123 | mutex_lock(&rdev->grbm_idx_mutex); | ||
3124 | for (i = 0; i < se_num; i++) { | 3120 | for (i = 0; i < se_num; i++) { |
3125 | for (j = 0; j < sh_per_se; j++) { | 3121 | for (j = 0; j < sh_per_se; j++) { |
3126 | cik_select_se_sh(rdev, i, j); | 3122 | cik_select_se_sh(rdev, i, j); |
@@ -3132,7 +3128,6 @@ static void cik_setup_rb(struct radeon_device *rdev, | |||
3132 | } | 3128 | } |
3133 | } | 3129 | } |
3134 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 3130 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
3135 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
3136 | 3131 | ||
3137 | mask = 1; | 3132 | mask = 1; |
3138 | for (i = 0; i < max_rb_num_per_se * se_num; i++) { | 3133 | for (i = 0; i < max_rb_num_per_se * se_num; i++) { |
@@ -3143,7 +3138,6 @@ static void cik_setup_rb(struct radeon_device *rdev, | |||
3143 | 3138 | ||
3144 | rdev->config.cik.backend_enable_mask = enabled_rbs; | 3139 | rdev->config.cik.backend_enable_mask = enabled_rbs; |
3145 | 3140 | ||
3146 | mutex_lock(&rdev->grbm_idx_mutex); | ||
3147 | for (i = 0; i < se_num; i++) { | 3141 | for (i = 0; i < se_num; i++) { |
3148 | cik_select_se_sh(rdev, i, 0xffffffff); | 3142 | cik_select_se_sh(rdev, i, 0xffffffff); |
3149 | data = 0; | 3143 | data = 0; |
@@ -3171,7 +3165,6 @@ static void cik_setup_rb(struct radeon_device *rdev, | |||
3171 | WREG32(PA_SC_RASTER_CONFIG, data); | 3165 | WREG32(PA_SC_RASTER_CONFIG, data); |
3172 | } | 3166 | } |
3173 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 3167 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
3174 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
3175 | } | 3168 | } |
3176 | 3169 | ||
3177 | /** | 3170 | /** |
@@ -3391,12 +3384,6 @@ static void cik_gpu_init(struct radeon_device *rdev) | |||
3391 | /* set HW defaults for 3D engine */ | 3384 | /* set HW defaults for 3D engine */ |
3392 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); | 3385 | WREG32(CP_MEQ_THRESHOLDS, MEQ1_START(0x30) | MEQ2_START(0x60)); |
3393 | 3386 | ||
3394 | mutex_lock(&rdev->grbm_idx_mutex); | ||
3395 | /* | ||
3396 | * making sure that the following register writes will be broadcasted | ||
3397 | * to all the shaders | ||
3398 | */ | ||
3399 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | ||
3400 | WREG32(SX_DEBUG_1, 0x20); | 3387 | WREG32(SX_DEBUG_1, 0x20); |
3401 | 3388 | ||
3402 | WREG32(TA_CNTL_AUX, 0x00010000); | 3389 | WREG32(TA_CNTL_AUX, 0x00010000); |
@@ -3452,7 +3439,6 @@ static void cik_gpu_init(struct radeon_device *rdev) | |||
3452 | 3439 | ||
3453 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); | 3440 | WREG32(PA_CL_ENHANCE, CLIP_VTX_REORDER_ENA | NUM_CLIP_SEQ(3)); |
3454 | WREG32(PA_SC_ENHANCE, ENABLE_PA_SC_OUT_OF_ORDER); | 3441 | WREG32(PA_SC_ENHANCE, ENABLE_PA_SC_OUT_OF_ORDER); |
3455 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
3456 | 3442 | ||
3457 | udelay(50); | 3443 | udelay(50); |
3458 | } | 3444 | } |
@@ -4432,11 +4418,12 @@ static int cik_mec_init(struct radeon_device *rdev) | |||
4432 | /* | 4418 | /* |
4433 | * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total | 4419 | * KV: 2 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 64 Queues total |
4434 | * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total | 4420 | * CI/KB: 1 MEC, 4 Pipes/MEC, 8 Queues/Pipe - 32 Queues total |
4435 | * Nonetheless, we assign only 1 pipe because all other pipes will | ||
4436 | * be handled by KFD | ||
4437 | */ | 4421 | */ |
4438 | rdev->mec.num_mec = 1; | 4422 | if (rdev->family == CHIP_KAVERI) |
4439 | rdev->mec.num_pipe = 1; | 4423 | rdev->mec.num_mec = 2; |
4424 | else | ||
4425 | rdev->mec.num_mec = 1; | ||
4426 | rdev->mec.num_pipe = 4; | ||
4440 | rdev->mec.num_queue = rdev->mec.num_mec * rdev->mec.num_pipe * 8; | 4427 | rdev->mec.num_queue = rdev->mec.num_mec * rdev->mec.num_pipe * 8; |
4441 | 4428 | ||
4442 | if (rdev->mec.hpd_eop_obj == NULL) { | 4429 | if (rdev->mec.hpd_eop_obj == NULL) { |
@@ -4579,8 +4566,11 @@ static int cik_cp_compute_resume(struct radeon_device *rdev) | |||
4579 | /* init the pipes */ | 4566 | /* init the pipes */ |
4580 | mutex_lock(&rdev->srbm_mutex); | 4567 | mutex_lock(&rdev->srbm_mutex); |
4581 | 4568 | ||
4582 | for (i = 0; i < rdev->mec.num_pipe; ++i) { | 4569 | for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); ++i) { |
4583 | cik_srbm_select(rdev, 0, i, 0, 0); | 4570 | int me = (i < 4) ? 1 : 2; |
4571 | int pipe = (i < 4) ? i : (i - 4); | ||
4572 | |||
4573 | cik_srbm_select(rdev, me, pipe, 0, 0); | ||
4584 | 4574 | ||
4585 | eop_gpu_addr = rdev->mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE * 2) ; | 4575 | eop_gpu_addr = rdev->mec.hpd_eop_gpu_addr + (i * MEC_HPD_SIZE * 2) ; |
4586 | /* write the EOP addr */ | 4576 | /* write the EOP addr */ |
@@ -4597,6 +4587,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev) | |||
4597 | WREG32(CP_HPD_EOP_CONTROL, tmp); | 4587 | WREG32(CP_HPD_EOP_CONTROL, tmp); |
4598 | 4588 | ||
4599 | } | 4589 | } |
4590 | cik_srbm_select(rdev, 0, 0, 0, 0); | ||
4600 | mutex_unlock(&rdev->srbm_mutex); | 4591 | mutex_unlock(&rdev->srbm_mutex); |
4601 | 4592 | ||
4602 | /* init the queues. Just two for now. */ | 4593 | /* init the queues. Just two for now. */ |
@@ -5830,7 +5821,6 @@ static void cik_wait_for_rlc_serdes(struct radeon_device *rdev) | |||
5830 | u32 i, j, k; | 5821 | u32 i, j, k; |
5831 | u32 mask; | 5822 | u32 mask; |
5832 | 5823 | ||
5833 | mutex_lock(&rdev->grbm_idx_mutex); | ||
5834 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { | 5824 | for (i = 0; i < rdev->config.cik.max_shader_engines; i++) { |
5835 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { | 5825 | for (j = 0; j < rdev->config.cik.max_sh_per_se; j++) { |
5836 | cik_select_se_sh(rdev, i, j); | 5826 | cik_select_se_sh(rdev, i, j); |
@@ -5842,7 +5832,6 @@ static void cik_wait_for_rlc_serdes(struct radeon_device *rdev) | |||
5842 | } | 5832 | } |
5843 | } | 5833 | } |
5844 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 5834 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
5845 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
5846 | 5835 | ||
5847 | mask = SE_MASTER_BUSY_MASK | GC_MASTER_BUSY | TC0_MASTER_BUSY | TC1_MASTER_BUSY; | 5836 | mask = SE_MASTER_BUSY_MASK | GC_MASTER_BUSY | TC0_MASTER_BUSY | TC1_MASTER_BUSY; |
5848 | for (k = 0; k < rdev->usec_timeout; k++) { | 5837 | for (k = 0; k < rdev->usec_timeout; k++) { |
@@ -5977,12 +5966,10 @@ static int cik_rlc_resume(struct radeon_device *rdev) | |||
5977 | WREG32(RLC_LB_CNTR_INIT, 0); | 5966 | WREG32(RLC_LB_CNTR_INIT, 0); |
5978 | WREG32(RLC_LB_CNTR_MAX, 0x00008000); | 5967 | WREG32(RLC_LB_CNTR_MAX, 0x00008000); |
5979 | 5968 | ||
5980 | mutex_lock(&rdev->grbm_idx_mutex); | ||
5981 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 5969 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
5982 | WREG32(RLC_LB_INIT_CU_MASK, 0xffffffff); | 5970 | WREG32(RLC_LB_INIT_CU_MASK, 0xffffffff); |
5983 | WREG32(RLC_LB_PARAMS, 0x00600408); | 5971 | WREG32(RLC_LB_PARAMS, 0x00600408); |
5984 | WREG32(RLC_LB_CNTL, 0x80000004); | 5972 | WREG32(RLC_LB_CNTL, 0x80000004); |
5985 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
5986 | 5973 | ||
5987 | WREG32(RLC_MC_CNTL, 0); | 5974 | WREG32(RLC_MC_CNTL, 0); |
5988 | WREG32(RLC_UCODE_CNTL, 0); | 5975 | WREG32(RLC_UCODE_CNTL, 0); |
@@ -6049,13 +6036,11 @@ static void cik_enable_cgcg(struct radeon_device *rdev, bool enable) | |||
6049 | 6036 | ||
6050 | tmp = cik_halt_rlc(rdev); | 6037 | tmp = cik_halt_rlc(rdev); |
6051 | 6038 | ||
6052 | mutex_lock(&rdev->grbm_idx_mutex); | ||
6053 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 6039 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
6054 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); | 6040 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
6055 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); | 6041 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
6056 | tmp2 = BPM_ADDR_MASK | CGCG_OVERRIDE_0 | CGLS_ENABLE; | 6042 | tmp2 = BPM_ADDR_MASK | CGCG_OVERRIDE_0 | CGLS_ENABLE; |
6057 | WREG32(RLC_SERDES_WR_CTRL, tmp2); | 6043 | WREG32(RLC_SERDES_WR_CTRL, tmp2); |
6058 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
6059 | 6044 | ||
6060 | cik_update_rlc(rdev, tmp); | 6045 | cik_update_rlc(rdev, tmp); |
6061 | 6046 | ||
@@ -6098,13 +6083,11 @@ static void cik_enable_mgcg(struct radeon_device *rdev, bool enable) | |||
6098 | 6083 | ||
6099 | tmp = cik_halt_rlc(rdev); | 6084 | tmp = cik_halt_rlc(rdev); |
6100 | 6085 | ||
6101 | mutex_lock(&rdev->grbm_idx_mutex); | ||
6102 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 6086 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
6103 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); | 6087 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
6104 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); | 6088 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
6105 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_0; | 6089 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_0; |
6106 | WREG32(RLC_SERDES_WR_CTRL, data); | 6090 | WREG32(RLC_SERDES_WR_CTRL, data); |
6107 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
6108 | 6091 | ||
6109 | cik_update_rlc(rdev, tmp); | 6092 | cik_update_rlc(rdev, tmp); |
6110 | 6093 | ||
@@ -6148,13 +6131,11 @@ static void cik_enable_mgcg(struct radeon_device *rdev, bool enable) | |||
6148 | 6131 | ||
6149 | tmp = cik_halt_rlc(rdev); | 6132 | tmp = cik_halt_rlc(rdev); |
6150 | 6133 | ||
6151 | mutex_lock(&rdev->grbm_idx_mutex); | ||
6152 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 6134 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
6153 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); | 6135 | WREG32(RLC_SERDES_WR_CU_MASTER_MASK, 0xffffffff); |
6154 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); | 6136 | WREG32(RLC_SERDES_WR_NONCU_MASTER_MASK, 0xffffffff); |
6155 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_1; | 6137 | data = BPM_ADDR_MASK | MGCG_OVERRIDE_1; |
6156 | WREG32(RLC_SERDES_WR_CTRL, data); | 6138 | WREG32(RLC_SERDES_WR_CTRL, data); |
6157 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
6158 | 6139 | ||
6159 | cik_update_rlc(rdev, tmp); | 6140 | cik_update_rlc(rdev, tmp); |
6160 | } | 6141 | } |
@@ -6583,12 +6564,10 @@ static u32 cik_get_cu_active_bitmap(struct radeon_device *rdev, u32 se, u32 sh) | |||
6583 | u32 mask = 0, tmp, tmp1; | 6564 | u32 mask = 0, tmp, tmp1; |
6584 | int i; | 6565 | int i; |
6585 | 6566 | ||
6586 | mutex_lock(&rdev->grbm_idx_mutex); | ||
6587 | cik_select_se_sh(rdev, se, sh); | 6567 | cik_select_se_sh(rdev, se, sh); |
6588 | tmp = RREG32(CC_GC_SHADER_ARRAY_CONFIG); | 6568 | tmp = RREG32(CC_GC_SHADER_ARRAY_CONFIG); |
6589 | tmp1 = RREG32(GC_USER_SHADER_ARRAY_CONFIG); | 6569 | tmp1 = RREG32(GC_USER_SHADER_ARRAY_CONFIG); |
6590 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); | 6570 | cik_select_se_sh(rdev, 0xffffffff, 0xffffffff); |
6591 | mutex_unlock(&rdev->grbm_idx_mutex); | ||
6592 | 6571 | ||
6593 | tmp &= 0xffff0000; | 6572 | tmp &= 0xffff0000; |
6594 | 6573 | ||
@@ -7074,7 +7053,8 @@ static int cik_irq_init(struct radeon_device *rdev) | |||
7074 | int cik_irq_set(struct radeon_device *rdev) | 7053 | int cik_irq_set(struct radeon_device *rdev) |
7075 | { | 7054 | { |
7076 | u32 cp_int_cntl; | 7055 | u32 cp_int_cntl; |
7077 | u32 cp_m1p0; | 7056 | u32 cp_m1p0, cp_m1p1, cp_m1p2, cp_m1p3; |
7057 | u32 cp_m2p0, cp_m2p1, cp_m2p2, cp_m2p3; | ||
7078 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; | 7058 | u32 crtc1 = 0, crtc2 = 0, crtc3 = 0, crtc4 = 0, crtc5 = 0, crtc6 = 0; |
7079 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; | 7059 | u32 hpd1, hpd2, hpd3, hpd4, hpd5, hpd6; |
7080 | u32 grbm_int_cntl = 0; | 7060 | u32 grbm_int_cntl = 0; |
@@ -7107,6 +7087,13 @@ int cik_irq_set(struct radeon_device *rdev) | |||
7107 | dma_cntl1 = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; | 7087 | dma_cntl1 = RREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; |
7108 | 7088 | ||
7109 | cp_m1p0 = RREG32(CP_ME1_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | 7089 | cp_m1p0 = RREG32(CP_ME1_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; |
7090 | cp_m1p1 = RREG32(CP_ME1_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7091 | cp_m1p2 = RREG32(CP_ME1_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7092 | cp_m1p3 = RREG32(CP_ME1_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7093 | cp_m2p0 = RREG32(CP_ME2_PIPE0_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7094 | cp_m2p1 = RREG32(CP_ME2_PIPE1_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7095 | cp_m2p2 = RREG32(CP_ME2_PIPE2_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7096 | cp_m2p3 = RREG32(CP_ME2_PIPE3_INT_CNTL) & ~TIME_STAMP_INT_ENABLE; | ||
7110 | 7097 | ||
7111 | /* enable CP interrupts on all rings */ | 7098 | /* enable CP interrupts on all rings */ |
7112 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { | 7099 | if (atomic_read(&rdev->irq.ring_int[RADEON_RING_TYPE_GFX_INDEX])) { |
@@ -7121,6 +7108,33 @@ int cik_irq_set(struct radeon_device *rdev) | |||
7121 | case 0: | 7108 | case 0: |
7122 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; | 7109 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
7123 | break; | 7110 | break; |
7111 | case 1: | ||
7112 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; | ||
7113 | break; | ||
7114 | case 2: | ||
7115 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; | ||
7116 | break; | ||
7117 | case 3: | ||
7118 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; | ||
7119 | break; | ||
7120 | default: | ||
7121 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); | ||
7122 | break; | ||
7123 | } | ||
7124 | } else if (ring->me == 2) { | ||
7125 | switch (ring->pipe) { | ||
7126 | case 0: | ||
7127 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; | ||
7128 | break; | ||
7129 | case 1: | ||
7130 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; | ||
7131 | break; | ||
7132 | case 2: | ||
7133 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; | ||
7134 | break; | ||
7135 | case 3: | ||
7136 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; | ||
7137 | break; | ||
7124 | default: | 7138 | default: |
7125 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); | 7139 | DRM_DEBUG("si_irq_set: sw int cp1 invalid pipe %d\n", ring->pipe); |
7126 | break; | 7140 | break; |
@@ -7137,6 +7151,33 @@ int cik_irq_set(struct radeon_device *rdev) | |||
7137 | case 0: | 7151 | case 0: |
7138 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; | 7152 | cp_m1p0 |= TIME_STAMP_INT_ENABLE; |
7139 | break; | 7153 | break; |
7154 | case 1: | ||
7155 | cp_m1p1 |= TIME_STAMP_INT_ENABLE; | ||
7156 | break; | ||
7157 | case 2: | ||
7158 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; | ||
7159 | break; | ||
7160 | case 3: | ||
7161 | cp_m1p2 |= TIME_STAMP_INT_ENABLE; | ||
7162 | break; | ||
7163 | default: | ||
7164 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); | ||
7165 | break; | ||
7166 | } | ||
7167 | } else if (ring->me == 2) { | ||
7168 | switch (ring->pipe) { | ||
7169 | case 0: | ||
7170 | cp_m2p0 |= TIME_STAMP_INT_ENABLE; | ||
7171 | break; | ||
7172 | case 1: | ||
7173 | cp_m2p1 |= TIME_STAMP_INT_ENABLE; | ||
7174 | break; | ||
7175 | case 2: | ||
7176 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; | ||
7177 | break; | ||
7178 | case 3: | ||
7179 | cp_m2p2 |= TIME_STAMP_INT_ENABLE; | ||
7180 | break; | ||
7140 | default: | 7181 | default: |
7141 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); | 7182 | DRM_DEBUG("si_irq_set: sw int cp2 invalid pipe %d\n", ring->pipe); |
7142 | break; | 7183 | break; |
@@ -7217,6 +7258,13 @@ int cik_irq_set(struct radeon_device *rdev) | |||
7217 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, dma_cntl1); | 7258 | WREG32(SDMA0_CNTL + SDMA1_REGISTER_OFFSET, dma_cntl1); |
7218 | 7259 | ||
7219 | WREG32(CP_ME1_PIPE0_INT_CNTL, cp_m1p0); | 7260 | WREG32(CP_ME1_PIPE0_INT_CNTL, cp_m1p0); |
7261 | WREG32(CP_ME1_PIPE1_INT_CNTL, cp_m1p1); | ||
7262 | WREG32(CP_ME1_PIPE2_INT_CNTL, cp_m1p2); | ||
7263 | WREG32(CP_ME1_PIPE3_INT_CNTL, cp_m1p3); | ||
7264 | WREG32(CP_ME2_PIPE0_INT_CNTL, cp_m2p0); | ||
7265 | WREG32(CP_ME2_PIPE1_INT_CNTL, cp_m2p1); | ||
7266 | WREG32(CP_ME2_PIPE2_INT_CNTL, cp_m2p2); | ||
7267 | WREG32(CP_ME2_PIPE3_INT_CNTL, cp_m2p3); | ||
7220 | 7268 | ||
7221 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); | 7269 | WREG32(GRBM_INT_CNTL, grbm_int_cntl); |
7222 | 7270 | ||
diff --git a/drivers/gpu/drm/radeon/cik_reg.h b/drivers/gpu/drm/radeon/cik_reg.h index 4e883fdc59d8..318377df09ef 100644 --- a/drivers/gpu/drm/radeon/cik_reg.h +++ b/drivers/gpu/drm/radeon/cik_reg.h | |||
@@ -147,8 +147,6 @@ | |||
147 | 147 | ||
148 | #define CIK_LB_DESKTOP_HEIGHT 0x6b0c | 148 | #define CIK_LB_DESKTOP_HEIGHT 0x6b0c |
149 | 149 | ||
150 | #define KFD_CIK_SDMA_QUEUE_OFFSET 0x200 | ||
151 | |||
152 | #define SQ_IND_INDEX 0x8DE0 | 150 | #define SQ_IND_INDEX 0x8DE0 |
153 | #define SQ_CMD 0x8DEC | 151 | #define SQ_CMD 0x8DEC |
154 | #define SQ_IND_DATA 0x8DE4 | 152 | #define SQ_IND_DATA 0x8DE4 |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index a8e546569858..d34887873dea 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -731,10 +731,6 @@ struct radeon_doorbell { | |||
731 | 731 | ||
732 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *page); | 732 | int radeon_doorbell_get(struct radeon_device *rdev, u32 *page); |
733 | void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell); | 733 | void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell); |
734 | void radeon_doorbell_get_kfd_info(struct radeon_device *rdev, | ||
735 | phys_addr_t *aperture_base, | ||
736 | size_t *aperture_size, | ||
737 | size_t *start_offset); | ||
738 | 734 | ||
739 | /* | 735 | /* |
740 | * IRQS. | 736 | * IRQS. |
@@ -2442,8 +2438,6 @@ struct radeon_device { | |||
2442 | struct radeon_atcs atcs; | 2438 | struct radeon_atcs atcs; |
2443 | /* srbm instance registers */ | 2439 | /* srbm instance registers */ |
2444 | struct mutex srbm_mutex; | 2440 | struct mutex srbm_mutex; |
2445 | /* GRBM index mutex. Protects concurrents access to GRBM index */ | ||
2446 | struct mutex grbm_idx_mutex; | ||
2447 | /* clock, powergating flags */ | 2441 | /* clock, powergating flags */ |
2448 | u32 cg_flags; | 2442 | u32 cg_flags; |
2449 | u32 pg_flags; | 2443 | u32 pg_flags; |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index ffc10cadcf34..8d3e3d2e0090 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
@@ -392,37 +392,6 @@ void radeon_doorbell_free(struct radeon_device *rdev, u32 doorbell) | |||
392 | __clear_bit(doorbell, rdev->doorbell.used); | 392 | __clear_bit(doorbell, rdev->doorbell.used); |
393 | } | 393 | } |
394 | 394 | ||
395 | /** | ||
396 | * radeon_doorbell_get_kfd_info - Report doorbell configuration required to | ||
397 | * setup KFD | ||
398 | * | ||
399 | * @rdev: radeon_device pointer | ||
400 | * @aperture_base: output returning doorbell aperture base physical address | ||
401 | * @aperture_size: output returning doorbell aperture size in bytes | ||
402 | * @start_offset: output returning # of doorbell bytes reserved for radeon. | ||
403 | * | ||
404 | * Radeon and the KFD share the doorbell aperture. Radeon sets it up, | ||
405 | * takes doorbells required for its own rings and reports the setup to KFD. | ||
406 | * Radeon reserved doorbells are at the start of the doorbell aperture. | ||
407 | */ | ||
408 | void radeon_doorbell_get_kfd_info(struct radeon_device *rdev, | ||
409 | phys_addr_t *aperture_base, | ||
410 | size_t *aperture_size, | ||
411 | size_t *start_offset) | ||
412 | { | ||
413 | /* The first num_doorbells are used by radeon. | ||
414 | * KFD takes whatever's left in the aperture. */ | ||
415 | if (rdev->doorbell.size > rdev->doorbell.num_doorbells * sizeof(u32)) { | ||
416 | *aperture_base = rdev->doorbell.base; | ||
417 | *aperture_size = rdev->doorbell.size; | ||
418 | *start_offset = rdev->doorbell.num_doorbells * sizeof(u32); | ||
419 | } else { | ||
420 | *aperture_base = 0; | ||
421 | *aperture_size = 0; | ||
422 | *start_offset = 0; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | /* | 395 | /* |
427 | * radeon_wb_*() | 396 | * radeon_wb_*() |
428 | * Writeback is the the method by which the the GPU updates special pages | 397 | * Writeback is the the method by which the the GPU updates special pages |
@@ -1341,7 +1310,6 @@ int radeon_device_init(struct radeon_device *rdev, | |||
1341 | mutex_init(&rdev->pm.mutex); | 1310 | mutex_init(&rdev->pm.mutex); |
1342 | mutex_init(&rdev->gpu_clock_mutex); | 1311 | mutex_init(&rdev->gpu_clock_mutex); |
1343 | mutex_init(&rdev->srbm_mutex); | 1312 | mutex_init(&rdev->srbm_mutex); |
1344 | mutex_init(&rdev->grbm_idx_mutex); | ||
1345 | init_rwsem(&rdev->pm.mclk_lock); | 1313 | init_rwsem(&rdev->pm.mclk_lock); |
1346 | init_rwsem(&rdev->exclusive_lock); | 1314 | init_rwsem(&rdev->exclusive_lock); |
1347 | init_waitqueue_head(&rdev->irq.vblank_queue); | 1315 | init_waitqueue_head(&rdev->irq.vblank_queue); |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index 98e30d71d9e0..557fd7915973 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -347,7 +347,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, | |||
347 | if (unlikely(r)) { | 347 | if (unlikely(r)) { |
348 | goto out_cleanup; | 348 | goto out_cleanup; |
349 | } | 349 | } |
350 | r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, new_mem); | 350 | r = ttm_bo_move_ttm(bo, &ctx, new_mem); |
351 | out_cleanup: | 351 | out_cleanup: |
352 | ttm_bo_mem_put(bo, &tmp_mem); | 352 | ttm_bo_mem_put(bo, &tmp_mem); |
353 | return r; | 353 | return r; |
@@ -380,7 +380,7 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, | |||
380 | if (unlikely(r)) { | 380 | if (unlikely(r)) { |
381 | return r; | 381 | return r; |
382 | } | 382 | } |
383 | r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, &tmp_mem); | 383 | r = ttm_bo_move_ttm(bo, &ctx, &tmp_mem); |
384 | if (unlikely(r)) { | 384 | if (unlikely(r)) { |
385 | goto out_cleanup; | 385 | goto out_cleanup; |
386 | } | 386 | } |
@@ -445,8 +445,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict, | |||
445 | 445 | ||
446 | if (r) { | 446 | if (r) { |
447 | memcpy: | 447 | memcpy: |
448 | r = ttm_bo_move_memcpy(bo, ctx->interruptible, | 448 | r = ttm_bo_move_memcpy(bo, ctx, new_mem); |
449 | ctx->no_wait_gpu, new_mem); | ||
450 | if (r) { | 449 | if (r) { |
451 | return r; | 450 | return r; |
452 | } | 451 | } |
diff --git a/drivers/gpu/drm/scheduler/Makefile b/drivers/gpu/drm/scheduler/Makefile new file mode 100644 index 000000000000..bd0377c0d2ee --- /dev/null +++ b/drivers/gpu/drm/scheduler/Makefile | |||
@@ -0,0 +1,26 @@ | |||
1 | # | ||
2 | # Copyright 2017 Advanced Micro Devices, Inc. | ||
3 | # | ||
4 | # Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | # copy of this software and associated documentation files (the "Software"), | ||
6 | # to deal in the Software without restriction, including without limitation | ||
7 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | # and/or sell copies of the Software, and to permit persons to whom the | ||
9 | # Software is furnished to do so, subject to the following conditions: | ||
10 | # | ||
11 | # The above copyright notice and this permission notice shall be included in | ||
12 | # all copies or substantial portions of the Software. | ||
13 | # | ||
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | # THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
18 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
19 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
20 | # OTHER DEALINGS IN THE SOFTWARE. | ||
21 | # | ||
22 | # | ||
23 | ccflags-y := -Iinclude/drm | ||
24 | gpu-sched-y := gpu_scheduler.o sched_fence.o | ||
25 | |||
26 | obj-$(CONFIG_DRM_SCHED) += gpu-sched.o | ||
diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index dcb987e6d94a..2c18996d59c5 100644 --- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c | |||
@@ -19,37 +19,36 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | * | ||
23 | */ | 22 | */ |
23 | |||
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/wait.h> | 25 | #include <linux/wait.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <uapi/linux/sched/types.h> | 27 | #include <uapi/linux/sched/types.h> |
28 | #include <drm/drmP.h> | 28 | #include <drm/drmP.h> |
29 | #include "gpu_scheduler.h" | 29 | #include <drm/gpu_scheduler.h> |
30 | 30 | #include <drm/spsc_queue.h> | |
31 | #include "spsc_queue.h" | ||
32 | 31 | ||
33 | #define CREATE_TRACE_POINTS | 32 | #define CREATE_TRACE_POINTS |
34 | #include "gpu_sched_trace.h" | 33 | #include <drm/gpu_scheduler_trace.h> |
35 | 34 | ||
36 | #define to_amd_sched_job(sched_job) \ | 35 | #define to_drm_sched_job(sched_job) \ |
37 | container_of((sched_job), struct amd_sched_job, queue_node) | 36 | container_of((sched_job), struct drm_sched_job, queue_node) |
38 | 37 | ||
39 | static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity); | 38 | static bool drm_sched_entity_is_ready(struct drm_sched_entity *entity); |
40 | static void amd_sched_wakeup(struct amd_gpu_scheduler *sched); | 39 | static void drm_sched_wakeup(struct drm_gpu_scheduler *sched); |
41 | static void amd_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb); | 40 | static void drm_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb); |
42 | 41 | ||
43 | /* Initialize a given run queue struct */ | 42 | /* Initialize a given run queue struct */ |
44 | static void amd_sched_rq_init(struct amd_sched_rq *rq) | 43 | static void drm_sched_rq_init(struct drm_sched_rq *rq) |
45 | { | 44 | { |
46 | spin_lock_init(&rq->lock); | 45 | spin_lock_init(&rq->lock); |
47 | INIT_LIST_HEAD(&rq->entities); | 46 | INIT_LIST_HEAD(&rq->entities); |
48 | rq->current_entity = NULL; | 47 | rq->current_entity = NULL; |
49 | } | 48 | } |
50 | 49 | ||
51 | static void amd_sched_rq_add_entity(struct amd_sched_rq *rq, | 50 | static void drm_sched_rq_add_entity(struct drm_sched_rq *rq, |
52 | struct amd_sched_entity *entity) | 51 | struct drm_sched_entity *entity) |
53 | { | 52 | { |
54 | if (!list_empty(&entity->list)) | 53 | if (!list_empty(&entity->list)) |
55 | return; | 54 | return; |
@@ -58,8 +57,8 @@ static void amd_sched_rq_add_entity(struct amd_sched_rq *rq, | |||
58 | spin_unlock(&rq->lock); | 57 | spin_unlock(&rq->lock); |
59 | } | 58 | } |
60 | 59 | ||
61 | static void amd_sched_rq_remove_entity(struct amd_sched_rq *rq, | 60 | static void drm_sched_rq_remove_entity(struct drm_sched_rq *rq, |
62 | struct amd_sched_entity *entity) | 61 | struct drm_sched_entity *entity) |
63 | { | 62 | { |
64 | if (list_empty(&entity->list)) | 63 | if (list_empty(&entity->list)) |
65 | return; | 64 | return; |
@@ -77,17 +76,17 @@ static void amd_sched_rq_remove_entity(struct amd_sched_rq *rq, | |||
77 | * | 76 | * |
78 | * Try to find a ready entity, returns NULL if none found. | 77 | * Try to find a ready entity, returns NULL if none found. |
79 | */ | 78 | */ |
80 | static struct amd_sched_entity * | 79 | static struct drm_sched_entity * |
81 | amd_sched_rq_select_entity(struct amd_sched_rq *rq) | 80 | drm_sched_rq_select_entity(struct drm_sched_rq *rq) |
82 | { | 81 | { |
83 | struct amd_sched_entity *entity; | 82 | struct drm_sched_entity *entity; |
84 | 83 | ||
85 | spin_lock(&rq->lock); | 84 | spin_lock(&rq->lock); |
86 | 85 | ||
87 | entity = rq->current_entity; | 86 | entity = rq->current_entity; |
88 | if (entity) { | 87 | if (entity) { |
89 | list_for_each_entry_continue(entity, &rq->entities, list) { | 88 | list_for_each_entry_continue(entity, &rq->entities, list) { |
90 | if (amd_sched_entity_is_ready(entity)) { | 89 | if (drm_sched_entity_is_ready(entity)) { |
91 | rq->current_entity = entity; | 90 | rq->current_entity = entity; |
92 | spin_unlock(&rq->lock); | 91 | spin_unlock(&rq->lock); |
93 | return entity; | 92 | return entity; |
@@ -97,7 +96,7 @@ amd_sched_rq_select_entity(struct amd_sched_rq *rq) | |||
97 | 96 | ||
98 | list_for_each_entry(entity, &rq->entities, list) { | 97 | list_for_each_entry(entity, &rq->entities, list) { |
99 | 98 | ||
100 | if (amd_sched_entity_is_ready(entity)) { | 99 | if (drm_sched_entity_is_ready(entity)) { |
101 | rq->current_entity = entity; | 100 | rq->current_entity = entity; |
102 | spin_unlock(&rq->lock); | 101 | spin_unlock(&rq->lock); |
103 | return entity; | 102 | return entity; |
@@ -116,22 +115,22 @@ amd_sched_rq_select_entity(struct amd_sched_rq *rq) | |||
116 | * Init a context entity used by scheduler when submit to HW ring. | 115 | * Init a context entity used by scheduler when submit to HW ring. |
117 | * | 116 | * |
118 | * @sched The pointer to the scheduler | 117 | * @sched The pointer to the scheduler |
119 | * @entity The pointer to a valid amd_sched_entity | 118 | * @entity The pointer to a valid drm_sched_entity |
120 | * @rq The run queue this entity belongs | 119 | * @rq The run queue this entity belongs |
121 | * @kernel If this is an entity for the kernel | 120 | * @kernel If this is an entity for the kernel |
122 | * @jobs The max number of jobs in the job queue | 121 | * @jobs The max number of jobs in the job queue |
123 | * | 122 | * |
124 | * return 0 if succeed. negative error code on failure | 123 | * return 0 if succeed. negative error code on failure |
125 | */ | 124 | */ |
126 | int amd_sched_entity_init(struct amd_gpu_scheduler *sched, | 125 | int drm_sched_entity_init(struct drm_gpu_scheduler *sched, |
127 | struct amd_sched_entity *entity, | 126 | struct drm_sched_entity *entity, |
128 | struct amd_sched_rq *rq, | 127 | struct drm_sched_rq *rq, |
129 | uint32_t jobs, atomic_t *guilty) | 128 | uint32_t jobs, atomic_t *guilty) |
130 | { | 129 | { |
131 | if (!(sched && entity && rq)) | 130 | if (!(sched && entity && rq)) |
132 | return -EINVAL; | 131 | return -EINVAL; |
133 | 132 | ||
134 | memset(entity, 0, sizeof(struct amd_sched_entity)); | 133 | memset(entity, 0, sizeof(struct drm_sched_entity)); |
135 | INIT_LIST_HEAD(&entity->list); | 134 | INIT_LIST_HEAD(&entity->list); |
136 | entity->rq = rq; | 135 | entity->rq = rq; |
137 | entity->sched = sched; | 136 | entity->sched = sched; |
@@ -146,6 +145,7 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched, | |||
146 | 145 | ||
147 | return 0; | 146 | return 0; |
148 | } | 147 | } |
148 | EXPORT_SYMBOL(drm_sched_entity_init); | ||
149 | 149 | ||
150 | /** | 150 | /** |
151 | * Query if entity is initialized | 151 | * Query if entity is initialized |
@@ -155,8 +155,8 @@ int amd_sched_entity_init(struct amd_gpu_scheduler *sched, | |||
155 | * | 155 | * |
156 | * return true if entity is initialized, false otherwise | 156 | * return true if entity is initialized, false otherwise |
157 | */ | 157 | */ |
158 | static bool amd_sched_entity_is_initialized(struct amd_gpu_scheduler *sched, | 158 | static bool drm_sched_entity_is_initialized(struct drm_gpu_scheduler *sched, |
159 | struct amd_sched_entity *entity) | 159 | struct drm_sched_entity *entity) |
160 | { | 160 | { |
161 | return entity->sched == sched && | 161 | return entity->sched == sched && |
162 | entity->rq != NULL; | 162 | entity->rq != NULL; |
@@ -169,7 +169,7 @@ static bool amd_sched_entity_is_initialized(struct amd_gpu_scheduler *sched, | |||
169 | * | 169 | * |
170 | * Return true if entity don't has any unscheduled jobs. | 170 | * Return true if entity don't has any unscheduled jobs. |
171 | */ | 171 | */ |
172 | static bool amd_sched_entity_is_idle(struct amd_sched_entity *entity) | 172 | static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity) |
173 | { | 173 | { |
174 | rmb(); | 174 | rmb(); |
175 | if (spsc_queue_peek(&entity->job_queue) == NULL) | 175 | if (spsc_queue_peek(&entity->job_queue) == NULL) |
@@ -185,7 +185,7 @@ static bool amd_sched_entity_is_idle(struct amd_sched_entity *entity) | |||
185 | * | 185 | * |
186 | * Return true if entity could provide a job. | 186 | * Return true if entity could provide a job. |
187 | */ | 187 | */ |
188 | static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity) | 188 | static bool drm_sched_entity_is_ready(struct drm_sched_entity *entity) |
189 | { | 189 | { |
190 | if (spsc_queue_peek(&entity->job_queue) == NULL) | 190 | if (spsc_queue_peek(&entity->job_queue) == NULL) |
191 | return false; | 191 | return false; |
@@ -204,12 +204,12 @@ static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity) | |||
204 | * | 204 | * |
205 | * Cleanup and free the allocated resources. | 205 | * Cleanup and free the allocated resources. |
206 | */ | 206 | */ |
207 | void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, | 207 | void drm_sched_entity_fini(struct drm_gpu_scheduler *sched, |
208 | struct amd_sched_entity *entity) | 208 | struct drm_sched_entity *entity) |
209 | { | 209 | { |
210 | int r; | 210 | int r; |
211 | 211 | ||
212 | if (!amd_sched_entity_is_initialized(sched, entity)) | 212 | if (!drm_sched_entity_is_initialized(sched, entity)) |
213 | return; | 213 | return; |
214 | /** | 214 | /** |
215 | * The client will not queue more IBs during this fini, consume existing | 215 | * The client will not queue more IBs during this fini, consume existing |
@@ -219,10 +219,10 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, | |||
219 | r = -ERESTARTSYS; | 219 | r = -ERESTARTSYS; |
220 | else | 220 | else |
221 | r = wait_event_killable(sched->job_scheduled, | 221 | r = wait_event_killable(sched->job_scheduled, |
222 | amd_sched_entity_is_idle(entity)); | 222 | drm_sched_entity_is_idle(entity)); |
223 | amd_sched_entity_set_rq(entity, NULL); | 223 | drm_sched_entity_set_rq(entity, NULL); |
224 | if (r) { | 224 | if (r) { |
225 | struct amd_sched_job *job; | 225 | struct drm_sched_job *job; |
226 | 226 | ||
227 | /* Park the kernel for a moment to make sure it isn't processing | 227 | /* Park the kernel for a moment to make sure it isn't processing |
228 | * our enity. | 228 | * our enity. |
@@ -236,37 +236,38 @@ void amd_sched_entity_fini(struct amd_gpu_scheduler *sched, | |||
236 | entity->dependency = NULL; | 236 | entity->dependency = NULL; |
237 | } | 237 | } |
238 | 238 | ||
239 | while ((job = to_amd_sched_job(spsc_queue_pop(&entity->job_queue)))) { | 239 | while ((job = to_drm_sched_job(spsc_queue_pop(&entity->job_queue)))) { |
240 | struct amd_sched_fence *s_fence = job->s_fence; | 240 | struct drm_sched_fence *s_fence = job->s_fence; |
241 | amd_sched_fence_scheduled(s_fence); | 241 | drm_sched_fence_scheduled(s_fence); |
242 | dma_fence_set_error(&s_fence->finished, -ESRCH); | 242 | dma_fence_set_error(&s_fence->finished, -ESRCH); |
243 | amd_sched_fence_finished(s_fence); | 243 | drm_sched_fence_finished(s_fence); |
244 | WARN_ON(s_fence->parent); | 244 | WARN_ON(s_fence->parent); |
245 | dma_fence_put(&s_fence->finished); | 245 | dma_fence_put(&s_fence->finished); |
246 | sched->ops->free_job(job); | 246 | sched->ops->free_job(job); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } | 249 | } |
250 | EXPORT_SYMBOL(drm_sched_entity_fini); | ||
250 | 251 | ||
251 | static void amd_sched_entity_wakeup(struct dma_fence *f, struct dma_fence_cb *cb) | 252 | static void drm_sched_entity_wakeup(struct dma_fence *f, struct dma_fence_cb *cb) |
252 | { | 253 | { |
253 | struct amd_sched_entity *entity = | 254 | struct drm_sched_entity *entity = |
254 | container_of(cb, struct amd_sched_entity, cb); | 255 | container_of(cb, struct drm_sched_entity, cb); |
255 | entity->dependency = NULL; | 256 | entity->dependency = NULL; |
256 | dma_fence_put(f); | 257 | dma_fence_put(f); |
257 | amd_sched_wakeup(entity->sched); | 258 | drm_sched_wakeup(entity->sched); |
258 | } | 259 | } |
259 | 260 | ||
260 | static void amd_sched_entity_clear_dep(struct dma_fence *f, struct dma_fence_cb *cb) | 261 | static void drm_sched_entity_clear_dep(struct dma_fence *f, struct dma_fence_cb *cb) |
261 | { | 262 | { |
262 | struct amd_sched_entity *entity = | 263 | struct drm_sched_entity *entity = |
263 | container_of(cb, struct amd_sched_entity, cb); | 264 | container_of(cb, struct drm_sched_entity, cb); |
264 | entity->dependency = NULL; | 265 | entity->dependency = NULL; |
265 | dma_fence_put(f); | 266 | dma_fence_put(f); |
266 | } | 267 | } |
267 | 268 | ||
268 | void amd_sched_entity_set_rq(struct amd_sched_entity *entity, | 269 | void drm_sched_entity_set_rq(struct drm_sched_entity *entity, |
269 | struct amd_sched_rq *rq) | 270 | struct drm_sched_rq *rq) |
270 | { | 271 | { |
271 | if (entity->rq == rq) | 272 | if (entity->rq == rq) |
272 | return; | 273 | return; |
@@ -274,37 +275,39 @@ void amd_sched_entity_set_rq(struct amd_sched_entity *entity, | |||
274 | spin_lock(&entity->rq_lock); | 275 | spin_lock(&entity->rq_lock); |
275 | 276 | ||
276 | if (entity->rq) | 277 | if (entity->rq) |
277 | amd_sched_rq_remove_entity(entity->rq, entity); | 278 | drm_sched_rq_remove_entity(entity->rq, entity); |
278 | 279 | ||
279 | entity->rq = rq; | 280 | entity->rq = rq; |
280 | if (rq) | 281 | if (rq) |
281 | amd_sched_rq_add_entity(rq, entity); | 282 | drm_sched_rq_add_entity(rq, entity); |
282 | 283 | ||
283 | spin_unlock(&entity->rq_lock); | 284 | spin_unlock(&entity->rq_lock); |
284 | } | 285 | } |
286 | EXPORT_SYMBOL(drm_sched_entity_set_rq); | ||
285 | 287 | ||
286 | bool amd_sched_dependency_optimized(struct dma_fence* fence, | 288 | bool drm_sched_dependency_optimized(struct dma_fence* fence, |
287 | struct amd_sched_entity *entity) | 289 | struct drm_sched_entity *entity) |
288 | { | 290 | { |
289 | struct amd_gpu_scheduler *sched = entity->sched; | 291 | struct drm_gpu_scheduler *sched = entity->sched; |
290 | struct amd_sched_fence *s_fence; | 292 | struct drm_sched_fence *s_fence; |
291 | 293 | ||
292 | if (!fence || dma_fence_is_signaled(fence)) | 294 | if (!fence || dma_fence_is_signaled(fence)) |
293 | return false; | 295 | return false; |
294 | if (fence->context == entity->fence_context) | 296 | if (fence->context == entity->fence_context) |
295 | return true; | 297 | return true; |
296 | s_fence = to_amd_sched_fence(fence); | 298 | s_fence = to_drm_sched_fence(fence); |
297 | if (s_fence && s_fence->sched == sched) | 299 | if (s_fence && s_fence->sched == sched) |
298 | return true; | 300 | return true; |
299 | 301 | ||
300 | return false; | 302 | return false; |
301 | } | 303 | } |
304 | EXPORT_SYMBOL(drm_sched_dependency_optimized); | ||
302 | 305 | ||
303 | static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity) | 306 | static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity) |
304 | { | 307 | { |
305 | struct amd_gpu_scheduler *sched = entity->sched; | 308 | struct drm_gpu_scheduler *sched = entity->sched; |
306 | struct dma_fence * fence = entity->dependency; | 309 | struct dma_fence * fence = entity->dependency; |
307 | struct amd_sched_fence *s_fence; | 310 | struct drm_sched_fence *s_fence; |
308 | 311 | ||
309 | if (fence->context == entity->fence_context) { | 312 | if (fence->context == entity->fence_context) { |
310 | /* We can ignore fences from ourself */ | 313 | /* We can ignore fences from ourself */ |
@@ -312,7 +315,7 @@ static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity) | |||
312 | return false; | 315 | return false; |
313 | } | 316 | } |
314 | 317 | ||
315 | s_fence = to_amd_sched_fence(fence); | 318 | s_fence = to_drm_sched_fence(fence); |
316 | if (s_fence && s_fence->sched == sched) { | 319 | if (s_fence && s_fence->sched == sched) { |
317 | 320 | ||
318 | /* | 321 | /* |
@@ -323,7 +326,7 @@ static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity) | |||
323 | dma_fence_put(entity->dependency); | 326 | dma_fence_put(entity->dependency); |
324 | entity->dependency = fence; | 327 | entity->dependency = fence; |
325 | if (!dma_fence_add_callback(fence, &entity->cb, | 328 | if (!dma_fence_add_callback(fence, &entity->cb, |
326 | amd_sched_entity_clear_dep)) | 329 | drm_sched_entity_clear_dep)) |
327 | return true; | 330 | return true; |
328 | 331 | ||
329 | /* Ignore it when it is already scheduled */ | 332 | /* Ignore it when it is already scheduled */ |
@@ -332,25 +335,25 @@ static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity) | |||
332 | } | 335 | } |
333 | 336 | ||
334 | if (!dma_fence_add_callback(entity->dependency, &entity->cb, | 337 | if (!dma_fence_add_callback(entity->dependency, &entity->cb, |
335 | amd_sched_entity_wakeup)) | 338 | drm_sched_entity_wakeup)) |
336 | return true; | 339 | return true; |
337 | 340 | ||
338 | dma_fence_put(entity->dependency); | 341 | dma_fence_put(entity->dependency); |
339 | return false; | 342 | return false; |
340 | } | 343 | } |
341 | 344 | ||
342 | static struct amd_sched_job * | 345 | static struct drm_sched_job * |
343 | amd_sched_entity_pop_job(struct amd_sched_entity *entity) | 346 | drm_sched_entity_pop_job(struct drm_sched_entity *entity) |
344 | { | 347 | { |
345 | struct amd_gpu_scheduler *sched = entity->sched; | 348 | struct drm_gpu_scheduler *sched = entity->sched; |
346 | struct amd_sched_job *sched_job = to_amd_sched_job( | 349 | struct drm_sched_job *sched_job = to_drm_sched_job( |
347 | spsc_queue_peek(&entity->job_queue)); | 350 | spsc_queue_peek(&entity->job_queue)); |
348 | 351 | ||
349 | if (!sched_job) | 352 | if (!sched_job) |
350 | return NULL; | 353 | return NULL; |
351 | 354 | ||
352 | while ((entity->dependency = sched->ops->dependency(sched_job, entity))) | 355 | while ((entity->dependency = sched->ops->dependency(sched_job, entity))) |
353 | if (amd_sched_entity_add_dependency_cb(entity)) | 356 | if (drm_sched_entity_add_dependency_cb(entity)) |
354 | return NULL; | 357 | return NULL; |
355 | 358 | ||
356 | /* skip jobs from entity that marked guilty */ | 359 | /* skip jobs from entity that marked guilty */ |
@@ -368,13 +371,13 @@ amd_sched_entity_pop_job(struct amd_sched_entity *entity) | |||
368 | * | 371 | * |
369 | * Returns 0 for success, negative error code otherwise. | 372 | * Returns 0 for success, negative error code otherwise. |
370 | */ | 373 | */ |
371 | void amd_sched_entity_push_job(struct amd_sched_job *sched_job, | 374 | void drm_sched_entity_push_job(struct drm_sched_job *sched_job, |
372 | struct amd_sched_entity *entity) | 375 | struct drm_sched_entity *entity) |
373 | { | 376 | { |
374 | struct amd_gpu_scheduler *sched = sched_job->sched; | 377 | struct drm_gpu_scheduler *sched = sched_job->sched; |
375 | bool first = false; | 378 | bool first = false; |
376 | 379 | ||
377 | trace_amd_sched_job(sched_job, entity); | 380 | trace_drm_sched_job(sched_job, entity); |
378 | 381 | ||
379 | spin_lock(&entity->queue_lock); | 382 | spin_lock(&entity->queue_lock); |
380 | first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); | 383 | first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node); |
@@ -385,25 +388,26 @@ void amd_sched_entity_push_job(struct amd_sched_job *sched_job, | |||
385 | if (first) { | 388 | if (first) { |
386 | /* Add the entity to the run queue */ | 389 | /* Add the entity to the run queue */ |
387 | spin_lock(&entity->rq_lock); | 390 | spin_lock(&entity->rq_lock); |
388 | amd_sched_rq_add_entity(entity->rq, entity); | 391 | drm_sched_rq_add_entity(entity->rq, entity); |
389 | spin_unlock(&entity->rq_lock); | 392 | spin_unlock(&entity->rq_lock); |
390 | amd_sched_wakeup(sched); | 393 | drm_sched_wakeup(sched); |
391 | } | 394 | } |
392 | } | 395 | } |
396 | EXPORT_SYMBOL(drm_sched_entity_push_job); | ||
393 | 397 | ||
394 | /* job_finish is called after hw fence signaled | 398 | /* job_finish is called after hw fence signaled |
395 | */ | 399 | */ |
396 | static void amd_sched_job_finish(struct work_struct *work) | 400 | static void drm_sched_job_finish(struct work_struct *work) |
397 | { | 401 | { |
398 | struct amd_sched_job *s_job = container_of(work, struct amd_sched_job, | 402 | struct drm_sched_job *s_job = container_of(work, struct drm_sched_job, |
399 | finish_work); | 403 | finish_work); |
400 | struct amd_gpu_scheduler *sched = s_job->sched; | 404 | struct drm_gpu_scheduler *sched = s_job->sched; |
401 | 405 | ||
402 | /* remove job from ring_mirror_list */ | 406 | /* remove job from ring_mirror_list */ |
403 | spin_lock(&sched->job_list_lock); | 407 | spin_lock(&sched->job_list_lock); |
404 | list_del_init(&s_job->node); | 408 | list_del_init(&s_job->node); |
405 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT) { | 409 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT) { |
406 | struct amd_sched_job *next; | 410 | struct drm_sched_job *next; |
407 | 411 | ||
408 | spin_unlock(&sched->job_list_lock); | 412 | spin_unlock(&sched->job_list_lock); |
409 | cancel_delayed_work_sync(&s_job->work_tdr); | 413 | cancel_delayed_work_sync(&s_job->work_tdr); |
@@ -411,7 +415,7 @@ static void amd_sched_job_finish(struct work_struct *work) | |||
411 | 415 | ||
412 | /* queue TDR for next job */ | 416 | /* queue TDR for next job */ |
413 | next = list_first_entry_or_null(&sched->ring_mirror_list, | 417 | next = list_first_entry_or_null(&sched->ring_mirror_list, |
414 | struct amd_sched_job, node); | 418 | struct drm_sched_job, node); |
415 | 419 | ||
416 | if (next) | 420 | if (next) |
417 | schedule_delayed_work(&next->work_tdr, sched->timeout); | 421 | schedule_delayed_work(&next->work_tdr, sched->timeout); |
@@ -421,42 +425,42 @@ static void amd_sched_job_finish(struct work_struct *work) | |||
421 | sched->ops->free_job(s_job); | 425 | sched->ops->free_job(s_job); |
422 | } | 426 | } |
423 | 427 | ||
424 | static void amd_sched_job_finish_cb(struct dma_fence *f, | 428 | static void drm_sched_job_finish_cb(struct dma_fence *f, |
425 | struct dma_fence_cb *cb) | 429 | struct dma_fence_cb *cb) |
426 | { | 430 | { |
427 | struct amd_sched_job *job = container_of(cb, struct amd_sched_job, | 431 | struct drm_sched_job *job = container_of(cb, struct drm_sched_job, |
428 | finish_cb); | 432 | finish_cb); |
429 | schedule_work(&job->finish_work); | 433 | schedule_work(&job->finish_work); |
430 | } | 434 | } |
431 | 435 | ||
432 | static void amd_sched_job_begin(struct amd_sched_job *s_job) | 436 | static void drm_sched_job_begin(struct drm_sched_job *s_job) |
433 | { | 437 | { |
434 | struct amd_gpu_scheduler *sched = s_job->sched; | 438 | struct drm_gpu_scheduler *sched = s_job->sched; |
435 | 439 | ||
436 | dma_fence_add_callback(&s_job->s_fence->finished, &s_job->finish_cb, | 440 | dma_fence_add_callback(&s_job->s_fence->finished, &s_job->finish_cb, |
437 | amd_sched_job_finish_cb); | 441 | drm_sched_job_finish_cb); |
438 | 442 | ||
439 | spin_lock(&sched->job_list_lock); | 443 | spin_lock(&sched->job_list_lock); |
440 | list_add_tail(&s_job->node, &sched->ring_mirror_list); | 444 | list_add_tail(&s_job->node, &sched->ring_mirror_list); |
441 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && | 445 | if (sched->timeout != MAX_SCHEDULE_TIMEOUT && |
442 | list_first_entry_or_null(&sched->ring_mirror_list, | 446 | list_first_entry_or_null(&sched->ring_mirror_list, |
443 | struct amd_sched_job, node) == s_job) | 447 | struct drm_sched_job, node) == s_job) |
444 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); | 448 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); |
445 | spin_unlock(&sched->job_list_lock); | 449 | spin_unlock(&sched->job_list_lock); |
446 | } | 450 | } |
447 | 451 | ||
448 | static void amd_sched_job_timedout(struct work_struct *work) | 452 | static void drm_sched_job_timedout(struct work_struct *work) |
449 | { | 453 | { |
450 | struct amd_sched_job *job = container_of(work, struct amd_sched_job, | 454 | struct drm_sched_job *job = container_of(work, struct drm_sched_job, |
451 | work_tdr.work); | 455 | work_tdr.work); |
452 | 456 | ||
453 | job->sched->ops->timedout_job(job); | 457 | job->sched->ops->timedout_job(job); |
454 | } | 458 | } |
455 | 459 | ||
456 | void amd_sched_hw_job_reset(struct amd_gpu_scheduler *sched, struct amd_sched_job *bad) | 460 | void drm_sched_hw_job_reset(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad) |
457 | { | 461 | { |
458 | struct amd_sched_job *s_job; | 462 | struct drm_sched_job *s_job; |
459 | struct amd_sched_entity *entity, *tmp; | 463 | struct drm_sched_entity *entity, *tmp; |
460 | int i;; | 464 | int i;; |
461 | 465 | ||
462 | spin_lock(&sched->job_list_lock); | 466 | spin_lock(&sched->job_list_lock); |
@@ -471,14 +475,14 @@ void amd_sched_hw_job_reset(struct amd_gpu_scheduler *sched, struct amd_sched_jo | |||
471 | } | 475 | } |
472 | spin_unlock(&sched->job_list_lock); | 476 | spin_unlock(&sched->job_list_lock); |
473 | 477 | ||
474 | if (bad && bad->s_priority != AMD_SCHED_PRIORITY_KERNEL) { | 478 | if (bad && bad->s_priority != DRM_SCHED_PRIORITY_KERNEL) { |
475 | atomic_inc(&bad->karma); | 479 | atomic_inc(&bad->karma); |
476 | /* don't increase @bad's karma if it's from KERNEL RQ, | 480 | /* don't increase @bad's karma if it's from KERNEL RQ, |
477 | * becuase sometimes GPU hang would cause kernel jobs (like VM updating jobs) | 481 | * becuase sometimes GPU hang would cause kernel jobs (like VM updating jobs) |
478 | * corrupt but keep in mind that kernel jobs always considered good. | 482 | * corrupt but keep in mind that kernel jobs always considered good. |
479 | */ | 483 | */ |
480 | for (i = AMD_SCHED_PRIORITY_MIN; i < AMD_SCHED_PRIORITY_KERNEL; i++ ) { | 484 | for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_KERNEL; i++ ) { |
481 | struct amd_sched_rq *rq = &sched->sched_rq[i]; | 485 | struct drm_sched_rq *rq = &sched->sched_rq[i]; |
482 | 486 | ||
483 | spin_lock(&rq->lock); | 487 | spin_lock(&rq->lock); |
484 | list_for_each_entry_safe(entity, tmp, &rq->entities, list) { | 488 | list_for_each_entry_safe(entity, tmp, &rq->entities, list) { |
@@ -495,30 +499,22 @@ void amd_sched_hw_job_reset(struct amd_gpu_scheduler *sched, struct amd_sched_jo | |||
495 | } | 499 | } |
496 | } | 500 | } |
497 | } | 501 | } |
502 | EXPORT_SYMBOL(drm_sched_hw_job_reset); | ||
498 | 503 | ||
499 | void amd_sched_job_kickout(struct amd_sched_job *s_job) | 504 | void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) |
500 | { | ||
501 | struct amd_gpu_scheduler *sched = s_job->sched; | ||
502 | |||
503 | spin_lock(&sched->job_list_lock); | ||
504 | list_del_init(&s_job->node); | ||
505 | spin_unlock(&sched->job_list_lock); | ||
506 | } | ||
507 | |||
508 | void amd_sched_job_recovery(struct amd_gpu_scheduler *sched) | ||
509 | { | 505 | { |
510 | struct amd_sched_job *s_job, *tmp; | 506 | struct drm_sched_job *s_job, *tmp; |
511 | bool found_guilty = false; | 507 | bool found_guilty = false; |
512 | int r; | 508 | int r; |
513 | 509 | ||
514 | spin_lock(&sched->job_list_lock); | 510 | spin_lock(&sched->job_list_lock); |
515 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, | 511 | s_job = list_first_entry_or_null(&sched->ring_mirror_list, |
516 | struct amd_sched_job, node); | 512 | struct drm_sched_job, node); |
517 | if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) | 513 | if (s_job && sched->timeout != MAX_SCHEDULE_TIMEOUT) |
518 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); | 514 | schedule_delayed_work(&s_job->work_tdr, sched->timeout); |
519 | 515 | ||
520 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { | 516 | list_for_each_entry_safe(s_job, tmp, &sched->ring_mirror_list, node) { |
521 | struct amd_sched_fence *s_fence = s_job->s_fence; | 517 | struct drm_sched_fence *s_fence = s_job->s_fence; |
522 | struct dma_fence *fence; | 518 | struct dma_fence *fence; |
523 | uint64_t guilty_context; | 519 | uint64_t guilty_context; |
524 | 520 | ||
@@ -536,45 +532,47 @@ void amd_sched_job_recovery(struct amd_gpu_scheduler *sched) | |||
536 | if (fence) { | 532 | if (fence) { |
537 | s_fence->parent = dma_fence_get(fence); | 533 | s_fence->parent = dma_fence_get(fence); |
538 | r = dma_fence_add_callback(fence, &s_fence->cb, | 534 | r = dma_fence_add_callback(fence, &s_fence->cb, |
539 | amd_sched_process_job); | 535 | drm_sched_process_job); |
540 | if (r == -ENOENT) | 536 | if (r == -ENOENT) |
541 | amd_sched_process_job(fence, &s_fence->cb); | 537 | drm_sched_process_job(fence, &s_fence->cb); |
542 | else if (r) | 538 | else if (r) |
543 | DRM_ERROR("fence add callback failed (%d)\n", | 539 | DRM_ERROR("fence add callback failed (%d)\n", |
544 | r); | 540 | r); |
545 | dma_fence_put(fence); | 541 | dma_fence_put(fence); |
546 | } else { | 542 | } else { |
547 | amd_sched_process_job(NULL, &s_fence->cb); | 543 | drm_sched_process_job(NULL, &s_fence->cb); |
548 | } | 544 | } |
549 | spin_lock(&sched->job_list_lock); | 545 | spin_lock(&sched->job_list_lock); |
550 | } | 546 | } |
551 | spin_unlock(&sched->job_list_lock); | 547 | spin_unlock(&sched->job_list_lock); |
552 | } | 548 | } |
549 | EXPORT_SYMBOL(drm_sched_job_recovery); | ||
553 | 550 | ||
554 | /* init a sched_job with basic field */ | 551 | /* init a sched_job with basic field */ |
555 | int amd_sched_job_init(struct amd_sched_job *job, | 552 | int drm_sched_job_init(struct drm_sched_job *job, |
556 | struct amd_gpu_scheduler *sched, | 553 | struct drm_gpu_scheduler *sched, |
557 | struct amd_sched_entity *entity, | 554 | struct drm_sched_entity *entity, |
558 | void *owner) | 555 | void *owner) |
559 | { | 556 | { |
560 | job->sched = sched; | 557 | job->sched = sched; |
561 | job->s_priority = entity->rq - sched->sched_rq; | 558 | job->s_priority = entity->rq - sched->sched_rq; |
562 | job->s_fence = amd_sched_fence_create(entity, owner); | 559 | job->s_fence = drm_sched_fence_create(entity, owner); |
563 | if (!job->s_fence) | 560 | if (!job->s_fence) |
564 | return -ENOMEM; | 561 | return -ENOMEM; |
565 | job->id = atomic64_inc_return(&sched->job_id_count); | 562 | job->id = atomic64_inc_return(&sched->job_id_count); |
566 | 563 | ||
567 | INIT_WORK(&job->finish_work, amd_sched_job_finish); | 564 | INIT_WORK(&job->finish_work, drm_sched_job_finish); |
568 | INIT_LIST_HEAD(&job->node); | 565 | INIT_LIST_HEAD(&job->node); |
569 | INIT_DELAYED_WORK(&job->work_tdr, amd_sched_job_timedout); | 566 | INIT_DELAYED_WORK(&job->work_tdr, drm_sched_job_timedout); |
570 | 567 | ||
571 | return 0; | 568 | return 0; |
572 | } | 569 | } |
570 | EXPORT_SYMBOL(drm_sched_job_init); | ||
573 | 571 | ||
574 | /** | 572 | /** |
575 | * Return ture if we can push more jobs to the hw. | 573 | * Return ture if we can push more jobs to the hw. |
576 | */ | 574 | */ |
577 | static bool amd_sched_ready(struct amd_gpu_scheduler *sched) | 575 | static bool drm_sched_ready(struct drm_gpu_scheduler *sched) |
578 | { | 576 | { |
579 | return atomic_read(&sched->hw_rq_count) < | 577 | return atomic_read(&sched->hw_rq_count) < |
580 | sched->hw_submission_limit; | 578 | sched->hw_submission_limit; |
@@ -583,27 +581,27 @@ static bool amd_sched_ready(struct amd_gpu_scheduler *sched) | |||
583 | /** | 581 | /** |
584 | * Wake up the scheduler when it is ready | 582 | * Wake up the scheduler when it is ready |
585 | */ | 583 | */ |
586 | static void amd_sched_wakeup(struct amd_gpu_scheduler *sched) | 584 | static void drm_sched_wakeup(struct drm_gpu_scheduler *sched) |
587 | { | 585 | { |
588 | if (amd_sched_ready(sched)) | 586 | if (drm_sched_ready(sched)) |
589 | wake_up_interruptible(&sched->wake_up_worker); | 587 | wake_up_interruptible(&sched->wake_up_worker); |
590 | } | 588 | } |
591 | 589 | ||
592 | /** | 590 | /** |
593 | * Select next entity to process | 591 | * Select next entity to process |
594 | */ | 592 | */ |
595 | static struct amd_sched_entity * | 593 | static struct drm_sched_entity * |
596 | amd_sched_select_entity(struct amd_gpu_scheduler *sched) | 594 | drm_sched_select_entity(struct drm_gpu_scheduler *sched) |
597 | { | 595 | { |
598 | struct amd_sched_entity *entity; | 596 | struct drm_sched_entity *entity; |
599 | int i; | 597 | int i; |
600 | 598 | ||
601 | if (!amd_sched_ready(sched)) | 599 | if (!drm_sched_ready(sched)) |
602 | return NULL; | 600 | return NULL; |
603 | 601 | ||
604 | /* Kernel run queue has higher priority than normal run queue*/ | 602 | /* Kernel run queue has higher priority than normal run queue*/ |
605 | for (i = AMD_SCHED_PRIORITY_MAX - 1; i >= AMD_SCHED_PRIORITY_MIN; i--) { | 603 | for (i = DRM_SCHED_PRIORITY_MAX - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) { |
606 | entity = amd_sched_rq_select_entity(&sched->sched_rq[i]); | 604 | entity = drm_sched_rq_select_entity(&sched->sched_rq[i]); |
607 | if (entity) | 605 | if (entity) |
608 | break; | 606 | break; |
609 | } | 607 | } |
@@ -611,22 +609,22 @@ amd_sched_select_entity(struct amd_gpu_scheduler *sched) | |||
611 | return entity; | 609 | return entity; |
612 | } | 610 | } |
613 | 611 | ||
614 | static void amd_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb) | 612 | static void drm_sched_process_job(struct dma_fence *f, struct dma_fence_cb *cb) |
615 | { | 613 | { |
616 | struct amd_sched_fence *s_fence = | 614 | struct drm_sched_fence *s_fence = |
617 | container_of(cb, struct amd_sched_fence, cb); | 615 | container_of(cb, struct drm_sched_fence, cb); |
618 | struct amd_gpu_scheduler *sched = s_fence->sched; | 616 | struct drm_gpu_scheduler *sched = s_fence->sched; |
619 | 617 | ||
620 | dma_fence_get(&s_fence->finished); | 618 | dma_fence_get(&s_fence->finished); |
621 | atomic_dec(&sched->hw_rq_count); | 619 | atomic_dec(&sched->hw_rq_count); |
622 | amd_sched_fence_finished(s_fence); | 620 | drm_sched_fence_finished(s_fence); |
623 | 621 | ||
624 | trace_amd_sched_process_job(s_fence); | 622 | trace_drm_sched_process_job(s_fence); |
625 | dma_fence_put(&s_fence->finished); | 623 | dma_fence_put(&s_fence->finished); |
626 | wake_up_interruptible(&sched->wake_up_worker); | 624 | wake_up_interruptible(&sched->wake_up_worker); |
627 | } | 625 | } |
628 | 626 | ||
629 | static bool amd_sched_blocked(struct amd_gpu_scheduler *sched) | 627 | static bool drm_sched_blocked(struct drm_gpu_scheduler *sched) |
630 | { | 628 | { |
631 | if (kthread_should_park()) { | 629 | if (kthread_should_park()) { |
632 | kthread_parkme(); | 630 | kthread_parkme(); |
@@ -636,52 +634,52 @@ static bool amd_sched_blocked(struct amd_gpu_scheduler *sched) | |||
636 | return false; | 634 | return false; |
637 | } | 635 | } |
638 | 636 | ||
639 | static int amd_sched_main(void *param) | 637 | static int drm_sched_main(void *param) |
640 | { | 638 | { |
641 | struct sched_param sparam = {.sched_priority = 1}; | 639 | struct sched_param sparam = {.sched_priority = 1}; |
642 | struct amd_gpu_scheduler *sched = (struct amd_gpu_scheduler *)param; | 640 | struct drm_gpu_scheduler *sched = (struct drm_gpu_scheduler *)param; |
643 | int r; | 641 | int r; |
644 | 642 | ||
645 | sched_setscheduler(current, SCHED_FIFO, &sparam); | 643 | sched_setscheduler(current, SCHED_FIFO, &sparam); |
646 | 644 | ||
647 | while (!kthread_should_stop()) { | 645 | while (!kthread_should_stop()) { |
648 | struct amd_sched_entity *entity = NULL; | 646 | struct drm_sched_entity *entity = NULL; |
649 | struct amd_sched_fence *s_fence; | 647 | struct drm_sched_fence *s_fence; |
650 | struct amd_sched_job *sched_job; | 648 | struct drm_sched_job *sched_job; |
651 | struct dma_fence *fence; | 649 | struct dma_fence *fence; |
652 | 650 | ||
653 | wait_event_interruptible(sched->wake_up_worker, | 651 | wait_event_interruptible(sched->wake_up_worker, |
654 | (!amd_sched_blocked(sched) && | 652 | (!drm_sched_blocked(sched) && |
655 | (entity = amd_sched_select_entity(sched))) || | 653 | (entity = drm_sched_select_entity(sched))) || |
656 | kthread_should_stop()); | 654 | kthread_should_stop()); |
657 | 655 | ||
658 | if (!entity) | 656 | if (!entity) |
659 | continue; | 657 | continue; |
660 | 658 | ||
661 | sched_job = amd_sched_entity_pop_job(entity); | 659 | sched_job = drm_sched_entity_pop_job(entity); |
662 | if (!sched_job) | 660 | if (!sched_job) |
663 | continue; | 661 | continue; |
664 | 662 | ||
665 | s_fence = sched_job->s_fence; | 663 | s_fence = sched_job->s_fence; |
666 | 664 | ||
667 | atomic_inc(&sched->hw_rq_count); | 665 | atomic_inc(&sched->hw_rq_count); |
668 | amd_sched_job_begin(sched_job); | 666 | drm_sched_job_begin(sched_job); |
669 | 667 | ||
670 | fence = sched->ops->run_job(sched_job); | 668 | fence = sched->ops->run_job(sched_job); |
671 | amd_sched_fence_scheduled(s_fence); | 669 | drm_sched_fence_scheduled(s_fence); |
672 | 670 | ||
673 | if (fence) { | 671 | if (fence) { |
674 | s_fence->parent = dma_fence_get(fence); | 672 | s_fence->parent = dma_fence_get(fence); |
675 | r = dma_fence_add_callback(fence, &s_fence->cb, | 673 | r = dma_fence_add_callback(fence, &s_fence->cb, |
676 | amd_sched_process_job); | 674 | drm_sched_process_job); |
677 | if (r == -ENOENT) | 675 | if (r == -ENOENT) |
678 | amd_sched_process_job(fence, &s_fence->cb); | 676 | drm_sched_process_job(fence, &s_fence->cb); |
679 | else if (r) | 677 | else if (r) |
680 | DRM_ERROR("fence add callback failed (%d)\n", | 678 | DRM_ERROR("fence add callback failed (%d)\n", |
681 | r); | 679 | r); |
682 | dma_fence_put(fence); | 680 | dma_fence_put(fence); |
683 | } else { | 681 | } else { |
684 | amd_sched_process_job(NULL, &s_fence->cb); | 682 | drm_sched_process_job(NULL, &s_fence->cb); |
685 | } | 683 | } |
686 | 684 | ||
687 | wake_up(&sched->job_scheduled); | 685 | wake_up(&sched->job_scheduled); |
@@ -699,8 +697,8 @@ static int amd_sched_main(void *param) | |||
699 | * | 697 | * |
700 | * Return 0 on success, otherwise error code. | 698 | * Return 0 on success, otherwise error code. |
701 | */ | 699 | */ |
702 | int amd_sched_init(struct amd_gpu_scheduler *sched, | 700 | int drm_sched_init(struct drm_gpu_scheduler *sched, |
703 | const struct amd_sched_backend_ops *ops, | 701 | const struct drm_sched_backend_ops *ops, |
704 | unsigned hw_submission, | 702 | unsigned hw_submission, |
705 | unsigned hang_limit, | 703 | unsigned hang_limit, |
706 | long timeout, | 704 | long timeout, |
@@ -712,8 +710,8 @@ int amd_sched_init(struct amd_gpu_scheduler *sched, | |||
712 | sched->name = name; | 710 | sched->name = name; |
713 | sched->timeout = timeout; | 711 | sched->timeout = timeout; |
714 | sched->hang_limit = hang_limit; | 712 | sched->hang_limit = hang_limit; |
715 | for (i = AMD_SCHED_PRIORITY_MIN; i < AMD_SCHED_PRIORITY_MAX; i++) | 713 | for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_MAX; i++) |
716 | amd_sched_rq_init(&sched->sched_rq[i]); | 714 | drm_sched_rq_init(&sched->sched_rq[i]); |
717 | 715 | ||
718 | init_waitqueue_head(&sched->wake_up_worker); | 716 | init_waitqueue_head(&sched->wake_up_worker); |
719 | init_waitqueue_head(&sched->job_scheduled); | 717 | init_waitqueue_head(&sched->job_scheduled); |
@@ -723,7 +721,7 @@ int amd_sched_init(struct amd_gpu_scheduler *sched, | |||
723 | atomic64_set(&sched->job_id_count, 0); | 721 | atomic64_set(&sched->job_id_count, 0); |
724 | 722 | ||
725 | /* Each scheduler will run on a seperate kernel thread */ | 723 | /* Each scheduler will run on a seperate kernel thread */ |
726 | sched->thread = kthread_run(amd_sched_main, sched, sched->name); | 724 | sched->thread = kthread_run(drm_sched_main, sched, sched->name); |
727 | if (IS_ERR(sched->thread)) { | 725 | if (IS_ERR(sched->thread)) { |
728 | DRM_ERROR("Failed to create scheduler for %s.\n", name); | 726 | DRM_ERROR("Failed to create scheduler for %s.\n", name); |
729 | return PTR_ERR(sched->thread); | 727 | return PTR_ERR(sched->thread); |
@@ -731,14 +729,16 @@ int amd_sched_init(struct amd_gpu_scheduler *sched, | |||
731 | 729 | ||
732 | return 0; | 730 | return 0; |
733 | } | 731 | } |
732 | EXPORT_SYMBOL(drm_sched_init); | ||
734 | 733 | ||
735 | /** | 734 | /** |
736 | * Destroy a gpu scheduler | 735 | * Destroy a gpu scheduler |
737 | * | 736 | * |
738 | * @sched The pointer to the scheduler | 737 | * @sched The pointer to the scheduler |
739 | */ | 738 | */ |
740 | void amd_sched_fini(struct amd_gpu_scheduler *sched) | 739 | void drm_sched_fini(struct drm_gpu_scheduler *sched) |
741 | { | 740 | { |
742 | if (sched->thread) | 741 | if (sched->thread) |
743 | kthread_stop(sched->thread); | 742 | kthread_stop(sched->thread); |
744 | } | 743 | } |
744 | EXPORT_SYMBOL(drm_sched_fini); | ||
diff --git a/drivers/gpu/drm/amd/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c index 33f54d0a5c4f..69aab086b913 100644 --- a/drivers/gpu/drm/amd/scheduler/sched_fence.c +++ b/drivers/gpu/drm/scheduler/sched_fence.c | |||
@@ -19,20 +19,20 @@ | |||
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * | 21 | * |
22 | * | ||
23 | */ | 22 | */ |
23 | |||
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/wait.h> | 25 | #include <linux/wait.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <drm/drmP.h> | 27 | #include <drm/drmP.h> |
28 | #include "gpu_scheduler.h" | 28 | #include <drm/gpu_scheduler.h> |
29 | 29 | ||
30 | static struct kmem_cache *sched_fence_slab; | 30 | static struct kmem_cache *sched_fence_slab; |
31 | 31 | ||
32 | int amd_sched_fence_slab_init(void) | 32 | static int __init drm_sched_fence_slab_init(void) |
33 | { | 33 | { |
34 | sched_fence_slab = kmem_cache_create( | 34 | sched_fence_slab = kmem_cache_create( |
35 | "amd_sched_fence", sizeof(struct amd_sched_fence), 0, | 35 | "drm_sched_fence", sizeof(struct drm_sched_fence), 0, |
36 | SLAB_HWCACHE_ALIGN, NULL); | 36 | SLAB_HWCACHE_ALIGN, NULL); |
37 | if (!sched_fence_slab) | 37 | if (!sched_fence_slab) |
38 | return -ENOMEM; | 38 | return -ENOMEM; |
@@ -40,36 +40,13 @@ int amd_sched_fence_slab_init(void) | |||
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | void amd_sched_fence_slab_fini(void) | 43 | static void __exit drm_sched_fence_slab_fini(void) |
44 | { | 44 | { |
45 | rcu_barrier(); | 45 | rcu_barrier(); |
46 | kmem_cache_destroy(sched_fence_slab); | 46 | kmem_cache_destroy(sched_fence_slab); |
47 | } | 47 | } |
48 | 48 | ||
49 | struct amd_sched_fence *amd_sched_fence_create(struct amd_sched_entity *entity, | 49 | void drm_sched_fence_scheduled(struct drm_sched_fence *fence) |
50 | void *owner) | ||
51 | { | ||
52 | struct amd_sched_fence *fence = NULL; | ||
53 | unsigned seq; | ||
54 | |||
55 | fence = kmem_cache_zalloc(sched_fence_slab, GFP_KERNEL); | ||
56 | if (fence == NULL) | ||
57 | return NULL; | ||
58 | |||
59 | fence->owner = owner; | ||
60 | fence->sched = entity->sched; | ||
61 | spin_lock_init(&fence->lock); | ||
62 | |||
63 | seq = atomic_inc_return(&entity->fence_seq); | ||
64 | dma_fence_init(&fence->scheduled, &amd_sched_fence_ops_scheduled, | ||
65 | &fence->lock, entity->fence_context, seq); | ||
66 | dma_fence_init(&fence->finished, &amd_sched_fence_ops_finished, | ||
67 | &fence->lock, entity->fence_context + 1, seq); | ||
68 | |||
69 | return fence; | ||
70 | } | ||
71 | |||
72 | void amd_sched_fence_scheduled(struct amd_sched_fence *fence) | ||
73 | { | 50 | { |
74 | int ret = dma_fence_signal(&fence->scheduled); | 51 | int ret = dma_fence_signal(&fence->scheduled); |
75 | 52 | ||
@@ -81,7 +58,7 @@ void amd_sched_fence_scheduled(struct amd_sched_fence *fence) | |||
81 | "was already signaled\n"); | 58 | "was already signaled\n"); |
82 | } | 59 | } |
83 | 60 | ||
84 | void amd_sched_fence_finished(struct amd_sched_fence *fence) | 61 | void drm_sched_fence_finished(struct drm_sched_fence *fence) |
85 | { | 62 | { |
86 | int ret = dma_fence_signal(&fence->finished); | 63 | int ret = dma_fence_signal(&fence->finished); |
87 | 64 | ||
@@ -93,18 +70,18 @@ void amd_sched_fence_finished(struct amd_sched_fence *fence) | |||
93 | "was already signaled\n"); | 70 | "was already signaled\n"); |
94 | } | 71 | } |
95 | 72 | ||
96 | static const char *amd_sched_fence_get_driver_name(struct dma_fence *fence) | 73 | static const char *drm_sched_fence_get_driver_name(struct dma_fence *fence) |
97 | { | 74 | { |
98 | return "amd_sched"; | 75 | return "drm_sched"; |
99 | } | 76 | } |
100 | 77 | ||
101 | static const char *amd_sched_fence_get_timeline_name(struct dma_fence *f) | 78 | static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f) |
102 | { | 79 | { |
103 | struct amd_sched_fence *fence = to_amd_sched_fence(f); | 80 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
104 | return (const char *)fence->sched->name; | 81 | return (const char *)fence->sched->name; |
105 | } | 82 | } |
106 | 83 | ||
107 | static bool amd_sched_fence_enable_signaling(struct dma_fence *f) | 84 | static bool drm_sched_fence_enable_signaling(struct dma_fence *f) |
108 | { | 85 | { |
109 | return true; | 86 | return true; |
110 | } | 87 | } |
@@ -116,10 +93,10 @@ static bool amd_sched_fence_enable_signaling(struct dma_fence *f) | |||
116 | * | 93 | * |
117 | * Free up the fence memory after the RCU grace period. | 94 | * Free up the fence memory after the RCU grace period. |
118 | */ | 95 | */ |
119 | static void amd_sched_fence_free(struct rcu_head *rcu) | 96 | static void drm_sched_fence_free(struct rcu_head *rcu) |
120 | { | 97 | { |
121 | struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); | 98 | struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); |
122 | struct amd_sched_fence *fence = to_amd_sched_fence(f); | 99 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
123 | 100 | ||
124 | dma_fence_put(fence->parent); | 101 | dma_fence_put(fence->parent); |
125 | kmem_cache_free(sched_fence_slab, fence); | 102 | kmem_cache_free(sched_fence_slab, fence); |
@@ -133,11 +110,11 @@ static void amd_sched_fence_free(struct rcu_head *rcu) | |||
133 | * This function is called when the reference count becomes zero. | 110 | * This function is called when the reference count becomes zero. |
134 | * It just RCU schedules freeing up the fence. | 111 | * It just RCU schedules freeing up the fence. |
135 | */ | 112 | */ |
136 | static void amd_sched_fence_release_scheduled(struct dma_fence *f) | 113 | static void drm_sched_fence_release_scheduled(struct dma_fence *f) |
137 | { | 114 | { |
138 | struct amd_sched_fence *fence = to_amd_sched_fence(f); | 115 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
139 | 116 | ||
140 | call_rcu(&fence->finished.rcu, amd_sched_fence_free); | 117 | call_rcu(&fence->finished.rcu, drm_sched_fence_free); |
141 | } | 118 | } |
142 | 119 | ||
143 | /** | 120 | /** |
@@ -147,27 +124,68 @@ static void amd_sched_fence_release_scheduled(struct dma_fence *f) | |||
147 | * | 124 | * |
148 | * Drop the extra reference from the scheduled fence to the base fence. | 125 | * Drop the extra reference from the scheduled fence to the base fence. |
149 | */ | 126 | */ |
150 | static void amd_sched_fence_release_finished(struct dma_fence *f) | 127 | static void drm_sched_fence_release_finished(struct dma_fence *f) |
151 | { | 128 | { |
152 | struct amd_sched_fence *fence = to_amd_sched_fence(f); | 129 | struct drm_sched_fence *fence = to_drm_sched_fence(f); |
153 | 130 | ||
154 | dma_fence_put(&fence->scheduled); | 131 | dma_fence_put(&fence->scheduled); |
155 | } | 132 | } |
156 | 133 | ||
157 | const struct dma_fence_ops amd_sched_fence_ops_scheduled = { | 134 | const struct dma_fence_ops drm_sched_fence_ops_scheduled = { |
158 | .get_driver_name = amd_sched_fence_get_driver_name, | 135 | .get_driver_name = drm_sched_fence_get_driver_name, |
159 | .get_timeline_name = amd_sched_fence_get_timeline_name, | 136 | .get_timeline_name = drm_sched_fence_get_timeline_name, |
160 | .enable_signaling = amd_sched_fence_enable_signaling, | 137 | .enable_signaling = drm_sched_fence_enable_signaling, |
161 | .signaled = NULL, | 138 | .signaled = NULL, |
162 | .wait = dma_fence_default_wait, | 139 | .wait = dma_fence_default_wait, |
163 | .release = amd_sched_fence_release_scheduled, | 140 | .release = drm_sched_fence_release_scheduled, |
164 | }; | 141 | }; |
165 | 142 | ||
166 | const struct dma_fence_ops amd_sched_fence_ops_finished = { | 143 | const struct dma_fence_ops drm_sched_fence_ops_finished = { |
167 | .get_driver_name = amd_sched_fence_get_driver_name, | 144 | .get_driver_name = drm_sched_fence_get_driver_name, |
168 | .get_timeline_name = amd_sched_fence_get_timeline_name, | 145 | .get_timeline_name = drm_sched_fence_get_timeline_name, |
169 | .enable_signaling = amd_sched_fence_enable_signaling, | 146 | .enable_signaling = drm_sched_fence_enable_signaling, |
170 | .signaled = NULL, | 147 | .signaled = NULL, |
171 | .wait = dma_fence_default_wait, | 148 | .wait = dma_fence_default_wait, |
172 | .release = amd_sched_fence_release_finished, | 149 | .release = drm_sched_fence_release_finished, |
173 | }; | 150 | }; |
151 | |||
152 | struct drm_sched_fence *to_drm_sched_fence(struct dma_fence *f) | ||
153 | { | ||
154 | if (f->ops == &drm_sched_fence_ops_scheduled) | ||
155 | return container_of(f, struct drm_sched_fence, scheduled); | ||
156 | |||
157 | if (f->ops == &drm_sched_fence_ops_finished) | ||
158 | return container_of(f, struct drm_sched_fence, finished); | ||
159 | |||
160 | return NULL; | ||
161 | } | ||
162 | EXPORT_SYMBOL(to_drm_sched_fence); | ||
163 | |||
164 | struct drm_sched_fence *drm_sched_fence_create(struct drm_sched_entity *entity, | ||
165 | void *owner) | ||
166 | { | ||
167 | struct drm_sched_fence *fence = NULL; | ||
168 | unsigned seq; | ||
169 | |||
170 | fence = kmem_cache_zalloc(sched_fence_slab, GFP_KERNEL); | ||
171 | if (fence == NULL) | ||
172 | return NULL; | ||
173 | |||
174 | fence->owner = owner; | ||
175 | fence->sched = entity->sched; | ||
176 | spin_lock_init(&fence->lock); | ||
177 | |||
178 | seq = atomic_inc_return(&entity->fence_seq); | ||
179 | dma_fence_init(&fence->scheduled, &drm_sched_fence_ops_scheduled, | ||
180 | &fence->lock, entity->fence_context, seq); | ||
181 | dma_fence_init(&fence->finished, &drm_sched_fence_ops_finished, | ||
182 | &fence->lock, entity->fence_context + 1, seq); | ||
183 | |||
184 | return fence; | ||
185 | } | ||
186 | |||
187 | module_init(drm_sched_fence_slab_init); | ||
188 | module_exit(drm_sched_fence_slab_fini); | ||
189 | |||
190 | MODULE_DESCRIPTION("DRM GPU scheduler"); | ||
191 | MODULE_LICENSE("GPL and additional rights"); | ||
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 97c3da6d5f17..60bb5c12b568 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -42,10 +42,6 @@ | |||
42 | #include <linux/atomic.h> | 42 | #include <linux/atomic.h> |
43 | #include <linux/reservation.h> | 43 | #include <linux/reservation.h> |
44 | 44 | ||
45 | #define TTM_ASSERT_LOCKED(param) | ||
46 | #define TTM_DEBUG(fmt, arg...) | ||
47 | #define TTM_BO_HASH_ORDER 13 | ||
48 | |||
49 | static int ttm_bo_swapout(struct ttm_mem_shrink *shrink); | 45 | static int ttm_bo_swapout(struct ttm_mem_shrink *shrink); |
50 | static void ttm_bo_global_kobj_release(struct kobject *kobj); | 46 | static void ttm_bo_global_kobj_release(struct kobject *kobj); |
51 | 47 | ||
@@ -165,7 +161,7 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo) | |||
165 | struct ttm_bo_device *bdev = bo->bdev; | 161 | struct ttm_bo_device *bdev = bo->bdev; |
166 | struct ttm_mem_type_manager *man; | 162 | struct ttm_mem_type_manager *man; |
167 | 163 | ||
168 | lockdep_assert_held(&bo->resv->lock.base); | 164 | reservation_object_assert_held(bo->resv); |
169 | 165 | ||
170 | if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { | 166 | if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { |
171 | 167 | ||
@@ -216,7 +212,7 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); | |||
216 | 212 | ||
217 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) | 213 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) |
218 | { | 214 | { |
219 | lockdep_assert_held(&bo->resv->lock.base); | 215 | reservation_object_assert_held(bo->resv); |
220 | 216 | ||
221 | ttm_bo_del_from_lru(bo); | 217 | ttm_bo_del_from_lru(bo); |
222 | ttm_bo_add_to_lru(bo); | 218 | ttm_bo_add_to_lru(bo); |
@@ -233,7 +229,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc) | |||
233 | int ret = 0; | 229 | int ret = 0; |
234 | uint32_t page_flags = 0; | 230 | uint32_t page_flags = 0; |
235 | 231 | ||
236 | TTM_ASSERT_LOCKED(&bo->mutex); | 232 | reservation_object_assert_held(bo->resv); |
237 | bo->ttm = NULL; | 233 | bo->ttm = NULL; |
238 | 234 | ||
239 | if (bdev->need_dma32) | 235 | if (bdev->need_dma32) |
@@ -324,13 +320,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, | |||
324 | 320 | ||
325 | if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && | 321 | if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && |
326 | !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) | 322 | !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) |
327 | ret = ttm_bo_move_ttm(bo, ctx->interruptible, | 323 | ret = ttm_bo_move_ttm(bo, ctx, mem); |
328 | ctx->no_wait_gpu, mem); | ||
329 | else if (bdev->driver->move) | 324 | else if (bdev->driver->move) |
330 | ret = bdev->driver->move(bo, evict, ctx, mem); | 325 | ret = bdev->driver->move(bo, evict, ctx, mem); |
331 | else | 326 | else |
332 | ret = ttm_bo_move_memcpy(bo, ctx->interruptible, | 327 | ret = ttm_bo_move_memcpy(bo, ctx, mem); |
333 | ctx->no_wait_gpu, mem); | ||
334 | 328 | ||
335 | if (ret) { | 329 | if (ret) { |
336 | if (bdev->driver->move_notify) { | 330 | if (bdev->driver->move_notify) { |
@@ -588,12 +582,17 @@ static bool ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) | |||
588 | ddestroy); | 582 | ddestroy); |
589 | kref_get(&bo->list_kref); | 583 | kref_get(&bo->list_kref); |
590 | list_move_tail(&bo->ddestroy, &removed); | 584 | list_move_tail(&bo->ddestroy, &removed); |
591 | spin_unlock(&glob->lru_lock); | ||
592 | 585 | ||
593 | reservation_object_lock(bo->resv, NULL); | 586 | if (remove_all || bo->resv != &bo->ttm_resv) { |
587 | spin_unlock(&glob->lru_lock); | ||
588 | reservation_object_lock(bo->resv, NULL); | ||
594 | 589 | ||
595 | spin_lock(&glob->lru_lock); | 590 | spin_lock(&glob->lru_lock); |
596 | ttm_bo_cleanup_refs(bo, false, !remove_all, true); | 591 | ttm_bo_cleanup_refs(bo, false, !remove_all, true); |
592 | |||
593 | } else if (reservation_object_trylock(bo->resv)) { | ||
594 | ttm_bo_cleanup_refs(bo, false, !remove_all, true); | ||
595 | } | ||
597 | 596 | ||
598 | kref_put(&bo->list_kref, ttm_bo_release_list); | 597 | kref_put(&bo->list_kref, ttm_bo_release_list); |
599 | spin_lock(&glob->lru_lock); | 598 | spin_lock(&glob->lru_lock); |
@@ -662,7 +661,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, | |||
662 | struct ttm_placement placement; | 661 | struct ttm_placement placement; |
663 | int ret = 0; | 662 | int ret = 0; |
664 | 663 | ||
665 | lockdep_assert_held(&bo->resv->lock.base); | 664 | reservation_object_assert_held(bo->resv); |
666 | 665 | ||
667 | evict_mem = bo->mem; | 666 | evict_mem = bo->mem; |
668 | evict_mem.mm_node = NULL; | 667 | evict_mem.mm_node = NULL; |
@@ -709,7 +708,6 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, | |||
709 | EXPORT_SYMBOL(ttm_bo_eviction_valuable); | 708 | EXPORT_SYMBOL(ttm_bo_eviction_valuable); |
710 | 709 | ||
711 | static int ttm_mem_evict_first(struct ttm_bo_device *bdev, | 710 | static int ttm_mem_evict_first(struct ttm_bo_device *bdev, |
712 | struct reservation_object *resv, | ||
713 | uint32_t mem_type, | 711 | uint32_t mem_type, |
714 | const struct ttm_place *place, | 712 | const struct ttm_place *place, |
715 | struct ttm_operation_ctx *ctx) | 713 | struct ttm_operation_ctx *ctx) |
@@ -724,8 +722,9 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, | |||
724 | spin_lock(&glob->lru_lock); | 722 | spin_lock(&glob->lru_lock); |
725 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 723 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
726 | list_for_each_entry(bo, &man->lru[i], lru) { | 724 | list_for_each_entry(bo, &man->lru[i], lru) { |
727 | if (bo->resv == resv) { | 725 | if (bo->resv == ctx->resv) { |
728 | if (list_empty(&bo->ddestroy)) | 726 | if (!ctx->allow_reserved_eviction && |
727 | list_empty(&bo->ddestroy)) | ||
729 | continue; | 728 | continue; |
730 | } else { | 729 | } else { |
731 | locked = reservation_object_trylock(bo->resv); | 730 | locked = reservation_object_trylock(bo->resv); |
@@ -737,6 +736,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, | |||
737 | place)) { | 736 | place)) { |
738 | if (locked) | 737 | if (locked) |
739 | reservation_object_unlock(bo->resv); | 738 | reservation_object_unlock(bo->resv); |
739 | locked = false; | ||
740 | continue; | 740 | continue; |
741 | } | 741 | } |
742 | break; | 742 | break; |
@@ -836,7 +836,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, | |||
836 | return ret; | 836 | return ret; |
837 | if (mem->mm_node) | 837 | if (mem->mm_node) |
838 | break; | 838 | break; |
839 | ret = ttm_mem_evict_first(bdev, bo->resv, mem_type, place, ctx); | 839 | ret = ttm_mem_evict_first(bdev, mem_type, place, ctx); |
840 | if (unlikely(ret != 0)) | 840 | if (unlikely(ret != 0)) |
841 | return ret; | 841 | return ret; |
842 | } while (1); | 842 | } while (1); |
@@ -1018,7 +1018,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo, | |||
1018 | int ret = 0; | 1018 | int ret = 0; |
1019 | struct ttm_mem_reg mem; | 1019 | struct ttm_mem_reg mem; |
1020 | 1020 | ||
1021 | lockdep_assert_held(&bo->resv->lock.base); | 1021 | reservation_object_assert_held(bo->resv); |
1022 | 1022 | ||
1023 | mem.num_pages = bo->num_pages; | 1023 | mem.num_pages = bo->num_pages; |
1024 | mem.size = mem.num_pages << PAGE_SHIFT; | 1024 | mem.size = mem.num_pages << PAGE_SHIFT; |
@@ -1088,7 +1088,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, | |||
1088 | int ret; | 1088 | int ret; |
1089 | uint32_t new_flags; | 1089 | uint32_t new_flags; |
1090 | 1090 | ||
1091 | lockdep_assert_held(&bo->resv->lock.base); | 1091 | reservation_object_assert_held(bo->resv); |
1092 | /* | 1092 | /* |
1093 | * Check whether we need to move buffer. | 1093 | * Check whether we need to move buffer. |
1094 | */ | 1094 | */ |
@@ -1182,7 +1182,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, | |||
1182 | bo->sg = sg; | 1182 | bo->sg = sg; |
1183 | if (resv) { | 1183 | if (resv) { |
1184 | bo->resv = resv; | 1184 | bo->resv = resv; |
1185 | lockdep_assert_held(&bo->resv->lock.base); | 1185 | reservation_object_assert_held(bo->resv); |
1186 | } else { | 1186 | } else { |
1187 | bo->resv = &bo->ttm_resv; | 1187 | bo->resv = &bo->ttm_resv; |
1188 | } | 1188 | } |
@@ -1204,7 +1204,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev, | |||
1204 | * since otherwise lockdep will be angered in radeon. | 1204 | * since otherwise lockdep will be angered in radeon. |
1205 | */ | 1205 | */ |
1206 | if (!resv) { | 1206 | if (!resv) { |
1207 | locked = ww_mutex_trylock(&bo->resv->lock); | 1207 | locked = reservation_object_trylock(bo->resv); |
1208 | WARN_ON(!locked); | 1208 | WARN_ON(!locked); |
1209 | } | 1209 | } |
1210 | 1210 | ||
@@ -1333,8 +1333,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, | |||
1333 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 1333 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
1334 | while (!list_empty(&man->lru[i])) { | 1334 | while (!list_empty(&man->lru[i])) { |
1335 | spin_unlock(&glob->lru_lock); | 1335 | spin_unlock(&glob->lru_lock); |
1336 | ret = ttm_mem_evict_first(bdev, NULL, mem_type, | 1336 | ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx); |
1337 | NULL, &ctx); | ||
1338 | if (ret) | 1337 | if (ret) |
1339 | return ret; | 1338 | return ret; |
1340 | spin_lock(&glob->lru_lock); | 1339 | spin_lock(&glob->lru_lock); |
@@ -1541,12 +1540,12 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) | |||
1541 | cancel_delayed_work_sync(&bdev->wq); | 1540 | cancel_delayed_work_sync(&bdev->wq); |
1542 | 1541 | ||
1543 | if (ttm_bo_delayed_delete(bdev, true)) | 1542 | if (ttm_bo_delayed_delete(bdev, true)) |
1544 | TTM_DEBUG("Delayed destroy list was clean\n"); | 1543 | pr_debug("Delayed destroy list was clean\n"); |
1545 | 1544 | ||
1546 | spin_lock(&glob->lru_lock); | 1545 | spin_lock(&glob->lru_lock); |
1547 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) | 1546 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) |
1548 | if (list_empty(&bdev->man[0].lru[0])) | 1547 | if (list_empty(&bdev->man[0].lru[0])) |
1549 | TTM_DEBUG("Swap list %d was clean\n", i); | 1548 | pr_debug("Swap list %d was clean\n", i); |
1550 | spin_unlock(&glob->lru_lock); | 1549 | spin_unlock(&glob->lru_lock); |
1551 | 1550 | ||
1552 | drm_vma_offset_manager_destroy(&bdev->vma_manager); | 1551 | drm_vma_offset_manager_destroy(&bdev->vma_manager); |
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index e7a519f1849b..6e353df4e4bc 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c | |||
@@ -45,7 +45,7 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo) | |||
45 | } | 45 | } |
46 | 46 | ||
47 | int ttm_bo_move_ttm(struct ttm_buffer_object *bo, | 47 | int ttm_bo_move_ttm(struct ttm_buffer_object *bo, |
48 | bool interruptible, bool no_wait_gpu, | 48 | struct ttm_operation_ctx *ctx, |
49 | struct ttm_mem_reg *new_mem) | 49 | struct ttm_mem_reg *new_mem) |
50 | { | 50 | { |
51 | struct ttm_tt *ttm = bo->ttm; | 51 | struct ttm_tt *ttm = bo->ttm; |
@@ -53,7 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, | |||
53 | int ret; | 53 | int ret; |
54 | 54 | ||
55 | if (old_mem->mem_type != TTM_PL_SYSTEM) { | 55 | if (old_mem->mem_type != TTM_PL_SYSTEM) { |
56 | ret = ttm_bo_wait(bo, interruptible, no_wait_gpu); | 56 | ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); |
57 | 57 | ||
58 | if (unlikely(ret != 0)) { | 58 | if (unlikely(ret != 0)) { |
59 | if (ret != -ERESTARTSYS) | 59 | if (ret != -ERESTARTSYS) |
@@ -329,7 +329,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst, | |||
329 | } | 329 | } |
330 | 330 | ||
331 | int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, | 331 | int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, |
332 | bool interruptible, bool no_wait_gpu, | 332 | struct ttm_operation_ctx *ctx, |
333 | struct ttm_mem_reg *new_mem) | 333 | struct ttm_mem_reg *new_mem) |
334 | { | 334 | { |
335 | struct ttm_bo_device *bdev = bo->bdev; | 335 | struct ttm_bo_device *bdev = bo->bdev; |
@@ -345,7 +345,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, | |||
345 | unsigned long add = 0; | 345 | unsigned long add = 0; |
346 | int dir; | 346 | int dir; |
347 | 347 | ||
348 | ret = ttm_bo_wait(bo, interruptible, no_wait_gpu); | 348 | ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu); |
349 | if (ret) | 349 | if (ret) |
350 | return ret; | 350 | return ret; |
351 | 351 | ||
@@ -485,7 +485,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, | |||
485 | fbo->acc_size = 0; | 485 | fbo->acc_size = 0; |
486 | fbo->resv = &fbo->ttm_resv; | 486 | fbo->resv = &fbo->ttm_resv; |
487 | reservation_object_init(fbo->resv); | 487 | reservation_object_init(fbo->resv); |
488 | ret = ww_mutex_trylock(&fbo->resv->lock); | 488 | ret = reservation_object_trylock(fbo->resv); |
489 | WARN_ON(!ret); | 489 | WARN_ON(!ret); |
490 | 490 | ||
491 | *new_obj = fbo; | 491 | *new_obj = fbo; |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 44343a2bf55c..b5ba6441489f 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c | |||
@@ -455,6 +455,7 @@ ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) | |||
455 | freed += (nr_free_pool - shrink_pages) << pool->order; | 455 | freed += (nr_free_pool - shrink_pages) << pool->order; |
456 | if (freed >= sc->nr_to_scan) | 456 | if (freed >= sc->nr_to_scan) |
457 | break; | 457 | break; |
458 | shrink_pages <<= pool->order; | ||
458 | } | 459 | } |
459 | mutex_unlock(&lock); | 460 | mutex_unlock(&lock); |
460 | return freed; | 461 | return freed; |
@@ -543,7 +544,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags, | |||
543 | int r = 0; | 544 | int r = 0; |
544 | unsigned i, j, cpages; | 545 | unsigned i, j, cpages; |
545 | unsigned npages = 1 << order; | 546 | unsigned npages = 1 << order; |
546 | unsigned max_cpages = min(count, (unsigned)NUM_PAGES_TO_ALLOC); | 547 | unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC); |
547 | 548 | ||
548 | /* allocate array for page caching change */ | 549 | /* allocate array for page caching change */ |
549 | caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); | 550 | caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); |